mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[7787] Apply death preventing buffs after absorbing damage
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
727268a4e8
commit
ac239e6178
2 changed files with 57 additions and 15 deletions
|
|
@ -1613,6 +1613,9 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
|
||||||
// Reflect damage spells (not cast any damage spell in aura lookup)
|
// Reflect damage spells (not cast any damage spell in aura lookup)
|
||||||
uint32 reflectSpell = 0;
|
uint32 reflectSpell = 0;
|
||||||
int32 reflectDamage = 0;
|
int32 reflectDamage = 0;
|
||||||
|
// Death Prevention Aura
|
||||||
|
SpellEntry const* preventDeathSpell = NULL;
|
||||||
|
int32 preventDeathAmount = 0;
|
||||||
// Need remove expired auras after
|
// Need remove expired auras after
|
||||||
bool existExpired = false;
|
bool existExpired = false;
|
||||||
// absorb without mana cost
|
// absorb without mana cost
|
||||||
|
|
@ -1628,7 +1631,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
|
||||||
// Max Amount can be absorbed by this aura
|
// Max Amount can be absorbed by this aura
|
||||||
int32 currentAbsorb = mod->m_amount;
|
int32 currentAbsorb = mod->m_amount;
|
||||||
|
|
||||||
// Found empty aura (umpossible but..)
|
// Found empty aura (impossible but..)
|
||||||
if (currentAbsorb <=0)
|
if (currentAbsorb <=0)
|
||||||
{
|
{
|
||||||
existExpired = true;
|
existExpired = true;
|
||||||
|
|
@ -1699,26 +1702,29 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
|
||||||
}
|
}
|
||||||
case SPELLFAMILY_ROGUE:
|
case SPELLFAMILY_ROGUE:
|
||||||
{
|
{
|
||||||
// Cheat Death
|
// Cheat Death (make less prio with Guardian Spirit case)
|
||||||
if(spellProto->SpellIconID == 2109)
|
if (!preventDeathSpell && spellProto->SpellIconID == 2109 &&
|
||||||
|
pVictim->GetTypeId()==TYPEID_PLAYER && // Only players
|
||||||
|
!((Player*)pVictim)->HasSpellCooldown(31231) &&
|
||||||
|
// Only if no cooldown
|
||||||
|
roll_chance_i((*i)->GetModifier()->m_amount))
|
||||||
|
// Only if roll
|
||||||
{
|
{
|
||||||
if (pVictim->GetTypeId()==TYPEID_PLAYER && // Only players
|
preventDeathSpell = (*i)->GetSpellProto();
|
||||||
pVictim->GetHealth() <= RemainingDamage && // Only if damage kill
|
|
||||||
!((Player*)pVictim)->HasSpellCooldown(31231) && // Only if no cooldown
|
|
||||||
roll_chance_i(currentAbsorb)) // Only if roll
|
|
||||||
{
|
|
||||||
pVictim->CastSpell(pVictim,31231,true);
|
|
||||||
((Player*)pVictim)->AddSpellCooldown(31231,0,time(NULL)+60);
|
|
||||||
// with health > 10% lost health until health==10%, in other case no losses
|
|
||||||
uint32 health10 = pVictim->GetMaxHealth()/10;
|
|
||||||
RemainingDamage = pVictim->GetHealth() > health10 ? pVictim->GetHealth() - health10 : 0;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPELLFAMILY_PRIEST:
|
case SPELLFAMILY_PRIEST:
|
||||||
{
|
{
|
||||||
|
// Guardian Spirit
|
||||||
|
if (spellProto->SpellIconID == 2873)
|
||||||
|
{
|
||||||
|
preventDeathSpell = (*i)->GetSpellProto();
|
||||||
|
preventDeathAmount = (*i)->GetModifier()->m_amount;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Reflective Shield
|
// Reflective Shield
|
||||||
if (spellProto->SpellFamilyFlags == 0x1)
|
if (spellProto->SpellFamilyFlags == 0x1)
|
||||||
{
|
{
|
||||||
|
|
@ -1834,6 +1840,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cast back reflect damage spell
|
// Cast back reflect damage spell
|
||||||
if (reflectSpell)
|
if (reflectSpell)
|
||||||
pVictim->CastCustomSpell(this, reflectSpell, &reflectDamage, NULL, NULL, true);
|
pVictim->CastCustomSpell(this, reflectSpell, &reflectDamage, NULL, NULL, true);
|
||||||
|
|
@ -1931,6 +1938,41 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply death prevention spells effects
|
||||||
|
if (preventDeathSpell && RemainingDamage >= pVictim->GetHealth())
|
||||||
|
{
|
||||||
|
switch(preventDeathSpell->SpellFamilyName)
|
||||||
|
{
|
||||||
|
// Cheat Death
|
||||||
|
case SPELLFAMILY_ROGUE:
|
||||||
|
{
|
||||||
|
// Cheat Death
|
||||||
|
if (preventDeathSpell->SpellIconID == 2109)
|
||||||
|
{
|
||||||
|
pVictim->CastSpell(pVictim,31231,true);
|
||||||
|
((Player*)pVictim)->AddSpellCooldown(31231,0,time(NULL)+60);
|
||||||
|
// with health > 10% lost health until health==10%, in other case no losses
|
||||||
|
uint32 health10 = pVictim->GetMaxHealth()/10;
|
||||||
|
RemainingDamage = pVictim->GetHealth() > health10 ? pVictim->GetHealth() - health10 : 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Guardian Spirit
|
||||||
|
case SPELLFAMILY_PRIEST:
|
||||||
|
{
|
||||||
|
// Guardian Spirit
|
||||||
|
if (preventDeathSpell->SpellIconID == 2873)
|
||||||
|
{
|
||||||
|
int32 healAmount = pVictim->GetMaxHealth() * preventDeathAmount / 100;
|
||||||
|
pVictim->CastCustomSpell(pVictim, 48153, &healAmount, NULL, NULL, true);
|
||||||
|
pVictim->RemoveAurasDueToSpell(preventDeathSpell->Id);
|
||||||
|
RemainingDamage = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*absorb = damage - RemainingDamage - *resist;
|
*absorb = damage - RemainingDamage - *resist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7786"
|
#define REVISION_NR "7787"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue