[10672] Allow damage own pet in sanctuary.

Also mome repeating code to new function.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
mns 2010-11-01 14:10:19 +03:00 committed by VladimirMangos
parent a32d68febd
commit 54d0c9b77d
3 changed files with 37 additions and 21 deletions

View file

@ -504,15 +504,11 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
//You don't lose health from damage taken from another player while in a sanctuary
//You still see it in the combat log though
if (pVictim != this && IsCharmerOrOwnerPlayerOrPlayerItself() && pVictim->IsCharmerOrOwnerPlayerOrPlayerItself())
if (!IsAllowedDamageInArea(pVictim))
{
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
if (area && area->flags & AREA_FLAG_SANCTUARY) //sanctuary
{
if(absorb)
*absorb += damage;
damage = 0;
}
if(absorb)
*absorb += damage;
damage = 0;
}
uint32 originalDamage = damage;
@ -1350,12 +1346,8 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
//You don't lose health from damage taken from another player while in a sanctuary
//You still see it in the combat log though
if (pVictim != this && IsCharmerOrOwnerPlayerOrPlayerItself() && pVictim->IsCharmerOrOwnerPlayerOrPlayerItself())
{
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
if (area && area->flags & AREA_FLAG_SANCTUARY) // sanctuary
return;
}
if (!IsAllowedDamageInArea(pVictim))
return;
// Call default DealDamage (send critical in hit info for threat calculation)
CleanDamage cleanDamage(0, BASE_ATTACK, damageInfo->HitInfo & SPELL_HIT_TYPE_CRIT ? MELEE_HIT_CRIT : MELEE_HIT_NORMAL);
@ -1654,12 +1646,8 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
//You don't lose health from damage taken from another player while in a sanctuary
//You still see it in the combat log though
if (pVictim != this && IsCharmerOrOwnerPlayerOrPlayerItself() && pVictim->IsCharmerOrOwnerPlayerOrPlayerItself())
{
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
if (area && area->flags & AREA_FLAG_SANCTUARY) // sanctuary
return;
}
if (!IsAllowedDamageInArea(pVictim))
return;
// Hmmmm dont like this emotes client must by self do all animations
if (damageInfo->HitInfo&HITINFO_CRITICALHIT)
@ -10683,3 +10671,29 @@ SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid, uint64 casterGUID)
return NULL;
}
bool Unit::IsAllowedDamageInArea(Unit* pVictim) const
{
// can damage self anywhere
if (pVictim == this)
return true;
// non player controlled unit can damage anywhere
if (!IsCharmerOrOwnerPlayerOrPlayerItself())
return true;
// can damage own pet anywhere
if (pVictim->GetOwnerGuid() == GetObjectGuid())
return true;
// can damage non player controlled victim anywhere
if (!pVictim->IsCharmerOrOwnerPlayerOrPlayerItself())
return true;
// can't damage player controlled unit by player controlled unit in sanctuary
AreaTableEntry const* area = GetAreaEntryByAreaID(pVictim->GetAreaId());
if (area && area->flags & AREA_FLAG_SANCTUARY)
return false;
return true;
}

View file

@ -1322,6 +1322,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK);
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss);
bool IsAllowedDamageInArea(Unit * pVictim) const;
void CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK);
void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10671"
#define REVISION_NR "10672"
#endif // __REVISION_NR_H__