fix use skill buff

This commit is contained in:
VDH
2026-03-07 09:54:02 +07:00
parent ec8807ed72
commit a184aa0ed5
5 changed files with 170 additions and 517 deletions
@@ -25,11 +25,10 @@ namespace PerfectWorld.Scripts.Managers
Dictionary<int, int> m_UkPlayerTab = new Dictionary<int, int>();
Dictionary<int, EC_ElsePlayer> m_PlayerTab = new Dictionary<int, EC_ElsePlayer>();
private readonly object m_csPlayerTab = new object();
CECHostPlayer m_pHostPlayer;
public int HandlerId => (int)MANAGER_INDEX.MAN_PLAYER;
public bool ProcessMessage(ECMSG Msg)
{
if (Msg.iSubID == 0)
{
if (CECGameRun.Instance == null) return true;
@@ -85,6 +84,7 @@ namespace PerfectWorld.Scripts.Managers
case EC_MsgDef.MSG_PM_PLAYEREXTPROP:
OnMsgPlayerExtProp(Msg);
break;
case int value when value == EC_MsgDef.MSG_PM_PLAYERDUELOPT:
// PLAYER_DUEL_START (229): server may send to both duelists; update host state if host is one of them
// dwParam2 is ushort (pCmdHeader from GameSession); use Convert to avoid InvalidCastException when unboxing
@@ -99,7 +99,7 @@ namespace PerfectWorld.Scripts.Managers
}
TransmitMessage(Msg);
break;
case EC_MsgDef.MSG_PM_PLAYEREXIT:
case EC_MsgDef.MSG_PM_PLAYEREXIT:
OnMsgPlayerExit(Msg);
break;
}
@@ -717,46 +717,47 @@ namespace PerfectWorld.Scripts.Managers
public bool OnMsgPlayerExtProp(ECMSG Msg)
{
object pData;
object pData;
int idPlayer, iIndex;
switch (Msg.dwParam2)
{
case CommandID.PLAYER_EXT_PROP_BASE:
{
cmd_pep_base pCmd = GPDataTypeHelper.FromBytes<cmd_pep_base>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_base;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_BASE;
break;
}
case CommandID.PLAYER_EXT_PROP_MOVE:
{
cmd_pep_move pCmd = GPDataTypeHelper.FromBytes<cmd_pep_move>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_move;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_MOVE;
break;
}
case CommandID.PLAYER_EXT_PROP_ATK:
{
cmd_pep_attack pCmd = GPDataTypeHelper.FromBytes<cmd_pep_attack>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_attack;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_ATTACK;
break;
}
BMLogger.LogError("OnMsgPlayerExtProp Msg.dwParam2=" + Msg.dwParam2);
switch (Convert.ToInt32(Msg.dwParam2))
{
case CommandID.PLAYER_EXT_PROP_BASE:
{
cmd_pep_base pCmd = GPDataTypeHelper.FromBytes<cmd_pep_base>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_base;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_BASE;
break;
}
case CommandID.PLAYER_EXT_PROP_MOVE:
{
cmd_pep_move pCmd = GPDataTypeHelper.FromBytes<cmd_pep_move>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_move;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_MOVE;
break;
}
case CommandID.PLAYER_EXT_PROP_ATK:
{
cmd_pep_attack pCmd = GPDataTypeHelper.FromBytes<cmd_pep_attack>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_attack;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_ATTACK;
break;
}
case CommandID.PLAYER_EXT_PROP_DEF:
{
cmd_pep_def pCmd = GPDataTypeHelper.FromBytes<cmd_pep_def>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_def;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_DEF;
break;
}
default:
return false;
{
cmd_pep_def pCmd = GPDataTypeHelper.FromBytes<cmd_pep_def>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_def;
iIndex = (int)ExtendPropertyClass.EXTPROPIDX_DEF;
break;
}
default:
return false;
}
if (!GPDataTypeHelper.ISPLAYERID(idPlayer))
@@ -767,7 +768,7 @@ namespace PerfectWorld.Scripts.Managers
//CECGameSession* pSession = g_pGame.GetGameSession();
if (idPlayer == m_pHostPlayer.GetCharacterID())
if (idPlayer == GetHostPlayer().GetCharacterID())
{
GetHostPlayer().SetPartExtendProps(iIndex, pData);
}
@@ -787,7 +788,7 @@ namespace PerfectWorld.Scripts.Managers
CECHostPlayer pHost = GetHostPlayer();
if (pHost == null)
return;
// Note: IsSkeletonReady() check is commented out in Unity codebase
// if (!pHost.IsSkeletonReady())
// {
@@ -803,7 +804,7 @@ namespace PerfectWorld.Scripts.Managers
EC_ElsePlayer pPlayer = kvp.Value;
if (pPlayer == null)
continue;
if (!pPlayer.IsSelectable() ||
pPlayer.IsDead() ||
pPlayer.GetCharacterID() == idCurSel ||
@@ -2220,6 +2220,7 @@ namespace BrewMonster
// Set part extend properties
public void SetPartExtendProps(int iPropIdx, object pData)
{
BMLogger.LogError($"HoangDev: SetPartExtendProps iPropIdx={iPropIdx} pData={pData} ");
switch (iPropIdx)
{
case (int)ExtendPropertyClass.EXTPROPIDX_BASE:
@@ -1040,6 +1040,7 @@ namespace CSNetwork
case CommandID.PLAYER_EXT_PROP_MOVE:
case CommandID.PLAYER_EXT_PROP_ATK:
case CommandID.PLAYER_EXT_PROP_DEF:
BMLogger.LogError("EC_MsgDef.MSG_PM_PLAYEREXTPROP");
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYEREXTPROP, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
break;
case CommandID.OWN_EXT_PROP:
@@ -1,5 +1,6 @@
using CSNetwork;
using CSNetwork.GPDataType;
using CommandID = CSNetwork.GPDataType.CommandID;
namespace BrewMonster
{
@@ -21,6 +22,87 @@ namespace BrewMonster
m_BasicProps.iVigour = pCmd.vigour;
}
/// <summary>
/// Handle MSG_PM_PLAYEREXTPROP - Player extended properties update (for movement speed buffs, etc.)
/// Mirrors C++ CECPlayerMan::OnMsgPlayerExtProp (EC_ManPlayer.cpp:797-863)
/// </summary>
void OnMsgPlayerExtProp(ECMSG Msg)
{
int cmdID = (int)Msg.dwParam2; // Command ID: PLAYER_EXT_PROP_MOVE (54), PLAYER_EXT_PROP_BASE (53), etc.
int idPlayer;
object pData;
BMLogger.LogError("OnMsgPlayerExtProp cmdID=" + cmdID);
switch (cmdID)
{
case CommandID.PLAYER_EXT_PROP_BASE:
{
cmd_pep_base pCmd = GPDataTypeHelper.FromBytes<cmd_pep_base>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_base;
break;
}
case CommandID.PLAYER_EXT_PROP_MOVE:
{
cmd_pep_move pCmd = GPDataTypeHelper.FromBytes<cmd_pep_move>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_move;
break;
}
case CommandID.PLAYER_EXT_PROP_ATK:
{
cmd_pep_attack pCmd = GPDataTypeHelper.FromBytes<cmd_pep_attack>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_attack;
break;
}
case CommandID.PLAYER_EXT_PROP_DEF:
{
cmd_pep_def pCmd = GPDataTypeHelper.FromBytes<cmd_pep_def>((byte[])Msg.dwParam1);
idPlayer = pCmd.idPlayer;
pData = pCmd.ep_def;
break;
}
default:
UnityEngine.Debug.LogError($"OnMsgPlayerExtProp: Unknown command ID {cmdID}");
return;
}
// Check if this is the host player (mirrors C++: idPlayer == pSession->GetCharacterID())
if (idPlayer == GetCharacterID())
{
SetPartExtendProps(cmdID, pData);
}
// TODO: Handle other players (CECElsePlayer) if needed
}
/// <summary>
/// Set part of extended properties based on property index.
/// Mirrors C++ CECPlayer::SetPartExtendProps (EC_Player.cpp:4051-4079)
/// </summary>
void SetPartExtendProps(int cmdID, object pData)
{
switch (cmdID)
{
case CommandID.PLAYER_EXT_PROP_BASE:
m_ExtProps.bs = (ROLEEXTPROP_BASE)pData;
break;
case CommandID.PLAYER_EXT_PROP_MOVE:
m_ExtProps.mv = (ROLEEXTPROP_MOVE)pData;
// Speed buff applied - movement speed should now be updated
break;
case CommandID.PLAYER_EXT_PROP_ATK:
m_ExtProps.ak = (ROLEEXTPROP_ATK)pData;
break;
case CommandID.PLAYER_EXT_PROP_DEF:
m_ExtProps.df = (ROLEEXTPROP_DEF)pData;
break;
default:
UnityEngine.Debug.LogError($"SetPartExtendProps: Unknown command ID {cmdID}");
return;
}
}
private void OnMsgHstInfo00(in ECMSG Msg)
{
cmd_self_info_00 pCmd = GPDataTypeHelper.FromBytes<cmd_self_info_00>((byte[])Msg.dwParam1);
File diff suppressed because one or more lines are too long