diff options
author | maximius <none@none> | 2009-11-18 06:22:43 +0100 |
---|---|---|
committer | maximius <none@none> | 2009-11-18 06:22:43 +0100 |
commit | 929df85572f8f05751cbdf36d1c463fbd829d49d (patch) | |
tree | ccfb084eb09d9b14e86bb004e1f36618a8c9be66 | |
parent | d03c14e0b7f37fb09048b8cb2be363cb20e30b7a (diff) |
*Tenacity: correct way to keep hp% after spell being casted, by Spp, closes #240
--HG--
branch : trunk
-rw-r--r-- | src/game/SpellAuras.cpp | 6 | ||||
-rw-r--r-- | src/game/Wintergrasp.cpp | 38 | ||||
-rw-r--r-- | src/game/Wintergrasp.h | 3 |
3 files changed, 17 insertions, 30 deletions
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 2a420a3c7f2..4cb094f06c5 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -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 // 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 - 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*/) { + // 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); + if (m_target->isAlive()) + m_target->SetHealth(uint32(m_target->GetMaxHealth()*percent)); } void AuraEffect::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/, bool /*changeAmount*/) diff --git a/src/game/Wintergrasp.cpp b/src/game/Wintergrasp.cpp index a8397438324..4c42cea5e01 100644 --- a/src/game/Wintergrasp.cpp +++ b/src/game/Wintergrasp.cpp @@ -83,7 +83,6 @@ void RespawnCreatureIfNeeded(Creature *cr, uint32 entry) (p)->RemoveAura(SPELL_CORPORAL);(p)->RemoveAura(SPELL_LIEUTENANT);\ (p)->RemoveAura(SPELL_TOWER_CONTROL);\ (p)->RemoveAura(SPELL_SPIRITUAL_IMMUNITY) -#define REMOVE_TENACITY_AURA(p) CastTenacity(p, 0) // Visual defines, easier to understand code #define getDefenderTeam() m_defender @@ -718,9 +717,9 @@ void OPvPWintergrasp::OnCreatureCreate(Creature *creature, bool add) } 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) - CastTenacity(creature, -m_tenacityStack); + creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, -m_tenacityStack); } 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) { if (plr->HasAura(SPELL_TENACITY)) - CastTenacity(plr, 0); + plr->RemoveAurasDueToSpell(SPELL_TENACITY); + int32 newStack = m_tenacityStack < 0 ? -m_tenacityStack : m_tenacityStack; if (newStack > 20) newStack = 20; - CastTenacity(plr, newStack); + plr->SetAuraStack(SPELL_TENACITY, plr, newStack); } // Tower Control @@ -1140,7 +1140,7 @@ void OPvPWintergrasp::HandlePlayerLeaveZone(Player * plr, uint32 zone) plr->GetVehicle()->Dismiss(); REMOVE_WARTIME_AURAS(plr); } - REMOVE_TENACITY_AURA(plr); + plr->RemoveAurasDueToSpell(SPELL_TENACITY); OutdoorPvP::HandlePlayerLeaveZone(plr, zone); UpdateTenacityStack(); 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 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) 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) - REMOVE_TENACITY_AURA((*itr)); + (*itr)->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE); } // 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) 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) - CastTenacity((*itr), newStack); + (*itr)->SetAuraStack(SPELL_TENACITY_VEHICLE, (*itr), newStack); } } @@ -1529,7 +1513,7 @@ void OPvPWintergrasp::EndBattle() (*itr)->ResurrectPlayer(1.0f); ObjectAccessor::Instance().ConvertCorpseForPlayer((*itr)->GetGUID()); } - REMOVE_TENACITY_AURA(*itr); + (*itr)->RemoveAurasDueToSpell(SPELL_TENACITY); (*itr)->CombatStop(true); (*itr)->getHostilRefManager().deleteReferences(); } diff --git a/src/game/Wintergrasp.h b/src/game/Wintergrasp.h index 73739a44695..59ffefb1411 100644 --- a/src/game/Wintergrasp.h +++ b/src/game/Wintergrasp.h @@ -56,7 +56,7 @@ enum WintergraspSpell // other SPELL_NOFLYZONE_WG = 58730, SPELL_PARACHUTE_WG = 61243, - + // SPELL_TELEPORT_DALARAN = 53360, // SPELL_VICTORY_AURA = 60044, }; @@ -271,7 +271,6 @@ class OPvPWintergrasp : public OutdoorPvP void UpdateClockDigit(uint32 &timer, uint32 digit, uint32 mod); void PromotePlayer(Player *player) const; void UpdateTenacityStack(); - void CastTenacity(Unit *utr, int32 newStack); void UpdateAllWorldObject(); bool UpdateCreatureInfo(Creature *creature); bool UpdateGameObjectInfo(GameObject *go) const; |