fix(Scripts/Northrend): 'Preparations for War' flight to Icecrown (#23999)

Co-authored-by: Killyana <morphone1@gmail.com>
Co-authored-by: Rocco Silipo <108557877+Rorschach91@users.noreply.github.com>
This commit is contained in:
sogladev
2025-12-01 02:07:15 +01:00
committed by GitHub
parent a8c05b236c
commit ff80216e41
3 changed files with 215 additions and 55 deletions

View File

@@ -15,52 +15,100 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CombatAI.h"
#include "CreatureScript.h"
#include "PassiveAI.h"
#include "Player.h"
#include "ScriptedCreature.h"
#include "SmartScriptMgr.h"
#include "SpellAuras.h"
#include "SpellScript.h"
#include "Transport.h"
#include "Vehicle.h"
enum ePreparationsForWar
{
NPC_HAMMERHEAD = 30585,
NPC_CLOUDBUSTER = 30470,
TRANSPORT_ORGRIMS_HAMMER = 192241,
TRANSPORT_THE_SKYBREAKER = 192242
NPC_CLOUDBUSTER = 30470,
NPC_HAMMERHEAD = 30585,
TRANSPORT_ORGRIMS_HAMMER = 192241,
TRANSPORT_THE_SKYBREAKER = 192242,
SEAT_PLAYER = 0,
SPELL_FLIGHT = 48602,
SPELL_TO_ICECROWN_PLAYER_AURA_DISMOUNT_A = 56904,
SPELL_TO_ICECROWN_PLAYER_AURA_DISMOUNT_H = 57419,
SPELL_TO_ICECROWN_AIRSHIP_PLAYER_AURA_TELEPORT_TO_DALARAN = 57460,
SPELL_TO_ICECROWN_AIRSHIP_FROST_WYRM_WAITING_TO_SUMMON_AURA = 57498,
POINT_END = 16,
SPELL_TO_ICECROWN_AIRSHIP_AURA_DISMOUNT_RESPONSE = 56921, // unhandled - vehicle casts 50630 on self
SPELL_EJECT_ALL_PASSENGERS = 50630,
SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_A_FORCE_PLAYER_TO_CAST = 57554,
SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_H_FORCE_PLAYER_TO_CAST = 57556,
SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_A = 56917,
SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_H = 57417,
};
struct npc_preparations_for_war_vehicle : public NullCreatureAI
struct npc_preparations_for_war_vehicle : public VehicleAI
{
npc_preparations_for_war_vehicle(Creature* creature) : NullCreatureAI(creature) { }
uint8 pointId;
uint32 searchForShipTimer;
uint32 transportEntry;
void InitializeAI() override
explicit npc_preparations_for_war_vehicle(Creature* creature) : VehicleAI(creature), searchForShipTimer(0), transportEntry(me->GetEntry() == NPC_CLOUDBUSTER ? TRANSPORT_THE_SKYBREAKER : TRANSPORT_ORGRIMS_HAMMER)
{
me->GetMotionMaster()->MovePath(me->GetEntry(), FORCED_MOVEMENT_NONE, PathSource::SMART_WAYPOINT_MGR);
NullCreatureAI::InitializeAI();
pointId = 0;
searchForShipTimer = 0;
transportEntry = (me->GetEntry() == NPC_HAMMERHEAD ? TRANSPORT_ORGRIMS_HAMMER : TRANSPORT_THE_SKYBREAKER);
if (transportEntry == TRANSPORT_THE_SKYBREAKER)
{
// 30476 - [DND] Icecrown Flight To Airship Bunny (A)
passenger_x = 31.41805;
passenger_y = 0.126893;
passenger_z = 41.69821;
}
else // TRANSPORT_ORGRIMS_HAMMER
{
// 30588 - [DND] Icecrown Flight To Airship Bunny (H)
passenger_x = -18.10283;
passenger_y = -0.042108;
passenger_z = 45.31725;
}
}
void MovementInform(uint32 type, uint32 /*id*/) override
void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply) override
{
if (type == ESCORT_MOTION_TYPE)
if (++pointId == 17) // path size
searchForShipTimer = 3000;
if (apply)
{
DoCastSelf(SPELL_TO_ICECROWN_AIRSHIP_PLAYER_AURA_TELEPORT_TO_DALARAN, true);
DoCastSelf(SPELL_FLIGHT, true);
DoCastSelf(me->GetEntry() == NPC_CLOUDBUSTER ? SPELL_TO_ICECROWN_PLAYER_AURA_DISMOUNT_A : SPELL_TO_ICECROWN_PLAYER_AURA_DISMOUNT_H , true);
DoCastSelf(SPELL_TO_ICECROWN_AIRSHIP_FROST_WYRM_WAITING_TO_SUMMON_AURA, true);
me->GetMotionMaster()->MovePath(me->GetEntry(), FORCED_MOVEMENT_NONE, PathSource::SMART_WAYPOINT_MGR);
}
else
who->RemoveAurasDueToSpell(VEHICLE_SPELL_PARACHUTE); // maybe vehicle / seat flag should be responsible for parachute gain?
}
void MovementInform(uint32 type, uint32 id) override
{
if (type == ESCORT_MOTION_TYPE && id == POINT_END)
searchForShipTimer = 3000;
}
void SpellHit(Unit* /*caster*/, SpellInfo const* spell) override
{
switch (spell->Id)
{
case SPELL_TO_ICECROWN_AIRSHIP_AURA_DISMOUNT_RESPONSE:
break;
case SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_A_FORCE_PLAYER_TO_CAST:
case SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_H_FORCE_PLAYER_TO_CAST:
{
uint32 teleportSpell = (spell->Id == SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_A_FORCE_PLAYER_TO_CAST)
? SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_A
: SPELL_TO_ICECROWN_AIRSHIP_TELEPORT_TO_AIRSHIP_H;
DoCastSelf(teleportSpell, true); // hack: cast on self to avoid visual glitch on player when ejecting and teleporting on transport
DoCastSelf(SPELL_EJECT_ALL_PASSENGERS, true);
me->DespawnOrUnsummon(0s);
break;
}
default:
break;
}
}
void UpdateAI(uint32 diff) override
{
// horde 7.55f, -0.09, 34.44, 3.13, +20
// ally 45.18f, 0.03, 40.09, 3.14 +5
if (searchForShipTimer)
{
searchForShipTimer += diff;
@@ -68,37 +116,14 @@ struct npc_preparations_for_war_vehicle : public NullCreatureAI
{
searchForShipTimer = 1;
TransportsContainer const& transports = me->GetMap()->GetAllTransports();
for (TransportsContainer::const_iterator itr = transports.begin(); itr != transports.end(); ++itr)
for (auto const transport : transports)
{
if ((*itr)->GetEntry() == transportEntry)
if (transport->GetEntry() == transportEntry)
{
float x, y, z;
if (transportEntry == TRANSPORT_ORGRIMS_HAMMER)
{
x = 7.55f;
y = -0.09f;
z = 54.44f;
}
else
{
x = 45.18f;
y = 0.03f;
z = 45.09f;
}
float x = passenger_x, y = passenger_y, z = passenger_z;
transport->CalculatePassengerPosition(x, y, z);
(*itr)->CalculatePassengerPosition(x, y, z);
if (me->GetDistance2d(x, y) < 10.0f)
{
me->DespawnOrUnsummon(1s);
if (Vehicle* vehicle = me->GetVehicleKit())
if (Unit* passenger = vehicle->GetPassenger(0))
{
passenger->NearTeleportTo(x, y, z - (transportEntry == TRANSPORT_ORGRIMS_HAMMER ? 19.0f : 4.0f), M_PI);
passenger->RemoveAurasDueToSpell(VEHICLE_SPELL_PARACHUTE); // maybe vehicle / seat flag should be responsible for parachute gain?
}
}
else
if (me->GetDistance2d(x, y) > 20.0f) // dismount trigger (56905, 57420) range is 30
me->GetMotionMaster()->MovePoint(0, x, y, z, FORCED_MOVEMENT_NONE, 0.f, 0.f, false, false);
break;
}
@@ -106,6 +131,10 @@ struct npc_preparations_for_war_vehicle : public NullCreatureAI
}
}
}
private:
float passenger_x, passenger_y, passenger_z;
uint32 searchForShipTimer;
uint32 transportEntry;
};
/*******************************************************