mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-23 05:07:47 +00:00
Events are now pushed onto a stack and popped off. Turns out multiple events *CAN* happen. Fixed quantity bugs when saving to DB. Fixed buying stacks.
This commit is contained in:
parent
08c5980b22
commit
a9d4e621e3
7 changed files with 38 additions and 58 deletions
|
@ -1624,9 +1624,9 @@ namespace FFXIVClassic_Map_Server
|
|||
|
||||
string query = @"
|
||||
INSERT INTO server_items
|
||||
(itemId, quality)
|
||||
(itemId, quantity, quality)
|
||||
VALUES
|
||||
(@itemId, @quality);
|
||||
(@itemId, @quantity, @quality);
|
||||
";
|
||||
|
||||
string query2 = @"
|
||||
|
@ -1638,6 +1638,7 @@ namespace FFXIVClassic_Map_Server
|
|||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@itemId", itemId);
|
||||
cmd.Parameters.AddWithValue("@quantity", quantity);
|
||||
cmd.Parameters.AddWithValue("@quality", quality);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@
|
|||
<Compile Include="actors\quest\Quest.cs" />
|
||||
<Compile Include="actors\StaticActors.cs" />
|
||||
<Compile Include="actors\world\WorldMaster.cs" />
|
||||
<Compile Include="dataobjects\GameEvent.cs" />
|
||||
<Compile Include="dataobjects\GuildleveData.cs" />
|
||||
<Compile Include="dataobjects\TradeTransaction.cs" />
|
||||
<Compile Include="dataobjects\ZoneConnection.cs" />
|
||||
|
|
|
@ -175,11 +175,6 @@ namespace FFXIVClassic_Map_Server
|
|||
|
||||
Actor ownerActor = Server.GetStaticActors(eventStart.scriptOwnerActorID);
|
||||
|
||||
|
||||
session.GetActor().currentEventOwner = eventStart.scriptOwnerActorID;
|
||||
session.GetActor().currentEventName = eventStart.triggerName;
|
||||
|
||||
|
||||
if (ownerActor == null)
|
||||
{
|
||||
//Is it your retainer?
|
||||
|
@ -187,7 +182,7 @@ namespace FFXIVClassic_Map_Server
|
|||
ownerActor = session.GetActor().currentSpawnedRetainer;
|
||||
//Is it a instance actor?
|
||||
if (ownerActor == null)
|
||||
ownerActor = session.GetActor().zone.FindActorInArea(session.GetActor().currentEventOwner);
|
||||
ownerActor = session.GetActor().zone.FindActorInArea(eventStart.scriptOwnerActorID);
|
||||
if (ownerActor == null)
|
||||
{
|
||||
//Is it a Director?
|
||||
|
|
|
@ -1060,19 +1060,16 @@ namespace FFXIVClassic_Map_Server
|
|||
if (cost < 0)
|
||||
return false;
|
||||
|
||||
if (itemToBuy.GetBazaarMode() == InventoryItem.TYPE_STACK)
|
||||
{
|
||||
itemToBuy.ChangeQuantity(-quantity);
|
||||
buyer.AddItemStack(itemToBuy.itemId, quantity, itemToBuy.quality);
|
||||
buyer.GetItemPackage(Inventory.CURRENCY_CRYSTALS).RemoveItem(1000001, cost);
|
||||
}
|
||||
else
|
||||
if (itemToBuy.GetBazaarMode() == InventoryItem.TYPE_SINGLE || itemToBuy.GetBazaarMode() == InventoryItem.TYPE_MULTI || itemToBuy.GetBazaarMode() == InventoryItem.TYPE_STACK)
|
||||
{
|
||||
itemToBuy.ChangeQuantity(-quantity);
|
||||
buyer.AddItem(itemToBuy.itemId, quantity, itemToBuy.quality);
|
||||
buyer.GetItemPackage(Inventory.CURRENCY_CRYSTALS).RemoveItem(1000001, cost);
|
||||
}
|
||||
|
||||
if (itemToBuy.quantity == 0)
|
||||
Database.ClearBazaarEntry(bazaar, itemToBuy);
|
||||
|
||||
bazaar.CheckBazaarFlags();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -151,18 +151,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
ushort itemPackage = GetPackageForItem(catalogID);
|
||||
if (itemPackages.ContainsKey(itemPackage))
|
||||
{
|
||||
InventoryItem item = Server.GetWorldManager().CreateItem(catalogID, quantity, quality);
|
||||
itemPackages[itemPackage].AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddItemStack(uint catalogID, int quantity, byte quality)
|
||||
{
|
||||
ItemData itemData = Server.GetItemGamedata(catalogID);
|
||||
if (itemData != null)
|
||||
{
|
||||
int totalQuantity = itemData.maxStack * quantity;
|
||||
AddItem(catalogID, totalQuantity, quality);
|
||||
itemPackages[itemPackage].AddItem(catalogID, quantity, quality);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,10 +88,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
74000, 78000, 81000, 85000, 89000, 92000, 96000, 100000, 100000, 110000}; //Level <= 50
|
||||
|
||||
//Event Related
|
||||
public uint currentEventOwner = 0;
|
||||
public string currentEventName = "";
|
||||
|
||||
public Coroutine currentEventRunning;
|
||||
private Stack<GameEvent> runningEvents = new Stack<GameEvent>();
|
||||
|
||||
//Player Info
|
||||
public uint destinationZone;
|
||||
|
@ -1645,12 +1642,15 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
public void StartEvent(Actor owner, EventStartPacket start)
|
||||
{
|
||||
LuaEngine.GetInstance().EventStarted(this, owner, start);
|
||||
GameEvent startedEvent = new GameEvent(start.triggerName, this, owner);
|
||||
runningEvents.Push(startedEvent);
|
||||
LuaEngine.GetInstance().EventStarted(startedEvent, start);
|
||||
}
|
||||
|
||||
public void UpdateEvent(EventUpdatePacket update)
|
||||
{
|
||||
LuaEngine.GetInstance().OnEventUpdate(this, update.luaParams);
|
||||
GameEvent updateEvent = runningEvents.Peek();
|
||||
LuaEngine.GetInstance().OnEventUpdate(updateEvent, update.luaParams);
|
||||
}
|
||||
|
||||
public void KickEvent(Actor actor, string conditionName, params object[] parameters)
|
||||
|
@ -1683,20 +1683,17 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
public void RunEventFunction(string functionName, params object[] parameters)
|
||||
{
|
||||
List<LuaParam> lParams = LuaUtils.CreateLuaParamList(parameters);
|
||||
SubPacket spacket = RunEventFunctionPacket.BuildPacket(actorId, currentEventOwner, currentEventName, functionName, lParams);
|
||||
SubPacket spacket = RunEventFunctionPacket.BuildPacket(actorId, runningEvents.Peek().GetOwnerActorId(), runningEvents.Peek().GetEventName(), functionName, lParams);
|
||||
spacket.DebugPrintSubPacket();
|
||||
QueuePacket(spacket);
|
||||
}
|
||||
|
||||
public void EndEvent()
|
||||
{
|
||||
SubPacket p = EndEventPacket.BuildPacket(actorId, currentEventOwner, currentEventName);
|
||||
GameEvent endingEvent = runningEvents.Pop();
|
||||
SubPacket p = EndEventPacket.BuildPacket(actorId, endingEvent.GetOwnerActorId(), endingEvent.GetEventName());
|
||||
p.DebugPrintSubPacket();
|
||||
QueuePacket(p);
|
||||
|
||||
currentEventOwner = 0;
|
||||
currentEventName = "";
|
||||
currentEventRunning = null;
|
||||
}
|
||||
|
||||
public void SendInstanceUpdate()
|
||||
|
|
|
@ -36,7 +36,6 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
|
||||
private Timer luaTimer;
|
||||
|
||||
|
||||
private LuaEngine()
|
||||
{
|
||||
UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic;
|
||||
|
@ -108,25 +107,25 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
}
|
||||
}
|
||||
|
||||
public void OnEventUpdate(Player player, List<LuaParam> args)
|
||||
public void OnEventUpdate(GameEvent gEvent, List<LuaParam> args)
|
||||
{
|
||||
if (mSleepingOnPlayerEvent.ContainsKey(player.actorId))
|
||||
if (mSleepingOnPlayerEvent.ContainsKey(gEvent.GetUniqueEventId()))
|
||||
{
|
||||
try
|
||||
{
|
||||
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
|
||||
mSleepingOnPlayerEvent.Remove(player.actorId);
|
||||
Coroutine coroutine = mSleepingOnPlayerEvent[gEvent.GetUniqueEventId()];
|
||||
mSleepingOnPlayerEvent.Remove(gEvent.GetUniqueEventId());
|
||||
DynValue value = coroutine.Resume(LuaUtils.CreateLuaParamObjectList(args));
|
||||
ResolveResume(player, coroutine, value);
|
||||
ResolveResume(gEvent.GetPlayerActor(), coroutine, value);
|
||||
}
|
||||
catch (ScriptRuntimeException e)
|
||||
{
|
||||
LuaEngine.SendError(player, String.Format("OnEventUpdated: {0}", e.DecoratedMessage));
|
||||
player.EndEvent();
|
||||
LuaEngine.SendError(gEvent.GetPlayerActor(), String.Format("OnEventUpdated: {0}", e.DecoratedMessage));
|
||||
gEvent.GetPlayerActor().EndEvent();
|
||||
}
|
||||
}
|
||||
else
|
||||
player.EndEvent();
|
||||
gEvent.GetPlayerActor().EndEvent();
|
||||
}
|
||||
|
||||
private static string GetScriptPath(Actor target)
|
||||
|
@ -365,14 +364,15 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
}
|
||||
}
|
||||
|
||||
public void EventStarted(Player player, Actor target, EventStartPacket eventStart)
|
||||
public void EventStarted(GameEvent gEvent, EventStartPacket eventStart)
|
||||
{
|
||||
List<LuaParam> lparams = eventStart.luaParams;
|
||||
lparams.Insert(0, new LuaParam(2, eventStart.triggerName));
|
||||
if (mSleepingOnPlayerEvent.ContainsKey(player.actorId))
|
||||
|
||||
if (mSleepingOnPlayerEvent.ContainsKey(gEvent.GetUniqueEventId()))
|
||||
{
|
||||
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
|
||||
mSleepingOnPlayerEvent.Remove(player.actorId);
|
||||
Coroutine coroutine = mSleepingOnPlayerEvent[gEvent.GetUniqueEventId()];
|
||||
mSleepingOnPlayerEvent.Remove(gEvent.GetUniqueEventId());
|
||||
|
||||
try{
|
||||
DynValue value = coroutine.Resume();
|
||||
|
@ -380,16 +380,16 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
}
|
||||
catch (ScriptRuntimeException e)
|
||||
{
|
||||
LuaEngine.SendError(player, String.Format("OnEventStarted: {0}", e.DecoratedMessage));
|
||||
player.EndEvent();
|
||||
LuaEngine.SendError(gEvent.GetPlayerActor(), String.Format("OnEventStarted: {0}", e.DecoratedMessage));
|
||||
gEvent.GetPlayerActor().EndEvent();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target is Director)
|
||||
((Director)target).OnEventStart(player, LuaUtils.CreateLuaParamObjectList(lparams));
|
||||
if (gEvent.GetOwnerActor() is Director)
|
||||
((Director)gEvent.GetOwnerActor()).OnEventStart(gEvent.GetPlayerActor(), LuaUtils.CreateLuaParamObjectList(lparams));
|
||||
else
|
||||
CallLuaFunction(player, target, "onEventStarted", false, LuaUtils.CreateLuaParamObjectList(lparams));
|
||||
CallLuaFunction(gEvent.GetPlayerActor(), gEvent.GetOwnerActor(), "onEventStarted", false, LuaUtils.CreateLuaParamObjectList(lparams));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,7 +611,7 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
return;
|
||||
List<SubPacket> SendError = new List<SubPacket>();
|
||||
player.SendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", message);
|
||||
player.QueuePacket(EndEventPacket.BuildPacket(player.actorId, player.currentEventOwner, player.currentEventName));
|
||||
player.EndEvent();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue