diff --git a/Data/scripts/commands/gm/nudge.lua b/Data/scripts/commands/gm/nudge.lua index 65b79140..bb3ceb50 100644 --- a/Data/scripts/commands/gm/nudge.lua +++ b/Data/scripts/commands/gm/nudge.lua @@ -26,11 +26,11 @@ vertical = { function onTrigger(player, argc, arg1, arg2) local pos = player:GetPos(); - local x = pos[0]; - local y = pos[1]; - local z = pos[2]; - local rot = pos[3]; - local zone = pos[4]; + local x = pos[1]; + local y = pos[2]; + local z = pos[3]; + local rot = pos[4]; + local zone = pos[5]; local angle = rot + (math.pi/2); local worldManager = GetWorldManager(); diff --git a/Data/scripts/commands/gm/testmapobj.lua b/Data/scripts/commands/gm/testmapobj.lua index 6682b589..cdc74c3d 100644 --- a/Data/scripts/commands/gm/testmapobj.lua +++ b/Data/scripts/commands/gm/testmapobj.lua @@ -23,16 +23,18 @@ function onTrigger(player, argc, animation, regionId, layoutId, maxLayoutId) end local pos = player:GetPos(); - local x = pos[0]; - local y = pos[1]; - local z = pos[2]; - local zone = pos[4]; + local x = pos[1]; + local y = pos[2]; + local z = pos[3]; + local zone = pos[5]; actorClassId = tonumber(actorClassId); if (actorClassId ~= nil) then zone = player:GetZone(); - actor = zone:SpawnActor(actorClassId, "mapobj", pos[0], pos[1], pos[2], tonumber(regionId), tonumber(layoutId)); + actor = zone:SpawnActor(actorClassId, "mapobj", pos[1], pos[2], pos[3], tonumber(regionId), tonumber(layoutId)); + + print("test"); wait(0.8); actor:PlayMapObjAnimation(player, animation); zone:DespawnActor("mapobj"); diff --git a/Map Server/Lua/LuaEngine.cs b/Map Server/Lua/LuaEngine.cs index 3fb68cc6..28f05812 100644 --- a/Map Server/Lua/LuaEngine.cs +++ b/Map Server/Lua/LuaEngine.cs @@ -38,6 +38,7 @@ using System.Threading; using Meteor.Map.actors.chara.ai; using Meteor.Map.actors.chara.ai.controllers; using Meteor.Map.DataObjects; +using Meteor.Map.actors.chara.player; namespace Meteor.Map.lua { @@ -64,17 +65,23 @@ namespace Meteor.Map.lua luaTimer = new Timer(new TimerCallback(PulseSleepingOnTime), null, TimeSpan.Zero, TimeSpan.FromMilliseconds(50)); + UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic; + + /* UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); + */ } public static LuaEngine GetInstance() @@ -425,18 +432,20 @@ namespace Meteor.Map.lua Area area = target.zone; if (area is PrivateArea) { - if (File.Exists(String.Format($"{ConfigConstants.OPTIONS_SCRIPTPATH}/unique/{0}/privatearea/{1}_{2}/{3}/{4}.lua", area.zoneName, ((PrivateArea)area).GetPrivateAreaName(), ((PrivateArea)area).GetPrivateAreaType(), target.className, target.GetUniqueId()))) - child = LuaEngine.LoadScript(String.Format($"{ConfigConstants.OPTIONS_SCRIPTPATH}/unique/{0}/privatearea/{1}_{2}/{3}/{4}.lua", area.zoneName, ((PrivateArea)area).GetPrivateAreaName(), ((PrivateArea)area).GetPrivateAreaType(), target.className, target.GetUniqueId()), ref errorMsg); + string path = $"{ConfigConstants.OPTIONS_SCRIPTPATH}/unique/{area.zoneName}/privatearea/{((PrivateArea)area).GetPrivateAreaName()}_{((PrivateArea)area).GetPrivateAreaType()}/{target.className}/{target.GetUniqueId()}.lua"; + if (File.Exists(path)) + child = LuaEngine.LoadScript(path, ref errorMsg); } else { - if (File.Exists(String.Format($"{ConfigConstants.OPTIONS_SCRIPTPATH}/unique/{0}/{1}/{2}.lua", area.zoneName, target.className, target.GetUniqueId()))) - child = LuaEngine.LoadScript(String.Format($"{ConfigConstants.OPTIONS_SCRIPTPATH}/unique/{0}/{1}/{2}.lua", area.zoneName, target.className, target.GetUniqueId()), ref errorMsg); + string path = $"{ConfigConstants.OPTIONS_SCRIPTPATH}/unique/{area.zoneName}/{target.className}/{target.GetUniqueId()}.lua"; + if (File.Exists(path)) + child = LuaEngine.LoadScript(path, ref errorMsg); } if (parent == null && child == null) { - LuaEngine.SendError(player, String.Format("ERROR: Could not find script for actor {0}.", target.GetName())); + LuaEngine.SendError(player, $"ERROR: Could not find script for actor {target.GetName()}."); } //Run Script diff --git a/Map Server/Packets/Send/Actor/Events/SetEmoteEventCondition.cs b/Map Server/Packets/Send/Actor/Events/SetEmoteEventCondition.cs index e7b6ec73..f12b915f 100644 --- a/Map Server/Packets/Send/Actor/Events/SetEmoteEventCondition.cs +++ b/Map Server/Packets/Send/Actor/Events/SetEmoteEventCondition.cs @@ -40,9 +40,10 @@ namespace Meteor.Map.packets.send.actor.events { using (BinaryWriter binWriter = new BinaryWriter(mem)) { - binWriter.Write((Byte)condition.unknown1); //4 - binWriter.Write((UInt16)condition.emoteId); //82, 76, 6E - binWriter.Write(Encoding.ASCII.GetBytes(condition.conditionName), 0, Encoding.ASCII.GetByteCount(condition.conditionName) >= 0x24 ? 0x24 : Encoding.ASCII.GetByteCount(condition.conditionName)); + binWriter.Write((Byte)4); //Id type? Priority + binWriter.Write((Byte)condition.unknown2); + binWriter.Write((UInt16)condition.emoteId); //82, 76, 6E are emotes used in captures + binWriter.Write(Encoding.ASCII.GetBytes(condition.conditionName), 0, Encoding.ASCII.GetByteCount(condition.conditionName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(condition.conditionName)); } } diff --git a/Map Server/Packets/Send/Actor/Events/SetNoticeEventCondition.cs b/Map Server/Packets/Send/Actor/Events/SetNoticeEventCondition.cs index ba95d618..83cbfa98 100644 --- a/Map Server/Packets/Send/Actor/Events/SetNoticeEventCondition.cs +++ b/Map Server/Packets/Send/Actor/Events/SetNoticeEventCondition.cs @@ -43,7 +43,7 @@ namespace Meteor.Map.packets.send.actor.events { binWriter.Write((Byte)condition.unknown1); //Seen: 0, 1, E binWriter.Write((Byte)condition.unknown2); //Seen: 0, 1 - binWriter.Write(Encoding.ASCII.GetBytes(condition.conditionName), 0, Encoding.ASCII.GetByteCount(condition.conditionName) >= 0x24 ? 0x24 : Encoding.ASCII.GetByteCount(condition.conditionName)); + binWriter.Write(Encoding.ASCII.GetBytes(condition.conditionName), 0, Encoding.ASCII.GetByteCount(condition.conditionName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(condition.conditionName)); } } diff --git a/Map Server/Server.cs b/Map Server/Server.cs index aa97403e..6feba4fd 100644 --- a/Map Server/Server.cs +++ b/Map Server/Server.cs @@ -69,7 +69,6 @@ namespace Meteor.Map mWorldManager = new WorldManager(this); mWorldManager.LoadZoneList(); - mWorldManager.LoadZoneEntranceList(); mWorldManager.LoadSeamlessBoundryList(); mWorldManager.LoadActorClasses(); mWorldManager.LoadSpawnLocations(); diff --git a/Map Server/WorldManager.cs b/Map Server/WorldManager.cs index afb66c3c..2a03fede 100644 --- a/Map Server/WorldManager.cs +++ b/Map Server/WorldManager.cs @@ -49,7 +49,6 @@ namespace Meteor.Map private WorldMaster worldMaster = new WorldMaster(); private Dictionary zoneList; private Dictionary> seamlessBoundryList; - private Dictionary zoneEntranceList; private Dictionary actorClasses = new Dictionary(); private Dictionary currentPlayerParties = new Dictionary(); //GroupId, Party object private Dictionary statusEffectList = new Dictionary(); @@ -184,57 +183,6 @@ namespace Meteor.Map Program.Log.Info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2)); } - public void LoadZoneEntranceList() - { - zoneEntranceList = new Dictionary(); - int count = 0; - using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD))) - { - try - { - conn.Open(); - - string query = @" - SELECT - id, - zoneId, - spawnType, - spawnX, - spawnY, - spawnZ, - spawnRotation, - privateAreaName - FROM server_zones_spawnlocations"; - - MySqlCommand cmd = new MySqlCommand(query, conn); - - using (MySqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - { - uint id = reader.GetUInt32(0); - string privArea = null; - - if (!reader.IsDBNull(7)) - privArea = reader.GetString(7); - - ZoneEntrance entance = new ZoneEntrance(reader.GetUInt32(1), privArea, 1, reader.GetByte(2), reader.GetFloat(3), reader.GetFloat(4), reader.GetFloat(5), reader.GetFloat(6)); - zoneEntranceList[id] = entance; - count++; - } - } - } - catch (MySqlException e) - { Console.WriteLine(e); } - finally - { - conn.Dispose(); - } - } - - Program.Log.Info(String.Format("Loaded {0} zone spawn locations.", count)); - } - public void LoadSeamlessBoundryList() { seamlessBoundryList = new Dictionary>(); @@ -881,26 +829,13 @@ namespace Meteor.Map return xIsGood && yIsGood; } - //Moves actor to new zone, and sends packets to spawn at the given zone entrance - public void DoZoneChange(Player player, uint zoneEntrance) - { - if (!zoneEntranceList.ContainsKey(zoneEntrance)) - { - Program.Log.Error("Given zone entrance was not found: " + zoneEntrance); - return; - } - - ZoneEntrance ze = zoneEntranceList[zoneEntrance]; - DoZoneChange(player, ze.zoneId, ze.privateAreaName, ze.privateAreaType, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation); - } - //Moves actor to new zone, and sends packets to spawn at the given coords. public void DoZoneChange(Player player, uint destinationZoneId, string destinationPrivateArea, int destinationPrivateAreaType, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation) { //Add player to new zone and update Area newArea; - if (destinationPrivateArea == null) + if (destinationPrivateArea == null || destinationPrivateArea.Equals("")) newArea = GetZone(destinationZoneId); else //Add check for -1 if it is a instance newArea = GetZone(destinationZoneId).GetPrivateArea(destinationPrivateArea, (uint)destinationPrivateAreaType); @@ -965,23 +900,6 @@ namespace Meteor.Map LuaEngine.GetInstance().CallLuaFunction(player, newArea, "onZoneIn", true); } - //Moves actor within zone to spawn position - public void DoPlayerMoveInZone(Player player, uint zoneEntrance) - { - if (!zoneEntranceList.ContainsKey(zoneEntrance)) - { - Program.Log.Error("Given zone entrance was not found: " + zoneEntrance); - return; - } - - ZoneEntrance ze = zoneEntranceList[zoneEntrance]; - - if (ze.zoneId != player.zoneId) - return; - - DoPlayerMoveInZone(player, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation, ze.spawnType); - } - //Moves actor within the zone public void DoPlayerMoveInZone(Player player, float spawnX, float spawnY, float spawnZ, float spawnRotation, byte spawnType = 0xF) { @@ -1947,14 +1865,6 @@ namespace Meteor.Map } } - public ZoneEntrance GetZoneEntrance(uint entranceId) - { - if (zoneEntranceList.ContainsKey(entranceId)) - return zoneEntranceList[entranceId]; - else - return null; - } - public ActorClass GetActorClass(uint id) { if (actorClasses.ContainsKey(id))