Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented the stun effect.

Also mde the status effects timers update only when the battle isn't
waiting for the player to be a little bit more fair.

By avoiding to use the StunTimer() function, I also was able
to get rid of the BattleTimer class which look useless to me,
and corner case-prone.

I also added a 'Zzz' icon displayed on top of the enemies
when they're stunned.

Note also that the stun effect can miss, separately from the
damage chances.
  • Loading branch information...
commit 0e6c8aa3431501197c01b8f5bf2ee87d7f57ac90 1 parent e443c9a
Yohann Ferreira authored
View
15 dat/effects/status.lua
@@ -428,6 +428,7 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_RAISE] = {
end
end,
+ -- Note: This modifies the actor's idle state wait time accordingly.
Remove = function(effect)
effect:GetAffectedActor():ResetAgility();
end,
@@ -454,8 +455,8 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_RAISE] = {
print("Lua warning: status effect had an invalid intensity value: " .. intensity);
end
- actor:SetStrength(base_value * attribute_modifier);
- -- TODO: Need to modify actor's idle state wait time accordingly here
+ -- Note: This modifies the actor's idle state wait time accordingly.
+ actor:SetAgility(base_value * attribute_modifier);
end
}
@@ -475,10 +476,12 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_LOWER] = {
end
end,
+ -- Note: This modifies the actor's idle state wait time accordingly.
Remove = function(effect)
effect:GetAffectedActor():ResetAgility();
end,
+ -- Note: This modifies the actor's idle state wait time accordingly.
ModifyAttribute = function(effect)
actor = effect:GetAffectedActor();
intensity = effect:GetIntensity();
@@ -502,7 +505,6 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_LOWER] = {
end
actor:SetAgility(base_value * attribute_modifier);
- -- TODO: Need to modify actor's idle state wait time accordingly here
end
}
@@ -684,10 +686,8 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_PARALYSIS] = {
opposite_effect = hoa_global.GameGlobal.GLOBAL_STATUS_INVALID,
Apply = function(effect)
- -- TODO: Implement paralysis
battle_actor = effect:GetAffectedActor();
- --battle_actor:RegisterParalysis();
- print("Paralysis not implemented yet!!");
+ battle_actor:SetStunned(true);
end,
Update = function(effect)
@@ -695,9 +695,8 @@ status_effects[hoa_global.GameGlobal.GLOBAL_STATUS_PARALYSIS] = {
end,
Remove = function(effect)
- -- TODO: Implement paralysis
battle_actor = effect:GetAffectedActor();
- --battle_actor:UnregisterParalysis();
+ battle_actor:SetStunned(false);
end
}
View
17 dat/skills/attack.lua
@@ -96,20 +96,29 @@ skills[2] = {
skills[3] = {
name = hoa_system.Translate("Stun Strike"),
- description = hoa_system.Translate("A blow which targets vital areas and temporarily stun its target."),
+ description = hoa_system.Translate("A blow which temporarily stun its target."),
sp_required = 5,
warmup_time = 1200,
cooldown_time = 0,
action_name = "attack",
- target_type = hoa_global.GameGlobal.GLOBAL_TARGET_FOE,
+ target_type = hoa_global.GameGlobal.GLOBAL_TARGET_FOE_POINT,
BattleExecute = function(user, target)
target_actor = target:GetActor();
if (hoa_battle.CalculateStandardEvasionAdder(target, 5.5) == false) then
+ -- Calculate chance for paralysis effect and activate it
+ local attack_point = target_actor:GetAttackPoint(target:GetPoint());
+ local chance_modifier = (user:GetTotalMetaphysicalAttack() - attack_point:GetTotalMetaphysicalDefense()) * 3.0;
+ local chance = (hoa_utils.RandomFloat() * 100.0);
+ if (chance <= (50.0 + chance_modifier)) then
+ target_actor:RegisterStatusChange(hoa_global.GameGlobal.GLOBAL_STATUS_PARALYSIS, hoa_global.GameGlobal.GLOBAL_INTENSITY_POS_LESSER);
+ else
+ target_actor:RegisterMiss(true);
+ end
+
+ -- The damages are applied after the potential effects, so that a potential target death handles the effect removal properly
target_actor:RegisterDamage(hoa_battle.CalculatePhysicalDamage(user, target));
- -- TODO: Calculate chance for paralysis effect and activate it
- target_actor:RegisterStatusChange(hoa_global.GameGlobal.GLOBAL_STATUS_PARALYSIS, hoa_global.GameGlobal.GLOBAL_INTENSITY_POS_LESSER);
AudioManager:PlaySound("snd/swordslice1.wav");
else
target_actor:RegisterMiss(true);
View
BIN  img/icons/effects/zzz.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
27 src/common/global/global_actors.h
@@ -360,40 +360,41 @@ class GlobalActor {
**/
//@{
void SetExperienceLevel(uint32 xp_level)
- { _experience_level = xp_level; }
+ { _experience_level = xp_level; }
void SetExperiencePoints(uint32 xp_points)
- { _experience_points = xp_points; }
+ { _experience_points = xp_points; }
void SetHitPoints(uint32 hp)
- { if (hp > _max_hit_points) _hit_points = _max_hit_points; else _hit_points = hp; }
+ { if (hp > _max_hit_points) _hit_points = _max_hit_points; else _hit_points = hp; }
void SetMaxHitPoints(uint32 hp)
- { _max_hit_points = hp; if (_hit_points > _max_hit_points) _hit_points = _max_hit_points; }
+ { _max_hit_points = hp; if (_hit_points > _max_hit_points) _hit_points = _max_hit_points; }
void SetSkillPoints(uint32 sp)
- { if (sp > _max_skill_points) _skill_points = _max_skill_points; else _skill_points = sp; }
+ { if (sp > _max_skill_points) _skill_points = _max_skill_points; else _skill_points = sp; }
void SetMaxSkillPoints(uint32 sp)
- { _max_skill_points = sp; if (_skill_points > _max_skill_points) _skill_points = _max_skill_points; }
+ { _max_skill_points = sp; if (_skill_points > _max_skill_points) _skill_points = _max_skill_points; }
void SetStrength(uint32 st)
- { _strength = st; _CalculateAttackRatings(); }
+ { _strength = st; _CalculateAttackRatings(); }
void SetVigor(uint32 vi)
- { _vigor = vi; _CalculateAttackRatings(); }
+ { _vigor = vi; _CalculateAttackRatings(); }
void SetFortitude(uint32 fo)
- { _fortitude = fo; _CalculateDefenseRatings(); }
+ { _fortitude = fo; _CalculateDefenseRatings(); }
void SetProtection(uint32 pr)
- { _protection = pr; _CalculateDefenseRatings(); }
+ { _protection = pr; _CalculateDefenseRatings(); }
- void SetAgility(uint32 ag)
- { _agility = ag; }
+ //! Made virtual to permit Battle Actors to recompute the idle state time.
+ virtual void SetAgility(uint32 ag)
+ { _agility = ag; }
void SetEvade(float ev)
- { _evade = ev; _CalculateEvadeRatings(); }
+ { _evade = ev; _CalculateEvadeRatings(); }
//@}
/** \name Class member add and subtract functions
View
1  src/defs.h
@@ -237,7 +237,6 @@ namespace hoa_battle {
class SkillAction;
class ItemAction;
- class BattleTimer;
class BattleTarget;
class BattleItem;
View
4 src/modes/battle/battle.cpp
@@ -157,6 +157,10 @@ BattleMedia::BattleMedia() {
}
script_file.CloseTable();
}
+
+ // Load the stunned icon
+ if (!_stunned_icon.Load("img/icons/effects/zzz.png"))
+ IF_PRINT_WARNING(BATTLE_DEBUG) << "failed to load stunned icon" << std::endl;
}
View
6 src/modes/battle/battle.h
@@ -114,6 +114,9 @@ class BattleMedia {
**/
hoa_video::StillImage* GetStatusIcon(hoa_global::GLOBAL_STATUS type, hoa_global::GLOBAL_INTENSITY intensity);
+ const hoa_video::StillImage& GetStunnedIcon()
+ { return _stunned_icon; }
+
// ---------- Public members
//! \brief The static background image to be used for the battle
@@ -207,6 +210,9 @@ class BattleMedia {
//! \brief Contains the entire set of status effect icons
std::vector<hoa_video::StillImage> _status_icons;
+
+ //! \brief An icon displayed above the character's head when it is stunned.
+ hoa_video::StillImage _stunned_icon;
}; // class BattleMedia
} // namespace private_battle
View
66 src/modes/battle/battle_actors.cpp
@@ -58,7 +58,8 @@ BattleActor::BattleActor(GlobalActor* actor) :
_action(NULL),
_execution_finished(false),
_idle_state_time(0),
- _shake_timer(0),
+ _hurt_timer(0),
+ _is_stunned(false),
_animation_timer(0),
_x_stamina_location(0.0f),
_y_stamina_location(0.0f),
@@ -204,31 +205,29 @@ void BattleActor::RegisterDamage(uint32 amount, BattleTarget* target) {
// Apply a stun to the actor timer depending on the amount of damage dealt
float damage_percent = static_cast<float>(amount) / static_cast<float>(GetMaxHitPoints());
- uint32 stun_time = 0;
+ uint32 hurt_time = 0;
if (damage_percent < 0.10f)
- stun_time = 250;
+ hurt_time = 250;
else if (damage_percent < 0.25f)
- stun_time = 500;
+ hurt_time = 500;
else if (damage_percent < 0.50f)
- stun_time = 750;
+ hurt_time = 750;
else // (damage_percent >= 0.50f)
- stun_time = 1000;
+ hurt_time = 1000;
// 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_ACTIVE)
- stun_time /= BATTLE_SEMI_ACTIVE_FACTOR;
+ hurt_time /= BATTLE_SEMI_ACTIVE_FACTOR;
else if (BM->GetBattleType() == BATTLE_TYPE_WAIT)
- stun_time /= BATTLE_WAIT_FACTOR;
+ hurt_time /= BATTLE_WAIT_FACTOR;
else if (BM->GetBattleType() == BATTLE_TYPE_ACTIVE)
- stun_time /= BATTLE_ACTIVE_FACTOR;
+ hurt_time /= BATTLE_ACTIVE_FACTOR;
- _state_timer.StunTimer(stun_time);
// Run a shake effect for the same time.
- _shake_timer.Initialize(stun_time);
- _shake_timer.Run();
-
+ _hurt_timer.Initialize(hurt_time);
+ _hurt_timer.Run();
// If the damage dealt was to a point target type, check for and apply any status effects triggered by this point hit
if ((target != NULL) && (IsTargetPoint(target->GetType()) == true)) {
@@ -311,16 +310,25 @@ void BattleActor::RegisterStatusChange(GLOBAL_STATUS status, GLOBAL_INTENSITY in
void BattleActor::Update() {
// Don't update the state timer when the battle tells is to pause
// when in idle state.
- if (!BattleMode::CurrentInstance()->AreActorStatesPaused())
- _state_timer.Update();
+ // Also don't elapse the status effect time when paused.
+ if (!BattleMode::CurrentInstance()->AreActorStatesPaused()) {
+ // Don't update the state_timer if the character is hurt.
+ if (!_hurt_timer.IsRunning()) {
+
+ // Check the stun effect when in idle state.
+ if (_state != ACTOR_STATE_IDLE || !_is_stunned)
+ _state_timer.Update();
+ }
+
+ _effects_supervisor->Update();
+ }
// Ths shaking updates even in pause mode, so that the shaking
// doesn't last indefinitely in that state.
- _shake_timer.Update();
+ _hurt_timer.Update();
_UpdateStaminaIconPosition();
- _effects_supervisor->Update();
_indicator_supervisor->Update();
if (_state_timer.IsFinished() == true) {
@@ -388,9 +396,8 @@ void BattleActor::_UpdateStaminaIconPosition() {
}
// Add a shake effect when the battle actor has received damages
- if (_shake_timer.IsRunning()) {
+ if (_hurt_timer.IsRunning())
x_pos += RandomFloat(-4.0f, 4.0f);
- }
_x_stamina_location = x_pos;
_y_stamina_location = y_pos;
@@ -601,9 +608,8 @@ void BattleCharacter::Update() {
}
// Add a shake effect when the battle actor has received damages
- if (_shake_timer.IsRunning()) {
+ if (_hurt_timer.IsRunning())
_x_location = _x_origin + RandomFloat(-6.0f, 6.0f);
- }
// If the character has finished to execute its battle action,
if (_state == ACTOR_STATE_ACTING && _state_timer.IsFinished()) {
@@ -626,6 +632,11 @@ void BattleCharacter::Update() {
void BattleCharacter::DrawSprite() {
VideoManager->Move(_x_location, _y_location);
_global_character->RetrieveBattleAnimation(_sprite_animation_alias)->Draw();
+
+ if (_is_stunned && _state == ACTOR_STATE_IDLE) {
+ VideoManager->MoveRelative(0, GetSpriteHeight());
+ BattleMode::CurrentInstance()->GetMedia().GetStunnedIcon().Draw();
+ }
} // void BattleCharacter::DrawSprite()
void BattleCharacter::ChangeSpriteAnimation(const std::string& alias) {
@@ -895,7 +906,7 @@ void BattleEnemy::Update() {
}
// Add a shake effect when the battle actor has received damages
- if (_shake_timer.IsRunning())
+ if (_hurt_timer.IsRunning())
_x_location += RandomFloat(-2.0f, 2.0f);
if (_state == ACTOR_STATE_ACTING) {
@@ -911,16 +922,14 @@ void BattleEnemy::Update() {
}
void BattleEnemy::DrawSprite() {
- VideoManager->Move(_x_location, _y_location);
-
- std::vector<StillImage>& sprite_frames = *(_global_enemy->GetBattleSpriteFrames());
-
// Dead enemies are gone from screen.
if (_state == ACTOR_STATE_DEAD)
return;
+ std::vector<StillImage>& sprite_frames = *(_global_enemy->GetBattleSpriteFrames());
float hp_percent = static_cast<float>(GetHitPoints()) / static_cast<float>(GetMaxHitPoints());
+ VideoManager->Move(_x_location, _y_location);
// Alpha will range from 1.0 to 0.0 in the following calculations
if (_state == ACTOR_STATE_DYING) {
sprite_frames[3].Draw(Color(1.0f, 1.0f, 1.0f, _sprite_alpha));
@@ -943,6 +952,11 @@ void BattleEnemy::DrawSprite() {
float alpha = 1.0f - (hp_percent * 3.0f);
sprite_frames[3].Draw(Color(1.0f, 1.0f, 1.0f, alpha));
}
+
+ if (_is_stunned && _state == ACTOR_STATE_IDLE) {
+ VideoManager->MoveRelative(0, GetSpriteHeight());
+ BattleMode::CurrentInstance()->GetMedia().GetStunnedIcon().Draw();
+ }
} // void BattleEnemy::DrawSprite()
void BattleEnemy::_DecideAction() {
View
20 src/modes/battle/battle_actors.h
@@ -303,6 +303,11 @@ class BattleActor : public hoa_global::GlobalActor, public BattleObject {
**/
void ChangeSkillPoints(int32 amount);
+ //! \brief Stuns the BattleActor, preventing its state timer to update.
+ //! \param stun Whether the actor should be stunned.
+ void SetStunned(bool stun)
+ { _is_stunned = stun; }
+
/** \brief Updates the state of the actor
***
*** The optional boolean parameter is primarily used by battle sequences which desire to update the sprite graphics
@@ -398,7 +403,7 @@ class BattleActor : public hoa_global::GlobalActor, public BattleObject {
hoa_video::StillImage& GetStaminaIcon()
{ return _stamina_icon; }
- BattleTimer& GetStateTimer()
+ hoa_system::SystemTimer& GetStateTimer()
{ return _state_timer; }
//! \note If the actor is in the idle state, this will not affect the state timer
@@ -426,18 +431,17 @@ class BattleActor : public hoa_global::GlobalActor, public BattleObject {
uint32 _idle_state_time;
//! \brief A timer used as the character progresses through the standard series of actor states
- BattleTimer _state_timer;
+ hoa_system::SystemTimer _state_timer;
+
+ //! \brief A timer telling the time the character is hurt, making it visually shaking.
+ hoa_system::SystemTimer _hurt_timer;
- //! \brief A timer telling the time the character will be visually shaking.
- hoa_system::SystemTimer _shake_timer;
+ //! \brief Tells whether the actor is stunned, preventing its idle state time to update.
+ bool _is_stunned;
//! \brief Used to assist in the animation of actors as they move on the battlefield
hoa_system::SystemTimer _animation_timer;
- // TODO: add later for effects such as "petrify"
-// //! \brief When set to true, the actor essentially has immunity and can not be targeted by attacks
-// bool _not_targetable;
-
//! \brief The x and y coordinates of the actor's current stamina icon on the stamina bar.
float _x_stamina_location, _y_stamina_location;
View
158 src/modes/battle/battle_utils.cpp
@@ -425,164 +425,6 @@ uint32 CalculateMetaphysicalDamageMultiplier(BattleActor* attacker, BattleTarget
} // uint32 CalculateMetaphysicalDamageMultiplier(BattleActor* attacker, BattleTarget* target, float mul_phys, float std_dev)
////////////////////////////////////////////////////////////////////////////////
-// BattleTimer class
-////////////////////////////////////////////////////////////////////////////////
-
-BattleTimer::BattleTimer() :
- SystemTimer(),
- _stun_time(0),
- _visible_time_expired(0),
- _multiplier_active(false),
- _multiplier_factor(0.0f),
- _multiplier_fraction_accumulator(0.0f)
-{}
-
-
-
-BattleTimer::BattleTimer(uint32 duration, int32 loops) :
- SystemTimer(duration, loops),
- _stun_time(0),
- _visible_time_expired(0),
- _multiplier_active(false),
- _multiplier_factor(0.0f),
- _multiplier_fraction_accumulator(0.0f)
-{}
-
-
-
-void BattleTimer::Update() {
- Update(SystemManager->GetUpdateTime());
-}
-
-
-
-void BattleTimer::Update(uint32 time) {
- if (_auto_update == true) {
- IF_PRINT_WARNING(SYSTEM_DEBUG) << "update failed because timer is in automatic update mode" << std::endl;
- return;
- }
- if (IsRunning() == false) {
- return;
- }
-
- if (_multiplier_active == true) {
- time = _ApplyMultiplier(time);
- }
- time = _ApplyStun(time);
- SystemTimer::_UpdateTimer(time);
- _UpdateVisibleTimeExpired(time);
-}
-
-
-
-void BattleTimer::Reset() {
- SystemTimer::Reset();
- _multiplier_fraction_accumulator = 0.0f;
-}
-
-
-
-void BattleTimer::SetTimeExpired(uint32 time) {
- _time_expired = time;
-
- if ((_time_expired == 0) && (_times_completed == 0)) {
- _state = SYSTEM_TIMER_INITIAL;
- }
-
- else if (_time_expired >= _duration) {
- _time_expired = 0;
- _times_completed++;
-
- // Check if the timer has finished the final loop and should reach the finished state
- if ((_number_loops >= 0) && (_times_completed >= static_cast<uint32>(_number_loops))) {
- _state = SYSTEM_TIMER_FINISHED;
- }
- }
-}
-
-
-
-void BattleTimer::ActivateMultiplier(bool activate, float multiplier) {
- _multiplier_active = activate;
-
- if (activate == true) {
- if (multiplier < 0.0f) {
- IF_PRINT_WARNING(BATTLE_DEBUG) << "attempted to activate a negative multiplier factor: " << multiplier << std::endl;
- _multiplier_active = false;
- }
- else {
- _multiplier_factor = multiplier;
- // Note: the fraction accumulator is not reset in this case. This allows the multiplier factor to
- // change without reseting the fraction. Fractions are only reset when the multiplier is deactivated
- }
- }
- else {
- _multiplier_factor = 0.0f;
- _multiplier_fraction_accumulator = 0.0f;
- }
-}
-
-
-
-void BattleTimer::_AutoUpdate() {
- if (_auto_update == false) {
- IF_PRINT_WARNING(SYSTEM_DEBUG) << "tried to automatically update a timer that does not have auto updates enabled" << std::endl;
- return;
- }
- if (IsRunning() == false) {
- return;
- }
-
- uint32 time = SystemManager->GetUpdateTime();
- if (_multiplier_active == true) {
- time = _ApplyMultiplier(time);
- }
- time = _ApplyStun(time);
- SystemTimer::_UpdateTimer(time);
- _UpdateVisibleTimeExpired(time);
-}
-
-
-
-uint32 BattleTimer::_ApplyStun(uint32 time) {
- if (_stun_time > 0) {
- if (_stun_time >= time) {
- _stun_time -= time;
- time = 0;
- }
- else {
- _stun_time = 0;
- time -= _stun_time;
- }
- }
-
- return time;
-}
-
-
-
-uint32 BattleTimer::_ApplyMultiplier(uint32 time) {
- float update_time = _multiplier_factor * static_cast<float>(time);
- uint32 return_time = static_cast<uint32>(_multiplier_factor * time);
-
- _multiplier_fraction_accumulator += (update_time - return_time);
-
- if (_multiplier_fraction_accumulator >= 1.0f) {
- uint32 accumulator_overflow = static_cast<uint32>(_multiplier_fraction_accumulator);
- _multiplier_fraction_accumulator -= accumulator_overflow;
- return_time += accumulator_overflow;
- }
-
- return return_time;
-}
-
-
-
-void BattleTimer::_UpdateVisibleTimeExpired(uint32 time) {
- // TODO: adjust the _visible_time_expired member accordingly
-}
-
-////////////////////////////////////////////////////////////////////////////////
// BattleTarget class
////////////////////////////////////////////////////////////////////////////////
View
153 src/modes/battle/battle_utils.h
@@ -307,159 +307,6 @@ uint32 CalculateMetaphysicalDamageMultiplier(BattleActor* attacker, BattleTarget
uint32 CalculateMetaphysicalDamageMultiplier(BattleActor* attacker, BattleTarget* target, float mul_atk, float std_dev);
//@}
-
-/** ****************************************************************************
-*** \brief Builds upon the SystemTimer to provide more flexibility and features
-***
-*** Battle mode timers are a bit more advanced over the standard system engine
-*** timer to meet the needs of some timers in battle mode. The additional features
-*** available to battle timers over system timers include the following.
-***
-*** - The ability to set the expiration time of the current loop to any value
-*** - Apply a floating-point multiplier to speed up or slow down the timer
-***
-*** \note Not all timers in battle mode will require the features of this class.
-*** Evaluate the needs of a timer in the battle code and determine whether or not
-*** it should use this class or if the standard SystemTimer will meet its needs.
-*** ***************************************************************************/
-class BattleTimer : public hoa_system::SystemTimer {
- friend class SystemEngine; // For allowing SystemEngine to call the _AutoUpdate() method
-
-public:
- BattleTimer();
-
- /** \brief Creates and places the timer in the SYSTEM_TIMER_INITIAL state
- *** \param duration The duration (in milliseconds) that the timer should count for
- *** \param loops The number of times that the timer should loop for. Default value is set to no looping.
- **/
- BattleTimer(uint32 duration, int32 loops = 0);
-
- ~BattleTimer()
- {}
-
- //! \brief Overrides the SystemTimer::Update() method
- void Update();
-
- /** \brief Overrides the SystemTimer::Update(uint32) method
- *** \param time The amount of time to increment the timer by
- **/
- void Update(uint32 time);
-
- //! \brief Overrides the SystemTimer::Reset() method
- void Reset();
-
- /** \brief Sets the time expired member and updates the timer object appropriately
- *** \param time The value to set for the expiration time
- ***
- *** This method will do nothing if the state of the object is SYSTEM_TIMER_INVALID or SYSTEM_TIMER_FINISHED.
- *** The new expiration time applies only to the current loop. So for example, if the timer is on loop #2
- *** of 5 and the loop duration is 1000ms, setting the time to 1500ms will result in the timer
- *** state changing to loop #3 and set the expiration time back to zero. Reaching the last loop
- *** will set the timer to the FINISHED state. Using a zero value for the time while on the first loop will
- *** change the timer to the INITIAL state.
- ***
- *** If you're only looking to increment the expiration time and wish for that increment to take
- *** effect for more than just the current loop, use the Update(uint32) method. Although be aware that
- *** Update() will take into account any timer multipliers that are active while this method ignores
- *** the timer multiplier.
- **/
- void SetTimeExpired(uint32 time);
-
- /** \brief Stops the timer for the amount of time specified before it can continue
- *** \param time The number of milliseconds for the timer to remain "stunned"
- ***
- *** You can call this function multiple times and the stun time values will accumulate. For example, if you
- *** call the function with a value of 100, then 20ms later call it again with a value of 50, the stun time
- *** will be 130ms after the second call (100 - 20 + 50).
- **/
- void StunTimer(uint32 time)
- { _stun_time += time; }
-
- /** \brief Activates or deactivates the timer multiplier
- *** \param activate True will activate and set the multiplier while false will deactivate.
- *** \param multiplier The multiplier value to apply towards the timer, which should be positive.
- ***
- *** If the activate argument is false, the multiplier value will be ignored. The multiplier
- *** value is multiplied directly to the raw update time to obtain the actual update time.
- *** So for example if the raw update time is 25 and the multiplier value is 0.8f, the actual
- *** update time for the class will be 20.
- **/
- void ActivateMultiplier(bool activate, float multiplier);
-
- //! \name Class member accessor methods
- //@{
- bool IsStunActive() const
- { return (_stun_time > 0); }
-
- bool IsMultiplierActive() const
- { return _multiplier_active; }
-
- float GetMultiplierFactor() const
- { return _multiplier_factor; }
- //@}
-
-protected:
- //! \brief This value must be consumed by the update process before the _time_expired member can continue to be updated
- uint32 _stun_time;
-
- /** \brief Constantly tries to approach the value of _time_expired in a gradual manner
- ***
- *** This member allows us to show "gradual shifts" whenever the _time_expired member jumps to a new value. For example,
- *** if a battle skill is used that reduces the _time_expired value of the target to zero, instead of instantly jumping the
- *** stamina portrait of the target to the zero mark on the stamina bar, this member will show a quick but gradual move downward.
- **/
- uint32 _visible_time_expired;
-
- //! \brief When true the timer multiplier is applied to all timer updates
- bool _multiplier_active;
-
- //! \brief A zero or positive value that is multiplied to the update time
- float _multiplier_factor;
-
- //! \brief Accumulates fractions of a millisecond that were applied by a mutliplier (ie, an update of 15.5ms would store the 0.5)
- float _multiplier_fraction_accumulator;
-
- //! \brief Overrides the SystemTimer::_AutoUpdate() method
- virtual void _AutoUpdate();
-
-private:
- /** \brief Computes and returns the update time after any stun duration has been accounted for
- *** \param time The update time to apply to any active stun effect
- *** \return The modified update time after stun has been acounted for
- ***
- *** If the value of _stun_time is zero, this function will do nothing and return the value that it was passed.
- *** It is possible that this function may consume the entire update time to reduce an active stun effect, and
- *** thus would return a zero value.
- **/
- uint32 _ApplyStun(uint32 time);
-
- /** \brief Computes and returns the update time after the multiplier has been applied
- *** \param time The raw update time to use in the calculation
- *** \return The modified update time
- ***
- *** This method does not do any error checking such as whether the multiplier is a valid number
- *** (non-negative) or whether or not the multiplier is active. The code that calls this function
- *** is responsible for that condition checking.
- ***
- *** This function also adds any remainders after applying the multiplier to the accumulator. If it
- *** finds the value of the accumulator is greater than or equal to 1.0f, it adds the integer amount
- *** to the return value and subtracts this amount from the accumulator. For example, if the accumulator
- *** held a value of 0.85f before this function was called, and the multiplier application left an additional
- *** 0.5f remainder, the value of the accumulator after the call returns will be 0.35f and a value of 1 will
- *** be added into the value that the function returns.
- **/
- uint32 _ApplyMultiplier(uint32 time);
-
- /** \brief Updates the value of the _visible_time_expired member to reduce the distance between it and _UpdateTime
- *** \param time The amount of time that the actual timer was just updated by. Zero if no update was applied to the timer.
- ***
- *** This function aims to make the _visible_time_expired member equal to the _time_expired member over a series of gradual steps.
- *** The time argument is used to keep the two members in sync when they are already equal in value.
- **/
- void _UpdateVisibleTimeExpired(uint32 time);
-}; // class BattleTimer : public hoa_system::SystemTimer
-
-
/** ****************************************************************************
*** \brief Container class for representing the target of a battle action
***
View
1  src/modes/mode_bindings.cpp
@@ -652,6 +652,7 @@ void BindModeCode() {
.def("RegisterRevive", &BattleActor::RegisterRevive)
.def("RegisterMiss", &BattleActor::RegisterMiss)
.def("RegisterStatusChange", &BattleActor::RegisterStatusChange)
+ .def("SetStunned", &BattleActor::SetStunned)
.def("ResetHitPoints", &BattleActor::ResetHitPoints)
.def("ResetMaxHitPoints", &BattleActor::ResetMaxHitPoints)
.def("ResetSkillPoints", &BattleActor::ResetSkillPoints)
Please sign in to comment.
Something went wrong with that request. Please try again.