From 0fddae0bfdc0f7081b64eb00beb14091a6ddf7fa Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Sun, 16 Sep 2012 00:14:04 +0200 Subject: [PATCH] Gathered and turned the battle type speed factor magic numbers into const. I also renamed SEMI_WAIT into SEMI ACTIVE, which sounds more logical. --- dat/config/debug_battle.lua | 2 +- src/modes/battle/battle.cpp | 12 ++++++------ src/modes/battle/battle.h | 10 +++++++++- src/modes/battle/battle_actors.cpp | 8 +++++--- src/modes/battle/battle_command.cpp | 2 +- src/modes/mode_bindings.cpp | 2 +- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dat/config/debug_battle.lua b/dat/config/debug_battle.lua index f49fb9754..192f690c9 100644 --- a/dat/config/debug_battle.lua +++ b/dat/config/debug_battle.lua @@ -24,7 +24,7 @@ function BootBattleTest() -- Set the battle to wait, semi active or active --battle:SetBattleType(hoa_battle.BattleMode.BATTLE_TYPE_WAIT); - --battle:SetBattleType(hoa_battle.BattleMode.BATTLE_TYPE_SEMI_WAIT); + --battle:SetBattleType(hoa_battle.BattleMode.BATTLE_TYPE_SEMI_ACTIVE); battle:SetBattleType(hoa_battle.BattleMode.BATTLE_TYPE_ACTIVE); ModeManager:Push(battle, false, false); diff --git a/src/modes/battle/battle.cpp b/src/modes/battle/battle.cpp index fcaf2ff07..43a9d72c3 100644 --- a/src/modes/battle/battle.cpp +++ b/src/modes/battle/battle.cpp @@ -458,7 +458,7 @@ void BattleMode::Update() { // that the command menu is open whenever we find a character in the command state. If the command menu is not open, we // forcibly open it and make the player choose a command for the character so that the battle may continue. if (!_last_enemy_dying - && (_battle_type == BATTLE_TYPE_WAIT || _battle_type == BATTLE_TYPE_SEMI_WAIT)) { + && (_battle_type == BATTLE_TYPE_WAIT || _battle_type == BATTLE_TYPE_SEMI_ACTIVE)) { for (uint32 i = 0; i < _character_actors.size(); i++) { if (_character_actors[i]->GetState() == ACTOR_STATE_COMMAND) { if (_state != BATTLE_STATE_COMMAND) { @@ -805,18 +805,18 @@ void BattleMode::_Initialize() { // We also factor the idle time using the battle type setting // ACTIVE BATTLE - float time_factor = 1.0f; + float time_factor = BATTLE_ACTIVE_FACTOR; // WAIT battle type is always safe, since the character has got all the time // he/she wants to think so we can dimish the idle time of character and jump // right to the command status. if (_battle_type == BATTLE_TYPE_WAIT) - time_factor = 3.0f; - // SEMI_WAIT battle type is a bit more dangerous as if the player is taking + time_factor = BATTLE_WAIT_FACTOR; + // SEMI_ACTIVE battle type is a bit more dangerous as if the player is taking // too much time to think, the enemies will have slightly more chances to hit. // Yet, the semi wait battles are far simpler than active ones, so we // can make them relatively faster. - else if (_battle_type == BATTLE_TYPE_SEMI_WAIT) - time_factor = 1.5f; + else if (_battle_type == BATTLE_TYPE_SEMI_ACTIVE) + time_factor = BATTLE_SEMI_ACTIVE_FACTOR; float proportion; for (uint32 i = 0; i < _character_actors.size(); i++) { diff --git a/src/modes/battle/battle.h b/src/modes/battle/battle.h index c412590b1..2d05e6a46 100644 --- a/src/modes/battle/battle.h +++ b/src/modes/battle/battle.h @@ -31,6 +31,7 @@ #include +struct B; namespace hoa_battle { //! \brief Determines whether the code in the hoa_battle namespace should print debug statements or not. @@ -48,12 +49,19 @@ enum BATTLE_TYPE { BATTLE_TYPE_WAIT = 0, //! Monsters will wait for characters to finish their command before attacking //! but will move up until being ready anyway. - BATTLE_TYPE_SEMI_WAIT = 1, + BATTLE_TYPE_SEMI_ACTIVE = 1, //! The battle will continue progressing while player selects commands BATTLE_TYPE_ACTIVE = 2, BATTLE_TYPE_TOTAL = 3 }; +//! Tells the battle speed factor used in wait battle modes. +const float BATTLE_WAIT_FACTOR = 3.0f; +//! Tells the battle speed factor used in semi-active battle modes. +const float BATTLE_SEMI_ACTIVE_FACTOR = 1.5f; +//! Tells the battle speed factor used in active battle modes. +const float BATTLE_ACTIVE_FACTOR = 1.0f; + /** **************************************************************************** *** \brief A companion class to BattleMode that holds various multimedia data *** diff --git a/src/modes/battle/battle_actors.cpp b/src/modes/battle/battle_actors.cpp index 8aedfe291..92f0efdac 100644 --- a/src/modes/battle/battle_actors.cpp +++ b/src/modes/battle/battle_actors.cpp @@ -220,10 +220,12 @@ void BattleActor::RegisterDamage(uint32 amount, BattleTarget* target) { // Make the stun effect disappear faster depending on the battle type, // to not advantage the attacker. BattleMode* BM = BattleMode::CurrentInstance(); - if (BM->GetBattleType() == BATTLE_TYPE_SEMI_WAIT) - stun_time /= 1.5f; + if (BM->GetBattleType() == BATTLE_TYPE_SEMI_ACTIVE) + stun_time /= BATTLE_SEMI_ACTIVE_FACTOR; else if (BM->GetBattleType() == BATTLE_TYPE_WAIT) - stun_time /= 3; + stun_time /= BATTLE_WAIT_FACTOR; + else if (BM->GetBattleType() == BATTLE_TYPE_ACTIVE) + stun_time /= BATTLE_ACTIVE_FACTOR; _state_timer.StunTimer(stun_time); // Run a shake effect for the same time. diff --git a/src/modes/battle/battle_command.cpp b/src/modes/battle/battle_command.cpp index 5afee82f9..fd9149491 100644 --- a/src/modes/battle/battle_command.cpp +++ b/src/modes/battle/battle_command.cpp @@ -969,7 +969,7 @@ void CommandSupervisor::_UpdateCategory() { // The only time we do not allow the player to abort the command menu is if they are running the battle with the "wait" setting active and the // current character is in the command state. Under these circumstances, the player has to enter a command for this character before the battle // is allowed to continue. - if ((BM->GetBattleType() == BATTLE_TYPE_WAIT || BM->GetBattleType() == BATTLE_TYPE_SEMI_WAIT) + if ((BM->GetBattleType() == BATTLE_TYPE_WAIT || BM->GetBattleType() == BATTLE_TYPE_SEMI_ACTIVE) && (GetCommandCharacter()->GetState() == ACTOR_STATE_COMMAND)) { BM->GetMedia().cancel_sound.Play(); } diff --git a/src/modes/mode_bindings.cpp b/src/modes/mode_bindings.cpp index e799ac50b..563e67d0f 100644 --- a/src/modes/mode_bindings.cpp +++ b/src/modes/mode_bindings.cpp @@ -630,7 +630,7 @@ void BindModeCode() { // Battle settings luabind::value("BATTLE_TYPE_INVALID", BATTLE_TYPE_INVALID), luabind::value("BATTLE_TYPE_WAIT", BATTLE_TYPE_WAIT), - luabind::value("BATTLE_TYPE_SEMI_WAIT", BATTLE_TYPE_SEMI_WAIT), + luabind::value("BATTLE_TYPE_SEMI_ACTIVE", BATTLE_TYPE_SEMI_ACTIVE), luabind::value("BATTLE_TYPE_ACTIVE", BATTLE_TYPE_ACTIVE), luabind::value("BATTLE_TYPE_TOTAL", BATTLE_TYPE_TOTAL) ]