diff options
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 34 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 49 | ||||
-rw-r--r-- | src/server/game/Handlers/MiscHandler.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Miscellaneous/SharedDefines.h | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 1 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 44 | ||||
-rw-r--r-- | src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp | 2 |
7 files changed, 99 insertions, 37 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index bfe86337b4d..e1030766704 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -693,7 +693,7 @@ Player::Player(WorldSession* session): Unit(true), phaseMgr(this) m_nextSave = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE); - clearResurrectRequestData(); + _resurrectionData = NULL; memset(m_items, 0, sizeof(Item*)*PLAYER_SLOTS_COUNT); @@ -905,6 +905,8 @@ Player::~Player() for (uint8 i = 0; i < MAX_CUF_PROFILES; ++i) delete _CUFProfiles[i]; + ClearResurrectRequestData(); + sWorld->DecreasePlayerCount(); } @@ -1842,7 +1844,7 @@ void Player::setDeathState(DeathState s) // lost combo points at any target (targeted combo points clear in Unit::setDeathState) ClearComboPoints(); - clearResurrectRequestData(); + ClearResurrectRequestData(); //FIXME: is pet dismissed at dying or releasing spirit? if second, add setDeathState(DEAD) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD) RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); @@ -2348,13 +2350,13 @@ void Player::ProcessDelayedOperations() { ResurrectPlayer(0.0f, false); - if (GetMaxHealth() > m_resurrectHealth) - SetHealth(m_resurrectHealth); + if (GetMaxHealth() > _resurrectionData->Health) + SetHealth(_resurrectionData->Health); else SetFullHealth(); - if (uint32(GetMaxPower(POWER_MANA)) > m_resurrectMana) - SetPower(POWER_MANA, m_resurrectMana); + if (uint32(GetMaxPower(POWER_MANA)) > _resurrectionData->Mana) + SetPower(POWER_MANA, _resurrectionData->Mana); else SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); @@ -2362,6 +2364,9 @@ void Player::ProcessDelayedOperations() SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); SetPower(POWER_ECLIPSE, 0); + if (uint32 aura = _resurrectionData->Aura) + CastSpell(this, aura, true, NULL, NULL, _resurrectionData->GUID); + SpawnCorpseBones(); } @@ -7505,7 +7510,7 @@ void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/, bo } } -void Player::SetCurrency(uint32 id, uint32 count, bool printLog /*= true*/) +void Player::SetCurrency(uint32 id, uint32 count, bool /*printLog*/ /*= true*/) { PlayerCurrenciesMap::iterator itr = _currencyStorage.find(id); if (itr == _currencyStorage.end()) @@ -23557,7 +23562,9 @@ bool Player::IsAtRecruitAFriendDistance(WorldObject const* pOther) const void Player::ResurectUsingRequestData() { /// Teleport before resurrecting by player, otherwise the player might get attacked from creatures near his corpse - TeleportTo(m_resurrectMap, m_resurrectX, m_resurrectY, m_resurrectZ, GetOrientation()); + float x, y, z, o; + _resurrectionData->Location.GetPosition(x, y, z, o); + TeleportTo(_resurrectionData->Location.GetMapId(), x, y, z, o); if (IsBeingTeleported()) { @@ -23567,13 +23574,13 @@ void Player::ResurectUsingRequestData() ResurrectPlayer(0.0f, false); - if (GetMaxHealth() > m_resurrectHealth) - SetHealth(m_resurrectHealth); + if (GetMaxHealth() > _resurrectionData->Health) + SetHealth(_resurrectionData->Health); else SetFullHealth(); - if (uint32(GetMaxPower(POWER_MANA)) > m_resurrectMana) - SetPower(POWER_MANA, m_resurrectMana); + if (uint32(GetMaxPower(POWER_MANA)) > _resurrectionData->Mana) + SetPower(POWER_MANA, _resurrectionData->Mana); else SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); @@ -23582,6 +23589,9 @@ void Player::ResurectUsingRequestData() SetPower(POWER_FOCUS, GetMaxPower(POWER_FOCUS)); SetPower(POWER_ECLIPSE, 0); + if (uint32 aura = _resurrectionData->Aura) + CastSpell(this, aura, true, NULL, NULL, _resurrectionData->GUID); + SpawnCorpseBones(); } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 12674552666..c3bdfd5bd7f 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1163,6 +1163,15 @@ class TradeData uint64 m_items[TRADE_SLOT_COUNT]; // traded items from m_player side including non-traded slot }; +struct ResurrectionData +{ + uint64 GUID; + WorldLocation Location; + uint32 Health; + uint32 Mana; + uint32 Aura; +}; + class KillRewarder { public: @@ -1974,19 +1983,32 @@ class Player : public Unit, public GridObject<Player> void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; } void UpdatePotionCooldown(Spell* spell = NULL); - void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) + void SetResurrectRequestData(Unit* caster, uint32 health, uint32 mana, uint32 appliedAura) + { + ASSERT(!IsRessurectRequested()); + _resurrectionData = new ResurrectionData(); + _resurrectionData->GUID = caster->GetGUID(); + _resurrectionData->Location.WorldRelocate(*caster); + _resurrectionData->Health = health; + _resurrectionData->Mana = mana; + _resurrectionData->Aura = appliedAura; + } + + void ClearResurrectRequestData() { - m_resurrectGUID = guid; - m_resurrectMap = mapId; - m_resurrectX = X; - m_resurrectY = Y; - m_resurrectZ = Z; - m_resurrectHealth = health; - m_resurrectMana = mana; + delete _resurrectionData; + _resurrectionData = NULL; } - void clearResurrectRequestData() { setResurrectRequestData(0, 0, 0.0f, 0.0f, 0.0f, 0, 0); } - bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; } - bool isRessurectRequested() const { return m_resurrectGUID != 0; } + + bool IsRessurectRequestedBy(uint64 guid) const + { + if (!IsRessurectRequested()) + return false; + + return _resurrectionData->GUID == guid; + } + + bool IsRessurectRequested() const { return _resurrectionData != NULL; } void ResurectUsingRequestData(); uint8 getCinematic() @@ -2963,10 +2985,7 @@ class Player : public Unit, public GridObject<Player> void ResetTimeSync(); void SendTimeSync(); - uint64 m_resurrectGUID; - uint32 m_resurrectMap; - float m_resurrectX, m_resurrectY, m_resurrectZ; - uint32 m_resurrectHealth, m_resurrectMana; + ResurrectionData* _resurrectionData; WorldSession* m_session; diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 29af54f195f..ff319fdbfe9 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -783,11 +783,11 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recvData) if (status == 0) { - GetPlayer()->clearResurrectRequestData(); // reject + GetPlayer()->ClearResurrectRequestData(); // reject return; } - if (!GetPlayer()->isRessurectRequestedBy(guid)) + if (!GetPlayer()->IsRessurectRequestedBy(guid)) return; GetPlayer()->ResurectUsingRequestData(); diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index f59e10ba846..c855f7e2af2 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -952,7 +952,7 @@ enum SpellEffects SPELL_EFFECT_DESTROY_ITEM = 169, SPELL_EFFECT_170 = 170, SPELL_EFFECT_171 = 171, // Summons gamebject - SPELL_EFFECT_172 = 172, // Aoe ressurection + SPELL_EFFECT_RESURRECT_WITH_AURA = 172, SPELL_EFFECT_UNLOCK_GUILD_VAULT_TAB = 173, // Guild tab unlocked (guild perk) SPELL_EFFECT_174 = 174, SPELL_EFFECT_175 = 175, // Unused (4.3.4) diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 2a976d74f30..b009bc6e2d7 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -339,6 +339,7 @@ class Spell void EffectCastButtons(SpellEffIndex effIndex); void EffectRechargeManaGem(SpellEffIndex effIndex); void EffectGiveCurrency(SpellEffIndex effIndex); + void EffectResurrectWithAura(SpellEffIndex effIndex); typedef std::set<Aura*> UsedSpellMods; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 3e6994176cc..f76b696dfc3 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -241,7 +241,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= &Spell::EffectNULL, //169 SPELL_EFFECT_DESTROY_ITEM &Spell::EffectNULL, //170 SPELL_EFFECT_170 &Spell::EffectNULL, //171 SPELL_EFFECT_171 - &Spell::EffectNULL, //172 SPELL_EFFECT_172 + &Spell::EffectResurrectWithAura, //172 SPELL_EFFECT_RESURRECT_WITH_AURA &Spell::EffectNULL, //173 SPELL_EFFECT_UNLOCK_GUILD_VAULT_TAB &Spell::EffectNULL, //174 SPELL_EFFECT_174 &Spell::EffectUnused, //175 SPELL_EFFECT_175 unused @@ -280,13 +280,13 @@ void Spell::EffectResurrectNew(SpellEffIndex effIndex) Player* target = unitTarget->ToPlayer(); - if (target->isRessurectRequested()) // already have one active request + if (target->IsRessurectRequested()) // already have one active request return; uint32 health = damage; uint32 mana = m_spellInfo->Effects[effIndex].MiscValue; ExecuteLogEffectResurrect(effIndex, target); - target->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); + target->SetResurrectRequestData(m_caster, health, mana, 0); SendResurrectRequest(target); } @@ -4622,7 +4622,7 @@ void Spell::EffectResurrect(SpellEffIndex effIndex) Player* target = unitTarget->ToPlayer(); - if (target->isRessurectRequested()) // already have one active request + if (target->IsRessurectRequested()) // already have one active request return; uint32 health = target->CountPctFromMaxHealth(damage); @@ -4630,7 +4630,7 @@ void Spell::EffectResurrect(SpellEffIndex effIndex) ExecuteLogEffectResurrect(effIndex, target); - target->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); + target->SetResurrectRequestData(m_caster, health, mana, 0); SendResurrectRequest(target); } @@ -5896,7 +5896,7 @@ void Spell::EffectRemoveAura(SpellEffIndex effIndex) unitTarget->RemoveAurasDueToSpell(m_spellInfo->Effects[effIndex].TriggerSpell); } -void Spell::EffectDamageFromMaxHealthPCT(SpellEffIndex effIndex) +void Spell::EffectDamageFromMaxHealthPCT(SpellEffIndex /*effIndex*/) { if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; @@ -6046,3 +6046,35 @@ void Spell::EffectSummonRaFFriend(SpellEffIndex effIndex) m_caster->CastSpell(unitTarget, m_spellInfo->Effects[effIndex].TriggerSpell, true); } + +void Spell::EffectResurrectWithAura(SpellEffIndex effIndex) +{ + if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) + return; + + if (!unitTarget || !unitTarget->IsInWorld()) + return; + + Player* target = unitTarget->ToPlayer(); + if (!target) + return; + + if (unitTarget->isAlive()) + return; + + if (target->IsRessurectRequested()) // already have one active request + return; + + uint32 health = target->CountPctFromMaxHealth(damage); + uint32 mana = CalculatePct(target->GetMaxPower(POWER_MANA), damage); + uint32 resurrectAura = 0; + if (sSpellMgr->GetSpellInfo(GetSpellInfo()->Effects[effIndex].TriggerSpell)) + resurrectAura = GetSpellInfo()->Effects[effIndex].TriggerSpell; + + if (resurrectAura && target->HasAura(resurrectAura)) + return; + + ExecuteLogEffectResurrect(effIndex, target); + target->SetResurrectRequestData(m_caster, health, mana, resurrectAura); + SendResurrectRequest(target); +} diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp index 6e7f7e103c5..8f10bad2095 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/the_scarlet_enclave.cpp @@ -92,7 +92,7 @@ public: FlyBackTimer = 4500; break; case 2: - if (!player->isRessurectRequested()) + if (!player->IsRessurectRequested()) { me->HandleEmoteCommand(EMOTE_ONESHOT_CUSTOM_SPELL_01); DoCast(player, SPELL_REVIVE, true); |