diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkTrace.cs b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkTrace.cs index c4f01ffceb..d99fcf0542 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkTrace.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkTrace.cs @@ -345,6 +345,7 @@ public class CECTracedPlayer : CECTracedObject if (m_iObjectId == m_pHost.m_idSelTarget && m_pHost.AttackableJudge(m_iObjectId, m_bForceAttack) == 1) { + Debug.LogError("c2s_CmdNormalAttack"); byte byPVPMask = EC_Utility.glb_BuildPVPMask(m_bForceAttack); UnityGameSession.c2s_CmdNormalAttack(byPVPMask); m_pHost.m_bPrepareFight = true; @@ -579,7 +580,7 @@ public class CECHPWorkTrace : CECHPWork public override bool Tick(float dwDeltaTime) { base.Tick(dwDeltaTime); - + Debug.LogError("Tick"); CheckPrepSkill(); UpdateResetUseAutoPF(); @@ -605,6 +606,7 @@ public class CECHPWorkTrace : CECHPWork //return true; if (m_pTraceObject.CanTouchFrom(m_pHost.GetPos() + new A3DVECTOR3(0f, m_pHost.m_CDRInfo.vExtent.y, 0f))) { + Debug.LogError("OnTouchTarget"); OnTouchTarget(); return true; } @@ -829,7 +831,6 @@ public class CECHPWorkTrace : CECHPWork vCurPos = m_pHost.m_MoveCtrl.GroundMove(m_vCurDirH, m_pHost.GetGroundSpeed(), fDeltaTime); if (m_pHost.m_MoveCtrl.MoveBlocked() >= 3) { - Debug.LogError("SendStopMoveCmd"); m_pHost.m_MoveCtrl.SetSlideLock(true); m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), m_pHost.GetGroundSpeed(), (int)GPMoveMode.GP_MOVE_SLIDE); m_bFinished = true; @@ -841,7 +842,6 @@ public class CECHPWorkTrace : CECHPWork //{ // CECIntelligentRoute::Instance().OnPlayerPosChange(vCurPos); //} - Debug.LogError("SendMoveCmd"); m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 2, GPDataTypeHelper.g_vOrigin, EC_Utility.ToA3DVECTOR3(cdr.vAbsVelocity), (int)GPMoveMode.GP_MOVE_SLIDE); } } @@ -888,7 +888,10 @@ public class CECHPWorkTrace : CECHPWork //} if (cdr.vTPNormal == Vector3.zero) + { + Debug.LogError("m_bCheckTouch = false"); m_bCheckTouch = false; + } //if (!m_vCurDirH.IsZero()) //{ @@ -897,11 +900,13 @@ public class CECHPWorkTrace : CECHPWork if (m_pHost.m_MoveCtrl.MoveBlocked() >= 3) { + Debug.LogError("m_pHost.m_MoveCtrl.SendStopMoveCmd"); //m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), m_pHost.GetGroundSpeed(), iMoveMode); PressCancel(); } else { + Debug.LogError("m_pHost.m_MoveCtrl.SendMoveCmd"); m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 0, vTargetPos, EC_Utility.ToA3DVECTOR3(cdr.vAbsVelocity), iMoveMode); } } @@ -928,7 +933,10 @@ public class CECHPWorkTrace : CECHPWork // immediately (m_bHaveMoved = false), we must need to send 'stop move' // command if (m_bHaveMoved || !m_pHost.m_MoveCtrl.IsStop()) + { + Debug.LogError("SendStopMoveCmd"); m_pHost.m_MoveCtrl.SendStopMoveCmd(); + } m_pHost.m_vVelocity.Clear(); //m_pHost.StopModelMove(); diff --git a/Assets/PerfectWorld/Scripts/Move/CECHostMove.cs b/Assets/PerfectWorld/Scripts/Move/CECHostMove.cs index a74a9fdf34..b0650de3df 100644 --- a/Assets/PerfectWorld/Scripts/Move/CECHostMove.cs +++ b/Assets/PerfectWorld/Scripts/Move/CECHostMove.cs @@ -327,7 +327,7 @@ public class CECHostMove } m_fMoveTime += fTime; - + m_pHost.m_CDRInfo.vTPNormal = cdr.vTPNormal; return vNewPos; } diff --git a/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs b/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs index 33c4477773..c5f4b24a68 100644 --- a/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs +++ b/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs @@ -135,9 +135,9 @@ namespace BrewMonster.Scripts vHitNormal = Vector3.up; bSupport = false; - float dist = Mathf.Max(fDeltaY, 0f); + float dist = Mathf.Max(fDeltaY, 0f) + vExt.y; Vector3 origin = vStart /*+ Vector3.down * vExt.y*/; - if (Physics.Raycast(origin, (Vector3.down ).normalized, out RaycastHit hit, 1<<6 | 1<<7)) + if (Physics.Raycast(origin, Vector3.down, out RaycastHit hit, dist, mask)) { vHitNormal = hit.normal; //Debug.DrawLine(origin, vHitNormal, Color.black, 10f); @@ -229,7 +229,6 @@ namespace BrewMonster.Scripts CDRInfo.fMoveDist += fDeltaDist; break; } - Debug.LogError("Hit"); //if (bStartSolid) //{ // CDRInfo.fMoveDist = 0f; @@ -317,7 +316,7 @@ namespace BrewMonster.Scripts if (downDist > 0f) { - if (!DoGroundProbe(vFinalPos, vExt, downDist, 1<<6, out Vector3 vEnd, out Vector3 groundNormal, out bool bSupport)) + if (!DoGroundProbe(vFinalPos, vExt, downDist, mask, out Vector3 vEnd, out Vector3 groundNormal, out bool bSupport)) { CDRInfo.fMoveDist = 0f; CDRInfo.vTPNormal = Vector3.up; @@ -326,9 +325,11 @@ namespace BrewMonster.Scripts if (bSupport) { - Debug.LogError("vFinal = " + vFinal + " == vEnd = " + vEnd); vFinal = vEnd; - if (!bJump) vTPNormal = groundNormal; + if (!bJump) + { + vTPNormal = groundNormal; + } } } diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 9c8a4aaa0d..9d41c7ca29 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -66,16 +66,21 @@ public class CECHostPlayer : CECPlayer public float m_fVertSpeed = 0f; // ====== Ground cast config ====== - [Header("Ground Cast")] [Tooltip("Khoảng thêm ngoài skinWidth để SphereCast xuống (m ngắn)")] [SerializeField] + [Header("Ground Cast")] + [Tooltip("Khoảng thêm ngoài skinWidth để SphereCast xuống (m ngắn)")] + [SerializeField] private float extraGroundDistance = 1f; - [Tooltip("Bớt bán kính một chút để tránh tự va vào capsule (epsilon)")] [SerializeField] + [Tooltip("Bớt bán kính một chút để tránh tự va vào capsule (epsilon)")] + [SerializeField] private float radiusEpsilon = 0.005f; - [Tooltip("Layer mặt đất")] [SerializeField] - private LayerMask groundMask = 1<<6; + [Tooltip("Layer mặt đất")] + [SerializeField] + private LayerMask groundMask = 1 << 6; - [Tooltip("Layer mặt đất")] [SerializeField] + [Tooltip("Layer mặt đất")] + [SerializeField] private float slopeToleranceDeg = 2f; // cache tùy chọn (không bắt buộc) @@ -193,13 +198,13 @@ public class CECHostPlayer : CECPlayer // return; //} // Trace a object - if (iTraceReason == CECHPWorkTrace.Trace_reason.TRACE_ATTACK) - { - if (!CanDo(ActionCanDo.CANDO_MELEE)) - return; - Debug.LogError("Attack"); - NormalAttackObject(idTraceTarget, bForceAttack); - } + if (iTraceReason == CECHPWorkTrace.Trace_reason.TRACE_ATTACK) + { + if (!CanDo(ActionCanDo.CANDO_MELEE)) + return; + Debug.LogError("Attack"); + NormalAttackObject(idTraceTarget, bForceAttack); + } //else //{ // if (!CanDo(CANDO_MOVETO)) @@ -336,21 +341,21 @@ public class CECHostPlayer : CECPlayer case int value when value == EC_MsgDef.MSG_HST_CORRECTPOS: OnMsgHstCorrectPos(Msg); break; case int value when value == EC_MsgDef.MSG_HST_GOTO: OnMsgHstGoto(Msg); break; case int value when value == EC_MsgDef.MSG_HST_IVTRINFO: - { - OnMsgHstIvtrInfo(Msg); - break; - } + { + OnMsgHstIvtrInfo(Msg); + break; + } case int value when value == EC_MsgDef.MSG_HST_OWNITEMINFO: - { - OnMsgHstOwnItemInfo(Msg); - break; - } + { + OnMsgHstOwnItemInfo(Msg); + break; + } case int value when value == EC_MsgDef.MSG_HST_TASKDATA: - { - OnMsgHstTaskData(Msg); - //Debug.LogError("[Dat]- OnMsgHstTaskData"); - break; - } + { + OnMsgHstTaskData(Msg); + //Debug.LogError("[Dat]- OnMsgHstTaskData"); + break; + } case int value when value == EC_MsgDef.MSG_HST_ITEMOPERATION: OnMsgHstItemOperation(Msg); break; @@ -368,14 +373,15 @@ public class CECHostPlayer : CECPlayer private void OnMsgHstInfo00(in ECMSG Msg) { - cmd_self_info_00 pCmd = GPDataTypeHelper.FromBytes((byte[]) Msg.dwParam1); - + cmd_self_info_00 pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + bool bFirstTime = m_BasicProps.iLevel == 0 ? true : false; if (!bFirstTime) { int iLimit = (int)(pCmd.iMaxHP * 0.3f); - if (pCmd.iHP < m_BasicProps.iCurHP && m_BasicProps.iCurHP >= iLimit && pCmd.iHP < iLimit) { - + if (pCmd.iHP < m_BasicProps.iCurHP && m_BasicProps.iCurHP >= iLimit && pCmd.iHP < iLimit) + { + /*if (CECUIHelper::GetGameUIMan()->IsShowLowHP()) { // ѪÁ¿µÍÓÚÁÙ½çÖµÔò²¥·ÅÌØÐ§ const int GfxLastTime = 10000; // ³ÖÐøÊ±¼ä10Ãë @@ -396,22 +402,22 @@ public class CECHostPlayer : CECPlayer g_pGame->GetGameRun()->AddFixedMessage(FIXMSG_ADDMAXAP, pCmd->iMaxAP - m_ExtProps.max_ap);*/ } - m_BasicProps.iLevel = pCmd.sLevel; + m_BasicProps.iLevel = pCmd.sLevel; SetLevel2(pCmd.Level2, bFirstTime); - m_BasicProps.iExp = pCmd.iExp; - m_BasicProps.iSP = pCmd.iSP; - m_BasicProps.iCurHP = pCmd.iHP; - m_BasicProps.iCurMP = pCmd.iMP; - m_BasicProps.iCurAP = pCmd.iAP; - m_ExtProps.bs.max_hp = pCmd.iMaxHP; - m_ExtProps.bs.max_mp = pCmd.iMaxMP; - m_ExtProps.max_ap = pCmd.iMaxAP; + m_BasicProps.iExp = pCmd.iExp; + m_BasicProps.iSP = pCmd.iSP; + m_BasicProps.iCurHP = pCmd.iHP; + m_BasicProps.iCurMP = pCmd.iMP; + m_BasicProps.iCurAP = pCmd.iAP; + m_ExtProps.bs.max_hp = pCmd.iMaxHP; + m_ExtProps.bs.max_mp = pCmd.iMaxMP; + m_ExtProps.max_ap = pCmd.iMaxAP; EventBus.Publish(new EXPToUpLevel(GetLevelUpExp(pCmd.sLevel))); EventBus.Publish(pCmd); // if (pCmd.State != 0 && m_bFight == false) PlayEnterBattleGfx(); m_bFight = pCmd.State != 0 ? true : false; - + // UpdateGodEvilSprite(); /*CECGameUIMan* pGameUI = g_pGame->GetGameRun()->GetUIManager()->GetInGameUIMan(); @@ -536,82 +542,32 @@ public class CECHostPlayer : CECPlayer switch (cmd) { case CommandID.HOST_OBTAIN_ITEM: - { - // Parse cmd_host_obtain_item struct data - int type = BitConverter.ToInt32(data, 0); - int expire_date = BitConverter.ToInt32(data, 4); - uint amount = BitConverter.ToUInt32(data, 8); - uint slot_amount = BitConverter.ToUInt32(data, 12); - byte where = data[16]; // Package index - byte index = data[17]; // Slot index in that package - // Create new inventory item data - var newItem = new InventoryItemData { - Package = where, - Slot = index, - TemplateId = type, - ExpireDate = expire_date, - State = 0, - Count = (int)amount, - Crc = 0, - Content = null - }; - - // Add item to inventory - EC_Inventory.SetItem(where, index, newItem); - - Debug.Log( - $"[HOST_OBTAIN_ITEM] Successfully added item {type} to package {where}, slot {index} with count {amount}"); - - // Trigger UI refresh if an EC_InventoryUI is present in scene - var ui = GameObject.FindFirstObjectByType(); - if (ui != null) - { - ui.RefreshAll(); - } - } - break; - case CommandID.PICKUP_ITEM: - { - int tid = BitConverter.ToInt32(data, 0); - int expire_date = BitConverter.ToInt32(data, 4); - uint iAmount = BitConverter.ToUInt32(data, 8); - uint iSlotAmount = BitConverter.ToUInt32(data, 12); - byte byPackage = data[16]; - byte bySlot = data[17]; - - //Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}"); - - // Notify pickupItem script about successful pickup - pickupItem pickupScript = pickupItem.Instance; - if (pickupScript != null) - { - //Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}"); - - // Notify pickupItem script about successful pickup - pickupScript = UnityEngine.Object.FindFirstObjectByType(); - if (pickupScript != null) - { - pickupScript.OnPickupSuccess(tid); - } - - // Create new inventory item data + // Parse cmd_host_obtain_item struct data + int type = BitConverter.ToInt32(data, 0); + int expire_date = BitConverter.ToInt32(data, 4); + uint amount = BitConverter.ToUInt32(data, 8); + uint slot_amount = BitConverter.ToUInt32(data, 12); + byte where = data[16]; // Package index + byte index = data[17]; // Slot index in that package + // Create new inventory item data var newItem = new InventoryItemData { - Package = byPackage, - Slot = bySlot, - TemplateId = tid, + Package = where, + Slot = index, + TemplateId = type, ExpireDate = expire_date, State = 0, - Count = (int)iAmount, + Count = (int)amount, Crc = 0, Content = null }; // Add item to inventory - EC_Inventory.SetItem(byPackage, bySlot, newItem); + EC_Inventory.SetItem(where, index, newItem); - //Debug.Log($"[Inventory] Successfully added item {tid} to package {byPackage}, slot {bySlot} with count {iAmount}"); + Debug.Log( + $"[HOST_OBTAIN_ITEM] Successfully added item {type} to package {where}, slot {index} with count {amount}"); // Trigger UI refresh if an EC_InventoryUI is present in scene var ui = GameObject.FindFirstObjectByType(); @@ -620,43 +576,48 @@ public class CECHostPlayer : CECPlayer ui.RefreshAll(); } } - else - { - Debug.LogWarning("[Inventory] PICKUP_ITEM: Invalid data length"); - } - break; - } - } - } - - public void OnMsgHstItemOperation(ECMSG Msg) - { - var data = Msg.dwParam1 as byte[]; - int cmd = Convert.ToInt32(Msg.dwParam2); - switch (cmd) - { - case CommandID.PLAYER_DROP_ITEM: - { - // Parse the drop item data from the server response - if (data != null && data.Length >= 6) + case CommandID.PICKUP_ITEM: { - byte byPackage = data[0]; - byte bySlot = data[1]; - int count = BitConverter.ToInt32(data, 2); - int tid = BitConverter.ToInt32(data, 6); - byte reason = data[10]; + int tid = BitConverter.ToInt32(data, 0); + int expire_date = BitConverter.ToInt32(data, 4); + uint iAmount = BitConverter.ToUInt32(data, 8); + uint iSlotAmount = BitConverter.ToUInt32(data, 12); + byte byPackage = data[16]; + byte bySlot = data[17]; - Debug.Log( - $"[Inventory] PLAYER_DROP_ITEM: package={byPackage}, slot={bySlot}, count={count}, tid={tid}, reason={reason}"); + //Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}"); - // Update the inventory by removing the item - bool success = EC_Inventory.RemoveItem(byPackage, bySlot, count); - - if (success) + // Notify pickupItem script about successful pickup + pickupItem pickupScript = pickupItem.Instance; + if (pickupScript != null) { - Debug.Log( - $"[Inventory] Successfully removed {count} items from package {byPackage}, slot {bySlot}"); + //Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}"); + + // Notify pickupItem script about successful pickup + pickupScript = UnityEngine.Object.FindFirstObjectByType(); + if (pickupScript != null) + { + pickupScript.OnPickupSuccess(tid); + } + + // Create new inventory item data + var newItem = new InventoryItemData + { + Package = byPackage, + Slot = bySlot, + TemplateId = tid, + ExpireDate = expire_date, + State = 0, + Count = (int)iAmount, + Crc = 0, + Content = null + }; + + // Add item to inventory + EC_Inventory.SetItem(byPackage, bySlot, newItem); + + //Debug.Log($"[Inventory] Successfully added item {tid} to package {byPackage}, slot {bySlot} with count {iAmount}"); // Trigger UI refresh if an EC_InventoryUI is present in scene var ui = GameObject.FindFirstObjectByType(); @@ -667,46 +628,91 @@ public class CECHostPlayer : CECPlayer } else { - Debug.LogWarning($"[Inventory] Failed to remove items from package {byPackage}, slot {bySlot}"); + Debug.LogWarning("[Inventory] PICKUP_ITEM: Invalid data length"); } - } - else - { - Debug.LogWarning("[Inventory] PLAYER_DROP_ITEM: Invalid data length"); - } - break; - } + break; + } + } + } + + public void OnMsgHstItemOperation(ECMSG Msg) + { + var data = Msg.dwParam1 as byte[]; + int cmd = Convert.ToInt32(Msg.dwParam2); + switch (cmd) + { + case CommandID.PLAYER_DROP_ITEM: + { + // Parse the drop item data from the server response + if (data != null && data.Length >= 6) + { + byte byPackage = data[0]; + byte bySlot = data[1]; + int count = BitConverter.ToInt32(data, 2); + int tid = BitConverter.ToInt32(data, 6); + byte reason = data[10]; + + Debug.Log( + $"[Inventory] PLAYER_DROP_ITEM: package={byPackage}, slot={bySlot}, count={count}, tid={tid}, reason={reason}"); + + // Update the inventory by removing the item + bool success = EC_Inventory.RemoveItem(byPackage, bySlot, count); + + if (success) + { + Debug.Log( + $"[Inventory] Successfully removed {count} items from package {byPackage}, slot {bySlot}"); + + // Trigger UI refresh if an EC_InventoryUI is present in scene + var ui = GameObject.FindFirstObjectByType(); + if (ui != null) + { + ui.RefreshAll(); + } + } + else + { + Debug.LogWarning($"[Inventory] Failed to remove items from package {byPackage}, slot {bySlot}"); + } + } + else + { + Debug.LogWarning("[Inventory] PLAYER_DROP_ITEM: Invalid data length"); + } + + break; + } case CommandID.EQUIP_ITEM: - { - byte index_inv = data[0]; - byte index_equip = data[1]; - // Update client-side data: move item between PACK_INVENTORY and PACK_EQUIPMENT - var invItem = EC_Inventory.GetItem(EC_Inventory.PACK_INVENTORY, index_inv, true); - var equipItem = EC_Inventory.GetItem(EC_Inventory.PACK_EQUIPMENT, index_equip, true); - if (invItem != null) { - invItem.Package = EC_Inventory.PACK_EQUIPMENT; - invItem.Slot = index_equip; - EC_Inventory.SetItem(EC_Inventory.PACK_EQUIPMENT, index_equip, invItem); - } + byte index_inv = data[0]; + byte index_equip = data[1]; + // Update client-side data: move item between PACK_INVENTORY and PACK_EQUIPMENT + var invItem = EC_Inventory.GetItem(EC_Inventory.PACK_INVENTORY, index_inv, true); + var equipItem = EC_Inventory.GetItem(EC_Inventory.PACK_EQUIPMENT, index_equip, true); + if (invItem != null) + { + invItem.Package = EC_Inventory.PACK_EQUIPMENT; + invItem.Slot = index_equip; + EC_Inventory.SetItem(EC_Inventory.PACK_EQUIPMENT, index_equip, invItem); + } - if (equipItem != null) - { - equipItem.Package = EC_Inventory.PACK_INVENTORY; - equipItem.Slot = index_inv; - EC_Inventory.SetItem(EC_Inventory.PACK_INVENTORY, index_inv, equipItem); - } + if (equipItem != null) + { + equipItem.Package = EC_Inventory.PACK_INVENTORY; + equipItem.Slot = index_inv; + EC_Inventory.SetItem(EC_Inventory.PACK_INVENTORY, index_inv, equipItem); + } - // Trigger UI refresh if an EC_InventoryUI is present in scene - var ui = GameObject.FindObjectOfType(); - if (ui != null) - { - ui.RefreshAll(); - } + // Trigger UI refresh if an EC_InventoryUI is present in scene + var ui = GameObject.FindObjectOfType(); + if (ui != null) + { + ui.RefreshAll(); + } - break; - } + break; + } } } @@ -716,13 +722,13 @@ public class CECHostPlayer : CECPlayer switch (cmd) { case CommandID.OWN_ITEM_INFO: - { - Debug.Log("[Inventory] OWN_ITEM_INFO received"); - var data = Msg.dwParam1 as byte[]; - int hostId = Convert.ToInt32(Msg.dwParam3); - EC_Inventory.LogInventoryPacket("OWN_ITEM_INFO", data, hostId); - break; - } + { + Debug.Log("[Inventory] OWN_ITEM_INFO received"); + var data = Msg.dwParam1 as byte[]; + int hostId = Convert.ToInt32(Msg.dwParam3); + EC_Inventory.LogInventoryPacket("OWN_ITEM_INFO", data, hostId); + break; + } } } @@ -735,111 +741,111 @@ public class CECHostPlayer : CECPlayer switch (cmd) { case CommandID.OWN_IVTR_DATA: - { - EC_Inventory.LogInventoryPacket("OWN_IVTR_DATA", data, hostId); - break; - } + { + EC_Inventory.LogInventoryPacket("OWN_IVTR_DATA", data, hostId); + break; + } case CommandID.OWN_IVTR_DETAIL_DATA: - { - EC_Inventory.LogInventoryPacket("OWN_IVTR_DETAIL_DATA", data, hostId); - // Parse and store - if (data != null && data.Length >= 6) { - byte byPackage = data[0]; - byte ivtrSize = data[1]; - if (EC_IvtrItem.TryParseInventoryDetail(data, out var pkg, - out var size, out var items)) + EC_Inventory.LogInventoryPacket("OWN_IVTR_DETAIL_DATA", data, hostId); + // Parse and store + if (data != null && data.Length >= 6) { - EC_Inventory.UpdatePack(pkg, size, items); + byte byPackage = data[0]; + byte ivtrSize = data[1]; + if (EC_IvtrItem.TryParseInventoryDetail(data, out var pkg, + out var size, out var items)) + { + EC_Inventory.UpdatePack(pkg, size, items); + } } - } - break; - } + break; + } case CommandID.GET_OWN_MONEY: - { - if (data != null) { - try + if (data != null) { - var money = GPDataTypeHelper.FromBytes(data); - var ui = GameObject.FindFirstObjectByType(); - if (ui == null) + try { - var all = Resources.FindObjectsOfTypeAll(); - if (all != null) + var money = GPDataTypeHelper.FromBytes(data); + var ui = GameObject.FindFirstObjectByType(); + if (ui == null) { - for (int i = 0; i < all.Length; i++) + var all = Resources.FindObjectsOfTypeAll(); + if (all != null) { - var candidate = all[i]; - if (candidate != null && candidate.gameObject.scene.IsValid()) + for (int i = 0; i < all.Length; i++) { - ui = candidate; - break; + var candidate = all[i]; + if (candidate != null && candidate.gameObject.scene.IsValid()) + { + ui = candidate; + break; + } } } } - } - if (ui != null) - { - ui.UpdateMoney(money.amount, money.max_amount); + if (ui != null) + { + ui.UpdateMoney(money.amount, money.max_amount); + } + else + { + BrewMonster.Scripts.Managers.EC_InventoryUI.CacheMoney(money.amount, money.max_amount); + } } - else + catch (Exception ex) { - BrewMonster.Scripts.Managers.EC_InventoryUI.CacheMoney(money.amount, money.max_amount); + Debug.LogWarning($"[Inventory] Failed to parse GET_OWN_MONEY: {ex.Message}"); } } - catch (Exception ex) - { - Debug.LogWarning($"[Inventory] Failed to parse GET_OWN_MONEY: {ex.Message}"); - } + + break; } - - break; - } case CommandID.PLAYER_CASH: - { - if (data != null) { - try + if (data != null) { - var cash = GPDataTypeHelper.FromBytes(data); - var ui = GameObject.FindFirstObjectByType(); - if (ui == null) + try { - var all = Resources.FindObjectsOfTypeAll(); - if (all != null) + var cash = GPDataTypeHelper.FromBytes(data); + var ui = GameObject.FindFirstObjectByType(); + if (ui == null) { - for (int i = 0; i < all.Length; i++) + var all = Resources.FindObjectsOfTypeAll(); + if (all != null) { - var candidate = all[i]; - if (candidate != null && candidate.gameObject.scene.IsValid()) + for (int i = 0; i < all.Length; i++) { - ui = candidate; - break; + var candidate = all[i]; + if (candidate != null && candidate.gameObject.scene.IsValid()) + { + ui = candidate; + break; + } } } } - } - if (ui != null) - { - ui.UpdateCash(cash.cash_amount); + if (ui != null) + { + ui.UpdateCash(cash.cash_amount); + } + else + { + BrewMonster.Scripts.Managers.EC_InventoryUI.CacheCash(cash.cash_amount); + } } - else + catch (Exception ex) { - BrewMonster.Scripts.Managers.EC_InventoryUI.CacheCash(cash.cash_amount); + Debug.LogWarning($"[Inventory] Failed to parse PLAYER_CASH: {ex.Message}"); } } - catch (Exception ex) - { - Debug.LogWarning($"[Inventory] Failed to parse PLAYER_CASH: {ex.Message}"); - } + + break; } - - break; - } } } @@ -928,6 +934,7 @@ public class CECHostPlayer : CECPlayer CalcPlayerAABB(); SetPos(pos); m_CDRInfo.fStepHeight = 0.8f; + //m_CDRInfo.vTPNormal = GroundCheck(out RaycastHit hit) ? hit.normal : Vector3.zero; m_CDRInfo.vExtent = EC_Utility.ToVector3(m_aabbServer.Extents); // Create work manager m_pWorkMan = new CECHPWorkMan(this); @@ -1284,28 +1291,27 @@ public class CECHostPlayer : CECPlayer switch (iReason) { case 1: // melee - { - float fRange; - if (fMaxCut >= 0.0f) { - float fCutDist = m_ExtProps.ak.AttackRange * 0.3f; - if (fCutDist > fMaxCut) - fCutDist = fMaxCut; + float fRange; + if (fMaxCut >= 0.0f) + { + float fCutDist = m_ExtProps.ak.AttackRange * 0.3f; + if (fCutDist > fMaxCut) + fCutDist = fMaxCut; - fRange = m_ExtProps.ak.AttackRange - fCutDist; - } - - else - fRange = m_ExtProps.ak.AttackRange * 0.7f; - - - fRange = 2.31f; + fRange = m_ExtProps.ak.AttackRange - fCutDist; + } + else + { + fRange = m_ExtProps.ak.AttackRange * 0.7f; + } + fRange = 1f; Debug.LogError("fDist - fTargetRad = " + (fDist - fTargetRad)); - if (fDist - fTargetRad <= fRange) - return true; + if (fDist - fTargetRad <= fRange) + return true; - break; - } + break; + } //case 2: // cast magic //{ // if (m_pPrepSkill) @@ -1323,19 +1329,19 @@ public class CECHostPlayer : CECPlayer // break; //} case 3: // talk - { - if (fDist - fTargetRad <= 5.0f) - return true; + { + if (fDist - fTargetRad <= 5.0f) + return true; - break; - } + break; + } default: // no special reason - { - if (fDist < (fTargetRad + m_fTouchRad) * 3.0f) - return true; + { + if (fDist < (fTargetRad + m_fTouchRad) * 3.0f) + return true; - break; - } + break; + } } return false; @@ -1524,14 +1530,14 @@ public class CECHostPlayer : CECPlayer break; case ActionCanDo.CANDO_MOVETO: - { - if (IsDead() /*|| IsSitting() || IsTrading() || IsUsingTrashBox()*/ || IsRooting() /*|| + { + if (IsDead() /*|| IsSitting() || IsTrading() || IsUsingTrashBox()*/ || IsRooting() /*|| IsReviving() || IsTalkingWithNPC() || IsChangingFace() || IsUsingItem() || GetBoothState() != 0 || m_bHangerOn || IsOperatingPet() || IsRebuildingPet() || IsPassiveMove()*/) - bRet = false; + bRet = false; - break; - } + break; + } case ActionCanDo.CANDO_MELEE: if (IsDead() /*|| IsSitting() */ || m_idSelTarget == 0 || m_idSelTarget == m_PlayerInfo.cid || @@ -1712,15 +1718,15 @@ public class CECHostPlayer : CECPlayer break; - //case ActionCanDo.CANDO_SWITCH_PARALLEL_WORLD: - // if (IsDead() || IsAboutToDie() || IsJumping() || IsFighting() || - // IsMeleeing() || IsTrading() || IsUsingTrashBox() || IsTalkingWithNPC() || - // IsChangingFace() || IsReviving() || IsSpellingMagic() || IsPicking() || - // IsGathering() || IsRooting() || GetBoothState() != 0 || - // m_iBuddyId || IsOperatingPet() || IsRebuildingPet() || IsUsingItem() || - // GetShapeType() == PLAYERMODEL_DUMMYTYPE2 || IsPassiveMove()) - // bRet = false; - // break; + //case ActionCanDo.CANDO_SWITCH_PARALLEL_WORLD: + // if (IsDead() || IsAboutToDie() || IsJumping() || IsFighting() || + // IsMeleeing() || IsTrading() || IsUsingTrashBox() || IsTalkingWithNPC() || + // IsChangingFace() || IsReviving() || IsSpellingMagic() || IsPicking() || + // IsGathering() || IsRooting() || GetBoothState() != 0 || + // m_iBuddyId || IsOperatingPet() || IsRebuildingPet() || IsUsingItem() || + // GetShapeType() == PLAYERMODEL_DUMMYTYPE2 || IsPassiveMove()) + // bRet = false; + // break; } return bRet; @@ -1799,7 +1805,7 @@ public struct EXPToUpLevel public int NeededExp; public EXPToUpLevel(int neededExp) { - NeededExp = neededExp; + NeededExp = neededExp; } } public struct NPCINFO