fix(Scripts/GrizzlyHills): Refactor Red Rocket quest to use SmartAI s… (#22517)

This commit is contained in:
Andrew
2025-07-21 20:29:22 -03:00
committed by GitHub
parent 8621c2cef9
commit f7d88089aa
2 changed files with 21 additions and 98 deletions

View File

@@ -1016,89 +1016,9 @@ class spell_infected_worgen_bite_aura : public AuraScript
## Quest: Riding the Red Rocket
######*/
enum RedRocket
{
SPELL_VEHICLE_WARHEAD_FUSE = 49107,
SPELL_ALLIANCE_KILL_CREDIT_TORPEDO = 49510,
SPELL_HORDE_KILL_CREDIT_TORPEDO = 49340,
NPC_HORDE_LUMBERBOAT = 27702,
NPC_ALLIANCE_LUMBERBOAT = 27688,
SPELL_DETONATE = 49250
};
class npc_rocket_propelled_warhead : public CreatureScript
{
public:
npc_rocket_propelled_warhead() : CreatureScript("npc_rocket_propelled_warhead") { }
struct npc_rocket_propelled_warheadAI : public VehicleAI
{
npc_rocket_propelled_warheadAI(Creature* creature) : VehicleAI(creature), _faction(ALLIANCE), _finished(false)
{
}
void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override
{
if (apply && who && who->ToPlayer())
{
DoCast(me, SPELL_VEHICLE_WARHEAD_FUSE);
_faction = who->ToPlayer()->GetTeamId();
}
}
void JustReachedHome() override
{
_finished = false;
me->SetVisible(true);
me->GetMotionMaster()->Clear(true);
}
void DoAction(int32 /*action*/) override
{
FinishQuest(false, _faction);
}
void SpellHit(Unit* caster, SpellInfo const* /*spellInfo*/) override
{
if (caster && (caster->GetEntry() == NPC_HORDE_LUMBERBOAT || caster->GetEntry() == NPC_ALLIANCE_LUMBERBOAT))
{
FinishQuest(true, _faction);
}
}
void FinishQuest(bool success, uint32 faction)
{
if (_finished)
{
return;
}
_finished = true;
if (success)
{
DoCast(me, faction == ALLIANCE ? SPELL_ALLIANCE_KILL_CREDIT_TORPEDO : SPELL_HORDE_KILL_CREDIT_TORPEDO, true);
}
DoCast(me, SPELL_DETONATE, true);
me->RemoveAllAuras();
me->SetVisible(false);
me->GetMotionMaster()->MoveTargetedHome();
}
private:
uint32 _faction;
bool _finished;
};
CreatureAI* GetAI(Creature* creature) const override
{
return new npc_rocket_propelled_warheadAI(creature);
}
};
enum WarheadSpells
{
SPELL_DETONATE = 49250,
SPELL_WARHEAD_Z_CHECK = 61678,
SPELL_WARHEAD_SEEKING_LUMBERSHIP = 49331,
SPELL_WARHEAD_FUSE = 49181
@@ -1110,18 +1030,18 @@ class spell_vehicle_warhead_fuse : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return sSpellMgr->GetSpellInfo(SPELL_WARHEAD_Z_CHECK)
&& sSpellMgr->GetSpellInfo(SPELL_WARHEAD_SEEKING_LUMBERSHIP)
&& sSpellMgr->GetSpellInfo(SPELL_WARHEAD_FUSE);
return ValidateSpellInfo({
SPELL_WARHEAD_Z_CHECK,
SPELL_WARHEAD_SEEKING_LUMBERSHIP,
SPELL_WARHEAD_FUSE
});
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (!caster)
{
return;
}
caster->CastSpell(caster, SPELL_WARHEAD_Z_CHECK, true);
caster->CastSpell(caster, SPELL_WARHEAD_SEEKING_LUMBERSHIP, true);
@@ -1147,7 +1067,7 @@ class spell_warhead_detonate : public SpellScript
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return sSpellMgr->GetSpellInfo(SPELL_PARACHUTE) && sSpellMgr->GetSpellInfo(SPELL_TORPEDO_EXPLOSION);
return ValidateSpellInfo({ SPELL_PARACHUTE, SPELL_TORPEDO_EXPLOSION });
}
void HandleDummy(SpellEffIndex /*effIndex*/)
@@ -1171,6 +1091,9 @@ class spell_warhead_detonate : public SpellScript
{
(*itr)->CastSpell((*itr), SPELL_TORPEDO_EXPLOSION, true);
}
if (Creature* rocket = caster->ToCreature())
rocket->DespawnOrUnsummon();
}
void Register() override
@@ -1194,12 +1117,8 @@ class spell_z_check_aura : public AuraScript
PreventDefaultAction();
if (_posZ != GetTarget()->GetPositionZ())
{
if (Creature* target = GetTarget()->ToCreature())
{
target->AI()->DoAction(0);
}
}
target->AI()->DoCastSelf(SPELL_DETONATE, true);
}
private:
@@ -1220,12 +1139,8 @@ class spell_warhead_fuse_aura : public AuraScript
void HandleOnEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* rocketUnit = GetTarget()->GetVehicleBase())
{
if (Creature* rocketCrea = rocketUnit->ToCreature())
{
rocketCrea->AI()->DoAction(0);
}
}
rocketCrea->AI()->DoCastSelf(SPELL_DETONATE, true);
}
void Register() override
@@ -1271,7 +1186,6 @@ void AddSC_grizzly_hills()
new npc_lake_frog();
RegisterSpellScript(spell_shredder_delivery);
RegisterSpellScript(spell_infected_worgen_bite_aura);
new npc_rocket_propelled_warhead();
RegisterSpellScript(spell_z_check_aura);
RegisterSpellScript(spell_warhead_detonate);
RegisterSpellScript(spell_vehicle_warhead_fuse);