From 74713f3dd6acb9e70c52fa110db8b149f735a6e4 Mon Sep 17 00:00:00 2001 From: CuriousJorge Date: Sun, 13 Mar 2022 20:35:29 -0400 Subject: [PATCH] Misc GM command fixes + ChangeJobCommand.lua Anim - Cleaned up some. It had old code sitting in it for whatever reason despite not affecting anything. Setstate, Warpplayer & Yolo - Fixed them up so they function again ChangeJobCommand - Just the script filled out to handle the equipping/dequipping of job stones, but it can cause issues, particularly with how the server handles a 'job' vs. a class, along with checking against skill compatibility. --- Data/scripts/commands/ChangeJobCommand.lua | 88 +++++++++++++++++++++- Data/scripts/commands/gm/anim.lua | 77 +++---------------- Data/scripts/commands/gm/setstate.lua | 8 +- Data/scripts/commands/gm/warpplayer.lua | 4 +- Data/scripts/commands/gm/yolo.lua | 12 +-- 5 files changed, 109 insertions(+), 80 deletions(-) diff --git a/Data/scripts/commands/ChangeJobCommand.lua b/Data/scripts/commands/ChangeJobCommand.lua index 930d8aa7..5cef1127 100644 --- a/Data/scripts/commands/ChangeJobCommand.lua +++ b/Data/scripts/commands/ChangeJobCommand.lua @@ -1,6 +1,90 @@ -function onEventStarted(player, caller, eventType, eventName, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) +require("global"); +--[[ - player:SetCurrentJob(17); +ChangeJobCommand Script +Called when the player equips/unequips a job stone or uses the /job command. + +--]] + + +local classToJob = { -- [classId] = {jobId, jobAnim, jobKeyItem} + [2] = {15, 0x4000028, 2000202}, -- PGL -> MNK + [3] = {16, 0x4000029, 2000201}, -- GLD -> PLD + [4] = {17, 0x4000027, 2000203}, -- MRD -> WAR + [7] = {18, 0x400002D, 2000205}, -- ARC -> BRD + [8] = {19, 0x400002C, 2000204}, -- LNC -> DRG + [22] = {26, 0x400002B, 2000207}, -- THM -> BLM + [23] = {27, 0x400002A, 2000206}, -- CNJ -> WHM +} + +local jobToClass = { -- [jobId] = classId + [15] = 2, -- MNK -> PGL + [16] = 3, -- PLD -> GLD + [17] = 4, -- WAR -> MRD + [18] = 7, -- BRD -> ARC + [19] = 8, -- DRG -> LNC + [26] = 22, -- BLM -> THM + [27] = 23 -- WHM -> CNJ +} + + +function onEventStarted(player, command, eventType, eventName, jobState) + + local currentClass = player:GetCurrentClassOrJob(); + local jobCheck = isJob(currentClass); + local hasKeyItem = false; + + if (jobCheck == false) then + hasKeyItem = player:GetItemPackage(INVENTORY_KEYITEMS):HasItem(classToJob[currentClass][3]); + end + + if (jobCheck ~= nil) then -- Valid Class/Job ids only + if (jobState == 0) then -- Toggle current class/job state + if ((jobCheck == false) and (hasKeyItem == true)) then + setPlayerJob(player, classToJob[currentClass][1], classToJob[currentClass][2]); + elseif (jobCheck == true) then + setPlayerClass(player, jobToClass[currentClass]) + end + + elseif (jobState == 1 and (jobCheck == false) and (hasKeyItem == true)) then -- Equipping Job stone + setPlayerJob(player, classToJob[currentClass][1], classToJob[currentClass][2]); + elseif (jobState == 2 and (jobCheck == true)) then -- Removing Job stone + setPlayerClass(player, jobToClass[currentClass]); + end + end + player:EndEvent(); +end + + +function setPlayerClass(player, id) + player:SetCurrentJob(0); + player:PrepareClassChange(id); + player:DoClassChange(id); + player:PlayAnimation(0x4001030); + player:SendGameMessage(player, GetWorldMaster(), 30103, 0x20, 0, 0, player, id); +end + +function setPlayerJob(player, id, anim) + player:SetCurrentJob(id); + player:PrepareClassChange(id); + player:DoClassChange(jobToClass[id]); + player:PlayAnimation(anim); + player:SendGameMessage(player, GetWorldMaster(), 30103, 0x20, 0, 0, player, id); +end + +function isJob(id) + local validId = { + [2] = 0, [3] = 0, [4] = 0, [7] = 0, [8] = 0, [22] = 0, [23] = 0, + [15] = 1, [16] = 1, [17] = 1, [18] = 1, [19] = 1, [26] = 1, [27] = 1 + } + + if (validId[id] == 0) then + return false; + elseif (validId[id] == 1) then + return true; + else + return nil; + end end \ No newline at end of file diff --git a/Data/scripts/commands/gm/anim.lua b/Data/scripts/commands/gm/anim.lua index bf33a593..d0b092e7 100644 --- a/Data/scripts/commands/gm/anim.lua +++ b/Data/scripts/commands/gm/anim.lua @@ -12,64 +12,23 @@ Sets anim id for current target } -function onTrigger(player, argc, aType, a1, a2, uID) - --if uID == nil then uID = "test"; end - local npc = GetWorldManager():GetActorInWorld(player.currentTarget) or nil; - --npc = GetWorldManager():GetActorInWorldByUniqueId(uID); - - --[[ if argc == 1 then - -- aType = tonumber(aType, 16) or 0; - if aType > 4294967295 then - - player:SendMessage(0x20, "[anim] ", "Error: Value too large"); - return; - else - player:PlayAnimation(aType); - end - else--]] - - aType = tonumber(aType) or 0; - a1 = tonumber(a1) or 0; - a2 = tonumber(a2) or 1; - - - a1 = bit32.band(a1, 0xFFF); - a2 = bit32.band(a2, 0xFFF); - aType = bit32.band(aType, 0xFF); - - animId = bit32.bor(bit32.lshift(a2, 12), a1); - animId = bit32.bor(bit32.lshift(aType, 24), animId); - print(animId); - - --[[ - if npc == nil then - player:PlayAnimation(animId); - else - npc:PlayAnimation(animId); - end - --]] +function onTrigger(player, argc, aType, a1, a2) + local actor = player.CurrentArea.FindActorInArea(player.currentTarget) or nil; - if player and actor then - - + if (player and actor) then a1 = bit32.band(a1, 0xFFF); a2 = bit32.band(a2, 0xFFF); aType = bit32.band(aType, 0xFF); animId = bit32.bor(bit32.lshift(a2, 12), a1); animId = bit32.bor(bit32.lshift(aType, 24), animId); - -- player:SendMessage(0x20, "[anim] ", tostring(animId)); + -- player:SendMessage(0x20, "[anim] ", tostring(animId)); actor:PlayAnimation(animId); - local output = string.format("%x", animId) + local output = string.format("%x", animId) player:SendMessage(0x20, "[anim] ", "0x"..tostring(output).. " Target:"..tostring(actor)); - - - end; - - - -end; + end +end --[[ Categories: @@ -96,9 +55,11 @@ end; 33 = ? 34 = Crash - 120 = ??? + +Notes: +------ CATEGORY Shift 18 bits right CMP 0xB @@ -123,24 +84,6 @@ CMP 71 ec000000 00FFFFFF -BTL: -ETC: -GL2: -KAO: - -MGK: 01 -SYS: 02 -LIB: 046 -ITM: 05-09 -GL?: 0B -GL1: 0C -CBI: 0D -ABL: 0E -POP: 0F -CFT: 10 -PIC: 14 -WSC: 12 - 19: Auto Attack? 6F: Casting 71: Seems to deal with signaling monster parts diff --git a/Data/scripts/commands/gm/setstate.lua b/Data/scripts/commands/gm/setstate.lua index cfff2cb0..c6e1b091 100644 --- a/Data/scripts/commands/gm/setstate.lua +++ b/Data/scripts/commands/gm/setstate.lua @@ -15,10 +15,12 @@ function onTrigger(player, argc, state) local sender = "[setstate] "; local s = tonumber(state); - local actor = GetWorldManager():GetActorInWorld(player.currentTarget) or nil; + local actor = player.CurrentArea:FindActorInArea(player.currentTarget) or nil; if player and actor then actor:ChangeState(s); - wait(0.8); - player:SendMessage(0x20, "", "state: "..s); + wait(0.8); + player:SendMessage(0x20, "", "state: "..s); + else + player:SendMessage(0x20, "", "Error: No target selected."); end; end; \ No newline at end of file diff --git a/Data/scripts/commands/gm/warpplayer.lua b/Data/scripts/commands/gm/warpplayer.lua index 297c9250..76970dd0 100644 --- a/Data/scripts/commands/gm/warpplayer.lua +++ b/Data/scripts/commands/gm/warpplayer.lua @@ -38,7 +38,7 @@ function onTrigger(player, argc, name, lastName, name2, lastName2) return; else local pos = p1:GetPos(); - worldManager:DoZoneChange(player, pos[4], nil, 0, 0x02, pos[0], pos[1], pos[2], pos[3]); + worldManager:DoZoneChange(player, pos[5], nil, 0, 0x02, pos[1], pos[2], pos[3], pos[4]); player:SendMessage(messageID, sender, string.format("Moving to %s %s 's coordinates.", name, lastName)); end; elseif argc == 4 then; @@ -50,7 +50,7 @@ function onTrigger(player, argc, name, lastName, name2, lastName2) local pos = p1:GetPos(); local pos2 = p2:GetPos(); - worldManager:DoZoneChange(p1, pos2[4], nil, 0, 0x02, pos2[0], pos2[1], pos2[2], pos2[3]); + worldManager:DoZoneChange(p1, pos2[5], nil, 0, 0x02, pos2[1], pos2[2], pos2[3], pos2[4]); player:SendMessage(messageID, sender, string.format("Moving %s %s to %s %s 's coordinates.", name, lastName, name2, lastName2)); p1:SendMessage(messageID, sender, string.format("You are being moved to %s %s 's coordinates.", name2, lastName2)); end; diff --git a/Data/scripts/commands/gm/yolo.lua b/Data/scripts/commands/gm/yolo.lua index 24f9b2a4..98471443 100644 --- a/Data/scripts/commands/gm/yolo.lua +++ b/Data/scripts/commands/gm/yolo.lua @@ -144,11 +144,11 @@ function onTrigger(player, argc, width, height, blockCount) end; local pos = player:GetPos(); - local x = tonumber(pos[0]); - local y = tonumber(pos[1]); - local z = tonumber(pos[2]); - local rot = tonumber(pos[3]); - local zone = pos[4]; + local x = tonumber(pos[1]); + local y = tonumber(pos[2]); + local z = tonumber(pos[3]); + local rot = tonumber(pos[4]); + local zone = pos[5]; local w = tonumber(width) or 0; local h = tonumber(height) or 0; @@ -160,7 +160,7 @@ function onTrigger(player, argc, width, height, blockCount) for i = 0, w do for j = 0, h do local actor = player.CurrentArea.SpawnActor(2104001, 'ass', x + (i * 1), y, z + (j * 1), rot, 0, 0, true); - --actor.ChangeNpcAppearance(2200905); + actor.ChangeNpcAppearance(2200905); actor.SetMaxHP(500); actor.SetHP(500); actor.SetMod(modifiersGlobal.CanBlock, 1);