diff --git a/src/game_battle.cpp b/src/game_battle.cpp index a9cbb8670a..5bcc6b9c9e 100644 --- a/src/game_battle.cpp +++ b/src/game_battle.cpp @@ -221,7 +221,7 @@ void Game_Battle::UpdateAtbGauges() { } ManiacBattleHook( - Game_Interpreter_Battle::AtbIncrement, + Game_Interpreter_Battle::ManiacBattleHookType::AtbIncrement, bat->GetType() == Game_Battler::Type_Enemy, bat->GetPartyIndex(), bat->GetAtbGauge(), diff --git a/src/game_battlealgorithm.cpp b/src/game_battlealgorithm.cpp index bf30cd1da6..f2eda7702d 100644 --- a/src/game_battlealgorithm.cpp +++ b/src/game_battlealgorithm.cpp @@ -89,11 +89,11 @@ Game_BattleAlgorithm::AlgorithmBase::AlgorithmBase(Type ty, Game_Battler* source } int Game_BattleAlgorithm::AlgorithmBase::GetActionType() { - return 0; + return -1; } int Game_BattleAlgorithm::AlgorithmBase::GetActionId() { - return 0; + return -1; } void Game_BattleAlgorithm::AlgorithmBase::Reset() { @@ -196,7 +196,7 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplySpEffect() { if (Player::IsPatchManiac()) { Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::StatChange, + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, target->GetType() == Game_Battler::Type_Enemy, target->GetPartyIndex(), target->GetDisplayX(), @@ -222,7 +222,7 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyAtkEffect() { if (Player::IsPatchManiac()) { Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::StatChange, + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, target->GetType() == Game_Battler::Type_Enemy, target->GetPartyIndex(), target->GetDisplayX(), @@ -247,7 +247,7 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyDefEffect() { if (Player::IsPatchManiac()) { Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::StatChange, + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, target->GetType() == Game_Battler::Type_Enemy, target->GetPartyIndex(), target->GetDisplayX(), @@ -272,7 +272,7 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplySpiEffect() { if (Player::IsPatchManiac()) { Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::StatChange, + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, target->GetType() == Game_Battler::Type_Enemy, target->GetPartyIndex(), target->GetDisplayX(), @@ -297,7 +297,7 @@ int Game_BattleAlgorithm::AlgorithmBase::ApplyAgiEffect() { if (Player::IsPatchManiac()) { Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::StatChange, + Game_Interpreter_Battle::ManiacBattleHookType::StatChange, target->GetType() == Game_Battler::Type_Enemy, target->GetPartyIndex(), target->GetDisplayX(), @@ -602,7 +602,23 @@ AlgorithmBase(Type::None, source, source) { } int Game_BattleAlgorithm::None::GetActionId() { - return 7; + return lcf::rpg::EnemyAction::Basic_nothing; +} + +int Game_BattleAlgorithm::None::GetActionType() { + return lcf::rpg::EnemyAction::Kind_basic; +} + +int Game_BattleAlgorithm::Normal::GetActionId() { + if (IsDualAttack()) { + return lcf::rpg::EnemyAction::Basic_dual_attack; + } + + return lcf::rpg::EnemyAction::Basic_attack; +} + +int Game_BattleAlgorithm::Normal::GetActionType() { + return lcf::rpg::EnemyAction::Kind_basic; } Game_BattleAlgorithm::Normal::Normal(Game_Battler* source, Game_Battler* target, int hits_multiplier, Style style) : @@ -813,12 +829,16 @@ bool Game_BattleAlgorithm::Normal::vExecute() { return SetIsSuccess(); } +bool Game_BattleAlgorithm::Normal::IsDualAttack() const { + return GetSource()->GetType() == Game_Battler::Type_Enemy && hits_multiplier == 2; +} + std::string Game_BattleAlgorithm::Normal::GetStartMessage(int line) const { if (line == 0) { if (Feature::HasRpg2kBattleSystem()) { return BattleMessage::GetNormalAttackStartMessage2k(*GetSource()); } - if (GetSource()->GetType() == Game_Battler::Type_Enemy && hits_multiplier == 2) { + if (IsDualAttack()) { return BattleMessage::GetDoubleAttackStartMessage2k3(*GetSource()); } } @@ -923,7 +943,7 @@ Game_BattleAlgorithm::Skill::Skill(Game_Battler* source, const lcf::rpg::Skill& } int Game_BattleAlgorithm::Skill::GetActionType() { - return 1; + return lcf::rpg::EnemyAction::Kind_skill; } int Game_BattleAlgorithm::Skill::GetActionId() { @@ -1429,8 +1449,12 @@ Game_BattleAlgorithm::Defend::Defend(Game_Battler* source) : source->SetIsDefending(true); } +int Game_BattleAlgorithm::Defend::GetActionType() { + return lcf::rpg::EnemyAction::Kind_basic; +} + int Game_BattleAlgorithm::Defend::GetActionId() { - return 2; + return lcf::rpg::EnemyAction::Basic_defense; } std::string Game_BattleAlgorithm::Defend::GetStartMessage(int line) const { @@ -1453,8 +1477,12 @@ AlgorithmBase(Type::Observe, source, source) { // no-op } +int Game_BattleAlgorithm::Observe::GetActionType() { + return lcf::rpg::EnemyAction::Kind_basic; +} + int Game_BattleAlgorithm::Observe::GetActionId() { - return 3; + return lcf::rpg::EnemyAction::Basic_observe; } std::string Game_BattleAlgorithm::Observe::GetStartMessage(int line) const { @@ -1473,8 +1501,12 @@ AlgorithmBase(Type::Charge, source, source) { // no-op } +int Game_BattleAlgorithm::Charge::GetActionType() { + return lcf::rpg::EnemyAction::Kind_basic; +} + int Game_BattleAlgorithm::Charge::GetActionId() { - return 4; + return lcf::rpg::EnemyAction::Basic_charge; } std::string Game_BattleAlgorithm::Charge::GetStartMessage(int line) const { @@ -1497,8 +1529,12 @@ AlgorithmBase(Type::SelfDestruct, source, target) { // no-op } +int Game_BattleAlgorithm::SelfDestruct::GetActionType() { + return lcf::rpg::EnemyAction::Kind_basic; +} + int Game_BattleAlgorithm::SelfDestruct::GetActionId() { - return 5; + return lcf::rpg::EnemyAction::Basic_autodestruction; } std::string Game_BattleAlgorithm::SelfDestruct::GetStartMessage(int line) const { @@ -1555,8 +1591,12 @@ Game_BattleAlgorithm::Escape::Escape(Game_Battler* source) : // no-op } +int Game_BattleAlgorithm::Escape::GetActionType() { + return lcf::rpg::EnemyAction::Kind_basic; +} + int Game_BattleAlgorithm::Escape::GetActionId() { - return 6; + return lcf::rpg::EnemyAction::Basic_escape; } std::string Game_BattleAlgorithm::Escape::GetStartMessage(int line) const { @@ -1597,7 +1637,7 @@ AlgorithmBase(Type::Transform, source, source), new_monster_id(new_monster_id) { } int Game_BattleAlgorithm::Transform::GetActionType() { - return 2; + return lcf::rpg::EnemyAction::Kind_transformation; } int Game_BattleAlgorithm::Transform::GetActionId() { @@ -1626,7 +1666,11 @@ AlgorithmBase(Type::DoNothing, source, source) { // no-op } +int Game_BattleAlgorithm::DoNothing::GetActionType() { + return lcf::rpg::EnemyAction::Kind_basic; +} + int Game_BattleAlgorithm::DoNothing::GetActionId() { - return 7; + return lcf::rpg::EnemyAction::Basic_nothing; } diff --git a/src/game_battlealgorithm.h b/src/game_battlealgorithm.h index dacc61b14c..a3829855a3 100644 --- a/src/game_battlealgorithm.h +++ b/src/game_battlealgorithm.h @@ -630,6 +630,9 @@ class None : public AlgorithmBase { public: None(Game_Battler* source); + /** @return the type associated with this action */ + int GetActionType() override; + /** @return the id associated with this action */ int GetActionId() override; }; @@ -644,6 +647,12 @@ class Normal : public AlgorithmBase { Style_MultiHit, }; + /** @return the type associated with this action */ + int GetActionType() override; + + /** @return the id associated with this action */ + int GetActionId() override; + static Style GetDefaultStyle(); Normal(Game_Battler* source, Game_Battler* target, int hits_multiplier = 1, Style style = GetDefaultStyle()); @@ -651,6 +660,7 @@ class Normal : public AlgorithmBase { bool vExecute() override; bool vStart() override; + bool IsDualAttack() const; int GetAnimationId(int i) const override; std::string GetStartMessage(int line) const override; @@ -752,6 +762,9 @@ class Defend : public AlgorithmBase { public: Defend(Game_Battler* source); + /** @return the type associated with this action */ + int GetActionType() override; + /** @return the id associated with this action */ int GetActionId() override; @@ -763,6 +776,9 @@ class Observe : public AlgorithmBase { public: Observe(Game_Battler* source); + /** @return the type associated with this action */ + int GetActionType() override; + /** @return the id associated with this action */ int GetActionId() override; @@ -773,6 +789,9 @@ class Charge : public AlgorithmBase { public: Charge(Game_Battler* source); + /** @return the type associated with this action */ + int GetActionType() override; + /** @return the id associated with this action */ int GetActionId() override; @@ -784,6 +803,9 @@ class SelfDestruct : public AlgorithmBase { public: SelfDestruct(Game_Battler* source, Game_Party_Base* target); + /** @return the type associated with this action */ + int GetActionType() override; + /** @return the id associated with this action */ int GetActionId() override; @@ -799,6 +821,9 @@ class Escape : public AlgorithmBase { public: Escape(Game_Battler* source); + /** @return the type associated with this action */ + int GetActionType() override; + /** @return the id associated with this action */ int GetActionId() override; @@ -830,6 +855,9 @@ class DoNothing : public AlgorithmBase { public: DoNothing(Game_Battler* source); + /** @return the type associated with this action */ + int GetActionType() override; + /** @return the id associated with this action */ int GetActionId() override; }; diff --git a/src/game_battler.cpp b/src/game_battler.cpp index 671b611d7f..221975a69e 100644 --- a/src/game_battler.cpp +++ b/src/game_battler.cpp @@ -368,7 +368,7 @@ bool Game_Battler::AddState(int state_id, bool allow_battle_states) { } Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::SetState, + Game_Interpreter_Battle::ManiacBattleHookType::SetState, GetType() == Game_Battler::Type_Enemy, GetPartyIndex(), state_id diff --git a/src/game_interpreter_battle.cpp b/src/game_interpreter_battle.cpp index 3d1ac489ae..023752e57d 100644 --- a/src/game_interpreter_battle.cpp +++ b/src/game_interpreter_battle.cpp @@ -15,7 +15,7 @@ * along with EasyRPG Player. If not, see . */ -// Headers + // Headers #include "game_actors.h" #include "game_battle.h" #include "game_enemyparty.h" @@ -45,13 +45,19 @@ enum TargetType { // Implemented as a static map, since maniac hooks can only have one common event callback at a time. // Subsequent calls will simply override the previous common event callback. -std::map> Game_Interpreter_Battle::maniac_hooks = { - {AtbIncrement, std::make_tuple(0, 0)}, - {DamagePop, std::make_tuple(0, 0)}, - {Targetting, std::make_tuple(0, 0)}, - {SetState, std::make_tuple(0, 0)}, - {StatChange, std::make_tuple(0, 0)} -}; +std::map> Game_Interpreter_Battle::maniac_hooks; + +void Game_Interpreter_Battle::InitBattle() { + if (Player::IsPatchManiac()) { + Game_Interpreter_Battle::maniac_hooks = { + {Game_Interpreter_Battle::ManiacBattleHookType::AtbIncrement, std::make_tuple(0, 0)}, + {Game_Interpreter_Battle::ManiacBattleHookType::DamagePop, std::make_tuple(0, 0)}, + {Game_Interpreter_Battle::ManiacBattleHookType::Targetting, std::make_tuple(0, 0)}, + {Game_Interpreter_Battle::ManiacBattleHookType::SetState, std::make_tuple(0, 0)}, + {Game_Interpreter_Battle::ManiacBattleHookType::StatChange, std::make_tuple(0, 0)} + }; + } +} static const char* target_text[] = { "actor", "party member", "enemy" }; diff --git a/src/game_interpreter_battle.h b/src/game_interpreter_battle.h index 0fff228ef3..4b83790eca 100644 --- a/src/game_interpreter_battle.h +++ b/src/game_interpreter_battle.h @@ -61,10 +61,12 @@ class Game_Interpreter_Battle : public Game_Interpreter bool ExecuteCommand(lcf::rpg::EventCommand const& com) override; + static void InitBattle(); + /** * All possible hook type events that maniacs offers. */ - enum ManiacBattleHookType { + enum class ManiacBattleHookType { AtbIncrement, DamagePop, Targetting, diff --git a/src/scene_battle_rpg2k3.cpp b/src/scene_battle_rpg2k3.cpp index b4ad096021..68f163f0f9 100644 --- a/src/scene_battle_rpg2k3.cpp +++ b/src/scene_battle_rpg2k3.cpp @@ -60,10 +60,13 @@ Scene_Battle_Rpg2k3::Scene_Battle_Rpg2k3(const BattleArgs& args) : void Scene_Battle_Rpg2k3::Start() { Scene_Battle::Start(); + Game_Interpreter_Battle::InitBattle(); InitBattleCondition(Game_Battle::GetBattleCondition()); CreateEnemySprites(); CreateActorSprites(); + Game_Battle::GetInterpreterBattle(); + // We need to wait for actor and enemy graphics to load before we can finish initializing the battle. AsyncNext([this]() { Start2(); }); } @@ -503,7 +506,7 @@ void Scene_Battle_Rpg2k3::DrawFloatText(int x, int y, int color, StringView text int value = 0; ss >> value; bool should_override = Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::DamagePop, + Game_Interpreter_Battle::ManiacBattleHookType::DamagePop, battler->GetType() == Game_Battler::Type_Enemy, battler->GetPartyIndex(), x, @@ -2234,7 +2237,7 @@ Scene_Battle_Rpg2k3::BattleActionReturn Scene_Battle_Rpg2k3::ProcessBattleAction damageTaken < 0 ? Font::ColorDefault : Font::ColorHeal, std::to_string(std::abs(damageTaken)), b, - damageTaken < 0 ? Damage : Heal); + damageTaken < 0 ? Scene_Battle_Rpg2k3::FloatTextType::Damage : Scene_Battle_Rpg2k3::FloatTextType::Heal); } if (b->GetType() == Game_Battler::Type_Ally) { auto* sprite = static_cast(b)->GetActorBattleSprite(); @@ -2659,7 +2662,7 @@ Scene_Battle_Rpg2k3::BattleActionReturn Scene_Battle_Rpg2k3::ProcessBattleAction hp > 0 ? Font::ColorHeal : Font::ColorDefault, std::to_string(std::abs(hp)), target, - hp > 0 ? Heal : Damage); + hp > 0 ? Scene_Battle_Rpg2k3::FloatTextType::Heal : Scene_Battle_Rpg2k3::FloatTextType::Damage); if (action->IsAbsorbHp()) { DrawFloatText( @@ -2668,7 +2671,7 @@ Scene_Battle_Rpg2k3::BattleActionReturn Scene_Battle_Rpg2k3::ProcessBattleAction hp > 0 ? Font::ColorDefault : Font::ColorHeal, std::to_string(std::abs(hp)), source, - hp > 0 ? Damage : Heal); + hp > 0 ? Scene_Battle_Rpg2k3::FloatTextType::Damage : Scene_Battle_Rpg2k3::FloatTextType::Heal); } } @@ -2691,7 +2694,7 @@ Scene_Battle_Rpg2k3::BattleActionReturn Scene_Battle_Rpg2k3::ProcessBattleAction 0, lcf::Data::terms.miss, target, - Miss); + Scene_Battle_Rpg2k3::FloatTextType::Miss); } status_window->Refresh(); @@ -2856,7 +2859,7 @@ void Scene_Battle_Rpg2k3::ActionSelectedCallback(Game_Battler* for_battler) { auto group_targets = for_battler->GetBattleAlgorithm()->GetOriginalPartyTarget(); // Target: 0 None, 1 Single Enemy, 2 All Enemies, 3 Single Ally, 4 All Allies Game_Battle::ManiacBattleHook( - Game_Interpreter_Battle::Targetting, + Game_Interpreter_Battle::ManiacBattleHookType::Targetting, for_battler->GetType() == Game_Battler::Type_Enemy, for_battler->GetPartyIndex(), for_battler->GetBattleAlgorithm()->GetActionType(), @@ -2953,7 +2956,7 @@ void Scene_Battle_Rpg2k3::OnEventHpChanged(Game_Battler* battler, int hp) { hp < 0 ? Font::ColorDefault : Font::ColorHeal, std::to_string(std::abs(hp)), battler, - hp < 0 ? Damage : Heal); + hp < 0 ? Scene_Battle_Rpg2k3::FloatTextType::Damage : Scene_Battle_Rpg2k3::FloatTextType::Heal); } void Scene_Battle_Rpg2k3::RecreateSpWindow(Game_Battler* battler) { diff --git a/src/scene_battle_rpg2k3.h b/src/scene_battle_rpg2k3.h index c88ab4d882..045d3ce6ac 100644 --- a/src/scene_battle_rpg2k3.h +++ b/src/scene_battle_rpg2k3.h @@ -123,7 +123,7 @@ class Scene_Battle_Rpg2k3 : public Scene_Battle { void RefreshCommandWindow(const Game_Actor* actor); void SetActiveActor(int idx); - enum FloatTextType { + enum class FloatTextType { Damage = 0, Heal = 1, Miss = 2,