Merge branch 'inventory_refactor' into develop

# Conflicts:
#	FFXIVClassic Map Server/Database.cs
#	FFXIVClassic Map Server/FFXIVClassic Map Server.csproj
#	FFXIVClassic Map Server/WorldManager.cs
#	FFXIVClassic Map Server/actors/area/Area.cs
#	FFXIVClassic Map Server/actors/area/Zone.cs
#	FFXIVClassic Map Server/actors/chara/Character.cs
#	FFXIVClassic Map Server/actors/chara/npc/Npc.cs
#	FFXIVClassic Map Server/actors/chara/player/Inventory.cs
#	FFXIVClassic Map Server/actors/chara/player/Player.cs
#	FFXIVClassic Map Server/dataobjects/ZoneConnection.cs
#	FFXIVClassic Map Server/lua/LuaEngine.cs
#	FFXIVClassic Map Server/packets/send/Actor/AddActorPacket.cs
#	FFXIVClassic Map Server/packets/send/Actor/DeleteAllActorsPacket.cs
#	FFXIVClassic Map Server/packets/send/Actor/SetActorPropetyPacket.cs
#	FFXIVClassic Map Server/packets/send/Actor/SetActorStatePacket.cs
#	FFXIVClassic Map Server/packets/send/Actor/SetActorStatusAllPacket.cs
#	FFXIVClassic Map Server/packets/send/Actor/SetActorStatusPacket.cs
#	FFXIVClassic Map Server/packets/send/Actor/_0x132Packet.cs
#	FFXIVClassic Map Server/packets/send/Actor/battle/BattleAction.cs
#	FFXIVClassic Map Server/packets/send/Actor/battle/BattleActionX10Packet.cs
#	FFXIVClassic Map Server/packets/send/Actor/battle/BattleActionX18Packet.cs
#	FFXIVClassic Map Server/packets/send/Actor/battle/CommandResultX00Packet.cs
#	FFXIVClassic Map Server/packets/send/Actor/events/SetEmoteEventCondition.cs
#	FFXIVClassic Map Server/packets/send/Actor/inventory/InventoryRemoveX08Packet.cs
#	data/scripts/commands/gm/giveitem.lua
This commit is contained in:
Filip Maj 2019-05-06 15:59:09 -04:00
commit bcb609e4f6
202 changed files with 2713 additions and 1040 deletions

View file

@ -0,0 +1,29 @@
--[[
BazaarCheckCommand Script
Handles what happens when you examine a player's bazaar
--]]
require ("global")
function onEventStarted(player, actor, triggerName, name, arg1, arg2, arg3, bazaarActorId)
local bazaarActor = nil;
if (name ~= nil) then
bazaarActor = player:GetZone():FindPCInZone(name);
elseif (bazaarActorId ~= nil) then
bazaarActor = player:GetZone():FindActorInArea(bazaarActorId);
end
if (bazaarActor ~= nil) then
callClientFunction(player, "delegateCommand", GetStaticActor("BazaarCheckCommand"), "processChackBazaar");
else
--Show error
end
player:EndEvent();
end

View file

@ -0,0 +1,71 @@
--[[
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)
local originalReward = nil;
local originalSeek = nil;
--Handle special case for offers
if (seekItem == nil) then
originalSeek = player:GetItemPackage(0):GetItemAtSlot(rewardItem.seekSlot);
originalReward = player:GetItemPackage(0):GetItemAtSlot(rewardItem.offerSlot);
end
--Handle Reward
if (type(rewardItem) == "number") then
rewardItem = GetWorldManager():CreateItem(rewardItem, rewardAmount);
player:RemoveItem(1000001, rewardAmount);
elseif (seekItem == nil) then
rewardItem = originalReward;
if (bazaarMode ~= 11) then
rewardItem = GetWorldManager():CreateItem(rewardItem.itemId, rewardAmount, rewardItem.quality, rewardItem.modifiers);
end
else
rewardItem = player:GetItem(rewardItem);
originalReward = rewardItem;
if (bazaarMode ~= 11) then
rewardItem = GetWorldManager():CreateItem(rewardItem.itemId, rewardAmount, rewardItem.quality, rewardItem.modifiers);
end
end
--Handle Seek
if (type(seekItem) == "number") then
seekItem = GetWorldManager():CreateItem(seekItem, seekAmount);
elseif (seekItem == nil) then
seekItem = originalSeek;
if (bazaarMode ~= 11) then
seekItem = GetWorldManager():CreateItem(seekItem.itemId, seekAmount, seekItem.quality, seekItem.modifiers);
end
else
seekItem = player:GetItem(seekItem);
originalSeek = seekItem;
if (bazaarMode ~= 11) then
seekItem = GetWorldManager():CreateItem(seekItem.itemId, seekAmount, seekItem.quality, seekItem.modifiers);
end
end
--If not selling, remove the seek item
if (bazaarMode ~= 11 and bazaarMode ~= 12 and bazaarMode ~= 13) then
if (originalSeek ~= nil) then
player:RemoveItem(originalSeek, seekAmount);
end
end
--Remove the reward item
if (originalReward ~= nil) then
player:RemoveItem(originalReward, rewardAmount);
end
GetWorldManager():AddToBazaar(player, rewardItem, seekItem, rewardAmount, seekAmount, bazaarMode);
player:EndEvent();
end

View file

@ -0,0 +1,53 @@
--[[
BazaarTradeCommand Script
Handles bazaar trade
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, seekItemOrCost, seekAmount, arg1, bazaarActorId, rewardAmount, rewardItemId, nameIndex, arg2, type9ItemIds)
local originalReward = nil;
local originalSeek = nil;
local bazaarActor = nil;
--Get the bazaar actor
if (bazaarActorId ~= nil) then
bazaarActor = player:GetZone():FindActorInArea(bazaarActorId);
end
--Abort if no actor
if (bazaarActor == nil) then
player:SendGameMessage(player, worldMaster, 25111, 0x20);
player:EndEvent();
return;
end
--If seekItem is a number, we are buying an item (ExecuteBazaarBuy)
if (type(seekItemOrCost) == "number") then
if (player:GetCurrentGil() >= seekItemOrCost) then
if (GetWorldManager():BazaarBuyOperation(bazaarActor, player, bazaarActor:GetItem(rewardItem), rewardAmount, seekItemOrCost)) then
else
player:SendGameMessage(player, worldMaster, 25111, 0x20);
end
else
player:SendGameMessage(player, worldMaster, 40252, 0x20);
end
else --Else we are fufilling a sought out item (ExecuteBazaarSell)
local rewardItem = bazaarActor:GetItem(rewardItem);
local seekItem = player:GetItem(seekItemOrCost);
if (rewardItem ~= nil and seekItem ~= nil) then
if (GetWorldManager():BazaarSellOperation(bazaarActor, player, rewardItem, rewardAmount, seekItem, seekAmount)) then
else
player:SendGameMessage(player, worldMaster, 25111, 0x20);
end
else
end
end
player:EndEvent();
end

View file

@ -0,0 +1,22 @@
--[[
BazaarUndealCommand Script
Handles canceling bazaar items
25107 - Your bazaar is either full or already contains that unique item.
25111 - Unable to complete transaction.
25112 - You are unable to remove the item from your bazaar. You cannot hold any more items.
25113 - Offered and sought items cannot be identical.
25114 - Items in less than mint condition cannot be offered.
25115 - Items in less than mint condition cannot be placed in your bazaar.
--]]
function onEventStarted(player, actor, triggerName, rewardItem, arg1, bazaarType, arg2, bazaarActor, rewardAmount, seekAmount, arg3, arg4, type9ItemIds)
GetWorldManager():RemoveFromBazaar(player, player:GetItem(rewardItem));
player:EndEvent();
end

View file

@ -0,0 +1,20 @@
--[[
ConfirmTradeCommand Script
Handles what happens when you accept/refuse a trade
--]]
function onEventStarted(player, actor, triggerName, groupType, result)
--Accept
if (result == 1) then
GetWorldManager():AcceptTrade(player);
--Refuse
elseif (result == 2) then
GetWorldManager():RefuseTrade(player);
end
player:EndEvent();
end

View file

@ -58,7 +58,7 @@ function onEventStarted(player, actor, triggerName, invActionInfo, param1, param
--Equip Item
if (invActionInfo ~= nil) then
item = player:GetInventory(0):GetItemAtSlot(invActionInfo.slot);
item = player:GetItemPackage(0):GetItemAtSlot(invActionInfo.slot);
equipItem(player, equipSlot, item);
player:SendAppearance();
--Unequip Item

View file

@ -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

View file

@ -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

View file

@ -9,7 +9,7 @@ The param "itemDBIds" has the vars: item1 and item2.
--]]
function onEventStarted(player, actor, triggerName, invActionInfo, param1, param2, param3, param4, param5, param6, param7, param8, itemDBIds)
player:GetInventory(0x00):RemoveItemAtSlot(invActionInfo.slot);
function onEventStarted(player, actor, triggerName, itemReference, targetPackage, sourcePackage, arg1, arg2, unknown, arg3, arg4, arg5, type9ItemIds)
player:GetItemPackage(itemReference.itemPackage):RemoveItemAtSlot(itemReference.slot);
player:EndEvent();
end

View file

@ -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

View file

@ -0,0 +1,14 @@
--[[
TradeOfferCommand Script
Handles what happens a player cancels a trade
--]]
function onEventStarted(player, actor, triggerName, commandId, result)
GetWorldManager():CancelTrade(player);
player:EndEvent();
end

View file

@ -0,0 +1,26 @@
--[[
TradeOfferCommand Script
Handles what happens when you invite to trade
--]]
function onEventStarted(player, actor, triggerName, name, arg1, arg2, arg3, actorId)
local otherActor = nil;
if (name ~= nil) then
otherActor = player:GetZone():FindPCInZone(name);
elseif (actorId ~= nil) then
otherActor = player:GetZone():FindActorInArea(actorId);
end
if (otherActor ~= nil) then
GetWorldManager():CreateTradeGroup(player, otherActor);
else
end
player:EndEvent();
end

View file

@ -27,7 +27,7 @@ function onTrigger(player, argc, qty, name, lastName)
qty = tonumber(qty) or 1;
location = INVENTORY_CURRENCY;
local added = player:GetInventory(location):AddItem(currency, qty, 1);
local added = player:GetItemPackage(location):AddItem(currency, qty, 1);
local messageID = MESSAGE_TYPE_SYSTEM_ERROR;
local message = "unable to add gil";

View file

@ -46,8 +46,7 @@ function onTrigger(player, argc, item, qty, location, name, lastName)
location = INVENTORY_NORMAL;
end;
local invCheck = player:getInventory(location):AddItem(item, qty, 1);
local invCheck = player:getItemPackage(location):addItem(item, qty, 1);
if (invCheck == INV_ERROR_FULL) then
-- Your inventory is full.