From 2a489953dbc6fbb0e1cda43f35b092da65d4f044 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Sat, 21 Oct 2017 13:01:14 -0400 Subject: [PATCH] Added the skeletons of the rest of the item commands. --- data/scripts/commands/BazaarDealCommand.lua | 23 +++++ data/scripts/commands/BazaarUndealCommand.lua | 13 +++ .../commands/ItemMovePackageCommand.lua | 13 +++ data/scripts/commands/ItemTransferCommand.lua | 13 +++ data/scripts/commands/TradeExecuteCommand.lua | 95 +++++++++++++++++++ 5 files changed, 157 insertions(+) create mode 100644 data/scripts/commands/BazaarDealCommand.lua create mode 100644 data/scripts/commands/BazaarUndealCommand.lua create mode 100644 data/scripts/commands/ItemMovePackageCommand.lua create mode 100644 data/scripts/commands/ItemTransferCommand.lua create mode 100644 data/scripts/commands/TradeExecuteCommand.lua diff --git a/data/scripts/commands/BazaarDealCommand.lua b/data/scripts/commands/BazaarDealCommand.lua new file mode 100644 index 00000000..83f94bea --- /dev/null +++ b/data/scripts/commands/BazaarDealCommand.lua @@ -0,0 +1,23 @@ +--[[ + +BazaarDealCommand Script + +Handles various bazaar transfer options + +All bazaar args have a Reward (The item the person who fufills the request gets) and a Seek (The item the player wants, either gil or an item). + +--]] + +function onEventStarted(player, actor, triggerName, rewardItem, seekItem, bazaarMode, arg1, bazaarActor, rewardAmount, seekAmount, arg2, arg3, type9ItemIds) + + --Get reward reference or itemId + + --Get seek reference or itemid + + --Tell worldmaster to add bazaar entry with reward, seek, rewardAmount, seekAmount, and bazaarMode + + --Remove reward items from inventory + + player:EndEvent(); + +end \ No newline at end of file diff --git a/data/scripts/commands/BazaarUndealCommand.lua b/data/scripts/commands/BazaarUndealCommand.lua new file mode 100644 index 00000000..b16f42fb --- /dev/null +++ b/data/scripts/commands/BazaarUndealCommand.lua @@ -0,0 +1,13 @@ +--[[ + +BazaarUndealCommand Script + +Handles canceling bazaar items + +--]] + +function onEventStarted(player, actor, triggerName, rewardItem, arg1, bazaarType, arg2, bazaarActor, rewardAmount, seekAmount, arg3, arg4, type9ItemIds) + + player:EndEvent(); + +end \ No newline at end of file diff --git a/data/scripts/commands/ItemMovePackageCommand.lua b/data/scripts/commands/ItemMovePackageCommand.lua new file mode 100644 index 00000000..5f1bd6c4 --- /dev/null +++ b/data/scripts/commands/ItemMovePackageCommand.lua @@ -0,0 +1,13 @@ +--[[ + +ItemMovePackageCommand Script + +Handles moving items across item packages (IE: Taking loot) + +--]] + +function onEventStarted(player, actor, triggerName, itemReference, targetPackage, sourcePackage, arg1, arg2, unknown, arg3, arg4, arg5, type9ItemIds) + + player:EndEvent(); + +end \ No newline at end of file diff --git a/data/scripts/commands/ItemTransferCommand.lua b/data/scripts/commands/ItemTransferCommand.lua new file mode 100644 index 00000000..392c54f9 --- /dev/null +++ b/data/scripts/commands/ItemTransferCommand.lua @@ -0,0 +1,13 @@ +--[[ + +ItemTransferCommand Script + +Handles giving an item to another party member. + +--]] + +function onEventStarted(player, actor, triggerName, itemReference, targetPackage, sourcePackage, arg1, targetPlayer, arg2, arg3, arg4, arg5, type9ItemIds) + + player:EndEvent(); + +end \ No newline at end of file diff --git a/data/scripts/commands/TradeExecuteCommand.lua b/data/scripts/commands/TradeExecuteCommand.lua new file mode 100644 index 00000000..730f491f --- /dev/null +++ b/data/scripts/commands/TradeExecuteCommand.lua @@ -0,0 +1,95 @@ +--[[ + +TradeExecuteCommand Script + +Handles all trading between players + +Functions: + +processTradeCommandOpenTray() - Opens the trade widget. +processTradeCommandCloseTray() - Closes the trade widget. +processTradeCommandReply(command, params) - Operates the trade widget. +processUpdateTradeCommandTrayData() - ? + +Commands: + +set: TradeWidget resets "Set Mode" (turned on once item selected while waiting for reply). +back: TradeWidget resets "Choose Mode" (turned on when ui operation is done). +fix: You have accepted the deal. +targetfix: Target has accepted the deal. +doedit: You have canceled your accept. +reedit: Target has canceled their accept. + +--]] + +require ("global") + +function onEventStarted(player, actor, triggerName) + + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandOpenTray"); + + tradeOffering = player:GetTradeOfferings(); + + while (true) do + widgetOpen, chosenOperation, tradeSlot, type7, quantity, packageId, quality = callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processUpdateTradeCommandTrayData"); + + --Abort script if client script dead + if (widgetOpen == false or widgetOpen == nil) then + break; + end + + --Handle you/target canceling/finishing the trade + if (not player:IsTrading() or not player:GetOtherTrader():IsTrading()) then + break; + end + + --Handle target accepting + if (player:GetOtherTrader():IsTradeAccepted() == true) then + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandReply", "targetfix"); + else + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandReply", "reedit"); + end + + --Check if both accepted the trade + if (player:IsTradeAccepted() and player:GetOtherTrader():IsTradeAccepted()) then + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandCloseTray"); + GetWorldManager():SwapTradedItems(player, player:GetOtherTrader()); + break; + end + + --Clear Item + if (chosenOperation == 1) then + player:RemoveTradeItem(tradeSlot - 1); + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandReply", "set"); + --Clear All + elseif (chosenOperation == 2) then + player:ClearTradeItems(1); + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandReply", "set"); + --Item Chosen + elseif (chosenOperation == 3) then + player:AddTradeItem(tradeSlot - 1, type7.slot, quantity); + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandReply", "set", 2, 2, 2, 2); + --Gil Chosen + elseif (chosenOperation == 4) then + player:AddTradeGil(quantity); + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandReply", "set"); + --Cancel + elseif (chosenOperation == 11) then + player:FinishTradeTransaction(); + break; + --OK + elseif (chosenOperation == 12) then + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandReply", "fix"); + player:AcceptTrade(true); + --Reedit + elseif (chosenOperation == 13) then + callClientFunction(player, "delegateCommand", GetStaticActor("TradeExecuteCommand"), "processTradeCommandReply", "doedit"); + player:AcceptTrade(false); + end + + wait(1); + end + + player:EndEvent(); + +end \ No newline at end of file