From d9bccb5bfff782a77d1631b9bc13d3aa62a00f00 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Sat, 19 Mar 2016 19:22:28 -0400 Subject: [PATCH] Fixed bug in equip script causing the classChange function to be called multiple times due to classId not being a local variable. Added some test scripts for Request Information/QuestJournal Command. --- scripts/commands/EquipCommand.lua | 73 +++++++++++-------- .../commands/RequestInformationCommand.lua | 13 ++++ .../commands/RequestQuestJournalCommand.lua | 12 +++ 3 files changed, 66 insertions(+), 32 deletions(-) create mode 100644 scripts/commands/RequestInformationCommand.lua create mode 100644 scripts/commands/RequestQuestJournalCommand.lua diff --git a/scripts/commands/EquipCommand.lua b/scripts/commands/EquipCommand.lua index 632f6269..5e7d93c3 100644 --- a/scripts/commands/EquipCommand.lua +++ b/scripts/commands/EquipCommand.lua @@ -74,10 +74,9 @@ end function loadGearset(player, classId) player:getEquipment():ToggleDBWrite(false); - gearset = player:getGearset(classId); + local gearset = player:getGearset(classId); if gearset == nil then - player:getEquipment():ToggleDBWrite(true); return; end @@ -103,19 +102,50 @@ function loadGearset(player, classId) player:getEquipment():ToggleDBWrite(true); - player:doClassChange(classId); end function equipItem(player, equipSlot, item) if (item ~= nil) then - worldMaster = getWorldMaster(); + local classId = nil; + local worldMaster = getWorldMaster(); + local gItem = getItemGamedata(item.itemId); + + --If it's the mainhand, begin class change based on weapon + if (equipSlot == EQUIPSLOT_MAINHAND) then + if (gItem:IsNailWeapon()) then classId = 2; + elseif (gItem:IsSwordWeapon()) then classId = 3; + elseif (gItem:IsAxeWeapon()) then classId = 4; + elseif (gItem:IsBowWeapon()) then classId = 7; + elseif (gItem:IsLanceWeapon()) then classId = 8; + + elseif (gItem:IsThaumaturgeWeapon()) then classId = 22; + elseif (gItem:IsConjurerWeapon()) then classId = 23; + + elseif (gItem:IsCarpenterWeapon()) then classId = 29; + elseif (gItem:IsBlackSmithWeapon()) then classId = 30; + elseif (gItem:IsArmorerWeapon()) then classId = 31; + elseif (gItem:IsGoldSmithWeapon()) then classId = 32; + elseif (gItem:IsTannerWeapon()) then classId = 33; + elseif (gItem:IsWeaverWeapon()) then classId = 34; + elseif (gItem:IsAlchemistWeapon()) then classId = 35; + elseif (gItem:IsCulinarianWeapon()) then classId = 36; + + elseif (gItem:IsMinerWeapon()) then classId = 39; + elseif (gItem:IsBotanistWeapon()) then classId = 40; + elseif (gItem:IsFishingWeapon()) then classId = 41; + end + + if (classId ~= nil) then + player:sendGameMessage(player, worldMaster, 30103, 0x20, 0, 0, player, classId); + player:prepareClassChange(classId); + end + + end --Item Equipped message player:sendGameMessage(player, worldMaster, 30601, 0x20, equipSlot+1, item.itemId, item.quality, 0, 0, 1); - player:getEquipment():Equip(equipSlot, item); - - gItem = getItemGamedata(item.itemId); + player:getEquipment():Equip(equipSlot, item); if (equipSlot == EQUIPSLOT_MAINHAND and gItem:IsNailWeapon() == false and gItem:IsBowWeapon() == false) then graphicSlot = GRAPHICSLOT_MAINHAND; elseif (equipSlot == EQUIPSLOT_OFFHAND) then graphicSlot = GRAPHICSLOT_OFFHAND; @@ -144,33 +174,12 @@ function equipItem(player, equipSlot, item) player:graphicChange(GRAPHICSLOT_L_EAR, item); end - --If it's the mainhand, begin class change based on weapon - if (equipSlot == EQUIPSLOT_MAINHAND) then - if (gItem:IsNailWeapon()) then classId = 2; - elseif (gItem:IsSwordWeapon()) then classId = 3; - elseif (gItem:IsAxeWeapon()) then classId = 4; - elseif (gItem:IsBowWeapon()) then classId = 7; - elseif (gItem:IsLanceWeapon()) then classId = 8; - - elseif (gItem:IsThaumaturgeWeapon()) then classId = 22; - elseif (gItem:IsConjurerWeapon()) then classId = 23; - - elseif (gItem:IsCarpenterWeapon()) then classId = 29; - elseif (gItem:IsBlackSmithWeapon()) then classId = 30; - elseif (gItem:IsArmorerWeapon()) then classId = 31; - elseif (gItem:IsGoldSmithWeapon()) then classId = 32; - elseif (gItem:IsTannerWeapon()) then classId = 33; - elseif (gItem:IsWeaverWeapon()) then classId = 34; - elseif (gItem:IsAlchemistWeapon()) then classId = 35; - elseif (gItem:IsCulinarianWeapon()) then classId = 36; - - elseif (gItem:IsMinerWeapon()) then classId = 39; - elseif (gItem:IsBotanistWeapon()) then classId = 40; - elseif (gItem:IsFishingWeapon()) then classId = 41; - end - + --Load gearset for new class and begin class change + if (classId ~= nil) then loadGearset(player, classId); + player:doClassChange(classId); end + end end diff --git a/scripts/commands/RequestInformationCommand.lua b/scripts/commands/RequestInformationCommand.lua new file mode 100644 index 00000000..c16e66ce --- /dev/null +++ b/scripts/commands/RequestInformationCommand.lua @@ -0,0 +1,13 @@ +--[[ + + +--]] + +function onEventStarted(player, actor, questId) + player:sendRequestedInfo("requestedData", "activegl", 7, nil, nil, nil, nil, nil, nil, nil); +-- player:sendRequestedInfo("requestedData", "glHist", 10, 0x1D4F2, 1009, 12464, 11727, 12485, 12526); +end + +function onEventUpdate(player, actor, step, arg1) + +end \ No newline at end of file diff --git a/scripts/commands/RequestQuestJournalCommand.lua b/scripts/commands/RequestQuestJournalCommand.lua new file mode 100644 index 00000000..e90a91ba --- /dev/null +++ b/scripts/commands/RequestQuestJournalCommand.lua @@ -0,0 +1,12 @@ +--[[ + + +--]] + +function onEventStarted(player, actor, questId) + player:sendRequestedInfo("requestedData", "qtdata", 0x1D4F2); +end + +function onEventUpdate(player, actor, step, arg1) + +end \ No newline at end of file