mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Added the game message packets. Fixed "canRideChocobo" param in zone not working. Added a lot more function for lua to access. Various minor changes.
This commit is contained in:
		| @@ -121,6 +121,7 @@ | ||||
|     <Compile Include="packets\receive\supportdesk\GMTicketIssuesRequestPacket.cs" /> | ||||
|     <Compile Include="packets\send\actor\ActorDoEmotePacket.cs" /> | ||||
|     <Compile Include="packets\send\actor\ActorInstantiatePacket.cs" /> | ||||
|     <Compile Include="packets\send\actor\BattleAction1Packet.cs" /> | ||||
|     <Compile Include="packets\send\actor\DeleteAllActorsPacket.cs" /> | ||||
|     <Compile Include="packets\send\actor\events\SetEventStatus.cs" /> | ||||
|     <Compile Include="packets\send\actor\events\SetNoticeEventCondition.cs" /> | ||||
|   | ||||
| @@ -221,19 +221,19 @@ namespace FFXIVClassic_Lobby_Server | ||||
|                         case 0x012D:                             | ||||
|                             subpacket.debugPrintSubPacket(); | ||||
|                             EventStartPacket eventStart = new EventStartPacket(subpacket.data); | ||||
|                             player.eventCurrentOwner = eventStart.scriptOwnerActorID; | ||||
|                             player.eventCurrentStarter = eventStart.eventStarter; | ||||
|                             player.getActor().eventCurrentOwner = eventStart.scriptOwnerActorID; | ||||
|                             player.getActor().eventCurrentStarter = eventStart.eventStarter; | ||||
|  | ||||
|                             //Is it a static actor? If not look in the player's instance | ||||
|                             Actor ownerActor = Server.getStaticActors(player.eventCurrentOwner); | ||||
|                             Actor ownerActor = Server.getStaticActors(player.getActor().eventCurrentOwner); | ||||
|                             if (ownerActor == null) | ||||
|                             { | ||||
|                                 ownerActor = mServer.GetWorldManager().GetActorInWorld(player.eventCurrentOwner); | ||||
|                                 ownerActor = mServer.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); | ||||
|                                 if (ownerActor == null) | ||||
|                                     break; | ||||
|                             } | ||||
|                              | ||||
|                             mServer.GetLuaEngine().doActorOnEventStarted(player.getActor(), ownerActor); | ||||
|                             mServer.GetLuaEngine().doActorOnEventStarted(player.getActor(), ownerActor, eventStart); | ||||
|  | ||||
|                             Log.debug(String.Format("\n===Event START===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nEvent Starter: {4}\nParams: {5}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.val1, eventStart.val2, eventStart.eventStarter, LuaUtils.dumpParams(eventStart.luaParams))); | ||||
|                             break; | ||||
| @@ -244,10 +244,10 @@ namespace FFXIVClassic_Lobby_Server | ||||
|                             Log.debug(String.Format("\n===Event UPDATE===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nStep: 0x{4:X}\nParams: {5}", eventUpdate.actorID, eventUpdate.scriptOwnerActorID, eventUpdate.val1, eventUpdate.val2, eventUpdate.step, LuaUtils.dumpParams(eventUpdate.luaParams))); | ||||
|  | ||||
|                             //Is it a static actor? If not look in the player's instance | ||||
|                             Actor updateOwnerActor = Server.getStaticActors(player.eventCurrentOwner); | ||||
|                             Actor updateOwnerActor = Server.getStaticActors(player.getActor().eventCurrentOwner); | ||||
|                             if (updateOwnerActor == null) | ||||
|                             { | ||||
|                                 updateOwnerActor = mServer.GetWorldManager().GetActorInWorld(player.eventCurrentOwner); | ||||
|                                 updateOwnerActor = mServer.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); | ||||
|                                 if (updateOwnerActor == null) | ||||
|                                     break; | ||||
|                             } | ||||
|   | ||||
| @@ -15,9 +15,8 @@ namespace FFXIVClassic_Lobby_Server | ||||
| { | ||||
|     class Program | ||||
|     { | ||||
|  | ||||
|         static void Main(string[] args) | ||||
|         {             | ||||
|         { | ||||
| #if DEBUG | ||||
|             TextWriterTraceListener myWriter = new TextWriterTraceListener(System.Console.Out); | ||||
|             Debug.Listeners.Add(myWriter); | ||||
|   | ||||
| @@ -221,6 +221,11 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|             return className; | ||||
|         } | ||||
|  | ||||
|         public ushort getState() | ||||
|         { | ||||
|             return currentMainState; | ||||
|         } | ||||
|  | ||||
|         public List<LuaParam> getLuaParams() | ||||
|         { | ||||
|             return classParams; | ||||
| @@ -230,7 +235,9 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|         { | ||||
|             currentMainState = newState; | ||||
|             SubPacket changeStatePacket = SetActorStatePacket.buildPacket(actorId, actorId, newState, currentSubState); | ||||
|             SubPacket battleActionPacket = BattleAction1Packet.buildPacket(actorId, actorId); | ||||
|             zone.broadcastPacketAroundActor(this, changeStatePacket); | ||||
|             zone.broadcastPacketAroundActor(this, battleActionPacket); | ||||
|         } | ||||
|  | ||||
|         public void changeSpeed(int type, float value) | ||||
|   | ||||
| @@ -28,7 +28,7 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|         private Dictionary<uint, Actor> mActorList = new Dictionary<uint,Actor>(); | ||||
|         private List<Actor>[,] mActorBlock; | ||||
|  | ||||
|         public Zone(uint id, string zoneName, ushort regionId, ushort bgmDay, ushort bgmNight, ushort bgmBattle, bool canStealth, bool isInn, bool canRideChocobo, bool isInstanceRaid) | ||||
|         public Zone(uint id, string zoneName, ushort regionId, ushort bgmDay, ushort bgmNight, ushort bgmBattle, bool isInn, bool canRideChocobo, bool canStealth, bool isInstanceRaid) | ||||
|             : base(id) | ||||
|         { | ||||
|  | ||||
| @@ -68,7 +68,7 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|         public override SubPacket createScriptBindPacket(uint playerActorId) | ||||
|         { | ||||
|             List<LuaParam> lParams; | ||||
|             lParams = LuaUtils.createLuaParamList("/Area/Zone/ZoneMasterPrvI0", false, true, zoneName, "", 0xFFFFFFFF, false, false, canStealth, isInn, false, false, false, false, false, false); | ||||
|             lParams = LuaUtils.createLuaParamList("/Area/Zone/ZoneMasterPrvI0", false, true, zoneName, "", -1, canRideChocobo ? (byte)1 : (byte)0, canStealth, isInn, false, false, false, false, false, false); | ||||
|             return ActorInstantiatePacket.buildPacket(actorId, playerActorId, actorName, className, lParams); | ||||
|         } | ||||
|  | ||||
| @@ -82,6 +82,7 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|             subpackets.Add(createStatePacket(playerActorId)); | ||||
|             subpackets.Add(createIsZoneingPacket(playerActorId)); | ||||
|             subpackets.Add(createScriptBindPacket(playerActorId)); | ||||
|             subpackets[6].debugPrintSubPacket(); | ||||
|             return BasePacket.createPacket(subpackets, true, false); | ||||
|         } | ||||
|  | ||||
| @@ -291,19 +292,16 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|  | ||||
|         public void broadcastPacketAroundActor(Actor actor, SubPacket packet) | ||||
|         { | ||||
|             if (zone != null) | ||||
|             List<Actor> aroundActor = getActorsAroundActor(actor, 50); | ||||
|             foreach (Actor a in aroundActor) | ||||
|             { | ||||
|                 List<Actor> aroundActor = getActorsAroundActor(actor, 50); | ||||
|                 foreach (Actor a in aroundActor) | ||||
|                 if (a is Player) | ||||
|                 { | ||||
|                     if (a is Player) | ||||
|                     { | ||||
|                         SubPacket clonedPacket = new SubPacket(packet, actor.actorId); | ||||
|                         Player p = (Player)a;                         | ||||
|                         p.queuePacket(clonedPacket); | ||||
|                     } | ||||
|                     SubPacket clonedPacket = new SubPacket(packet, actor.actorId); | ||||
|                     Player p = (Player)a;                         | ||||
|                     p.queuePacket(clonedPacket); | ||||
|                 } | ||||
|             } | ||||
|             }             | ||||
|         } | ||||
|  | ||||
|     } | ||||
|   | ||||
| @@ -48,18 +48,25 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|         public uint[] timers = new uint[20]; | ||||
|  | ||||
|         public ushort currentJob; | ||||
|  | ||||
|         public uint currentTitle; | ||||
|  | ||||
|         //GC Related | ||||
|         public byte gcCurrent; | ||||
|         public byte gcRankLimsa; | ||||
|         public byte gcRankGridania; | ||||
|         public byte gcRankUldah; | ||||
|  | ||||
|         //Mount Related | ||||
|         public bool hasChocobo; | ||||
|         public bool hasGoobbue; | ||||
|         public byte chocoboAppearance; | ||||
|         public string chocoboName; | ||||
|         public byte mountState = 0; | ||||
|  | ||||
|         //Event Related | ||||
|         public uint eventCurrentOwner = 0; | ||||
|         public string eventCurrentStarter = ""; | ||||
|         public uint eventMenuId = 0; | ||||
|  | ||||
|         public uint achievementPoints; | ||||
|  | ||||
| @@ -598,7 +605,25 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|         { | ||||
|             playerSession.queuePacket(packet, true, false); | ||||
|         } | ||||
|          | ||||
|  | ||||
|         public void broadcastPacket(SubPacket packet) | ||||
|         { | ||||
|             foreach (Actor a in playerSession.actorInstanceList) | ||||
|             { | ||||
|                 if (a is Player) | ||||
|                 { | ||||
|                     Player p = (Player)a; | ||||
|                     SubPacket clonedPacket = new SubPacket(packet, a.actorId); | ||||
|                     p.queuePacket(clonedPacket); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public Zone getZone() | ||||
|         { | ||||
|             return zone; | ||||
|         } | ||||
|  | ||||
|         public void sendMessage(uint logType, string sender, string message) | ||||
|         { | ||||
|             queuePacket(SendMessagePacket.buildPacket(actorId, actorId, logType, sender, message)); | ||||
| @@ -628,10 +653,54 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|         { | ||||
|             queuePacket(SetCurrentMountGoobbuePacket.buildPacket(actorId, 1)); | ||||
|         } | ||||
|          | ||||
|         public void sendWorldMessage(ushort worldMasterId, params object[] msgParams) | ||||
|  | ||||
|         public void setMountState(byte mountState) | ||||
|         { | ||||
|             //queuePacket(WorldMasterPacket.buildPacket()); | ||||
|             this.mountState = mountState; | ||||
|         } | ||||
|  | ||||
|         public byte getMountState() | ||||
|         { | ||||
|             return mountState; | ||||
|         } | ||||
|  | ||||
|         public void doEmote(uint emoteId) | ||||
|         {             | ||||
|             broadcastPacket(ActorDoEmotePacket.buildPacket(actorId, actorId, emoteId)); | ||||
|         } | ||||
|  | ||||
|         public void sendGameMessage(Actor sourceActor, Actor textIdOwner, ushort textId, byte log, params object[] msgParams) | ||||
|         { | ||||
|             if (msgParams.Length == 0) | ||||
|             { | ||||
|                 queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); | ||||
|             } | ||||
|             else | ||||
|                 queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); | ||||
|         } | ||||
|  | ||||
|         public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams) | ||||
|         { | ||||
|             if (msgParams.Length == 0) | ||||
|                 queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); | ||||
|             else | ||||
|                 queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); | ||||
|         } | ||||
|  | ||||
|         public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams) | ||||
|         { | ||||
|             if (msgParams.Length == 0) | ||||
|                 queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); | ||||
|             else | ||||
|                 queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); | ||||
|         } | ||||
|  | ||||
|         public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams) | ||||
|         { | ||||
|             if (msgParams.Length == 0) | ||||
|                 queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); | ||||
|             else | ||||
|                 queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); | ||||
|         } | ||||
|  | ||||
|         public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams) | ||||
| @@ -643,16 +712,29 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|         public void runEventFunction(string functionName, params object[] parameters) | ||||
|         { | ||||
|             List<LuaParam> lParams = LuaUtils.createLuaParamList(parameters); | ||||
|             SubPacket spacket = RunEventFunctionPacket.buildPacket(actorId, playerSession.eventCurrentOwner, playerSession.eventCurrentStarter, functionName, lParams); | ||||
|             SubPacket spacket = RunEventFunctionPacket.buildPacket(actorId, eventCurrentOwner, eventCurrentStarter, functionName, lParams); | ||||
|             spacket.debugPrintSubPacket(); | ||||
|             queuePacket(spacket); | ||||
|         } | ||||
|  | ||||
|         public void endEvent() | ||||
|         { | ||||
|             SubPacket p = EndEventPacket.buildPacket(actorId, playerSession.eventCurrentOwner, playerSession.eventCurrentStarter); | ||||
|             p.debugPrintSubPacket(); | ||||
|             SubPacket p = EndEventPacket.buildPacket(actorId, eventCurrentOwner, eventCurrentStarter); | ||||
|             queuePacket(p); | ||||
|  | ||||
|             eventCurrentOwner = 0; | ||||
|             eventCurrentStarter = ""; | ||||
|             eventMenuId = 0; | ||||
|         } | ||||
|  | ||||
|         public void setCurrentMenuId(uint id) | ||||
|         { | ||||
|             eventMenuId = id; | ||||
|         } | ||||
|  | ||||
|         public uint getCurrentMenuId() | ||||
|         { | ||||
|             return eventMenuId; | ||||
|         } | ||||
|  | ||||
|     } | ||||
|   | ||||
| @@ -15,10 +15,7 @@ namespace FFXIVClassic_Map_Server.dataobjects | ||||
|         public uint actorID = 0; | ||||
|         Player playerActor; | ||||
|         public List<Actor> actorInstanceList = new List<Actor>(); | ||||
|  | ||||
|         public uint eventCurrentOwner = 0; | ||||
|         public string eventCurrentStarter = ""; | ||||
|  | ||||
|          | ||||
|         private ClientConnection zoneConnection; | ||||
|         private ClientConnection chatConnection; | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ using FFXIVClassic_Map_Server.packets.send; | ||||
| using FFXIVClassic_Map_Server.packets.send.events; | ||||
| using MoonSharp.Interpreter; | ||||
| using MoonSharp.Interpreter.Interop; | ||||
| using MoonSharp.Interpreter.Loaders; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| @@ -36,7 +37,9 @@ namespace FFXIVClassic_Map_Server.lua | ||||
|                 if (File.Exists(luaPath)) | ||||
|                 { | ||||
|                     Script script = new Script(); | ||||
|                     ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; | ||||
|                     script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors; | ||||
|                     script.Globals["getWorldMaster"] = (Func<Actor>)Server.getServer().GetWorldManager().GetActor; | ||||
|                     script.DoFile(luaPath); | ||||
|                     DynValue result = script.Call(script.Globals["onInstantiate"], target); | ||||
|                     List<LuaParam> lparams = LuaUtils.createLuaParamList(result); | ||||
| @@ -45,7 +48,7 @@ namespace FFXIVClassic_Map_Server.lua | ||||
|                 else | ||||
|                 { | ||||
|                     List<SubPacket> sendError = new List<SubPacket>(); | ||||
|                     sendError.Add(EndEventPacket.buildPacket(player.actorId, player.playerSession.eventCurrentOwner, player.playerSession.eventCurrentStarter)); | ||||
|                     sendError.Add(EndEventPacket.buildPacket(player.actorId, player.eventCurrentOwner, player.eventCurrentStarter)); | ||||
|                     player.sendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", String.Format("ERROR: Could not find script for actor {0}.", target.getName())); | ||||
|                     player.playerSession.queuePacket(BasePacket.createPacket(sendError, true, false)); | ||||
|                     return null; | ||||
| @@ -55,106 +58,78 @@ namespace FFXIVClassic_Map_Server.lua | ||||
|             return null; | ||||
|         }        | ||||
|  | ||||
|         public void doActorOnEventStarted(Player player, Actor target) | ||||
|         public void doActorOnEventStarted(Player player, Actor target, EventStartPacket eventStart) | ||||
|         { | ||||
|             string luaPath; | ||||
|  | ||||
|             if (target is Command) | ||||
|             { | ||||
|                 luaPath = String.Format(FILEPATH_COMMANDS, target.getName()); | ||||
|                 if (File.Exists(luaPath)) | ||||
|                 { | ||||
|                     Script script = new Script(); | ||||
|                     script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors; | ||||
|                     script.DoFile(luaPath); | ||||
|                     DynValue result = script.Call(script.Globals["onEventStarted"], player, target); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     List<SubPacket> sendError = new List<SubPacket>(); | ||||
|                     sendError.Add(EndEventPacket.buildPacket(player.actorId, player.playerSession.eventCurrentOwner, player.playerSession.eventCurrentStarter)); | ||||
|                     player.sendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", String.Format("ERROR: Could not find script for actor {0}.", target.getName())); | ||||
|                     player.playerSession.queuePacket(BasePacket.createPacket(sendError, true, false)); | ||||
|                 } | ||||
|             } | ||||
|             else if (target is Npc) | ||||
|             { | ||||
|             else  | ||||
|                 luaPath = String.Format(FILEPATH_NPCS, target.zoneId, target.getName()); | ||||
|                 if (File.Exists(luaPath)) | ||||
|                 { | ||||
|                     Script script = new Script(); | ||||
|                     script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors; | ||||
|                     script.DoFile(luaPath); | ||||
|                     DynValue result = script.Call(script.Globals["onEventStarted"], player, target); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     List<SubPacket> sendError = new List<SubPacket>(); | ||||
|                     sendError.Add(EndEventPacket.buildPacket(player.actorId, player.playerSession.eventCurrentOwner, player.playerSession.eventCurrentStarter)); | ||||
|                     player.sendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", String.Format("ERROR: Could not find script for actor {0}.", target.getName())); | ||||
|                     player.playerSession.queuePacket(BasePacket.createPacket(sendError, true, false)); | ||||
|                 } | ||||
|  | ||||
|             if (File.Exists(luaPath)) | ||||
|             { | ||||
|                 Script script = new Script(); | ||||
|                 ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; | ||||
|                 script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors; | ||||
|                 script.Globals["getWorldMaster"] = (Func<Actor>)Server.getServer().GetWorldManager().GetActor; | ||||
|                 script.DoFile(luaPath); | ||||
|  | ||||
|                 //Have to do this to combine LuaParams | ||||
|                 List<Object> objects = new List<Object>(); | ||||
|                 objects.Add(player); | ||||
|                 objects.Add(target); | ||||
|                 objects.AddRange(LuaUtils.createLuaParamObjectList(eventStart.luaParams)); | ||||
|  | ||||
|                 //Run Script | ||||
|                 DynValue result = script.Call(script.Globals["onEventStarted"], objects.ToArray()); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 List<SubPacket> sendError = new List<SubPacket>(); | ||||
|                 sendError.Add(EndEventPacket.buildPacket(player.actorId, player.eventCurrentOwner, player.eventCurrentStarter)); | ||||
|                 player.sendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", String.Format("ERROR: Could not find script for actor {0}.", target.getName())); | ||||
|                 player.playerSession.queuePacket(BasePacket.createPacket(sendError, true, false)); | ||||
|             } | ||||
|             | ||||
|         } | ||||
|  | ||||
|         public void doActorOnEventUpdated(Player player, Actor target, EventUpdatePacket eventUpdate) | ||||
|         { | ||||
|             string luaPath; | ||||
|  | ||||
|             if (target is Command) | ||||
|             { | ||||
|             if (target is Command)             | ||||
|                 luaPath = String.Format(FILEPATH_COMMANDS, target.getName()); | ||||
|                 if (File.Exists(luaPath)) | ||||
|                 { | ||||
|                     Script script = new Script(); | ||||
|                     script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors; | ||||
|                     script.DoFile(luaPath); | ||||
|             else | ||||
|                  luaPath = String.Format(FILEPATH_NPCS, target.zoneId, target.getName()); | ||||
|  | ||||
|                     //Have to do this to combine LuaParams | ||||
|                     List<Object> objects = new List<Object>(); | ||||
|                     objects.Add(player); | ||||
|                     objects.Add(target); | ||||
|                     objects.Add(eventUpdate.step); | ||||
|                     objects.AddRange(LuaUtils.createLuaParamObjectList(eventUpdate.luaParams)); | ||||
|  | ||||
|                     //Run Script | ||||
|                     DynValue result = script.Call(script.Globals["onEventUpdate"], objects.ToArray()); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     List<SubPacket> sendError = new List<SubPacket>(); | ||||
|                     sendError.Add(EndEventPacket.buildPacket(player.actorId, player.playerSession.eventCurrentOwner, player.playerSession.eventCurrentStarter)); | ||||
|                     player.sendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", String.Format("ERROR: Could not find script for actor {0}.", target.getName())); | ||||
|                     player.playerSession.queuePacket(BasePacket.createPacket(sendError, true, false)); | ||||
|                 }        | ||||
|             } | ||||
|             else if (target is Npc) | ||||
|             if (File.Exists(luaPath)) | ||||
|             { | ||||
|                 luaPath = String.Format(FILEPATH_NPCS, target.zoneId, target.getName()); | ||||
|                 if (File.Exists(luaPath)) | ||||
|                 { | ||||
|                     Script script = new Script(); | ||||
|                     script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors; | ||||
|                     script.DoFile(luaPath); | ||||
|                 Script script = new Script(); | ||||
|                 ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; | ||||
|                 script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors; | ||||
|                 script.Globals["getWorldMaster"] = (Func<Actor>)Server.getServer().GetWorldManager().GetActor; | ||||
|                 script.DoFile(luaPath); | ||||
|  | ||||
|                     //Have to do this to combine LuaParams | ||||
|                     List<Object> objects = new List<Object>(); | ||||
|                     objects.Add(player); | ||||
|                     objects.Add(target); | ||||
|                     objects.Add(eventUpdate.step); | ||||
|                     objects.AddRange(LuaUtils.createLuaParamObjectList(eventUpdate.luaParams)); | ||||
|                 //Have to do this to combine LuaParams | ||||
|                 List<Object> objects = new List<Object>(); | ||||
|                 objects.Add(player); | ||||
|                 objects.Add(target); | ||||
|                 objects.Add(eventUpdate.step); | ||||
|                 objects.AddRange(LuaUtils.createLuaParamObjectList(eventUpdate.luaParams)); | ||||
|  | ||||
|                     //Run Script | ||||
|                     DynValue result = script.Call(script.Globals["onEventUpdate"], objects.ToArray()); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     List<SubPacket> sendError = new List<SubPacket>(); | ||||
|                     sendError.Add(EndEventPacket.buildPacket(player.actorId, player.playerSession.eventCurrentOwner, player.playerSession.eventCurrentStarter)); | ||||
|                     player.sendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", String.Format("ERROR: Could not find script for actor {0}.", target.getName())); | ||||
|                     player.playerSession.queuePacket(BasePacket.createPacket(sendError, true, false)); | ||||
|                 } | ||||
|                 //Run Script | ||||
|                 DynValue result = script.Call(script.Globals["onEventUpdate"], objects.ToArray()); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 List<SubPacket> sendError = new List<SubPacket>(); | ||||
|                 sendError.Add(EndEventPacket.buildPacket(player.actorId, player.eventCurrentOwner, player.eventCurrentStarter)); | ||||
|                 player.sendMessage(SendMessagePacket.MESSAGE_TYPE_SYSTEM_ERROR, "", String.Format("ERROR: Could not find script for actor {0}.", target.getName())); | ||||
|                 player.playerSession.queuePacket(BasePacket.createPacket(sendError, true, false)); | ||||
|             }                   | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -55,8 +55,8 @@ namespace FFXIVClassic_Map_Server | ||||
|                         break; | ||||
|                     case 0x6: //Actor (By Id) | ||||
|                         value = Utils.swapEndian(reader.ReadUInt32()); | ||||
|                         break; | ||||
|                     case 0x10: //Byte? | ||||
|                         break;                        | ||||
|                     case 0xC: //Byte | ||||
|                         value = reader.ReadByte(); | ||||
|                         break; | ||||
|                     case 0x1B: //Short? | ||||
| @@ -106,7 +106,8 @@ namespace FFXIVClassic_Map_Server | ||||
|                     case 0x6: //Actor (By Id) | ||||
|                         writer.Write((UInt32)Utils.swapEndian((UInt32)l.value)); | ||||
|                         break; | ||||
|                     case 0x10: //Byte?                         | ||||
|                     case 0xC: //Byte | ||||
|                         writer.Write((Byte)l.value); | ||||
|                         break; | ||||
|                     case 0x1B: //Short?                         | ||||
|                         break; | ||||
| @@ -164,7 +165,7 @@ namespace FFXIVClassic_Map_Server | ||||
|                             case 0x6: //Actor (By Id) | ||||
|                                 value = Utils.swapEndian(reader.ReadUInt32()); | ||||
|                                 break; | ||||
|                             case 0x10: //Byte? | ||||
|                             case 0xC: //Byte | ||||
|                                 value = reader.ReadByte(); | ||||
|                                 break; | ||||
|                             case 0x1B: //Short? | ||||
| @@ -268,7 +269,7 @@ namespace FFXIVClassic_Map_Server | ||||
|             else if (o is double) | ||||
|             { | ||||
|                 if (((double)o) % 1 == 0) | ||||
|                     luaParams.Add(new LuaParam(0x0, (uint)(double)o)); | ||||
|                     luaParams.Add(new LuaParam(0x0, (int)(double)o)); | ||||
|             } | ||||
|             else if (o is string) | ||||
|             { | ||||
| @@ -289,6 +290,10 @@ namespace FFXIVClassic_Map_Server | ||||
|             { | ||||
|                 luaParams.Add(new LuaParam(0x6, ((Actor)o).actorId)); | ||||
|             } | ||||
|             else if (o is byte) | ||||
|             { | ||||
|                 luaParams.Add(new LuaParam(0xC, (byte)o)); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public static object[] createLuaParamObjectList(List <LuaParam> luaParams) | ||||
| @@ -333,7 +338,7 @@ namespace FFXIVClassic_Map_Server | ||||
|                     case 0x6: //Actor (By Id) | ||||
|                         dumpString += String.Format("0x{0:X}", (uint)lParams[i].value); | ||||
|                         break; | ||||
|                     case 0x10: //Byte? | ||||
|                     case 0xC: //Byte | ||||
|                         dumpString += String.Format("0x{0:X}", (byte)lParams[i].value); | ||||
|                         break; | ||||
|                     case 0x1B: //Short? | ||||
|   | ||||
| @@ -0,0 +1,30 @@ | ||||
| using FFXIVClassic_Lobby_Server.packets; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
|  | ||||
| namespace FFXIVClassic_Map_Server.packets.send.actor | ||||
| { | ||||
|     class BattleAction1Packet | ||||
|     { | ||||
|         public const ushort OPCODE = 0x0139; | ||||
|         public const uint PACKET_SIZE = 0x58; | ||||
|  | ||||
|         public static SubPacket buildPacket(uint sourceId, uint targetId) | ||||
|         { | ||||
|             byte[] data = new byte[PACKET_SIZE - 0x20]; | ||||
|  | ||||
|             using (MemoryStream mem = new MemoryStream(data)) | ||||
|             { | ||||
|                 using (BinaryWriter binWriter = new BinaryWriter(mem)) | ||||
|                 {                     | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return new SubPacket(OPCODE, sourceId, targetId, data); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -60,14 +60,13 @@ namespace FFXIVClassic_Map_Server.packets.send.actor | ||||
|                     binWriter.Write((Single)walkSpeed); | ||||
|                     binWriter.Write((UInt32)1); | ||||
|  | ||||
|                     binWriter.Write((UInt16)00); | ||||
|                     binWriter.Write((Single)runSpeed); | ||||
|                     binWriter.Write((UInt32)2); | ||||
|                      | ||||
|                     binWriter.Write((Single)runSpeed); | ||||
|                     binWriter.Write((UInt32)3); | ||||
|  | ||||
|                     binWriter.BaseStream.Seek(0x90, SeekOrigin.Begin); | ||||
|                     binWriter.BaseStream.Seek(0x80, SeekOrigin.Begin); | ||||
|  | ||||
|                     binWriter.Write((UInt32)5); | ||||
|                 } | ||||
|   | ||||
| @@ -11,53 +11,53 @@ namespace FFXIVClassic_Map_Server.packets.send | ||||
| { | ||||
|     class GameMessagePacket | ||||
|     {         | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR1 = 0x157; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR2 = 0x158; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR3 = 0x159; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR4 = 0x15a; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR5 = 0x15b; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR1 = 0x157; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR2 = 0x158; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR3 = 0x159; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR4 = 0x15a; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR5 = 0x15b; | ||||
|  | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 = 0x15c; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 = 0x15d; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 = 0x15e; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 = 0x15f; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 = 0x160; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 = 0x15c; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 = 0x15d; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 = 0x15e; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 = 0x15f; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 = 0x160; | ||||
|  | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER1 = 0x161; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER2 = 0x162; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER3 = 0x163; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER4 = 0x164; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER5 = 0x165; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER1 = 0x161; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER2 = 0x162; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER3 = 0x163; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER4 = 0x164; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER5 = 0x165; | ||||
|  | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR1 = 0x166; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR2 = 0x167; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR3 = 0x168; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR4 = 0x169; | ||||
|         public const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR5 = 0x16a; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR1 = 0x166; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR2 = 0x167; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR3 = 0x168; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR4 = 0x169; | ||||
|         private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR5 = 0x16a; | ||||
|  | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_ACTOR1 = 0x30; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_ACTOR2 = 0x38; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_ACTOR3 = 0x40; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_ACTOR4 = 0x50; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_ACTOR5 = 0x70; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR1 = 0x30; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR2 = 0x38; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR3 = 0x40; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR4 = 0x50; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR5 = 0x70; | ||||
|  | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 = 0x48; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 = 0x58; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 = 0x68; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 = 0x78; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 = 0x98; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 = 0x48; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 = 0x58; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 = 0x68; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 = 0x78; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 = 0x98; | ||||
|  | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER1 = 0x30; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER2 = 0x38; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER3 = 0x40; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER4 = 0x50; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER5 = 0x60; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER1 = 0x30; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER2 = 0x38; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER3 = 0x40; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER4 = 0x50; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER5 = 0x60; | ||||
|  | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR1 = 0x28; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR2 = 0x38; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR3 = 0x38; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR4 = 0x48; | ||||
|         public const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR5 = 0x68; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR1 = 0x28; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR2 = 0x38; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR3 = 0x38; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR4 = 0x48; | ||||
|         private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR5 = 0x68; | ||||
|  | ||||
|         public static SubPacket buildPacket(uint sourceId, uint targetId, uint actorId, uint textOwnerActorId, ushort textId, byte log) | ||||
|         { | ||||
| @@ -310,9 +310,9 @@ namespace FFXIVClassic_Map_Server.packets.send | ||||
|                     binWriter.Write((UInt16)log); | ||||
|                     LuaUtils.writeLuaParams(binWriter, lParams); | ||||
|  | ||||
|                     if (lParamsSize <= 0x14 - 12) | ||||
|                     if (lParamsSize <= 0x8) | ||||
|                     { | ||||
|                         binWriter.Seek(0x30, SeekOrigin.Begin); | ||||
|                         binWriter.Seek(0x10, SeekOrigin.Begin); | ||||
|                         binWriter.Write((UInt32)8); | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -39,7 +39,7 @@ namespace FFXIVClassic_Map_Server.packets.send.events | ||||
|                         switch (p.typeID) | ||||
|                         { | ||||
|                             case 0x0: //Int32 | ||||
|                                 binWriter.Write(Utils.swapEndian((UInt32)p.value)); | ||||
|                                 binWriter.Write(Utils.swapEndian((Int32)p.value)); | ||||
|                                 break; | ||||
|                             case 0x1: //Int32 | ||||
|                                 binWriter.Write(Utils.swapEndian((UInt32)p.value)); | ||||
| @@ -59,8 +59,8 @@ namespace FFXIVClassic_Map_Server.packets.send.events | ||||
|                             case 0x6: //Actor (By Id) | ||||
|                                 binWriter.Write(Utils.swapEndian((UInt32)p.value));                                 | ||||
|                                 break; | ||||
|                             case 0x10: //Byte? | ||||
|                                 //value = reader.ReadByte(); | ||||
|                             case 0xC: //Byte | ||||
|                                 binWriter.Write((Byte)p.value);                 | ||||
|                                 break; | ||||
|                             case 0x1B: //Short? | ||||
|                                 //value = reader.ReadUInt16(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user