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

Function IsSkillUsable

src/algo.cpp:292–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292bool IsSkillUsable(const lcf::rpg::Skill& skill,
293 bool require_states_persist)
294{
295 const auto in_battle = Game_Battle::IsBattleRunning();
296
297 if (skill.type == lcf::rpg::Skill::Type_escape) {
298 return !in_battle && Main_Data::game_system->GetAllowEscape() && Main_Data::game_targets->HasEscapeTarget() && !Main_Data::game_player->IsFlying();
299 }
300
301 if (skill.type == lcf::rpg::Skill::Type_teleport) {
302 return !in_battle && Main_Data::game_system->GetAllowTeleport() && Main_Data::game_targets->HasTeleportTargets() && !Main_Data::game_player->IsFlying();
303 }
304
305 if (skill.type == lcf::rpg::Skill::Type_switch) {
306 return in_battle ? skill.occasion_battle : skill.occasion_field;
307 }
308
309 if (in_battle) {
310 return true;
311 }
312
313 if (SkillTargetsEnemies(skill)) {
314 return false;
315 }
316
317 if (skill.affect_hp || skill.affect_sp) {
318 return true;
319 }
320
321 bool affects_state = false;
322 for (int i = 0; i < static_cast<int>(skill.state_effects.size()); ++i) {
323 const bool inflict = skill.state_effects[i];
324 if (inflict) {
325 const auto* state = lcf::ReaderUtil::GetElement(lcf::Data::states, i + 1);
326 if (state && (!require_states_persist || state->type == lcf::rpg::State::Persistence_persists)) {
327 affects_state = true;
328 break;
329 }
330 }
331 }
332
333 return affects_state;
334}
335
336int GetNumberOfAttacks(int actor_id, const lcf::rpg::Item& weapon) {
337 assert(weapon.type == lcf::rpg::Item::Type_weapon);

Callers 4

IsSkillUsableMethod · 0.85
IsSkillUsableMethod · 0.85
AddStateMethod · 0.85
IsItemUsableMethod · 0.85

Calls 7

SkillTargetsEnemiesFunction · 0.85
GetAllowEscapeMethod · 0.80
HasEscapeTargetMethod · 0.80
GetAllowTeleportMethod · 0.80
HasTeleportTargetsMethod · 0.80
IsFlyingMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected