From 8d5f4465e3cc48b4c424718f5a1cf0dff164d97d Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Sun, 13 Feb 2022 18:50:48 -0500 Subject: [PATCH] New test gm scripts to help with positioning populace npcs --- Data/scripts/commands/gm/changetonpc.lua | 23 ++++++++++++ Data/scripts/commands/gm/setpopulacepos.lua | 32 +++++++++++++++++ Data/scripts/commands/gm/testpopulace.lua | 40 +++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 Data/scripts/commands/gm/changetonpc.lua create mode 100644 Data/scripts/commands/gm/setpopulacepos.lua create mode 100644 Data/scripts/commands/gm/testpopulace.lua diff --git a/Data/scripts/commands/gm/changetonpc.lua b/Data/scripts/commands/gm/changetonpc.lua new file mode 100644 index 00000000..9e6a4551 --- /dev/null +++ b/Data/scripts/commands/gm/changetonpc.lua @@ -0,0 +1,23 @@ +require("global"); + +properties = { + permissions = 0, + parameters = "", + description = +[[ +Changes appearance for equipment with given parameters. +!graphic +]], +} + +function onTrigger(player, argc) + local messageID = MESSAGE_TYPE_SYSTEM_ERROR; + local sender = "[changetonpc] "; + + local npc = player.CurrentArea:FindActorInArea(player.currentTarget); + + if npc then + player:ChangeIntoNpc(npc); + end + +end \ No newline at end of file diff --git a/Data/scripts/commands/gm/setpopulacepos.lua b/Data/scripts/commands/gm/setpopulacepos.lua new file mode 100644 index 00000000..d8bc0199 --- /dev/null +++ b/Data/scripts/commands/gm/setpopulacepos.lua @@ -0,0 +1,32 @@ +require("global"); + +properties = { + permissions = 0, + parameters = "sffff", + description = "Moves an actor into a new position instantly", +} + +function onTrigger(player, argc, name, posX, posY, posZ, rotation) + + local actor; + + if (name == nil) then + player:SendMessage(0x20, "", "No name provided."); + return; + end + + local pos = player:GetPos(); + local x = posX or pos[1]; + local y = posY or pos[2]; + local z = posZ or pos[3]; + local rot = rotation or pos[4]; + + actor = player.CurrentArea:FindActorInZoneByUniqueID(name); + if (actor ~= nil) then + actor:SetPos(x,y,z,rot,true); + player:SendMessage(0x20, "", string.format("Moved %s @ %f, %f, %f, %f", name, x, y, z, rot)); + else + player:SendMessage(0x20, "", string.format("Could not find %s.", name)); + end + +end \ No newline at end of file diff --git a/Data/scripts/commands/gm/testpopulace.lua b/Data/scripts/commands/gm/testpopulace.lua new file mode 100644 index 00000000..a7cf1d5a --- /dev/null +++ b/Data/scripts/commands/gm/testpopulace.lua @@ -0,0 +1,40 @@ +require("global"); + +properties = { + permissions = 0, + parameters = "dsdffff", + description = "Spawns an actor given the actorClassId", +} + +function onTrigger(player, argc, actorClassId, name, motionPack, posX, posY, posZ, rotation) + + local actor; + + if (actorClassId == nil) then + player:SendMessage(0x20, "", "No actor class id provided."); + return; + end + + if (motionPack == nil) then + motionPack = 0; + end + + local actorClassId = tonumber(actorClassId); + local pos = player:GetPos(); + local x = x or pos[1]; + local y = y or pos[2]; + local z = z or pos[3]; + local rot = rotation or pos[4]; + + if (actorClassId ~= nil and name ~= nil) then + + actor = player.CurrentArea:SpawnActor(1000001, name, x, y, z, rot, 0, motionPack); + actor:ChangeNpcAppearance(actorClassId) + player:SendMessage(0x20, "", string.format("Spawned %d @ %f, %f, %f, %f", actorClassId, x, y, z, rot)); + end + + if (actor == nil) then + player:SendMessage(0x20, "", "This actor class id cannot be spawned."); + end + +end; \ No newline at end of file