mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-20 19:57:46 +00:00
Implemented a intra-zone teleport. Trigger Name is now sent to to the "eventStart" lua callback. Lua scripts can now access world manager.
This commit is contained in:
parent
08fd862939
commit
2048d8d188
11 changed files with 92 additions and 31 deletions
|
@ -178,7 +178,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
case 0x0002:
|
||||
|
||||
client.queuePacket(SendMessagePacket.buildPacket(player.actorID, player.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "-------- Login Message --------\nWelcome to the 1.0 Dev Server"), true, false);
|
||||
mServer.GetWorldManager().DoLogin(player.getActor());
|
||||
Server.GetWorldManager().DoLogin(player.getActor());
|
||||
|
||||
|
||||
break;
|
||||
|
@ -239,23 +239,23 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
*/
|
||||
player.getActor().eventCurrentOwner = eventStart.scriptOwnerActorID;
|
||||
player.getActor().eventCurrentStarter = eventStart.eventStarter;
|
||||
player.getActor().eventCurrentStarter = eventStart.triggerName;
|
||||
|
||||
//Is it a static actor? If not look in the player's instance
|
||||
Actor ownerActor = Server.getStaticActors(player.getActor().eventCurrentOwner);
|
||||
if (ownerActor == null)
|
||||
{
|
||||
ownerActor = mServer.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
|
||||
ownerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
|
||||
if (ownerActor == null)
|
||||
{
|
||||
Log.debug(String.Format("\n===Event START===\nCould not find actor 0x{0:X} for event started by caller: 0x{1:X}\nEvent Starter: {2}\nParams: {3}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.eventStarter, LuaUtils.dumpParams(eventStart.luaParams)));
|
||||
Log.debug(String.Format("\n===Event START===\nCould not find actor 0x{0:X} for event started by caller: 0x{1:X}\nEvent Starter: {2}\nParams: {3}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LuaEngine.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)));
|
||||
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.triggerName, LuaUtils.dumpParams(eventStart.luaParams)));
|
||||
break;
|
||||
//Event Result
|
||||
case 0x012E:
|
||||
|
@ -267,7 +267,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
Actor updateOwnerActor = Server.getStaticActors(player.getActor().eventCurrentOwner);
|
||||
if (updateOwnerActor == null)
|
||||
{
|
||||
updateOwnerActor = mServer.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
|
||||
updateOwnerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
|
||||
if (updateOwnerActor == null)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
private List<ClientConnection> mConnectionList = new List<ClientConnection>();
|
||||
private LuaEngine mLuaEngine = new LuaEngine();
|
||||
|
||||
private WorldManager mWorldManager;
|
||||
private static WorldManager mWorldManager;
|
||||
private static Dictionary<uint, Item> gamedataItems;
|
||||
private static StaticActors mStaticActors;
|
||||
|
||||
|
@ -450,7 +450,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
}
|
||||
|
||||
public WorldManager GetWorldManager()
|
||||
public static WorldManager GetWorldManager()
|
||||
{
|
||||
return mWorldManager;
|
||||
}
|
||||
|
|
|
@ -403,6 +403,46 @@ namespace FFXIVClassic_Map_Server
|
|||
LuaEngine.onZoneIn(player);
|
||||
}
|
||||
|
||||
//Moves actor within zone to spawn position
|
||||
public void DoPlayerMoveInZone(Player player, uint zoneEntrance)
|
||||
{
|
||||
if (!zoneEntranceList.ContainsKey(zoneEntrance))
|
||||
{
|
||||
Log.error("Given zone entrance was not found: " + zoneEntrance);
|
||||
return;
|
||||
}
|
||||
|
||||
ZoneEntrance ze = zoneEntranceList[zoneEntrance];
|
||||
|
||||
if (ze.zoneId != player.zoneId)
|
||||
return;
|
||||
|
||||
DoPlayerMoveInZone(player, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation);
|
||||
}
|
||||
|
||||
//Moves actor within the zone
|
||||
public void DoPlayerMoveInZone(Player player, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation)
|
||||
{
|
||||
//Remove player from currentZone if transfer else it's login
|
||||
if (player.zone != null)
|
||||
{
|
||||
player.zone.removeActorFromZone(player);
|
||||
player.zone.addActorToZone(player);
|
||||
|
||||
//Update player actor's properties;
|
||||
player.positionX = spawnX;
|
||||
player.positionY = spawnY;
|
||||
player.positionZ = spawnZ;
|
||||
player.rotation = spawnRotation;
|
||||
|
||||
//Send packets
|
||||
player.playerSession.queuePacket(_0xE2Packet.buildPacket(player.actorId, 0x0), true, false);
|
||||
player.playerSession.queuePacket(player.createSpawnTeleportPacket(player.actorId, 0x0f), true, false);
|
||||
player.sendInstanceUpdate();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Login Zone In
|
||||
public void DoLogin(Player player)
|
||||
{
|
||||
|
|
|
@ -93,6 +93,22 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
//return SetActorPositionPacket.buildPacket(actorId, playerActorId, -211.895477f, 190.000000f, 29.651011f, 2.674819f, SetActorPositionPacket.SPAWNTYPE_PLAYERWAKE);
|
||||
spawnedFirstTime = true;
|
||||
|
||||
spawnPacket.debugPrintSubPacket();
|
||||
|
||||
return spawnPacket;
|
||||
}
|
||||
|
||||
public SubPacket createSpawnTeleportPacket(uint playerActorId, uint spawnType)
|
||||
{
|
||||
SubPacket spawnPacket;
|
||||
|
||||
spawnPacket = SetActorPositionPacket.buildPacket(actorId, playerActorId, 0xFFFFFFFF, positionX, positionY, positionZ, rotation, spawnType, false);
|
||||
|
||||
//return SetActorPositionPacket.buildPacket(actorId, playerActorId, -211.895477f, 190.000000f, 29.651011f, 2.674819f, SetActorPositionPacket.SPAWNTYPE_PLAYERWAKE);
|
||||
|
||||
spawnPacket.debugPrintSubPacket();
|
||||
|
||||
return spawnPacket;
|
||||
}
|
||||
|
||||
|
@ -176,7 +192,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
if (eventConditions.emoteEventConditions != null)
|
||||
{
|
||||
foreach (EventList.EmoteEventCondition condition in eventConditions.emoteEventConditions)
|
||||
subpackets.Add(SetEventStatus.buildPacket(playerActorId, actorId, 1, 1, condition.conditionName));
|
||||
subpackets.Add(SetEventStatus.buildPacket(playerActorId, actorId, 1, 3, condition.conditionName));
|
||||
}
|
||||
|
||||
if (eventConditions.pushWithCircleEventConditions != null)
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace FFXIVClassic_Map_Server.actors
|
|||
public class TalkEventCondition
|
||||
{
|
||||
public byte unknown1;
|
||||
public byte unknown2;
|
||||
public bool isDisabled = false;
|
||||
public string conditionName;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
{
|
||||
List<LuaParam> lParams;
|
||||
|
||||
Player player = Server.getServer().GetWorldManager().GetPCInWorld(playerActorId);
|
||||
Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
|
||||
lParams = LuaEngine.doActorOnInstantiate(player, this);
|
||||
|
||||
if (lParams == null)
|
||||
|
|
|
@ -704,34 +704,34 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
{
|
||||
if (msgParams.Length == 0)
|
||||
{
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getServer().GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.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)));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.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));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.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)));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.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));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.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)));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.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));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.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)));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
}
|
||||
|
||||
public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams)
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
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.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(luaPath);
|
||||
DynValue result = script.Call(script.Globals["onInstantiate"], target);
|
||||
|
@ -76,8 +76,9 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
{
|
||||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getServer().GetWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(luaPath);
|
||||
|
||||
|
@ -85,6 +86,7 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
List<Object> objects = new List<Object>();
|
||||
objects.Add(player);
|
||||
objects.Add(target);
|
||||
objects.Add(eventStart.triggerName);
|
||||
objects.AddRange(LuaUtils.createLuaParamObjectList(eventStart.luaParams));
|
||||
|
||||
//Run Script
|
||||
|
@ -113,8 +115,9 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
{
|
||||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getServer().GetWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(luaPath);
|
||||
|
||||
|
@ -145,8 +148,9 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
{
|
||||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getServer().GetWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(luaPath);
|
||||
|
||||
|
@ -161,8 +165,9 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
{
|
||||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getServer().GetWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(FILEPATH_PLAYER);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace FFXIVClassic_Map_Server.packets.receive.events
|
|||
public uint errorNum;
|
||||
public string error = null;
|
||||
|
||||
public string eventStarter;
|
||||
public string triggerName;
|
||||
|
||||
public List<LuaParam> luaParams;
|
||||
|
||||
|
@ -62,7 +62,7 @@ namespace FFXIVClassic_Map_Server.packets.receive.events
|
|||
{
|
||||
strList.Add(curByte);
|
||||
}
|
||||
eventStarter = Encoding.ASCII.GetString(strList.ToArray());
|
||||
triggerName = Encoding.ASCII.GetString(strList.ToArray());
|
||||
|
||||
binReader.BaseStream.Seek(0x31, SeekOrigin.Begin);
|
||||
|
||||
|
|
|
@ -22,9 +22,8 @@ namespace FFXIVClassic_Map_Server.packets.send.actor.events
|
|||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((Byte)condition.unknown1);
|
||||
binWriter.Write((Byte)condition.unknown2);
|
||||
binWriter.Write((UInt16)condition.emoteId);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,9 @@ namespace FFXIVClassic_Map_Server.packets.send.actor.events
|
|||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
condition.unknown1 = 4;
|
||||
binWriter.Write((Byte)condition.unknown1);
|
||||
binWriter.Write((Byte)condition.unknown2);
|
||||
binWriter.Write((Byte)(condition.isDisabled ? 0x1 : 0x0));
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(condition.conditionName), 0, Encoding.ASCII.GetByteCount(condition.conditionName) >= 0x24 ? 0x24 : Encoding.ASCII.GetByteCount(condition.conditionName));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue