void Game_BattleAlgorithm::AlgorithmBase::Apply() { if (GetAffectedHp() != -1) { int hp = GetAffectedHp(); (*current_target)->ChangeHp(IsPositive() ? hp : -hp); } if (GetAffectedSp() != -1) { int sp = GetAffectedSp(); (*current_target)->SetSp((*current_target)->GetSp() + (IsPositive() ? sp : -sp)); } // TODO if (GetAffectedAttack() != -1) { } if (GetAffectedDefense() != -1) { } if (GetAffectedSpirit() != -1) { } if (GetAffectedAgility() != -1) { } // End TODO if (GetAffectedSwitch() != -1) { Game_Switches[GetAffectedSwitch()] = true; } std::vector<RPG::State>::const_iterator it = conditions.begin(); for (; it != conditions.end(); ++it) { if (IsPositive()) { (*current_target)->RemoveState(it->ID); } else { (*current_target)->AddState(it->ID); } } source->SetDefending(false); }
void Game_BattleAlgorithm::AlgorithmBase::Apply() { if (GetAffectedHp() != -1) { int hp = GetAffectedHp(); int target_hp = (*current_target)->GetHp(); (*current_target)->ChangeHp(IsPositive() ? hp : -hp); if (absorb) { // Only absorb the hp that were left int src_hp = std::min(target_hp, IsPositive() ? -hp : hp); source->ChangeHp(src_hp); } } if (GetAffectedSp() != -1) { int sp = GetAffectedSp(); int target_sp = (*current_target)->GetSp(); (*current_target)->SetSp((*current_target)->GetSp() + (IsPositive() ? sp : -sp)); if (absorb) { int src_sp = std::min(target_sp, IsPositive() ? -sp : sp); source->ChangeSp(src_sp); } } if (GetAffectedAttack() != -1) { int atk = GetAffectedAttack(); (*current_target)->SetAtkModifier(IsPositive() ? atk : -atk); if (absorb) { source->SetAtkModifier(IsPositive() ? -atk : atk); } } if (GetAffectedDefense() != -1) { int def = GetAffectedDefense(); (*current_target)->SetDefModifier(IsPositive() ? def : -def); if (absorb) { source->SetDefModifier(IsPositive() ? -def : def); } } if (GetAffectedSpirit() != -1) { int spi = GetAffectedSpirit(); (*current_target)->SetSpiModifier(IsPositive() ? spi : -spi); if (absorb) { source->SetSpiModifier(IsPositive() ? -spi : spi); } } if (GetAffectedAgility() != -1) { int agi = GetAffectedAgility(); (*current_target)->SetAgiModifier(IsPositive() ? agi : -agi); if (absorb) { source->SetAgiModifier(IsPositive() ? -agi : agi); } } if (GetAffectedSwitch() != -1) { Game_Switches[GetAffectedSwitch()] = true; } std::vector<RPG::State>::const_iterator it = conditions.begin(); for (; it != conditions.end(); ++it) { if (IsPositive()) { if ((*current_target)->IsDead() && it->ID == 1) { // Was a revive skill with an effect rating of 0 (*current_target)->ChangeHp(1); } (*current_target)->RemoveState(it->ID); } else { (*current_target)->AddState(it->ID); } } source->SetDefending(false); }
void Game_BattleAlgorithm::AlgorithmBase::GetResultMessages(std::vector<std::string>& out) const { if (current_target == targets.end()) { return; } if (!success) { out.push_back((*current_target)->GetName() + Data::terms.dodge); } bool target_is_ally = (*current_target)->GetType() == Game_Battler::Type_Ally; if (GetAffectedHp() != -1) { std::stringstream ss; ss << (*current_target)->GetName(); if (IsPositive()) { if (!(*current_target)->IsDead()) { ss << " "; ss << Data::terms.health_points << " " << GetAffectedHp(); ss << Data::terms.hp_recovery; out.push_back(ss.str()); } } else { if (critical_hit) { out.push_back(target_is_ally ? Data::terms.actor_critical : Data::terms.enemy_critical); } if (GetAffectedHp() == 0) { ss << (target_is_ally ? Data::terms.actor_undamaged : Data::terms.enemy_undamaged); } else { if (absorb) { ss << " " << Data::terms.health_points << " " << GetAffectedHp(); ss << (target_is_ally ? Data::terms.actor_hp_absorbed : Data::terms.enemy_hp_absorbed); } else { ss << " " << GetAffectedHp() << (target_is_ally ? Data::terms.actor_damaged : Data::terms.enemy_damaged); } } out.push_back(ss.str()); } } if (GetAffectedSp() != -1) { std::stringstream ss; ss << (*current_target)->GetName(); if (IsPositive()) { ss << " "; ss << Data::terms.spirit_points << " " << GetAffectedSp(); ss << Data::terms.hp_recovery; } else { if (absorb) { ss << " " << Data::terms.spirit_points << " " << GetAffectedSp(); ss << (target_is_ally ? Data::terms.actor_hp_absorbed : Data::terms.enemy_hp_absorbed); } else { ss << " " << Data::terms.attack << " " << GetAffectedSp(); } } out.push_back(ss.str()); } if (GetAffectedAttack() != -1) { std::stringstream ss; ss << (*current_target)->GetName(); ss << " " << Data::terms.attack << " " << GetAffectedSp(); out.push_back(ss.str()); } if (GetAffectedDefense() != -1) { std::stringstream ss; ss << (*current_target)->GetName(); ss << " " << Data::terms.defense << " " << GetAffectedDefense(); out.push_back(ss.str()); } if (GetAffectedSpirit() != -1) { std::stringstream ss; ss << (*current_target)->GetName(); ss << " " << Data::terms.spirit << " " << GetAffectedSpirit(); out.push_back(ss.str()); } if (GetAffectedAgility() != -1) { std::stringstream ss; ss << (*current_target)->GetName(); ss << " " << Data::terms.agility << " " << GetAffectedAgility(); out.push_back(ss.str()); } std::vector<RPG::State>::const_iterator it = conditions.begin(); for (; it != conditions.end(); ++it) { std::stringstream ss; ss << (*current_target)->GetName(); if ((*current_target)->HasState(it->ID)) { if (IsPositive()) { ss << it->message_recovery; out.push_back(ss.str()); } if (!it->message_already.empty()) { ss << it->message_already; out.push_back(ss.str()); } } else { // Positive case doesn't report anything in case of uselessness if (IsPositive()) { continue; } if ((*current_target)->GetType() == Game_Battler::Type_Ally) { ss << it->message_actor; } else { ss << it->message_enemy; } out.push_back(ss.str()); // Reporting ends with death state if (it->ID == 1) { return; } } } }