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

@@ -0,0 +1,9 @@
--
UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = 27593;
DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 27593);
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(27593, 0, 0, 0, 27, 0, 100, 512, 0, 0, 0, 0, 0, 0, 11, 49107, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Rocket Propelled Warhead - On Passenger Boarded - Cast \'Vehicle: Warhead Fuse\''),
(27593, 0, 1, 3, 8, 0, 100, 512, 49372, 0, 0, 0, 0, 0, 11, 49510, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Rocket Propelled Warhead - On Spellhit \'Horde Boat to Torpedo\' - Cast \'Alliance Kill Credit Torpedo\''),
(27593, 0, 2, 3, 8, 0, 100, 512, 49257, 0, 0, 0, 0, 0, 11, 49340, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Rocket Propelled Warhead - On Spellhit \'Alliance Boat to Torpedo\' - Cast \'Horde Kill Credit Torpedo\''),
(27593, 0, 3, 0, 61, 0, 100, 512, 0, 0, 0, 0, 0, 0, 11, 49250, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Rocket Propelled Warhead - On Event Link - Cast \'Detonate\'');

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);