mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
refactor(Scripts/Pet): Death Knight use creature register macros (#22399)
This commit is contained in:
@@ -49,14 +49,9 @@ enum DeathKnightSpells
|
||||
SPELL_GHOUL_FRENZY = 62218,
|
||||
};
|
||||
|
||||
class npc_pet_dk_ebon_gargoyle : public CreatureScript
|
||||
struct npc_pet_dk_ebon_gargoyle : ScriptedAI
|
||||
{
|
||||
public:
|
||||
npc_pet_dk_ebon_gargoyle() : CreatureScript("npc_pet_dk_ebon_gargoyle") { }
|
||||
|
||||
struct npc_pet_dk_ebon_gargoyleAI : ScriptedAI
|
||||
{
|
||||
npc_pet_dk_ebon_gargoyleAI(Creature* creature) : ScriptedAI(creature)
|
||||
npc_pet_dk_ebon_gargoyle(Creature* creature) : ScriptedAI(creature)
|
||||
{
|
||||
_despawnTimer = 36000; // 30 secs + 4 fly out + 2 initial attack timer
|
||||
_despawning = false;
|
||||
@@ -83,12 +78,8 @@ public:
|
||||
// Xinef: Night of the Dead avoidance
|
||||
if (Aura* aur = me->GetAura(SPELL_DK_NIGHT_OF_THE_DEAD))
|
||||
if (AuraEffect* aurEff = owner->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2718, 0))
|
||||
{
|
||||
if (aur->GetEffect(0))
|
||||
{
|
||||
aur->GetEffect(0)->SetAmount(-aurEff->GetSpellInfo()->Effects[EFFECT_2].CalcValue());
|
||||
}
|
||||
}
|
||||
|
||||
me->SetCanFly(true);
|
||||
me->SetDisableGravity(true);
|
||||
@@ -181,12 +172,12 @@ public:
|
||||
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 50.0f);
|
||||
Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
|
||||
Cell::VisitAllObjects(me, searcher, 50.0f);
|
||||
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
||||
if ((*iter)->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID()))
|
||||
for (auto const& target : targets)
|
||||
if (target->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID()))
|
||||
{
|
||||
(*iter)->RemoveAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID());
|
||||
SetGazeOn(*iter);
|
||||
_targetGUID = (*iter)->GetGUID();
|
||||
target->RemoveAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID());
|
||||
SetGazeOn(target);
|
||||
_targetGUID = target->GetGUID();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -221,58 +212,34 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObjectGuid _targetGUID;
|
||||
uint32 _despawnTimer;
|
||||
uint32 _selectionTimer;
|
||||
uint32 _initialCastTimer;
|
||||
bool _despawning;
|
||||
bool _initialSelection;
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return new npc_pet_dk_ebon_gargoyleAI(creature);
|
||||
}
|
||||
};
|
||||
|
||||
class npc_pet_dk_ghoul : public CreatureScript
|
||||
struct npc_pet_dk_ghoul : public CombatAI
|
||||
{
|
||||
public:
|
||||
npc_pet_dk_ghoul() : CreatureScript("npc_pet_dk_ghoul") { }
|
||||
|
||||
struct npc_pet_dk_ghoulAI : public CombatAI
|
||||
{
|
||||
npc_pet_dk_ghoulAI(Creature* c) : CombatAI(c) { }
|
||||
npc_pet_dk_ghoul(Creature* c) : CombatAI(c) { }
|
||||
|
||||
void JustDied(Unit* /*who*/) override
|
||||
{
|
||||
if (me->IsGuardian() || me->IsSummon())
|
||||
me->ToTempSummon()->UnSummon();
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* pCreature) const override
|
||||
{
|
||||
return new npc_pet_dk_ghoulAI (pCreature);
|
||||
}
|
||||
};
|
||||
|
||||
class npc_pet_dk_risen_ally : public CreatureScript
|
||||
struct npc_pet_dk_risen_ally : public PossessedAI
|
||||
{
|
||||
public:
|
||||
npc_pet_dk_risen_ally() : CreatureScript("npc_pet_dk_risen_ally") { }
|
||||
|
||||
struct npc_pet_dk_risen_allyAI : public PossessedAI
|
||||
{
|
||||
npc_pet_dk_risen_allyAI(Creature* c) : PossessedAI(c) { }
|
||||
npc_pet_dk_risen_ally(Creature* c) : PossessedAI(c) { }
|
||||
|
||||
void OnCharmed(bool apply) override
|
||||
{
|
||||
if (!apply)
|
||||
{
|
||||
if (Unit* owner = me->GetCharmerOrOwner())
|
||||
{
|
||||
if (Player* player = owner->ToPlayer())
|
||||
{
|
||||
player->RemoveAurasDueToSpell(SPELL_DK_RAISE_ALLY); // Remove Raise Ally aura
|
||||
@@ -280,62 +247,31 @@ public:
|
||||
//player->ClearResurrectRequestData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* pCreature) const override
|
||||
{
|
||||
return new npc_pet_dk_risen_allyAI (pCreature);
|
||||
}
|
||||
};
|
||||
|
||||
class npc_pet_dk_army_of_the_dead : public CreatureScript
|
||||
struct npc_pet_dk_army_of_the_dead : public CombatAI
|
||||
{
|
||||
public:
|
||||
npc_pet_dk_army_of_the_dead() : CreatureScript("npc_pet_dk_army_of_the_dead") { }
|
||||
|
||||
struct npc_pet_dk_army_of_the_deadAI : public CombatAI
|
||||
{
|
||||
npc_pet_dk_army_of_the_deadAI(Creature* creature) : CombatAI(creature) { }
|
||||
npc_pet_dk_army_of_the_dead(Creature* creature) : CombatAI(creature) { }
|
||||
|
||||
void InitializeAI() override
|
||||
{
|
||||
CombatAI::InitializeAI();
|
||||
((Minion*)me)->SetFollowAngle(rand_norm() * 2 * M_PI);
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return new npc_pet_dk_army_of_the_deadAI (creature);
|
||||
}
|
||||
};
|
||||
|
||||
class npc_pet_dk_dancing_rune_weapon : public CreatureScript
|
||||
struct npc_pet_dk_dancing_rune_weapon : public NullCreatureAI
|
||||
{
|
||||
public:
|
||||
npc_pet_dk_dancing_rune_weapon() : CreatureScript("npc_pet_dk_dancing_rune_weapon") { }
|
||||
|
||||
struct npc_pet_dk_dancing_rune_weaponAI : public NullCreatureAI
|
||||
{
|
||||
npc_pet_dk_dancing_rune_weaponAI(Creature* creature) : NullCreatureAI(creature) { }
|
||||
npc_pet_dk_dancing_rune_weapon(Creature* creature) : NullCreatureAI(creature) { }
|
||||
|
||||
void InitializeAI() override
|
||||
{
|
||||
// Xinef: Hit / Expertise scaling
|
||||
me->AddAura(61017, me);
|
||||
me->AddAura(SPELL_HUNTER_PET_SCALING_04, me);
|
||||
if (Unit* owner = me->GetOwner())
|
||||
me->GetMotionMaster()->MoveFollow(owner, 0.01f, me->GetFollowAngle(), MOTION_SLOT_CONTROLLED);
|
||||
|
||||
NullCreatureAI::InitializeAI();
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return new npc_pet_dk_dancing_rune_weaponAI (creature);
|
||||
}
|
||||
};
|
||||
|
||||
class spell_pet_dk_gargoyle_strike : public SpellScript
|
||||
@@ -346,12 +282,8 @@ class spell_pet_dk_gargoyle_strike : public SpellScript
|
||||
{
|
||||
int32 damage = 60;
|
||||
if (Unit* caster = GetCaster())
|
||||
{
|
||||
if (caster->GetLevel() >= 60)
|
||||
{
|
||||
damage += (caster->GetLevel() - 60) * 4;
|
||||
}
|
||||
}
|
||||
|
||||
SetEffectValue(damage);
|
||||
}
|
||||
@@ -364,10 +296,10 @@ class spell_pet_dk_gargoyle_strike : public SpellScript
|
||||
|
||||
void AddSC_deathknight_pet_scripts()
|
||||
{
|
||||
new npc_pet_dk_ebon_gargoyle();
|
||||
new npc_pet_dk_ghoul();
|
||||
new npc_pet_dk_risen_ally();
|
||||
new npc_pet_dk_army_of_the_dead();
|
||||
new npc_pet_dk_dancing_rune_weapon();
|
||||
RegisterCreatureAI(npc_pet_dk_ebon_gargoyle);
|
||||
RegisterCreatureAI(npc_pet_dk_ghoul);
|
||||
RegisterCreatureAI(npc_pet_dk_risen_ally);
|
||||
RegisterCreatureAI(npc_pet_dk_army_of_the_dead);
|
||||
RegisterCreatureAI(npc_pet_dk_dancing_rune_weapon);
|
||||
RegisterSpellScript(spell_pet_dk_gargoyle_strike);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user