1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-20 11:47:48 +00:00

Reimplemented dream packets. Fixed instance update bug that was locking up client when waking up. When going to sleep the proper position is saved. Still need to handle if the player logs out in the inn vs sleeping.

This commit is contained in:
Filip Maj 2019-07-27 21:54:05 -04:00
parent e4d43d952b
commit 42f0046ee7
5 changed files with 95 additions and 42 deletions

View file

@ -9,8 +9,10 @@ function onEventStarted(player, npc, triggerName)
choice = callClientFunction(player, "askLogout", player); choice = callClientFunction(player, "askLogout", player);
if (choice == 2) then if (choice == 2) then
player:SetSleeping();
player:QuitGame(); player:QuitGame();
elseif (choice == 3) then elseif (choice == 3) then
player:SetSleeping();
player:Logout(); player:Logout();
elseif (choice == 4) then elseif (choice == 4) then
player:SendMessage(33, "", "Heck the bed"); player:SendMessage(33, "", "Heck the bed");

View file

@ -1,4 +1,4 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team Copyright (C) 2015-2019 Project Meteor Dev Team
@ -71,10 +71,10 @@ namespace Meteor.Map.Actors
public const int TIMER_RETURN = 18; public const int TIMER_RETURN = 18;
public const int TIMER_SKIRMISH = 19; public const int TIMER_SKIRMISH = 19;
public const int NPCLS_GONE = 0; public const int NPCLS_GONE = 0;
public const int NPCLS_INACTIVE = 1; public const int NPCLS_INACTIVE = 1;
public const int NPCLS_ACTIVE = 2; public const int NPCLS_ACTIVE = 2;
public const int NPCLS_ALERT = 3; public const int NPCLS_ALERT = 3;
public const int SLOT_MAINHAND = 0; public const int SLOT_MAINHAND = 0;
public const int SLOT_OFFHAND = 1; public const int SLOT_OFFHAND = 1;
@ -377,6 +377,16 @@ namespace Meteor.Map.Actors
else if (mountState == 2) else if (mountState == 2)
subpackets.Add(SetCurrentMountGoobbuePacket.BuildPacket(actorId, 1)); subpackets.Add(SetCurrentMountGoobbuePacket.BuildPacket(actorId, 1));
//Inn Packets (Dream, Cutscenes, Armoire)
if (zone.isInn)
{
SetCutsceneBookPacket cutsceneBookPacket = new SetCutsceneBookPacket();
for (int i = 0; i < 2048; i++)
cutsceneBookPacket.cutsceneFlags[i] = true;
QueuePacket(cutsceneBookPacket.BuildPacket(actorId, "<Path Companion>", 11, 1, 1));
QueuePacket(SetPlayerDreamPacket.BuildPacket(actorId, 0x16, GetInnCode()));
}
return subpackets; return subpackets;
} }
@ -434,7 +444,7 @@ namespace Meteor.Map.Actors
{ {
propPacketUtil.AddProperty(String.Format("charaWork.command[{0}]", i)); propPacketUtil.AddProperty(String.Format("charaWork.command[{0}]", i));
//Recast Timers //Recast Timers
if(i >= charaWork.commandBorder) if (i >= charaWork.commandBorder)
{ {
propPacketUtil.AddProperty(String.Format("charaWork.parameterTemp.maxCommandRecastTime[{0}]", i - charaWork.commandBorder)); propPacketUtil.AddProperty(String.Format("charaWork.parameterTemp.maxCommandRecastTime[{0}]", i - charaWork.commandBorder));
propPacketUtil.AddProperty(String.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", i - charaWork.commandBorder)); propPacketUtil.AddProperty(String.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", i - charaWork.commandBorder));
@ -577,10 +587,8 @@ namespace Meteor.Map.Actors
QueuePacket(SetWeatherPacket.BuildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR, 1)); QueuePacket(SetWeatherPacket.BuildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR, 1));
QueuePacket(SetMapPacket.BuildPacket(actorId, zone.regionId, zone.actorId)); QueuePacket(SetMapPacket.BuildPacket(actorId, zone.regionId, zone.actorId));
QueuePacket(SetPlayerDreamPacket.BuildPacket(actorId, 0));
QueuePackets(GetSpawnPackets(this, spawnType)); QueuePackets(GetSpawnPackets(this, spawnType));
//GetSpawnPackets(actorId, spawnType).DebugPrintPacket();
#region Inventory & Equipment #region Inventory & Equipment
QueuePacket(InventoryBeginChangePacket.BuildPacket(actorId, true)); QueuePacket(InventoryBeginChangePacket.BuildPacket(actorId, true));
@ -604,14 +612,11 @@ namespace Meteor.Map.Actors
playerSession.QueuePacket(debugSpawn); playerSession.QueuePacket(debugSpawn);
playerSession.QueuePacket(worldMasterSpawn); playerSession.QueuePacket(worldMasterSpawn);
//Inn Packets (Dream, Cutscenes, Armoire)
if (zone.GetWeatherDirector() != null) if (zone.GetWeatherDirector() != null)
{ {
playerSession.QueuePacket(zone.GetWeatherDirector().GetSpawnPackets()); playerSession.QueuePacket(zone.GetWeatherDirector().GetSpawnPackets());
} }
foreach (Director director in ownedDirectors) foreach (Director director in ownedDirectors)
{ {
QueuePackets(director.GetSpawnPackets()); QueuePackets(director.GetSpawnPackets());
@ -623,6 +628,8 @@ namespace Meteor.Map.Actors
if (currentParty != null) if (currentParty != null)
currentParty.SendGroupPackets(playerSession); currentParty.SendGroupPackets(playerSession);
SendInstanceUpdate();
} }
private void SendRemoveInventoryPackets(List<ushort> slots) private void SendRemoveInventoryPackets(List<ushort> slots)
@ -808,6 +815,48 @@ namespace Meteor.Map.Actors
QueuePacket(SendMessagePacket.BuildPacket(actorId, logType, sender, message)); QueuePacket(SendMessagePacket.BuildPacket(actorId, logType, sender, message));
} }
//Only use at logout since it's intensive
private byte GetInnCode()
{
if (zone.isInn)
{
Vector3 position = new Vector3(positionX, 0, positionZ);
if (Utils.Distance(position, new Vector3(0, 0, 0)) <= 20f)
return 3;
else if (Utils.Distance(position, new Vector3(160, 0, 160)) <= 20f)
return 2;
else if (Utils.Distance(position, new Vector3(-160, 0, -160)) <= 20f)
return 1;
}
return 0;
}
public void SetSleeping()
{
playerSession.LockUpdates(true);
switch(GetInnCode())
{
case 1:
positionX = -162.42f;
positionY = 0f;
positionZ = -154.21f;
rotation = 1.56f;
break;
case 2:
positionX = 157.55f;
positionY = 0f;
positionZ = 165.05f;
rotation = 1.53f;
break;
case 3:
positionX = -2.65f;
positionY = 0f;
positionZ = 3.94f;
rotation = 1.52f;
break;
}
}
public void Logout() public void Logout()
{ {
// todo: really this should be in CleanupAndSave but we might want logout/disconnect handled separately for some effects // todo: really this should be in CleanupAndSave but we might want logout/disconnect handled separately for some effects
@ -1810,7 +1859,7 @@ namespace Meteor.Map.Actors
BroadcastPacket(StartCountdownPacket.BuildPacket(actorId, countdownLength, syncTime, "Go!"), true); BroadcastPacket(StartCountdownPacket.BuildPacket(actorId, countdownLength, syncTime, "Go!"), true);
} }
public void SendInstanceUpdate() public void SendInstanceUpdate(bool force = false)
{ {
//Server.GetWorldManager().SeamlessCheck(this); //Server.GetWorldManager().SeamlessCheck(this);
@ -1821,7 +1870,7 @@ namespace Meteor.Map.Actors
aroundMe.AddRange(zone.GetActorsAroundActor(this, 50)); aroundMe.AddRange(zone.GetActorsAroundActor(this, 50));
if (zone2 != null) if (zone2 != null)
aroundMe.AddRange(zone2.GetActorsAroundActor(this, 50)); aroundMe.AddRange(zone2.GetActorsAroundActor(this, 50));
playerSession.UpdateInstance(aroundMe); playerSession.UpdateInstance(aroundMe, force);
} }
public bool IsInParty() public bool IsInParty()

View file

@ -105,9 +105,9 @@ namespace Meteor.Map.dataobjects
playerActor.QueuePositionUpdate(new Vector3(x,y,z)); playerActor.QueuePositionUpdate(new Vector3(x,y,z));
} }
public void UpdateInstance(List<Actor> list) public void UpdateInstance(List<Actor> list, bool force = false)
{ {
if (isUpdatesLocked) if (isUpdatesLocked && !force)
return; return;
List<BasePacket> basePackets = new List<BasePacket>(); List<BasePacket> basePackets = new List<BasePacket>();

View file

@ -30,16 +30,16 @@ namespace Meteor.Map.packets.send.player
public const ushort OPCODE = 0x01A7; public const ushort OPCODE = 0x01A7;
public const uint PACKET_SIZE = 0x28; public const uint PACKET_SIZE = 0x28;
public static SubPacket BuildPacket(uint sourceActorId, uint dreamID) public static SubPacket BuildPacket(uint sourceActorId, byte dreamID, byte innID)
{ {
dreamID = 0x0216;
byte[] data = new byte[PACKET_SIZE - 0x20]; byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data)) using (MemoryStream mem = new MemoryStream(data))
{ {
using (BinaryWriter binWriter = new BinaryWriter(mem)) using (BinaryWriter binWriter = new BinaryWriter(mem))
{ {
binWriter.Write((Int32)0x216); binWriter.Write((Byte)dreamID);
binWriter.Write((Byte)innID);
} }
} }

View file

@ -1047,7 +1047,7 @@ namespace Meteor.Map
player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x10)); player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x10));
player.SendZoneInPackets(this, spawnType); player.SendZoneInPackets(this, spawnType);
player.playerSession.ClearInstance(); player.playerSession.ClearInstance();
player.SendInstanceUpdate(); player.SendInstanceUpdate(true);
player.playerSession.LockUpdates(false); player.playerSession.LockUpdates(false);
@ -1078,7 +1078,6 @@ namespace Meteor.Map
{ {
player.playerSession.QueuePacket(DeleteAllActorsPacket.BuildPacket(player.actorId)); player.playerSession.QueuePacket(DeleteAllActorsPacket.BuildPacket(player.actorId));
player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x2)); player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x2));
//player.SendZoneInPackets(this, spawnType);
} }
player.SendZoneInPackets(this, spawnType); player.SendZoneInPackets(this, spawnType);
@ -1087,6 +1086,9 @@ namespace Meteor.Map
player.destinationSpawnType = 0; player.destinationSpawnType = 0;
Database.SavePlayerPosition(player); Database.SavePlayerPosition(player);
player.playerSession.ClearInstance();
player.SendInstanceUpdate(true);
player.playerSession.LockUpdates(false); player.playerSession.LockUpdates(false);
LuaEngine.GetInstance().CallLuaFunction(player, playerArea, "onZoneIn", true); LuaEngine.GetInstance().CallLuaFunction(player, playerArea, "onZoneIn", true);