mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[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:
parent
a32d68febd
commit
54d0c9b77d
3 changed files with 37 additions and 21 deletions
|
|
@ -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 don't lose health from damage taken from another player while in a sanctuary
|
||||||
//You still see it in the combat log though
|
//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(absorb)
|
||||||
if (area && area->flags & AREA_FLAG_SANCTUARY) //sanctuary
|
*absorb += damage;
|
||||||
{
|
damage = 0;
|
||||||
if(absorb)
|
|
||||||
*absorb += damage;
|
|
||||||
damage = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 originalDamage = damage;
|
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 don't lose health from damage taken from another player while in a sanctuary
|
||||||
//You still see it in the combat log though
|
//You still see it in the combat log though
|
||||||
if (pVictim != this && IsCharmerOrOwnerPlayerOrPlayerItself() && pVictim->IsCharmerOrOwnerPlayerOrPlayerItself())
|
if (!IsAllowedDamageInArea(pVictim))
|
||||||
{
|
return;
|
||||||
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
|
|
||||||
if (area && area->flags & AREA_FLAG_SANCTUARY) // sanctuary
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call default DealDamage (send critical in hit info for threat calculation)
|
// 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);
|
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 don't lose health from damage taken from another player while in a sanctuary
|
||||||
//You still see it in the combat log though
|
//You still see it in the combat log though
|
||||||
if (pVictim != this && IsCharmerOrOwnerPlayerOrPlayerItself() && pVictim->IsCharmerOrOwnerPlayerOrPlayerItself())
|
if (!IsAllowedDamageInArea(pVictim))
|
||||||
{
|
return;
|
||||||
const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId());
|
|
||||||
if (area && area->flags & AREA_FLAG_SANCTUARY) // sanctuary
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hmmmm dont like this emotes client must by self do all animations
|
// Hmmmm dont like this emotes client must by self do all animations
|
||||||
if (damageInfo->HitInfo&HITINFO_CRITICALHIT)
|
if (damageInfo->HitInfo&HITINFO_CRITICALHIT)
|
||||||
|
|
@ -10683,3 +10671,29 @@ SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid, uint64 casterGUID)
|
||||||
|
|
||||||
return NULL;
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1322,6 +1322,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK);
|
void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK);
|
||||||
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss);
|
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 CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK);
|
||||||
void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss);
|
void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10671"
|
#define REVISION_NR "10672"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue