*Tenacity: correct way to keep hp% after spell being casted, by Spp, closes #240

--HG--
branch : trunk
This commit is contained in:
maximius
2009-11-18 06:22:43 +01:00
parent d03c14e0b7
commit 929df85572
3 changed files with 17 additions and 30 deletions
+5 -1
View File
@@ -3316,7 +3316,7 @@ void AuraEffect::HandleAuraMounted(bool apply, bool Real, bool /*changeAmount*/)
//some mounts like Headless Horseman's Mount or broom stick are skill based spell //some mounts like Headless Horseman's Mount or broom stick are skill based spell
// need to remove ALL arura related to mounts, this will stop client crash with broom stick // need to remove ALL arura related to mounts, this will stop client crash with broom stick
// and never endless flying after using Headless Horseman's Mount // and never endless flying after using Headless Horseman's Mount
m_target->RemoveAurasByType(SPELL_AURA_MOUNTED); m_target->RemoveAurasByType(SPELL_AURA_MOUNTED);
} }
} }
@@ -5109,7 +5109,11 @@ void AuraEffect::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/, b
void AuraEffect::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/, bool /*changeAmount*/) void AuraEffect::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/, bool /*changeAmount*/)
{ {
// Unit will keep hp% after MaxHealth being modified if unit is alive.
float percent = ((float)m_target->GetHealth()) / m_target->GetMaxHealth();
m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_amount), apply); m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_amount), apply);
if (m_target->isAlive())
m_target->SetHealth(uint32(m_target->GetMaxHealth()*percent));
} }
void AuraEffect::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/, bool /*changeAmount*/) void AuraEffect::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/, bool /*changeAmount*/)
+11 -27
View File
@@ -83,7 +83,6 @@ void RespawnCreatureIfNeeded(Creature *cr, uint32 entry)
(p)->RemoveAura(SPELL_CORPORAL);(p)->RemoveAura(SPELL_LIEUTENANT);\ (p)->RemoveAura(SPELL_CORPORAL);(p)->RemoveAura(SPELL_LIEUTENANT);\
(p)->RemoveAura(SPELL_TOWER_CONTROL);\ (p)->RemoveAura(SPELL_TOWER_CONTROL);\
(p)->RemoveAura(SPELL_SPIRITUAL_IMMUNITY) (p)->RemoveAura(SPELL_SPIRITUAL_IMMUNITY)
#define REMOVE_TENACITY_AURA(p) CastTenacity(p, 0)
// Visual defines, easier to understand code // Visual defines, easier to understand code
#define getDefenderTeam() m_defender #define getDefenderTeam() m_defender
@@ -718,9 +717,9 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add)
} }
if (m_tenacityStack > 0 && team == TEAM_ALLIANCE) if (m_tenacityStack > 0 && team == TEAM_ALLIANCE)
CastTenacity(creature, m_tenacityStack); creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, m_tenacityStack);
else if (m_tenacityStack < 0 && team == TEAM_HORDE) else if (m_tenacityStack < 0 && team == TEAM_HORDE)
CastTenacity(creature, -m_tenacityStack); creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, -m_tenacityStack);
} }
else // the faction may be changed in uncharm else // the faction may be changed in uncharm
{ {
@@ -1106,11 +1105,12 @@ void OPvPWintergrasp::HandlePlayerResurrects(Player * plr, uint32 zone)
plr->GetTeamId() == TEAM_HORDE && m_tenacityStack < 0) plr->GetTeamId() == TEAM_HORDE && m_tenacityStack < 0)
{ {
if (plr->HasAura(SPELL_TENACITY)) if (plr->HasAura(SPELL_TENACITY))
CastTenacity(plr, 0); plr->RemoveAurasDueToSpell(SPELL_TENACITY);
int32 newStack = m_tenacityStack < 0 ? -m_tenacityStack : m_tenacityStack; int32 newStack = m_tenacityStack < 0 ? -m_tenacityStack : m_tenacityStack;
if (newStack > 20) if (newStack > 20)
newStack = 20; newStack = 20;
CastTenacity(plr, newStack); plr->SetAuraStack(SPELL_TENACITY, plr, newStack);
} }
// Tower Control // Tower Control
@@ -1140,7 +1140,7 @@ void OPvPWintergrasp::HandlePlayerLeaveZone(Player * plr, uint32 zone)
plr->GetVehicle()->Dismiss(); plr->GetVehicle()->Dismiss();
REMOVE_WARTIME_AURAS(plr); REMOVE_WARTIME_AURAS(plr);
} }
REMOVE_TENACITY_AURA(plr); plr->RemoveAurasDueToSpell(SPELL_TENACITY);
OutdoorPvP::HandlePlayerLeaveZone(plr, zone); OutdoorPvP::HandlePlayerLeaveZone(plr, zone);
UpdateTenacityStack(); UpdateTenacityStack();
plr->RemoveAura(SPELL_ESSENCE_OF_WG); plr->RemoveAura(SPELL_ESSENCE_OF_WG);
@@ -1217,22 +1217,6 @@ void OPvPWintergrasp::HandleKill(Player *killer, Unit *victim)
} }
} }
// Cast or removes Tenacity. MaxHP Modified, HP keeps it's % ratio
void OPvPWintergrasp::CastTenacity(Unit *unit, int32 newStack)
{
if (!unit)
return;
uint32 spellId = unit->GetTypeId() == TYPEID_PLAYER ? SPELL_TENACITY : SPELL_TENACITY_VEHICLE;
float percent = ((float)unit->GetHealth()) / unit->GetMaxHealth();
if (newStack)
unit->SetAuraStack(spellId, unit, newStack);
else
unit->RemoveAura(spellId);
if (unit->GetTypeId() != TYPEID_PLAYER || unit->isAlive())
unit->SetHealth(uint32(unit->GetMaxHealth()*percent));
}
// Recalculates Tenacity and applies it to Players / Vehicles // Recalculates Tenacity and applies it to Players / Vehicles
void OPvPWintergrasp::UpdateTenacityStack() void OPvPWintergrasp::UpdateTenacityStack()
{ {
@@ -1275,10 +1259,10 @@ void OPvPWintergrasp::UpdateTenacityStack()
{ {
for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if ((*itr)->getLevel() > 69) if ((*itr)->getLevel() > 69)
REMOVE_TENACITY_AURA((*itr)); (*itr)->RemoveAurasDueToSpell(SPELL_TENACITY);
for (CreatureSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) for (CreatureSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
REMOVE_TENACITY_AURA((*itr)); (*itr)->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
} }
// Apply new buff // Apply new buff
@@ -1292,10 +1276,10 @@ void OPvPWintergrasp::UpdateTenacityStack()
for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr) for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
if ((*itr)->getLevel() > 69) if ((*itr)->getLevel() > 69)
CastTenacity((*itr), newStack); (*itr)->SetAuraStack(SPELL_TENACITY, (*itr), newStack);
for (CreatureSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr) for (CreatureSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
CastTenacity((*itr), newStack); (*itr)->SetAuraStack(SPELL_TENACITY_VEHICLE, (*itr), newStack);
} }
} }
@@ -1529,7 +1513,7 @@ void OPvPWintergrasp::EndBattle()
(*itr)->ResurrectPlayer(1.0f); (*itr)->ResurrectPlayer(1.0f);
ObjectAccessor::Instance().ConvertCorpseForPlayer((*itr)->GetGUID()); ObjectAccessor::Instance().ConvertCorpseForPlayer((*itr)->GetGUID());
} }
REMOVE_TENACITY_AURA(*itr); (*itr)->RemoveAurasDueToSpell(SPELL_TENACITY);
(*itr)->CombatStop(true); (*itr)->CombatStop(true);
(*itr)->getHostilRefManager().deleteReferences(); (*itr)->getHostilRefManager().deleteReferences();
} }
+1 -2
View File
@@ -56,7 +56,7 @@ enum WintergraspSpell
// other // other
SPELL_NOFLYZONE_WG = 58730, SPELL_NOFLYZONE_WG = 58730,
SPELL_PARACHUTE_WG = 61243, SPELL_PARACHUTE_WG = 61243,
// SPELL_TELEPORT_DALARAN = 53360, // SPELL_TELEPORT_DALARAN = 53360,
// SPELL_VICTORY_AURA = 60044, // SPELL_VICTORY_AURA = 60044,
}; };
@@ -271,7 +271,6 @@ class OPvPWintergrasp : public OutdoorPvP
void UpdateClockDigit(uint32 &timer, uint32 digit, uint32 mod); void UpdateClockDigit(uint32 &timer, uint32 digit, uint32 mod);
void PromotePlayer(Player *player) const; void PromotePlayer(Player *player) const;
void UpdateTenacityStack(); void UpdateTenacityStack();
void CastTenacity(Unit *utr, int32 newStack);
void UpdateAllWorldObject(); void UpdateAllWorldObject();
bool UpdateCreatureInfo(Creature *creature); bool UpdateCreatureInfo(Creature *creature);
bool UpdateGameObjectInfo(GameObject *go) const; bool UpdateGameObjectInfo(GameObject *go) const;