diff options
Diffstat (limited to 'src/server/scripts')
| -rw-r--r-- | src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_dk.cpp | 91 |
2 files changed, 50 insertions, 43 deletions
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; } |
