Skip to content

Commit

Permalink
fix(Scripts/Dalaran): Update Toy Shop Toy Plane behaviour based on sn…
Browse files Browse the repository at this point in the history
…iffs (azerothcore#18239)

* fix(Scripts/Dalaran): Update Toy Shop Toy Plane behaviour based on sniffs

* update comments and waypoints for smoother movement

* move initalization to Reset() function
  • Loading branch information
sudlud authored Feb 3, 2024
1 parent 1324f42 commit 186cb58
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
9 changes: 9 additions & 0 deletions data/sql/updates/pending_db_world/rev_1705674468268232500.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Fix Dalaran Toy Store Plane behaviour

-- Update creature 29802 'Cosmetic Toy Plane' with sniffed values
DELETE FROM `creature` WHERE (`id1` = 29802) AND (`guid` IN (105492));
INSERT INTO `creature` (`guid`, `id1`, `map`, `spawnMask`, `phaseMask`, `equipment_id`, `position_x`, `position_y`, `position_z`, `orientation`, `spawntimesecs`, `wander_distance`, `MovementType`, `npcflag`, `unit_flags`, `dynamicflags`, `ScriptName`, `VerifiedBuild`, `CreateObject`, `Comment`) VALUES
(105492, 29802, 571, 1, 1, 0, 5809.88818359375, 683.577880859375, 653.68585205078125, 5.602106094360351562, 120, 0, 0, 0, 0, 0, "", 52237, 1, NULL);

-- ScriptedAI
UPDATE `creature_template` SET `AIName` = '', `ScriptName` = 'npc_cosmetic_toy_plane' WHERE (`entry` = 29802);
57 changes: 57 additions & 0 deletions src/server/scripts/Northrend/zone_dalaran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "CreatureScript.h"
#include "Player.h"
#include "MoveSplineInit.h"
#include "ScriptedCreature.h"
#include "ScriptedGossip.h"
#include "World.h"
Expand Down Expand Up @@ -795,6 +796,61 @@ class npc_dalaran_warrior : public CreatureScript
};
};

enum ToyPlane
{
NPC_DND_DALARAN_TOY_STORE_PLANE_STRING_HOOK = 29807,

SPELL_TOY_PLANE_CABLE = 55281,
};

struct npc_cosmetic_toy_plane : public ScriptedAI
{
npc_cosmetic_toy_plane(Creature* creature) : ScriptedAI(creature)
{
}

void Reset() override
{
Movement::MoveSplineInit init(me);
init.MovebyPath(_movementArray);
init.SetFly();
init.SetCyclic();
// one full loop is 10.76 seconds (sniffed value)
// loop diameter is approx. 9.225f (calculated from waypoints below)
// with a circumference of approx. 28.98f
// this results in flying speed of approx. 2.7f
init.SetVelocity(2.7f);
init.Launch();

scheduler.Schedule(420ms, [this](TaskContext context)
{
if (Creature* cr = me->FindNearestCreature(NPC_DND_DALARAN_TOY_STORE_PLANE_STRING_HOOK, 42.0f))
DoCast(cr, SPELL_TOY_PLANE_CABLE, true);
else
context.Repeat();
});
}

void UpdateAI(uint32 diff) override
{
scheduler.Update(diff);
}

private:
Movement::PointsArray const _movementArray = {
// cyclic movementspine unfortunately includes spawn into loop
// which results in an imperfect loop right now
// CO1 SPAWN(5809.888, 683.5779, 653.6859)
G3D::Vector3(5813.709, 682.51855, 653.6033),
G3D::Vector3(5816.815, 684.8459, 653.5755),
G3D::Vector3(5817.1997, 688.83527, 653.631),
G3D::Vector3(5814.235, 691.6307, 653.6587),
G3D::Vector3(5809.9287, 690.98224, 653.7697),
G3D::Vector3(5808.225, 687.1498, 653.6322),
G3D::Vector3(5809.8423, 683.6158, 653.6862),
};
};

void AddSC_dalaran()
{
// our
Expand All @@ -804,6 +860,7 @@ void AddSC_dalaran()
new npc_archmage_landalock();
new npc_dalaran_mage();
new npc_dalaran_warrior();
RegisterCreatureAI(npc_cosmetic_toy_plane);

// theirs
new npc_mageguard_dalaran();
Expand Down

0 comments on commit 186cb58

Please sign in to comment.