Scripts/Pets: Update Lil' K.T. (#28071)

This commit is contained in:
offl
2022-06-30 22:32:09 +03:00
committed by GitHub
parent b9450bcdd0
commit dfd1692e31
4 changed files with 203 additions and 101 deletions

View File

@@ -16,19 +16,17 @@
*/
/*
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "npc_pet_gen_".
* Spell and creature scripts in this file are not ordered but grouped(all scripts related to same creature in same place).
* Scriptnames of spells and creatures in this file should be prefixed with "spell_pet_gen_" and "npc_pet_gen_" respectively.
*/
/* ContentData
npc_pet_gen_pandaren_monk 100% Pandaren Monk drinks and bows with you
EndContentData */
#include "ScriptMgr.h"
#include "MotionMaster.h"
#include "PassiveAI.h"
#include "Player.h"
#include "ScriptedCreature.h"
#include "SpellAuraEffects.h"
#include "SpellScript.h"
enum PandarenMonkMisc
{
@@ -141,26 +139,153 @@ struct npc_pet_gen_soul_trader : public ScriptedAI
enum LichPet
{
SPELL_LICH_ONSUMMON = 69735,
SPELL_LICH_REMOVE_AURA = 69736
SPELL_LICH_PET_AURA = 69732,
SPELL_LICH_PET_AURA_ONKILL = 69731,
SPELL_LICH_PET_EMOTE = 70049,
NPC_LICH_PET = 36979
};
struct npc_pet_lich : public ScriptedAI
// 69735 - Lich Pet OnSummon
class spell_pet_gen_lich_pet_onsummon : public SpellScript
{
npc_pet_lich(Creature* creature) : ScriptedAI(creature) { }
PrepareSpellScript(spell_pet_gen_lich_pet_onsummon);
void OnDespawn() override
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (Unit* owner = me->GetOwner())
DoCast(owner, SPELL_LICH_REMOVE_AURA);
return ValidateSpellInfo({ SPELL_LICH_PET_AURA });
}
void JustAppeared() override
void HandleScript(SpellEffIndex /*effIndex*/)
{
if (Unit* owner = me->GetOwner())
DoCast(owner, SPELL_LICH_ONSUMMON);
Unit* target = GetHitUnit();
target->CastSpell(target, SPELL_LICH_PET_AURA, true);
}
CreatureAI::JustAppeared();
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_pet_gen_lich_pet_onsummon::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
// 69736 - Lich Pet Aura Remove
class spell_pet_gen_lich_pet_aura_remove : public SpellScript
{
PrepareSpellScript(spell_pet_gen_lich_pet_aura_remove);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_LICH_PET_AURA });
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
GetHitUnit()->RemoveAurasDueToSpell(SPELL_LICH_PET_AURA);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_pet_gen_lich_pet_aura_remove::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
// 69732 - Lich Pet Aura
class spell_pet_gen_lich_pet_aura : public AuraScript
{
PrepareAuraScript(spell_pet_gen_lich_pet_aura);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_LICH_PET_AURA_ONKILL });
}
bool CheckProc(ProcEventInfo& eventInfo)
{
return (eventInfo.GetProcTarget()->GetTypeId() == TYPEID_PLAYER);
}
void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
Unit* owner = GetUnitOwner();
std::list<Creature*> minionList;
owner->GetAllMinionsByEntry(minionList, NPC_LICH_PET);
for (Creature* minion : minionList)
owner->CastSpell(minion, SPELL_LICH_PET_AURA_ONKILL, true);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_pet_gen_lich_pet_aura::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_pet_gen_lich_pet_aura::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
// 70050 - [DND] Lich Pet
class spell_pet_gen_lich_pet_periodic_emote : public AuraScript
{
PrepareAuraScript(spell_pet_gen_lich_pet_periodic_emote);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_LICH_PET_EMOTE });
}
void OnPeriodic(AuraEffect const* /*aurEff*/)
{
// The chance to cast this spell is not 100%.
// Triggered spell roots creature for 3 sec and plays anim and sound (doesn't require any script).
// Emote and sound never shows up in sniffs because both comes from spell visual directly.
// Both 69683 and 70050 can trigger spells at once and are not linked together in any way.
// Effect of 70050 is overlapped by effect of 69683 but not instantly (69683 is a series of spell casts, takes longer to execute).
// However, for some reason emote is not played if creature is idle and only if creature is moving or is already rooted.
// For now it's scripted manually in script below to play emote always.
if (roll_chance_i(50))
GetTarget()->CastSpell(GetTarget(), SPELL_LICH_PET_EMOTE, true);
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_pet_gen_lich_pet_periodic_emote::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
// 70049 - [DND] Lich Pet
class spell_pet_gen_lich_pet_emote : public AuraScript
{
PrepareAuraScript(spell_pet_gen_lich_pet_emote);
void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->HandleEmoteCommand(EMOTE_ONESHOT_CUSTOM_SPELL_01);
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_pet_gen_lich_pet_emote::AfterApply, EFFECT_0, SPELL_AURA_MOD_ROOT, AURA_EFFECT_HANDLE_REAL);
}
};
// 69682 - Lil' K.T. Focus
class spell_pet_gen_lich_pet_focus : public SpellScript
{
PrepareSpellScript(spell_pet_gen_lich_pet_focus);
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()));
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_pet_gen_lich_pet_focus::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
@@ -168,5 +293,10 @@ void AddSC_generic_pet_scripts()
{
RegisterCreatureAI(npc_pet_gen_pandaren_monk);
RegisterCreatureAI(npc_pet_gen_soul_trader);
RegisterCreatureAI(npc_pet_lich);
RegisterSpellScript(spell_pet_gen_lich_pet_onsummon);
RegisterSpellScript(spell_pet_gen_lich_pet_aura_remove);
RegisterSpellScript(spell_pet_gen_lich_pet_aura);
RegisterSpellScript(spell_pet_gen_lich_pet_periodic_emote);
RegisterSpellScript(spell_pet_gen_lich_pet_emote);
RegisterSpellScript(spell_pet_gen_lich_pet_focus);
}

View File

@@ -1965,80 +1965,6 @@ class spell_gen_injured : public SpellScript
}
};
enum LichPet
{
NPC_LICH_PET = 36979,
SPELL_LICH_PET_AURA = 69732,
SPELL_LICH_PET_AURA_ONKILL = 69731
};
// 69732 - Lich Pet Aura
class spell_gen_lich_pet_aura : public AuraScript
{
PrepareAuraScript(spell_gen_lich_pet_aura);
bool CheckProc(ProcEventInfo& eventInfo)
{
return (eventInfo.GetProcTarget()->GetTypeId() == TYPEID_PLAYER);
}
void HandleProc(AuraEffect const* /* aurEff */, ProcEventInfo& /* eventInfo */)
{
PreventDefaultAction();
std::list<Creature*> minionList;
GetUnitOwner()->GetAllMinionsByEntry(minionList, NPC_LICH_PET);
for (Creature* minion : minionList)
if (minion->IsAIEnabled())
minion->AI()->DoCastSelf(SPELL_LICH_PET_AURA_ONKILL);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_gen_lich_pet_aura::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_gen_lich_pet_aura::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
// 69735 - Lich Pet OnSummon
class spell_gen_lich_pet_onsummon : public SpellScript
{
PrepareSpellScript(spell_gen_lich_pet_onsummon);
bool Validate(SpellInfo const* /* spellInfo */) override
{
return ValidateSpellInfo({ SPELL_LICH_PET_AURA });
}
void HandleScriptEffect(SpellEffIndex /* effIndex */)
{
Unit* target = GetHitUnit();
target->CastSpell(target, SPELL_LICH_PET_AURA, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_lich_pet_onsummon::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
// 69736 - Lich Pet Aura Remove
class spell_gen_lich_pet_aura_remove : public SpellScript
{
PrepareSpellScript(spell_gen_lich_pet_aura_remove);
void HandleScriptEffect(SpellEffIndex /* effIndex */)
{
GetHitUnit()->RemoveAurasDueToSpell(SPELL_LICH_PET_AURA);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_lich_pet_aura_remove::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
class spell_gen_lifeblood : public AuraScript
{
PrepareAuraScript(spell_gen_lifeblood);
@@ -4578,9 +4504,6 @@ void AddSC_generic_spell_scripts()
RegisterSpellScript(spell_gen_gnomish_transporter);
RegisterSpellScript(spell_gen_gryphon_wyvern_mount_check);
RegisterSpellScript(spell_gen_injured);
RegisterSpellScript(spell_gen_lich_pet_aura);
RegisterSpellScript(spell_gen_lich_pet_onsummon);
RegisterSpellScript(spell_gen_lich_pet_aura_remove);
RegisterSpellScript(spell_gen_lifeblood);
RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_hexlord_lifebloom", SPELL_HEXLORD_MALACRASS_LIFEBLOOM_FINAL_HEAL);
RegisterSpellScriptWithArgs(spell_gen_lifebloom, "spell_tur_ragepaw_lifebloom", SPELL_TUR_RAGEPAW_LIFEBLOOM_FINAL_HEAL);