aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-08-23 22:36:51 -0500
committermegamage <none@none>2009-08-23 22:36:51 -0500
commit5f1589d6d19bf9d4548e0e9fda97f77bb1240ebf (patch)
tree8d13ac05294821c049abb62fc8a3b73b924ec085
parent7712d5e0bd021e92b87e592a830129c69133dee4 (diff)
*Allow vehicles to regenerate energy.
--HG-- branch : trunk
-rw-r--r--src/game/Creature.cpp28
-rw-r--r--src/game/Creature.h1
-rw-r--r--src/game/Pet.cpp10
-rw-r--r--src/game/Pet.h3
-rw-r--r--src/game/Unit.cpp6
-rw-r--r--src/game/Unit.h2
6 files changed, 25 insertions, 25 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index a8d1ffe9b54..9aa6eb78c74 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -539,28 +539,22 @@ void Creature::Update(uint32 diff)
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if(!isAlive())
break;
- if(m_regenTimer > 0)
- {
- if(diff >= m_regenTimer)
- m_regenTimer = 0;
- else
- m_regenTimer -= diff;
- }
- if (m_regenTimer != 0)
- break;
- if (!isInCombat())
+ if(m_regenTimer > diff)
+ m_regenTimer -= diff;
+ else
{
- if(HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER))
- SetUInt32Value(UNIT_DYNAMIC_FLAGS, GetCreatureInfo()->dynamicflags);
- RegenerateHealth();
- }
- else if(IsPolymorphed())
+ if (!isInCombat() || IsPolymorphed())
RegenerateHealth();
- RegenerateMana();
+ if(getPowerType() == POWER_ENERGY)
+ Regenerate(POWER_ENERGY);
+ else
+ RegenerateMana();
+
+ m_regenTimer += 2000 - diff;
+ }
- m_regenTimer = 2000;
break;
}
case DEAD_FALLING:
diff --git a/src/game/Creature.h b/src/game/Creature.h
index a798c88a7e4..cd726c567fb 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -751,6 +751,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
ReactStates m_reactState; // for AI, not charmInfo
void RegenerateMana();
void RegenerateHealth();
+ void Regenerate(Powers power);
MovementGeneratorType m_defaultMovementType;
Cell m_currentCell; // store current cell where creature listed
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index e33fe6b7178..a2d0c3ddd32 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -537,17 +537,19 @@ void Pet::Update(uint32 diff)
{
case POWER_FOCUS:
Regenerate(POWER_FOCUS);
- m_regenTimer = 4000;
+ m_regenTimer += 4000 - diff;
+ if(!m_regenTimer) ++m_regenTimer;
break;
case POWER_ENERGY:
Regenerate(POWER_ENERGY);
- m_regenTimer = 2000;
+ m_regenTimer += 2000 - diff;
+ if(!m_regenTimer) ++m_regenTimer;
break;
default:
m_regenTimer = 0;
break;
}
- }
+ }
}
if(getPetType() != HUNTER_PET)
@@ -569,7 +571,7 @@ void Pet::Update(uint32 diff)
Creature::Update(diff);
}
-void Pet::Regenerate(Powers power)
+void Creature::Regenerate(Powers power)
{
uint32 curValue = GetPower(power);
uint32 maxValue = GetMaxPower(power);
diff --git a/src/game/Pet.h b/src/game/Pet.h
index ab654ca26a7..6cffc7cd44a 100644
--- a/src/game/Pet.h
+++ b/src/game/Pet.h
@@ -159,7 +159,6 @@ class Pet : public Guardian
return m_autospells[pos];
}
- void Regenerate(Powers power);
void LooseHappiness();
HappinessState GetHappinessState();
void GivePetXP(uint32 xp);
@@ -238,7 +237,7 @@ class Pet : public Guardian
int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets)
uint64 m_auraRaidUpdateMask;
bool m_loading;
- uint32 m_regenTimer;
+ int32 m_regenTimer;
DeclinedName *m_declinedname;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 55435379a73..2766d31d6bc 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -10550,8 +10550,12 @@ void Unit::ClearInCombat()
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
// Player's state will be cleared in Player::UpdateContestedPvP
- if(GetTypeId()!=TYPEID_PLAYER)
+ if(GetTypeId() != TYPEID_PLAYER)
+ {
clearUnitState(UNIT_STAT_ATTACK_PLAYER);
+ if(HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER))
+ SetUInt32Value(UNIT_DYNAMIC_FLAGS, ((Creature*)this)->GetCreatureInfo()->dynamicflags);
+ }
else
((Player*)this)->UpdatePotionCooldown();
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 270d8de883b..c7e2e838212 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1933,7 +1933,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
//uint32 m_unit_movement_flags;
uint32 m_reactiveTimer[MAX_REACTIVE];
- uint32 m_regenTimer;
+ int32 m_regenTimer;
ThreatManager m_ThreatManager;