Merge branch 'feature/revive' into develop

This commit is contained in:
HungDK
2025-11-05 09:38:45 +07:00
3 changed files with 68 additions and 0 deletions
@@ -31,6 +31,7 @@ public class CECNPCMan : IMsgHandler
case long value when value == EC_MsgDef.MSG_NM_NPCINFO: OnMsgNPCInfo(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCMOVE: OnMsgNPCMove(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCSTOPMOVE: OnMsgNPCStopMove(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCRUNOUT: OnMsgNPCRunOut(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCDIED: OnMsgNPCDied(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCDISAPPEAR: OnMsgNPCDisappear(Msg); break;
case long value when value == EC_MsgDef.MSG_NM_NPCATKRESULT: TransmitMessage(Msg); break;
@@ -251,6 +252,13 @@ public class CECNPCMan : IMsgHandler
return true;
}
private bool OnMsgNPCRunOut(ECMSG msg)
{
int id = GPDataTypeHelper.FromBytes<int>((byte[])msg.dwParam1);
NPCLeave(id);
return true;
}
private bool OnMsgNPCMove(ECMSG msg)
{
var buffer = (byte[])msg.dwParam1;
@@ -63,6 +63,9 @@ namespace PerfectWorld.Scripts.Managers
case int value when value == EC_MsgDef.MSG_PM_PLAYERREVIVE:
OnMsgPlayerRevive(Msg);
break;
case int value when value == EC_MsgDef.MSG_PM_PLAYERRUNOUT:
OnMsgPlayerRunOut(Msg);
break;
}
}
else
@@ -384,6 +387,47 @@ namespace PerfectWorld.Scripts.Managers
return true;
}
public bool OnMsgPlayerRunOut(ECMSG Msg)
{
int id = GPDataTypeHelper.FromBytes<int>((byte[])Msg.dwParam1);
CECHostPlayer pHost = GetHostPlayer();
if (pHost != null && id == pHost.GetCharacterID())
return true; // Don't process if it's the host player
ElsePlayerLeave(id, false);
return true;
}
private void ElsePlayerLeave(int cid, bool bExitGame)
{
EC_ElsePlayer pPlayer = SeekOutElsePlayer(cid);
if (pPlayer == null)
return;
// Remove from active player table
lock (m_csPlayerTab)
{
m_PlayerTab.Remove(cid);
}
// If this player is selected by host, cancel the selection
CECHostPlayer pHost = GetHostPlayer();
if (pHost != null && pHost.GetSelectedTarget() == cid)
pHost.SelectTarget(0);
// Release player resource
if (pPlayer != null)
{
if (bExitGame)
{
// Player exited game - handle differently if needed
}
// Destroy the player GameObject
if (pPlayer.gameObject != null)
UnityEngine.Object.Destroy(pPlayer.gameObject);
}
}
//private cmd_object_move ConvertToStruct(byte[] bytes)
//{
// if (bytes.Length < Marshal.SizeOf<cmd_object_move>())
@@ -445,6 +445,22 @@ namespace CSNetwork
break;
}
case CommandID.OBJECT_LEAVE_SLICE:
{
int id = GPDataTypeHelper.FromBytes<int>(pDataBuf);
if (ISPLAYERID(id))
{
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERRUNOUT, (int)MANAGER_INDEX.MAN_PLAYER, -1,
pDataBuf, pCmdHeader);
}
else if (ISNPCID(id))
{
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCRUNOUT, (int)MANAGER_INDEX.MAN_NPC, 0, pDataBuf,
pCmdHeader);
}
break;
}
case CommandID.OWN_IVTR_DATA:
case CommandID.OWN_IVTR_DETAIL_DATA:
case CommandID.GET_OWN_MONEY: