1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-20 19:57:46 +00:00

Added bazaar scripts and missing class file.

This commit is contained in:
Filip Maj 2017-12-10 22:54:47 -05:00
parent c0312079ef
commit 0cb2fe1a68
7 changed files with 169 additions and 5 deletions

View file

@ -0,0 +1,65 @@
using FFXIVClassic_Map_Server.Actors;
using MoonSharp.Interpreter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.dataobjects
{
class GameEvent
{
private string eventName;
private uint ownerActorId;
private Player playerActor;
private Actor ownerActor;
private Coroutine coroutine;
private uint hashCode;
public GameEvent(String eventName, Player player, Actor owner)
{
this.eventName = eventName;
this.playerActor = player;
this.ownerActor = owner;
this.ownerActorId = owner.actorId;
hashCode = (uint)new Tuple<uint, uint, string>(player.actorId, owner.actorId, eventName).GetHashCode();
}
public string GetEventName()
{
return eventName;
}
public uint GetOwnerActorId()
{
return ownerActorId;
}
public Player GetPlayerActor()
{
return playerActor;
}
public Actor GetOwnerActor()
{
return ownerActor;
}
public Coroutine GetCoroutine()
{
return coroutine;
}
public void SetCoroutine(Coroutine coroutine)
{
this.coroutine = coroutine;
}
public uint GetUniqueEventId()
{
return hashCode;
}
}
}

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

@ -13,25 +13,42 @@ function onEventStarted(player, actor, triggerName, rewardItem, seekItem, bazaar
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 = GetWorldManager():CreateItem(rewardItem.itemId, rewardAmount, rewardItem.quality, rewardItem.modifiers);
end
end
--Handle Seek
if (type(seekItem) == "number") then
seekItem = GetWorldManager():CreateItem(seekItem, rewardAmount);
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 = GetWorldManager():CreateItem(seekItem.itemId, seekAmount, seekItem.quality, seekItem.modifiers);
end
end

View file

@ -0,0 +1,51 @@
--[[
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: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
end
else
--Show no gil error
end
else --Else we are fufilling a sought out item (ExecuteBazaarSell)
local rewardItem = player: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
end
else
end
end
player:EndEvent();
end

View file

@ -8,6 +8,8 @@ Handles canceling bazaar items
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

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

@ -10,6 +10,6 @@ The param "itemDBIds" has the vars: item1 and item2.
--]]
function onEventStarted(player, actor, triggerName, itemReference, targetPackage, sourcePackage, arg1, arg2, unknown, arg3, arg4, arg5, type9ItemIds)
player:GetInventory(targetPackage):RemoveItemAtSlot(itemReference.slot);
player:GetItemPackage(itemReference.itemPackage):RemoveItemAtSlot(itemReference.slot);
player:EndEvent();
end