From 0d4ed1d1c8f5c05d2bde734071e1d5f49ec76347 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Sun, 9 Apr 2017 14:01:15 -0400 Subject: [PATCH] Cleaned up the way a npc ls is set. Added an optimization, no changes are made if it is being set to the same value already set. Added the handler for npc linkshells when they are used. --- .../actors/chara/player/Player.cs | 37 ++++++++++++++- .../commands/NpcLinkshellChatCommand.lua | 45 +++++++++++++++++++ data/scripts/commands/gm/setnpcls.lua | 8 ++-- 3 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 data/scripts/commands/NpcLinkshellChatCommand.lua diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index fb763db9..508d0448 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -73,6 +73,11 @@ namespace FFXIVClassic_Map_Server.Actors public const int TIMER_RETURN = 18; public const int TIMER_SKIRMISH = 19; + public const int NPCLS_GONE = 0; + public const int NPCLS_INACTIVE = 1; + public const int NPCLS_ACTIVE = 2; + public const int NPCLS_ALERT = 3; + public static int[] MAXEXP = {570, 700, 880, 1100, 1500, 1800, 2300, 3200, 4300, 5000, //Level <= 10 5900, 6800, 7700, 8700, 9700, 11000, 12000, 13000, 15000, 16000, //Level <= 20 20000, 22000, 23000, 25000, 27000, 29000, 31000, 33000, 35000, 38000, //Level <= 30 @@ -1254,8 +1259,36 @@ namespace FFXIVClassic_Map_Server.Actors return -1; } - public void SetNpcLS(uint npcLSId, bool isCalling, bool isExtra) - { + public void SetNpcLS(uint npcLSId, uint state) + { + bool isCalling, isExtra; + isCalling = isExtra = false; + + switch (state) + { + case NPCLS_INACTIVE: + + if (playerWork.npcLinkshellChatExtra[npcLSId] == true && playerWork.npcLinkshellChatCalling[npcLSId] == false) + return; + + isExtra = true; + break; + case NPCLS_ACTIVE: + + if (playerWork.npcLinkshellChatExtra[npcLSId] == false && playerWork.npcLinkshellChatCalling[npcLSId] == true) + return; + + isCalling = true; + break; + case NPCLS_ALERT: + + if (playerWork.npcLinkshellChatExtra[npcLSId] == true && playerWork.npcLinkshellChatCalling[npcLSId] == true) + return; + + isExtra = isCalling = true; + break; + } + playerWork.npcLinkshellChatExtra[npcLSId] = isExtra; playerWork.npcLinkshellChatCalling[npcLSId] = isCalling; diff --git a/data/scripts/commands/NpcLinkshellChatCommand.lua b/data/scripts/commands/NpcLinkshellChatCommand.lua new file mode 100644 index 00000000..e301614c --- /dev/null +++ b/data/scripts/commands/NpcLinkshellChatCommand.lua @@ -0,0 +1,45 @@ +require ("global") + +--[[ + +NpcLinkshellChatCommand Script + +Handler for when a player clicks a npc ls to talk to. If adding new linkshells to the handle, make sure to add +it to the handler table (with correct offset), and that your function is above the handler. If padding is needed +to hit some ID, add "nils". + +--]] + + +local function handleAdventurersGuild(player) + if (player:HasQuest(110006) == true) then + local man0g1Quest = player:GetQuest("Man0g1"); + player:SendGameMessage(man0g1Quest, 330, 39, 1300018); + end +end + +local function handlePathOfTheTwelve(player) + player:SendMessage(0x20, "", "Test"); +end + +local npcLsHandlers = { + handleAdventurersGuild, + nil, + nil, + nil, + nil, + handlePathOfTheTwelve +} + +function onEventStarted(player, command, triggerName, npcLsId) + + if (npcLsHandlers[npcLsId] ~= nil) then + npcLsHandlers[npcLsId](player); + player:SetNpcLS(npcLsId-1, NPCLS_ACTIVE); + else + player:SendMessage(0x20, "", "That Npc Linkshell is not implemented yet."); + end + + player:endEvent(); + +end diff --git a/data/scripts/commands/gm/setnpcls.lua b/data/scripts/commands/gm/setnpcls.lua index 5a195c99..6943e235 100644 --- a/data/scripts/commands/gm/setnpcls.lua +++ b/data/scripts/commands/gm/setnpcls.lua @@ -10,13 +10,13 @@ function onTrigger(player, argc, lsId, state) local id = tonumber(lsId) or 0; if (state == "alert") then - player:SetNpcLS(id, true, true); + player:SetNpcLS(id, NPCLS_ALERT); elseif (state == "active") then - player:SetNpcLS(id, true, false); + player:SetNpcLS(id, NPCLS_ACTIVE); elseif (state == "inactive") then - player:SetNpcLS(id, false, true); + player:SetNpcLS(id, NPCLS_INACTIVE); elseif (state == "gone") then - player:SetNpcLS(id, false, false); + player:SetNpcLS(id, NPCLS_GONE); else player:SendMessage(0x20, "", "Invalid state argument"); return;