Skip to content

Commit

Permalink
"2.5: RM2000: If the second line of a Skill is not empty: 1. The firs…
Browse files Browse the repository at this point in the history
…t 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.
  • Loading branch information
Albeleon authored and mateofio committed Nov 18, 2018
1 parent 25b5605 commit 9062472
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
38 changes: 36 additions & 2 deletions src/game_battlealgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down Expand Up @@ -1094,20 +1102,46 @@ 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 {
return skill.name;
}
}

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<int>(skill.battler_animation_data.size()) > source->GetId() - 1) {
Expand Down
19 changes: 18 additions & 1 deletion src/game_battlealgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion src/scene_battle_rpg2k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9062472

Please sign in to comment.