* Better fix for issue that players are unable to loot creatures when the HP of the creature is changed via a script. Do not use rev before this.

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2009-06-10 08:44:10 +02:00
parent d065bbf410
commit f137dc02ec
4 changed files with 12 additions and 6 deletions
@@ -62,6 +62,7 @@ struct TRINITY_DLL_DECL boss_murmurAI : public Scripted_NoMovementAI
//database should have `RegenHealth`=0 to prevent regen
uint32 hp = (m_creature->GetMaxHealth()*40)/100;
if (hp) m_creature->SetHealth(hp);
m_creature->ResetDamageByPlayers();
}
void SonicBoomEffect()
-1
View File
@@ -154,7 +154,6 @@ m_creatureInfo(NULL), m_reactState(REACT_AGGRESSIVE), m_formation(NULL), m_summo
m_unit_movement_flags = MOVEMENTFLAG_WALK_MODE;
DisableReputationGain = false;
ResetDamageByPlayers();
m_MinPlayerDamageReq = (uint32)(m_creature->GetHealth / m_creature->GetMaxHealth * 50);
}
Creature::~Creature()
+8 -4
View File
@@ -722,10 +722,14 @@ class TRINITY_DLL_SPEC Creature : public Unit
void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
bool IsReputationGainDisabled() { return DisableReputationGain; }
bool IsDamageEnoughForLootingAndReward() { return m_unDamageByPlayers >= m_MinPlayerDamageReq; }
void AddDamageByPlayers(uint32 unDamage) { m_unDamageByPlayers += unDamage; }
void ResetDamageByPlayers() { m_unDamageByPlayers = 0; }
uint32 m_MinPlayerDamageReq;
bool IsDamageEnoughForLootingAndReward() { return m_PlayerDamageReq == 0; }
void AddDamageByPlayers(uint32 unDamage)
{
if(m_PlayerDamageReq > 0)
m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0;
}
void ResetDamageByPlayers() { m_PlayerDamageReq = (uint32)(GetHealth() *50 / GetMaxHealth()); }
uint32 m_PlayerDamageReq;
void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; }
+3 -1
View File
@@ -586,8 +586,10 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss)
{
if(pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsAIEnabled)
{
((Creature*)pVictim)->AI()->DamageTaken(this, damage);
((Creature*)pVictim)->AddDamageByPlayers(damage);
}
if (damagetype != NODAMAGE)
{
// interrupting auras with AURA_INTERRUPT_FLAG_DAMAGE before checking !damage (absorbed damage breaks that type of auras)