From 90624725fc2eabc33402ddbef0ad42dae3b2126f Mon Sep 17 00:00:00 2001 From: Albeleon Date: Wed, 20 Jun 2018 01:06:44 +0200 Subject: [PATCH] "2.5: RM2000: If the second line of a Skill is not empty: 1. The first line should have a pause before the second line is printed, and 2. The animation should only start when the second line is printed." Solution: We should print separate each line in a skill with a time waiting between them. For this: 1. We modify Game_BattleAlgorithm::Skill::GetStartMessage so it only prints the first line. 2. We create two functions in AlgorithmBase, IsSecondStartMessage (which checks if there is a second message pendent, by default false) and GetSecondStartMessage (which prints the second line, by default empty). We override them in Skill so it prints adequately. 3. In Scene_Battle_Rpg2k::ProcessBattleAction, we print only the first line if it's empty, and the second line if there is one element and IsSecondStartMessage is true. 4. For the First target, we check if the first line was printed and IsSecondStartMessage is true. In that case, we force it to pause until GetDelayForWindow time passes. 5. When the screen is cleared in BattleActionState_Result, it should print also the second line if it's available. --- src/game_battlealgorithm.cpp | 38 ++++++++++++++++++++++++++++++++++-- src/game_battlealgorithm.h | 19 +++++++++++++++++- src/scene_battle_rpg2k.cpp | 10 +++++++++- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/game_battlealgorithm.cpp b/src/game_battlealgorithm.cpp index f8420d78ee..2f4fac5874 100644 --- a/src/game_battlealgorithm.cpp +++ b/src/game_battlealgorithm.cpp @@ -174,6 +174,14 @@ bool Game_BattleAlgorithm::AlgorithmBase::IsFirstAttack() const { return first_attack; } +bool Game_BattleAlgorithm::AlgorithmBase::HasSecondStartMessage() const { + return false; +} + +std::string Game_BattleAlgorithm::AlgorithmBase::GetSecondStartMessage() const { + return ""; +} + std::string Game_BattleAlgorithm::AlgorithmBase::GetDeathMessage() const { if (!killed_by_attack_damage) { return ""; @@ -1094,13 +1102,13 @@ std::string Game_BattleAlgorithm::Skill::GetStartMessage() const { if (Player::IsRPG2kE()) { auto* target = GetTarget(); return Utils::ReplacePlaceholders( - skill.using_message1 + '\n' + skill.using_message2, + skill.using_message1, {'S', 'O', 'U'}, {GetSource()->GetName(), (target ? target->GetName() : "???"), skill.name} ); } else { - return source->GetName() + skill.using_message1 + '\n' + skill.using_message2; + return source->GetName() + skill.using_message1; } } else { @@ -1108,6 +1116,32 @@ std::string Game_BattleAlgorithm::Skill::GetStartMessage() const { } } +bool Game_BattleAlgorithm::Skill::HasSecondStartMessage() const { + return Player::IsRPG2k() && (!item || item->using_message != 0) && !skill.using_message2.empty(); +} + +std::string Game_BattleAlgorithm::Skill::GetSecondStartMessage() const { + if (Player::IsRPG2k()) { + if (item && item->using_message == 0) { + return ""; + } + if (Player::IsRPG2kE()) { + auto* target = GetTarget(); + return Utils::ReplacePlaceholders( + skill.using_message2, + { 'S', 'O', 'U' }, + {GetSource()->GetName(), (target ? target->GetName() : "???"), skill.name} + ); + } + else { + return skill.using_message2; + } + } + else { + return ""; + } +} + int Game_BattleAlgorithm::Skill::GetSourceAnimationState() const { if (source->GetType() == Game_Battler::Type_Ally && skill.animation_id > 0) { if (static_cast(skill.battler_animation_data.size()) > source->GetId() - 1) { diff --git a/src/game_battlealgorithm.h b/src/game_battlealgorithm.h index 1fc3c068e6..e6b48b257d 100644 --- a/src/game_battlealgorithm.h +++ b/src/game_battlealgorithm.h @@ -233,13 +233,28 @@ class AlgorithmBase { virtual bool IsTargetValid() const; /** - * Gets the message that is displayed when the action is invoked. + * Gets the first line message that is displayed when the action is invoked. * Usually of style "[Name] uses/casts [Weapon/Item/Skill]". * * @return message */ virtual std::string GetStartMessage() const = 0; + /** + * Checks if there is a second line message to display when the action is invoked. + * + * @return check + */ + virtual bool HasSecondStartMessage() const; + + /** + * Gets the second line message that is displayed when the action is invoked. + * Usually of style "[Name] uses/casts [Weapon/Item/Skill]". + * + * @return message + */ + virtual std::string GetSecondStartMessage() const; + /** * Gets animation state id of the source character. * @@ -389,6 +404,8 @@ class Skill : public AlgorithmBase { void Apply() override; std::string GetStartMessage() const override; + bool HasSecondStartMessage() const override; + std::string GetSecondStartMessage() const override; int GetSourceAnimationState() const override; const RPG::Sound* GetStartSe() const override; const RPG::Sound* GetResultSe() const override; diff --git a/src/scene_battle_rpg2k.cpp b/src/scene_battle_rpg2k.cpp index 2ca66a60e2..f1fa592239 100644 --- a/src/scene_battle_rpg2k.cpp +++ b/src/scene_battle_rpg2k.cpp @@ -429,13 +429,19 @@ bool Scene_Battle_Rpg2k::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase battle_result_messages.clear(); action->GetResultMessages(battle_result_messages); - battle_message_window->Push(action->GetStartMessage()); + if (battle_message_window->GetLineCount() == 0) + battle_message_window->Push(action->GetStartMessage()); + else if ((battle_message_window->GetLineCount() == 1 && action->HasSecondStartMessage())) + battle_message_window->Push(action->GetSecondStartMessage()); action->Apply(); battle_result_messages_it = battle_result_messages.begin(); if (action->IsFirstAttack()) { + if (battle_message_window->GetLineCount() == 1 && action->HasSecondStartMessage()) { + return false; + } if (action->GetTarget() && action->GetTarget()->GetType() == Game_Battler::Type_Enemy) { @@ -529,6 +535,8 @@ bool Scene_Battle_Rpg2k::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase if (battle_result_messages_it != battle_result_messages.begin()) { battle_message_window->Clear(); battle_message_window->Push(action->GetStartMessage()); + if (action->HasSecondStartMessage()) + battle_message_window->Push(action->GetSecondStartMessage()); } battle_message_window->Push(*battle_result_messages_it); ++battle_result_messages_it;