Skip to content

Commit

Permalink
Gathered and turned the battle type speed factor magic numbers into c…
Browse files Browse the repository at this point in the history
…onst.

I also renamed SEMI_WAIT into SEMI ACTIVE, which sounds more logical.
  • Loading branch information
Yohann Ferreira committed Sep 15, 2012
1 parent 45ddff8 commit 0fddae0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dat/config/debug_battle.lua
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/modes/battle/battle.cpp
Expand Up @@ -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) {
Expand Down Expand Up @@ -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++) {
Expand Down
10 changes: 9 additions & 1 deletion src/modes/battle/battle.h
Expand Up @@ -31,6 +31,7 @@

#include <list>

struct B;

This comment has been minimized.

Copy link
@Bertram25

Bertram25 Sep 19, 2012

Member

Huh? Remove that

namespace hoa_battle {

//! \brief Determines whether the code in the hoa_battle namespace should print debug statements or not.
Expand All @@ -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
***
Expand Down
8 changes: 5 additions & 3 deletions src/modes/battle/battle_actors.cpp
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/modes/battle/battle_command.cpp
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/modes/mode_bindings.cpp
Expand Up @@ -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)
]
Expand Down

0 comments on commit 0fddae0

Please sign in to comment.