aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp91
-rw-r--r--src/server/game/Entities/Player/Player.h52
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp10
-rw-r--r--src/server/game/Spells/SpellEffects.cpp8
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp2
-rw-r--r--src/server/scripts/Spells/spell_dk.cpp91
7 files changed, 118 insertions, 138 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 4c3f7289b11..b66b62f0aaf 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -332,8 +332,6 @@ Player::Player(WorldSession* session): Unit(true)
m_nextSave = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
- clearResurrectRequestData();
-
memset(m_items, 0, sizeof(Item*)*PLAYER_SLOTS_COUNT);
m_social = nullptr;
@@ -1565,7 +1563,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(nullptr, PET_SAVE_NOT_IN_SLOT, true);
@@ -2056,24 +2054,7 @@ void Player::ProcessDelayedOperations()
return;
if (m_DelayedOperations & DELAYED_RESURRECT_PLAYER)
- {
- ResurrectPlayer(0.0f, false);
-
- if (GetMaxHealth() > m_resurrectHealth)
- SetHealth(m_resurrectHealth);
- else
- SetFullHealth();
-
- if (GetMaxPower(POWER_MANA) > m_resurrectMana)
- SetPower(POWER_MANA, m_resurrectMana);
- else
- SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
-
- SetPower(POWER_RAGE, 0);
- SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY));
-
- SpawnCorpseBones();
- }
+ ResurrectUsingRequestDataImpl();
if (m_DelayedOperations & DELAYED_SAVE_PLAYER)
SaveToDB();
@@ -4758,30 +4739,9 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
}
}
-void Player::SendGhoulResurrectRequest(Player* target)
-{
- target->m_ghoulResurrectPlayerGUID = GetGUID();
-
- WorldPacket data(SMSG_RESURRECT_REQUEST, 8 + 4 + 1 + 1);
- data << uint64(GetGUID());
- data << uint32(0);
- data << uint8(0);
- data << uint8(0);
- target->GetSession()->SendPacket(&data);
-}
-
-void Player::GhoulResurrect()
-{
- CastSpell(this, 46619 /*SPELL_DK_RAISE_ALLY*/, true, nullptr, nullptr, m_ghoulResurrectPlayerGUID);
-
- m_ghoulResurrectPlayerGUID = ObjectGuid::Empty;
-}
-
void Player::RemoveGhoul()
{
- if (IsGhouled())
- if (Creature* ghoul = ObjectAccessor::GetCreature(*this, m_ghoulResurrectGhoulGUID))
- ghoul->DespawnOrUnsummon(); // Raise Ally aura will handle unauras
+ RemoveAura(SPELL_DK_RAISE_ALLY);
}
void Player::KillPlayer()
@@ -7010,6 +6970,7 @@ void Player::SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
SetArenaTeamInfoField(slot, ARENA_TEAM_ID, ArenaTeamId);
SetArenaTeamInfoField(slot, ARENA_TEAM_TYPE, type);
}
+
void Player::SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
{
SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value);
@@ -21664,24 +21625,17 @@ void Player::UpdatePotionCooldown(Spell* spell)
m_lastPotionId = 0;
}
-void Player::setResurrectRequestData(ObjectGuid guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
+void Player::SetResurrectRequestData(Unit* caster, uint32 health, uint32 mana, uint32 appliedAura)
{
- m_resurrectGUID = guid;
- m_resurrectMap = mapId;
- m_resurrectX = X;
- m_resurrectY = Y;
- m_resurrectZ = Z;
- m_resurrectHealth = health;
- m_resurrectMana = mana;
+ ASSERT(!IsResurrectRequested());
+ _resurrectionData.reset(new ResurrectionData());
+ _resurrectionData->GUID = caster->GetGUID();
+ _resurrectionData->Location.WorldRelocate(*caster);
+ _resurrectionData->Health = health;
+ _resurrectionData->Mana = mana;
+ _resurrectionData->Aura = appliedAura;
}
-void Player::clearResurrectRequestData()
-{
- setResurrectRequestData(ObjectGuid::Empty, 0, 0.0f, 0.0f, 0.0f, 0, 0);
-
- m_ghoulResurrectPlayerGUID = ObjectGuid::Empty;
- m_ghoulResurrectGhoulGUID = ObjectGuid::Empty;
-}
//slot to be excluded while counting
bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) const
{
@@ -23588,8 +23542,14 @@ void Player::ResurrectUsingRequestData()
{
RemoveGhoul();
+ if (uint32 aura = _resurrectionData->Aura)
+ {
+ CastSpell(this, _resurrectionData->Aura, true, nullptr, nullptr, _resurrectionData->GUID);
+ return;
+ }
+
/// 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());
+ TeleportTo(_resurrectionData->Location);
if (IsBeingTeleported())
{
@@ -23597,15 +23557,20 @@ void Player::ResurrectUsingRequestData()
return;
}
+ ResurrectUsingRequestDataImpl();
+}
+
+void Player::ResurrectUsingRequestDataImpl()
+{
ResurrectPlayer(0.0f, false);
- if (GetMaxHealth() > m_resurrectHealth)
- SetHealth(m_resurrectHealth);
+ if (GetMaxHealth() > _resurrectionData->Health)
+ SetHealth(_resurrectionData->Health);
else
SetFullHealth();
- if (GetMaxPower(POWER_MANA) > m_resurrectMana)
- SetPower(POWER_MANA, m_resurrectMana);
+ if (GetMaxPower(POWER_MANA) > _resurrectionData->Mana)
+ SetPower(POWER_MANA, _resurrectionData->Mana);
else
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index b2cb2aed226..33b345cc5af 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1014,6 +1014,20 @@ struct TradeStatusInfo
uint8 Slot;
};
+struct ResurrectionData
+{
+ ObjectGuid GUID;
+ WorldLocation Location;
+ uint32 Health;
+ uint32 Mana;
+ uint32 Aura;
+};
+
+enum Spells
+{
+ SPELL_DK_RAISE_ALLY = 46619
+};
+
class Player : public Unit, public GridObject<Player>
{
friend class WorldSession;
@@ -1590,11 +1604,24 @@ class Player : public Unit, public GridObject<Player>
void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
void UpdatePotionCooldown(Spell* spell = nullptr);
- void setResurrectRequestData(ObjectGuid guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana);
- void clearResurrectRequestData();
- bool isResurrectRequestedBy(ObjectGuid guid) const { return !m_resurrectGUID.IsEmpty() && m_resurrectGUID == guid; }
- bool isResurrectRequested() const { return !m_resurrectGUID.IsEmpty(); }
+ void SetResurrectRequestData(Unit* caster, uint32 health, uint32 mana, uint32 appliedAura);
+
+ void ClearResurrectRequestData()
+ {
+ _resurrectionData.reset();
+ }
+
+ bool IsResurrectRequestedBy(uint64 guid) const
+ {
+ if (!IsResurrectRequested())
+ return false;
+
+ return !_resurrectionData->GUID.IsEmpty() && _resurrectionData->GUID == guid;
+ }
+
+ bool IsResurrectRequested() const { return _resurrectionData.get() != nullptr; }
void ResurrectUsingRequestData();
+ void ResurrectUsingRequestDataImpl();
uint8 getCinematic() const { return m_cinematic; }
void setCinematic(uint8 cine) { m_cinematic = cine; }
@@ -1785,14 +1812,7 @@ class Player : public Unit, public GridObject<Player>
void ResurrectPlayer(float restore_percent, bool applySickness = false);
void BuildPlayerRepop();
void RepopAtGraveyard();
- void SendGhoulResurrectRequest(Player* target);
- bool IsValidGhoulResurrectRequest(ObjectGuid guid)
- {
- return !m_ghoulResurrectPlayerGUID.IsEmpty() && m_ghoulResurrectPlayerGUID == guid;
- }
- void GhoulResurrect();
- void SetGhoulResurrectGhoulGUID(ObjectGuid guid) { m_ghoulResurrectGhoulGUID = guid; }
- ObjectGuid GetGhoulResurrectGhoulGUID() { return m_ghoulResurrectGhoulGUID; }
+
void RemoveGhoul();
void DurabilityLossAll(double percent, bool inventory);
@@ -2422,13 +2442,7 @@ class Player : public Unit, public GridObject<Player>
void ResetTimeSync();
void SendTimeSync();
- ObjectGuid m_resurrectGUID;
- uint32 m_resurrectMap;
- float m_resurrectX, m_resurrectY, m_resurrectZ;
- uint32 m_resurrectHealth, m_resurrectMana;
-
- ObjectGuid m_ghoulResurrectPlayerGUID;
- ObjectGuid m_ghoulResurrectGhoulGUID;
+ std::unique_ptr<ResurrectionData> _resurrectionData;
WorldSession* m_session;
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 0c4ee979748..38caa43598a 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1602,7 +1602,7 @@ class Unit : public WorldObject
bool IsAlive() const { return (m_deathState == ALIVE); }
bool isDying() const { return (m_deathState == JUST_DIED); }
bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); }
- bool IsGhouled() const { return HasAura(46619 /*SPELL_DK_RAISE_ALLY*/); }
+ bool IsGhouled() const { return HasAura(SPELL_DK_RAISE_ALLY); }
DeathState getDeathState() const { return m_deathState; }
virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 4fa5e2f848d..91df877e936 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -773,17 +773,11 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recvData)
if (status == 0)
{
- GetPlayer()->clearResurrectRequestData(); // reject
+ GetPlayer()->ClearResurrectRequestData(); // reject
return;
}
- if (GetPlayer()->IsValidGhoulResurrectRequest(guid))
- {
- GetPlayer()->GhoulResurrect();
- return;
- }
-
- if (!GetPlayer()->isResurrectRequestedBy(guid))
+ if (!GetPlayer()->IsResurrectRequestedBy(guid))
return;
GetPlayer()->ResurrectUsingRequestData();
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index f9bf33553cc..2a9db6f0449 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -250,13 +250,13 @@ void Spell::EffectResurrectNew(SpellEffIndex effIndex)
Player* target = unitTarget->ToPlayer();
- if (target->isResurrectRequested()) // already have one active request
+ if (target->IsResurrectRequested()) // 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);
}
@@ -4536,7 +4536,7 @@ void Spell::EffectResurrect(SpellEffIndex effIndex)
Player* target = unitTarget->ToPlayer();
- if (target->isResurrectRequested()) // already have one active request
+ if (target->IsResurrectRequested()) // already have one active request
return;
uint32 health = target->CountPctFromMaxHealth(damage);
@@ -4544,7 +4544,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);
}
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp
index 53b6d2be8dd..9abd0c049d8 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp
@@ -109,7 +109,7 @@ public:
FlyBackTimer = 4500;
break;
case 2:
- if (!player->isResurrectRequested())
+ if (!player->IsResurrectRequested())
{
me->HandleEmoteCommand(EMOTE_ONESHOT_CUSTOM_SPELL_01);
DoCast(player, SPELL_REVIVE, true);
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp
index 7c2bb0bfaa5..cf26b9c116e 100644
--- a/src/server/scripts/Spells/spell_dk.cpp
+++ b/src/server/scripts/Spells/spell_dk.cpp
@@ -1733,36 +1733,40 @@ public:
{
PrepareSpellScript(spell_dk_raise_ally_initial_SpellScript);
- bool Validate(SpellInfo const* /*spellInfo*/) override
+ bool Validate(SpellInfo const* spellInfo) override
{
- if (!sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_ALLY_INITIAL))
+ if (!sSpellMgr->GetSpellInfo(uint32(spellInfo->Effects[EFFECT_0].CalcValue())))
return false;
return true;
}
+ bool Load() override
+ {
+ return GetCaster()->GetTypeId() == TYPEID_PLAYER;
+ }
+
SpellCastResult CheckCast()
{
- // Raise Ally cannot be casted on alive players
Unit* target = GetExplTargetUnit();
if (!target)
return SPELL_FAILED_NO_VALID_TARGETS;
if (target->IsAlive())
return SPELL_FAILED_TARGET_NOT_DEAD;
- if (Player* playerCaster = GetCaster()->ToPlayer())
- if (playerCaster->InArena())
- return SPELL_FAILED_NOT_IN_ARENA;
if (target->IsGhouled())
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
-
return SPELL_CAST_OK;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
- Player* caster = GetCaster()->ToPlayer();
- Player* target = GetHitPlayer();
- if (caster && target)
- caster->SendGhoulResurrectRequest(target);
+ Unit* caster = GetCaster();
+ if (Player* target = GetHitPlayer())
+ {
+ if (target->IsResurrectRequested()) // already have one active request
+ return;
+ target->SetResurrectRequestData(GetCaster(), 0, 0, uint32(GetEffectValue()));
+ GetSpell()->SendResurrectRequest(target);
+ }
}
void Register() override
@@ -1785,12 +1789,8 @@ class player_ghoulAI : public PlayerAI
void UpdateAI(uint32 /*diff*/) override
{
- if (Creature* ghoul = ObjectAccessor::GetCreature(*me, _ghoulGUID))
- {
- if (!ghoul->IsAlive())
- me->RemoveAura(SPELL_DK_RAISE_ALLY);
- }
- else
+ Creature* ghoul = ObjectAccessor::GetCreature(*me, _ghoulGUID);
+ if (!ghoul || !ghoul->IsAlive())
me->RemoveAura(SPELL_DK_RAISE_ALLY);
}
@@ -1799,28 +1799,25 @@ class player_ghoulAI : public PlayerAI
};
// 46619 - Raise Ally
+#define DkRaiseAllyScriptName "spell_dk_raise_ally"
class spell_dk_raise_ally : public SpellScriptLoader
{
public:
- spell_dk_raise_ally() : SpellScriptLoader("spell_dk_raise_ally") { }
+ spell_dk_raise_ally() : SpellScriptLoader(DkRaiseAllyScriptName) { }
class spell_dk_raise_ally_SpellScript : public SpellScript
{
PrepareSpellScript(spell_dk_raise_ally_SpellScript);
- bool Validate(SpellInfo const* /*spellInfo*/) override
+ bool Load() override
{
- if (!sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_ALLY))
- return false;
- return true;
+ return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
void SendText()
{
- Player* caster = GetCaster()->ToPlayer();
- Unit* original = GetOriginalCaster();
- if (caster && original)
- original->Whisper(TEXT_RISE_ALLY, caster, true);
+ if (Unit* original = GetOriginalCaster())
+ original->Whisper(TEXT_RISE_ALLY, GetCaster()->ToPlayer(), true);
}
void HandleSummon(SpellEffIndex effIndex)
@@ -1839,9 +1836,8 @@ public:
SummonPropertiesEntry const* properties = sSummonPropertiesStore.LookupEntry(829);
uint32 duration = uint32(GetSpellInfo()->GetDuration());
- Position pos = caster->GetPosition();
- TempSummon* summon = originalCaster->GetMap()->SummonCreature(entry, pos, properties, duration, originalCaster, GetSpellInfo()->Id);
+ TempSummon* summon = originalCaster->GetMap()->SummonCreature(entry, *GetHitDest(), properties, duration, originalCaster, GetSpellInfo()->Id);
if (!summon)
return;
@@ -1868,15 +1864,25 @@ public:
// SMSG_POWER_UPDATE is sent
summon->SetMaxPower(POWER_ENERGY, 100);
- if (Player* player = GetCaster()->ToPlayer())
- player->SetGhoulResurrectGhoulGUID(summon->GetGUID());
+ _ghoulGuid = summon->GetGUID();
+ }
+
+ void SetGhoul(SpellEffIndex /*effIndex*/)
+ {
+ if (Aura* aura = GetHitAura())
+ if (spell_dk_raise_ally_AuraScript* script = dynamic_cast<spell_dk_raise_ally_AuraScript*>(aura->GetScriptByName(DkRaiseAllyScriptName)))
+ script->SetGhoulGuid(_ghoulGuid);
}
void Register() override
{
AfterHit += SpellHitFn(spell_dk_raise_ally_SpellScript::SendText);
OnEffectHit += SpellEffectFn(spell_dk_raise_ally_SpellScript::HandleSummon, EFFECT_0, SPELL_EFFECT_SUMMON);
+ OnEffectHitTarget += SpellEffectFn(spell_dk_raise_ally_SpellScript::SetGhoul, EFFECT_1, SPELL_EFFECT_APPLY_AURA);
}
+
+ private:
+ ObjectGuid _ghoulGuid;
};
SpellScript* GetSpellScript() const override
@@ -1895,31 +1901,32 @@ public:
oldAIState = false;
}
+ void SetGhoulGuid(ObjectGuid guid)
+ {
+ ghoulGuid = guid;
+ }
+
private:
- bool Validate(SpellInfo const* /*spellInfo*/) override
+ bool Load() override
{
- if (!sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_ALLY))
- return false;
- return true;
+ return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER;
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Player* player = GetTarget()->ToPlayer();
- if (!player || player->GetGhoulResurrectGhoulGUID().IsEmpty())
+ if (ghoulGuid.IsEmpty())
return;
oldAI = player->AI();
oldAIState = player->IsAIEnabled;
- player->SetAI(new player_ghoulAI(player, player->GetGhoulResurrectGhoulGUID()));
+ player->SetAI(new player_ghoulAI(player, ghoulGuid));
player->IsAIEnabled = true;
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Player* player = GetTarget()->ToPlayer();
- if (!player)
- return;
player->IsAIEnabled = oldAIState;
PlayerAI* thisAI = player->AI();
@@ -1927,13 +1934,12 @@ public:
delete thisAI;
// Dismiss ghoul if necessary
- if (Creature* ghoul = ObjectAccessor::GetCreature(*player, player->GetGhoulResurrectGhoulGUID()))
+ if (Creature* ghoul = ObjectAccessor::GetCreature(*player, ghoulGuid))
{
- ghoul->RemoveCharmedBy(nullptr);
+ ghoul->RemoveCharmedBy(player);
ghoul->DespawnOrUnsummon(1000);
}
- player->SetGhoulResurrectGhoulGUID(ObjectGuid::Empty);
player->RemoveAura(SPELL_GHOUL_FRENZY);
}
@@ -1943,6 +1949,7 @@ public:
AfterEffectRemove += AuraEffectRemoveFn(spell_dk_raise_ally_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
+ ObjectGuid ghoulGuid;
PlayerAI* oldAI;
bool oldAIState;
};
@@ -1965,7 +1972,7 @@ public:
bool Validate(SpellInfo const* /*spellInfo*/) override
{
- if (!sSpellMgr->GetSpellInfo(SPELL_DK_GHOUL_THRASH))
+ if (!sSpellMgr->GetSpellInfo(SPELL_GHOUL_FRENZY))
return false;
return true;
}