Core/Units: improved logic for determining when a power update shall happen
This commit is contained in:
1 parent
321a81cc30
commit
b5994ec6c5
7 files changed
+18
-17
No files matched your search
@@ -850,8 +850,13 @@ void Creature::Update(uint32 diff)
|
||||
if (!IsAlive())
|
||||
break;
|
||||
|
||||
_powerUpdateTimer -= diff;
|
||||
Regenerate(GetPowerType(), diff);
|
||||
|
||||
// Reset the power update timer after regeneration happened
|
||||
if (_powerUpdateTimer <= 0)
|
||||
_powerUpdateTimer = GetPowerUpdateInterval();
|
||||
|
||||
if (CanNotReachTarget() && !IsInEvadeMode() && !GetMap()->IsRaid())
|
||||
{
|
||||
m_cannotReachTimer += diff;
|
||||
|
||||
@@ -1204,9 +1204,15 @@ void Player::Update(uint32 p_time)
|
||||
m_zoneUpdateTimer -= p_time;
|
||||
}
|
||||
|
||||
// Power regeneration update
|
||||
_powerUpdateTimer -= p_time;
|
||||
if (IsAlive())
|
||||
RegenerateAll(p_time);
|
||||
|
||||
// Reset the power update timer after regeneration happened
|
||||
if (_powerUpdateTimer <= 0)
|
||||
_powerUpdateTimer = GetPowerUpdateInterval();
|
||||
|
||||
if (m_deathState == JUST_DIED)
|
||||
KillPlayer();
|
||||
|
||||
|
||||
@@ -1515,7 +1515,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
void ResetPetTalents();
|
||||
void RegenerateAll(uint32 diff);
|
||||
void RegenerateHealth() override;
|
||||
void SetRegenerationTimer(uint32 time) { _regenerationTimer = time;}
|
||||
void setWeaponChangeTimer(uint32 time) { m_weaponChangeTimer = time;}
|
||||
|
||||
uint64 GetMoney() const { return GetUInt64Value(PLAYER_FIELD_COINAGE); }
|
||||
|
||||
@@ -413,7 +413,7 @@ Unit::Unit(bool isWorldObject) :
|
||||
for (uint8 i = 0; i < MAX_POWERS_PER_CLASS; ++i)
|
||||
_powerFraction[i] = 0;
|
||||
|
||||
_regenerationTimer = GetRegenerationInterval();
|
||||
_powerUpdateTimer = GetPowerUpdateInterval();
|
||||
_healthRegenerationTimer = UNIT_HEALTH_REGENERATION_INTERVAL;
|
||||
|
||||
_oldFactionId = 0;
|
||||
@@ -522,12 +522,6 @@ void Unit::Update(uint32 p_time)
|
||||
// All position info based actions have been executed, reset info
|
||||
_positionUpdateInfo.Reset();
|
||||
|
||||
// Update Power regeneration interval
|
||||
if (_regenerationTimer >= int32(GetRegenerationInterval()))
|
||||
_regenerationTimer -= (GetRegenerationInterval() - p_time);
|
||||
else
|
||||
_regenerationTimer += p_time;
|
||||
|
||||
// Update Health Regeneration
|
||||
_healthRegenerationTimer -= p_time;
|
||||
if (_healthRegenerationTimer <= 0)
|
||||
@@ -10052,7 +10046,7 @@ void Unit::Regenerate(Powers powerType, uint32 diff)
|
||||
}
|
||||
|
||||
// Players update their powers in 2 seconds intervals, creatures in 1 second ones
|
||||
if (_regenerationTimer >= int32(GetRegenerationInterval()))
|
||||
if (_powerUpdateTimer <= 0)
|
||||
SetPower(powerType, curValue);
|
||||
else
|
||||
UpdateUInt32Value(UNIT_FIELD_POWER1 + powerIndex, curValue);
|
||||
|
||||
@@ -1806,7 +1806,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
LiquidTypeEntry const* _lastLiquid;
|
||||
uint32 _powerBarId;
|
||||
float _powerFraction[MAX_POWERS_PER_CLASS];
|
||||
int32 _regenerationTimer;
|
||||
int32 _powerUpdateTimer;
|
||||
int32 _healthRegenerationTimer;
|
||||
|
||||
bool IsAlwaysVisibleFor(WorldObject const* seer) const override;
|
||||
@@ -1825,6 +1825,8 @@ class TC_GAME_API Unit : public WorldObject
|
||||
virtual void AtDisengage() {}
|
||||
|
||||
void InterruptMovementBasedAuras();
|
||||
|
||||
uint32 GetPowerUpdateInterval() const { return IsPlayer() ? PLAYER_POWER_UPDATE_INTERVAL : UNIT_POWER_UPDATE_INTERVAL; }
|
||||
private:
|
||||
|
||||
void UpdateSplineMovement(uint32 t_diff);
|
||||
@@ -1836,8 +1838,6 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
void ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMask, uint32 hitMask, WeaponAttackType attType);
|
||||
|
||||
uint32 GetRegenerationInterval() const { return IsPlayer() ? PLAYER_REGENERATION_INTERVAL : UNIT_REGENERATION_INTERVAL; }
|
||||
|
||||
protected:
|
||||
void SetFeared(bool apply);
|
||||
void SetConfused(bool apply);
|
||||
|
||||
@@ -247,9 +247,9 @@ enum Powers
|
||||
};
|
||||
|
||||
#define MAX_POWERS_PER_CLASS 5
|
||||
#define PLAYER_REGENERATION_INTERVAL 2 * IN_MILLISECONDS
|
||||
#define UNIT_REGENERATION_INTERVAL 1 * IN_MILLISECONDS
|
||||
#define UNIT_HEALTH_REGENERATION_INTERVAL 2 * IN_MILLISECONDS
|
||||
static constexpr uint32 const PLAYER_POWER_UPDATE_INTERVAL = 2 * IN_MILLISECONDS;
|
||||
static constexpr uint32 const UNIT_POWER_UPDATE_INTERVAL = 1 * IN_MILLISECONDS;
|
||||
|
||||
enum SpellSchools
|
||||
{
|
||||
|
||||
@@ -2187,9 +2187,6 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
|
||||
{
|
||||
// for players, start regeneration after 1s (in polymorph fast regeneration case)
|
||||
// only if caster is Player (after patch 2.4.2)
|
||||
if (GetCasterGUID().IsPlayer())
|
||||
target->ToPlayer()->SetRegenerationTimer(1 * IN_MILLISECONDS);
|
||||
|
||||
//dismount polymorphed target (after patch 2.4.2)
|
||||
if (target->IsMounted())
|
||||
target->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||
|
||||
Reference in new issue
Block a user