mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-20 03:37: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:
parent
e4d43d952b
commit
42f0046ee7
5 changed files with 95 additions and 42 deletions
|
@ -9,8 +9,10 @@ function onEventStarted(player, npc, triggerName)
|
|||
choice = callClientFunction(player, "askLogout", player);
|
||||
|
||||
if (choice == 2) then
|
||||
player:SetSleeping();
|
||||
player:QuitGame();
|
||||
elseif (choice == 3) then
|
||||
player:SetSleeping();
|
||||
player:Logout();
|
||||
elseif (choice == 4) then
|
||||
player:SendMessage(33, "", "Heck the bed");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
|
@ -377,6 +377,16 @@ namespace Meteor.Map.Actors
|
|||
else if (mountState == 2)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -577,10 +587,8 @@ namespace Meteor.Map.Actors
|
|||
QueuePacket(SetWeatherPacket.BuildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR, 1));
|
||||
|
||||
QueuePacket(SetMapPacket.BuildPacket(actorId, zone.regionId, zone.actorId));
|
||||
QueuePacket(SetPlayerDreamPacket.BuildPacket(actorId, 0));
|
||||
|
||||
QueuePackets(GetSpawnPackets(this, spawnType));
|
||||
//GetSpawnPackets(actorId, spawnType).DebugPrintPacket();
|
||||
|
||||
#region Inventory & Equipment
|
||||
QueuePacket(InventoryBeginChangePacket.BuildPacket(actorId, true));
|
||||
|
@ -604,14 +612,11 @@ namespace Meteor.Map.Actors
|
|||
playerSession.QueuePacket(debugSpawn);
|
||||
playerSession.QueuePacket(worldMasterSpawn);
|
||||
|
||||
//Inn Packets (Dream, Cutscenes, Armoire)
|
||||
|
||||
if (zone.GetWeatherDirector() != null)
|
||||
{
|
||||
playerSession.QueuePacket(zone.GetWeatherDirector().GetSpawnPackets());
|
||||
}
|
||||
|
||||
|
||||
foreach (Director director in ownedDirectors)
|
||||
{
|
||||
QueuePackets(director.GetSpawnPackets());
|
||||
|
@ -623,6 +628,8 @@ namespace Meteor.Map.Actors
|
|||
|
||||
if (currentParty != null)
|
||||
currentParty.SendGroupPackets(playerSession);
|
||||
|
||||
SendInstanceUpdate();
|
||||
}
|
||||
|
||||
private void SendRemoveInventoryPackets(List<ushort> slots)
|
||||
|
@ -808,6 +815,48 @@ namespace Meteor.Map.Actors
|
|||
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()
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
public void SendInstanceUpdate()
|
||||
public void SendInstanceUpdate(bool force = false)
|
||||
{
|
||||
//Server.GetWorldManager().SeamlessCheck(this);
|
||||
|
||||
|
@ -1821,7 +1870,7 @@ namespace Meteor.Map.Actors
|
|||
aroundMe.AddRange(zone.GetActorsAroundActor(this, 50));
|
||||
if (zone2 != null)
|
||||
aroundMe.AddRange(zone2.GetActorsAroundActor(this, 50));
|
||||
playerSession.UpdateInstance(aroundMe);
|
||||
playerSession.UpdateInstance(aroundMe, force);
|
||||
}
|
||||
|
||||
public bool IsInParty()
|
||||
|
|
|
@ -105,9 +105,9 @@ namespace Meteor.Map.dataobjects
|
|||
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;
|
||||
|
||||
List<BasePacket> basePackets = new List<BasePacket>();
|
||||
|
|
|
@ -30,16 +30,16 @@ namespace Meteor.Map.packets.send.player
|
|||
public const ushort OPCODE = 0x01A7;
|
||||
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];
|
||||
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((Int32)0x216);
|
||||
binWriter.Write((Byte)dreamID);
|
||||
binWriter.Write((Byte)innID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1047,7 +1047,7 @@ namespace Meteor.Map
|
|||
player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x10));
|
||||
player.SendZoneInPackets(this, spawnType);
|
||||
player.playerSession.ClearInstance();
|
||||
player.SendInstanceUpdate();
|
||||
player.SendInstanceUpdate(true);
|
||||
|
||||
player.playerSession.LockUpdates(false);
|
||||
|
||||
|
@ -1078,7 +1078,6 @@ namespace Meteor.Map
|
|||
{
|
||||
player.playerSession.QueuePacket(DeleteAllActorsPacket.BuildPacket(player.actorId));
|
||||
player.playerSession.QueuePacket(_0xE2Packet.BuildPacket(player.actorId, 0x2));
|
||||
//player.SendZoneInPackets(this, spawnType);
|
||||
}
|
||||
|
||||
player.SendZoneInPackets(this, spawnType);
|
||||
|
@ -1087,6 +1086,9 @@ namespace Meteor.Map
|
|||
player.destinationSpawnType = 0;
|
||||
Database.SavePlayerPosition(player);
|
||||
|
||||
player.playerSession.ClearInstance();
|
||||
player.SendInstanceUpdate(true);
|
||||
|
||||
player.playerSession.LockUpdates(false);
|
||||
|
||||
LuaEngine.GetInstance().CallLuaFunction(player, playerArea, "onZoneIn", true);
|
||||
|
|
Loading…
Add table
Reference in a new issue