MCPcopy Create free account
hub / github.com/EasyRPG/Player / IsSkillUsable

Method IsSkillUsable

src/game_actor.cpp:228–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228bool Game_Actor::IsSkillUsable(int skill_id) const {
229 const lcf::rpg::Skill* skill = lcf::ReaderUtil::GetElement(lcf::Data::skills, skill_id);
230 if (!skill) {
231 Output::Warning("IsSkillUsable: Invalid skill ID {}", skill_id);
232 return false;
233 }
234
235 if (!skill->affect_attr_defence) {
236 // Actor must have all attributes of the skill equipped as weapons
237 const auto* w1 = GetWeapon();
238 const auto* w2 = Get2ndWeapon();
239
240 for (size_t i = 0; i < skill->attribute_effects.size(); ++i) {
241 bool required = skill->attribute_effects[i] && lcf::Data::attributes[i].type == lcf::rpg::Attribute::Type_physical;
242 if (required) {
243 if (w1 && i < w1->attribute_set.size() && w1->attribute_set[i]) {
244 continue;
245 }
246 if (w2 && i < w2->attribute_set.size() && w2->attribute_set[i]) {
247 continue;
248 }
249 return false;
250 }
251 }
252 }
253
254 return Game_Battler::IsSkillUsable(skill_id);
255}
256
257int Game_Actor::CalculateSkillCost(int skill_id) const {
258 const lcf::rpg::Skill* skill = lcf::ReaderUtil::GetElement(lcf::Data::skills, skill_id);

Callers 5

ActionIsPossibleMethod · 0.45
IsActionValidFunction · 0.45
CalcSkillAutoBattleRankFunction · 0.45
CheckEnableMethod · 0.45
enemyai.cppFile · 0.45

Calls 2

IsSkillUsableFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected