Permalink
Browse files

passive effects from equipment applied

equipment now gives "passive" application of status to your character!
An easy way to try this out is to simply add a extreme strength modifier
to the Arbalest, and watch Kayla do some SERIOUS damage!
  • Loading branch information...
1 parent ddad054 commit b7b92e6a0997d8e564b058b25bc4c82426ca4e12 @IkarusDowned IkarusDowned committed Mar 29, 2013
Showing with 100 additions and 3 deletions.
  1. +80 −3 src/modes/battle/battle.cpp
  2. +20 −0 src/modes/battle/battle.h
@@ -33,6 +33,7 @@
#include "modes/battle/battle_finish.h"
#include "modes/battle/battle_sequence.h"
#include "modes/battle/battle_utils.h"
+#include "modes/battle/battle_effects.h"
using namespace hoa_utils;
using namespace hoa_audio;
@@ -239,8 +240,6 @@ BattleMode::~BattleMode()
}
} // BattleMode::~BattleMode()
-
-
void BattleMode::Reset()
{
VideoManager->SetStandardCoordSys();
@@ -281,7 +280,11 @@ void BattleMode::RestartBattle()
// Reset the state of all characters and enemies
for(uint32 i = 0; i < _character_actors.size(); ++i)
+ {
_character_actors[i]->ResetActor();
+ _ResetPassiveStatusEffects(*(_character_actors[i]));
+ }
+
for(uint32 i = 0; i < _enemy_actors.size(); ++i)
_enemy_actors[i]->ResetActor();
@@ -733,7 +736,7 @@ void BattleMode::_Initialize()
BattleCharacter *new_actor = new BattleCharacter(dynamic_cast<GlobalCharacter *>(active_party->GetActorAtIndex(i)));
_character_actors.push_back(new_actor);
_character_party.push_back(new_actor);
-
+ _ResetPassiveStatusEffects(*new_actor);
// Check whether the character is alive
if(new_actor->GetHitPoints() == 0)
new_actor->ChangeState(ACTOR_STATE_DEAD);
@@ -812,6 +815,80 @@ void BattleMode::_Initialize()
ChangeState(BATTLE_STATE_INITIAL);
} // void BattleMode::_Initialize()
+void BattleMode::_ResetAttributesFromGlobalActor(private_battle::BattleActor &character)
+{
+ character.ResetAgility();
+ character.ResetEvade();
+ character.ResetFortitude();
+ character.ResetProtection();
+ character.ResetStrength();
+ character.ResetVigor();
+}
+
+//! \brief sets the max_effect at the proper index only if it is higher in value than the current one there
+static void SetEffectMaximum(GLOBAL_INTENSITY *max_effect, const std::vector<std::pair<GLOBAL_STATUS, GLOBAL_INTENSITY> >&status_effects)
+{
+ for(size_t i = 0; i < status_effects.size(); ++i)
+ {
+ //we are only interested in attribute effects
+
+ if(status_effects[i].first == GLOBAL_STATUS_INVALID ||
+ status_effects[i].first > GLOBAL_STATUS_EVADE_LOWER)
+ continue;
+ if(status_effects[i].second < GLOBAL_INTENSITY_NEG_EXTREME ||
+ status_effects[i].second > GLOBAL_INTENSITY_POS_EXTREME)
+ continue;
+
+ size_t index = (size_t) status_effects[i].first;
+ if((int)max_effect[index] < (int)(status_effects[i].second))
+ max_effect[index] = status_effects[i].second;
+ }
+}
+
+void BattleMode::_ApplyPassiveStatusEffects(private_battle::BattleActor &character,
+ const hoa_global::GlobalWeapon &weapon,
+ const std::vector<hoa_global::GlobalArmor *>& armors)
+{
+ //we only count the first 12 status effects as valid
+ //todo: allow a way for drain / regen
+ const static size_t MAX_VALID_STATUS = 12;
+ //max value array for each of the status types.
+ GLOBAL_INTENSITY max_effect[MAX_VALID_STATUS] = {GLOBAL_INTENSITY_INVALID};
+ //adjust effects for the weapons
+ SetEffectMaximum(max_effect, weapon.GetStatusEffects());
+ //adjust effects for armor
+ for(std::vector<hoa_global::GlobalArmor *>::const_iterator itr = armors.begin(),
+ end = armors.end(); itr != end; ++itr)
+ if((*itr))
+ SetEffectMaximum(max_effect, (*itr)->GetStatusEffects());
+ //go through each effect (as a pair) looking for the highest one.
+ for(size_t i = 0; i < MAX_VALID_STATUS; i += 2)
+ {
+ //no change for this status
+ if(max_effect[i] == GLOBAL_INTENSITY_INVALID && max_effect[i+1] == GLOBAL_INTENSITY_INVALID)
+ continue;
+ GLOBAL_STATUS max_status;
+ GLOBAL_INTENSITY max_intensity;
+ max_status = (int)max_effect[i] > (int)max_effect[i+1] ? (GLOBAL_STATUS)i : (GLOBAL_STATUS)(i + 1);
+ max_intensity = max_effect[(size_t)max_status];
+ if(max_intensity == GLOBAL_INTENSITY_NEUTRAL)
+ continue;
+ //now, we manually effect the player with a "permenant effect" by creating
+ //a battle effect and immediatly allowing it to modify the player.
+ //this effect does NOT go into the effect controller
+ private_battle::BattleStatusEffect scripted_effect(max_status, max_intensity, &character);
+ //immediatly apply the full effect
+ ScriptCallFunction<void>(scripted_effect.GetApplyFunction(), &scripted_effect);
+ }
+
+}
+
+void BattleMode::_ResetPassiveStatusEffects(hoa_battle::private_battle::BattleActor &character)
+{
+ _ResetAttributesFromGlobalActor(character);
+ _ApplyPassiveStatusEffects(character, *(character.GetGlobalActor()->GetWeaponEquipped()), character.GetGlobalActor()->GetArmorEquipped());
+}
+
void BattleMode::SetActorIdleStateTime(BattleActor *actor)
{
if(!actor || actor->GetAgility() == 0)
View
@@ -42,6 +42,7 @@ extern bool BATTLE_DEBUG;
namespace private_battle
{
+class BattleActor;
class BattleCharacter;
class BattleEnemy;
class BattleObject;
@@ -422,6 +423,7 @@ class BattleMode : public hoa_mode_manager::GameMode
//@}
private:
+
//! \brief A static pointer to the currently active instance of battle mode
static BattleMode *_current_instance;
@@ -531,6 +533,24 @@ class BattleMode : public hoa_mode_manager::GameMode
//! \brief Initializes all data necessary for the battle to begin
void _Initialize();
+ //! \brief resets the character's original global attributes
+ //! \note this also sets the BattleActor's attributes for the first time
+ void _ResetAttributesFromGlobalActor(private_battle::BattleActor &character);
+
+ //! \brief applies the highest status effect for the given weapon and armor
+ //! to the character.
+ //! \note this does not effect the global character, but only for the duration of the battle
+ void _ApplyPassiveStatusEffects(private_battle::BattleActor &character,
+ const hoa_global::GlobalWeapon &weapon,
+ const std::vector<hoa_global::GlobalArmor *>& armors);
+
+ //! \brief resets the actor to their global status values, and then applies
+ //! the passive effect
+ //! \note this is a very simple function, and technically cane be put into the header and inlined.
+ //! \note however, if you do that then you need to mess with the include order, and probably
+ //! \note increase both coupling and build time.
+ void _ResetPassiveStatusEffects(hoa_battle::private_battle::BattleActor &character);
+
/** \brief Sets the origin location of all character and enemy actors
*** The location of the actors in both parties is dependent upon the number and physical size of the actor
*** (the size of its sprite image). This function implements the algorithm that determines those locations.

0 comments on commit b7b92e6

Please sign in to comment.