fix: update attack normal.
This commit is contained in:
@@ -233,34 +233,34 @@ public class CECHostPlayer : EC_Player
|
||||
switch (cmd)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (equipItem != null)
|
||||
{
|
||||
equipItem.Package = EC_Inventory.PACK_INVENTORY;
|
||||
equipItem.Slot = index_inv;
|
||||
EC_Inventory.SetItem(EC_Inventory.PACK_INVENTORY, index_inv, equipItem);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Trigger UI refresh if an EC_InventoryUI is present in scene
|
||||
var ui = GameObject.FindObjectOfType<EC_InventoryUI>();
|
||||
if (ui != null)
|
||||
{
|
||||
ui.RefreshAll();
|
||||
}
|
||||
// Trigger UI refresh if an EC_InventoryUI is present in scene
|
||||
var ui = GameObject.FindObjectOfType<EC_InventoryUI>();
|
||||
if (ui != null)
|
||||
{
|
||||
ui.RefreshAll();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnMsgHstOwnItemInfo(ECMSG Msg)
|
||||
@@ -487,7 +487,7 @@ public class CECHostPlayer : EC_Player
|
||||
bool bUseAutoPF = false;
|
||||
//CECPlayerWrapper* pWrapper = CECAutoPolicy::GetInstance().GetPlayerWrapper();
|
||||
//if (CECAutoPolicy::GetInstance().IsAutoPolicyEnabled() && pWrapper.GetAttackError() >= 2)
|
||||
bUseAutoPF = true;
|
||||
bUseAutoPF = true;
|
||||
|
||||
CECHPWorkTrace pWorkTrace = null;
|
||||
CECHPWork pWork = null;
|
||||
@@ -686,7 +686,78 @@ public class CECHostPlayer : EC_Player
|
||||
return iRet;
|
||||
}
|
||||
|
||||
private float A3d_Magnitude(A3DVECTOR3 v)
|
||||
{
|
||||
return Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
}
|
||||
|
||||
public bool CannotAttack() { return (m_dwLIES & (uint)Logic_Influence_Extned_states.LIES_DISABLEFIGHT) != 0; }
|
||||
|
||||
public bool CanTouchTarget(A3DVECTOR3 vHostPos, A3DVECTOR3 vTargetPos, float fTargetRad, int iReason, float fMaxCut = 1.0f)
|
||||
{
|
||||
float fDist = A3d_Magnitude(vTargetPos - vHostPos);
|
||||
switch (iReason)
|
||||
{
|
||||
case 1: // melee
|
||||
{
|
||||
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;
|
||||
|
||||
if (fDist - fTargetRad <= fRange)
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
//case 2: // cast magic
|
||||
//{
|
||||
// if (m_pPrepSkill)
|
||||
// {
|
||||
// float fRange = m_pPrepSkill->GetCastRange(m_ExtProps.ak.AttackRange, GetPrayDistancePlus());
|
||||
// if (fRange > 0.0f)
|
||||
// {
|
||||
// if (fDist - fTargetRad <= fRange)
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// break;
|
||||
//}
|
||||
case 3: // talk
|
||||
{
|
||||
if (fDist - fTargetRad <= 5.0f)
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
default: // no special reason
|
||||
{
|
||||
if (fDist < (fTargetRad + m_fTouchRad) * 3.0f)
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CanTouchTarget(A3DVECTOR3 vTargetPos, float fTargetRad, int iReason, float fMaxCut = 1.0f)
|
||||
{
|
||||
A3DVECTOR3 vector = new A3DVECTOR3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
|
||||
return CanTouchTarget(vector, vTargetPos, fTargetRad, iReason, fMaxCut);
|
||||
}
|
||||
}
|
||||
|
||||
public enum StateAnim
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BrewMonster;
|
||||
using CSNetwork.GPDataType;
|
||||
using ModelRenderer.Scripts.GameData;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,6 +15,9 @@ public abstract class EC_Player : MonoBehaviour
|
||||
protected float rotationSpeed = 5;
|
||||
internal int m_iMoveMode; // Player's move mode
|
||||
internal int m_idSelTarget; // Ñ¡ÖÐÄ¿±êµÄID
|
||||
uint m_dwStates; // Player's basic states
|
||||
protected ROLEEXTPROP m_ExtProps; // Extend properties
|
||||
protected float m_fTouchRad = 0.3f; // Touch radius
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
@@ -32,7 +36,10 @@ public abstract class EC_Player : MonoBehaviour
|
||||
{
|
||||
BuildActionList();
|
||||
}
|
||||
public bool IsValidAction(int iIndex) { return (iIndex >= 0 && iIndex < (int)PLAYER_ACTION_TYPE.ACT_MAX) ? true : false; }
|
||||
|
||||
public bool IsDead(){ return (m_dwStates & PlayerNPCState.GP_STATE_CORPSE) != 0; }
|
||||
|
||||
public bool IsValidAction(int iIndex) { return (iIndex >= 0 && iIndex < (int)PLAYER_ACTION_TYPE.ACT_MAX) ? true : false; }
|
||||
private static void BuildActionList()
|
||||
{
|
||||
if (_default_actions == null)
|
||||
@@ -272,6 +279,7 @@ public abstract class EC_Player : MonoBehaviour
|
||||
ACT_CASTSKILL // Chỉ là placeholder cho skill actions
|
||||
}
|
||||
|
||||
public float GetTouchRadius(){ return m_fTouchRad; }
|
||||
}
|
||||
public struct PlayActionEvent
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user