fix: update normal atk.

This commit is contained in:
Tungdv
2025-10-08 19:32:05 +07:00
parent ddcc5c22d1
commit ff1e2dd89e
15 changed files with 1339 additions and 197 deletions
+119 -16
View File
@@ -1,4 +1,5 @@
using BrewMonster.Network;
using BrewMonster;
using BrewMonster.Network;
using CSNetwork;
using CSNetwork.GPDataType;
using CSNetwork.Protocols;
@@ -30,10 +31,17 @@ public class CECHostPlayer : EC_Player
PlayerStateMachine _playerStateMachine;
PlayerMoveState _moveState;
PlayerIdleState _idleState;
CECHostMove m_MoveCtrl;
public CECHostMove m_MoveCtrl;
CECHPWorkMan m_pWorkMan; // Host work manager
uint m_dwLIES; // Logic-influence extend states
FACTION_FORTRESS_ENTER m_fortressEnter; // ½øÈë»ùµØÐÅÏ¢
PVPINFO m_pvp; // pvp information
bool m_bInSanctuary = false; // true, player is in sanctuary
int m_idFaction = 0; // ID of player's faction
public bool m_bPrepareFight = false; // true, prepare to fight
int m_iJumpCount = 0;
bool m_bJumpInWater = false;
float playerSpeed = 5.0f;
float jumpHeight = 1.5f;
@@ -43,6 +51,9 @@ public class CECHostPlayer : EC_Player
bool isGrounded = false;
bool isRun = false;
Vector3 m_vLastSevPos;
public CDR_INFO m_CDRInfo;
public GNDINFO m_GndInfo;
public float m_fVertSpeed = 0f;
// ====== Ground cast config ======
[Header("Ground Cast")]
@@ -330,7 +341,7 @@ public class CECHostPlayer : EC_Player
}
private void SetPos(Vector3 pos)
public void SetPos(Vector3 pos)
{
transform.position = pos;
}
@@ -532,7 +543,7 @@ public class CECHostPlayer : EC_Player
if (idTarget == 0 || idTarget == m_PlayerInfo.cid)
return -1;
CECObject pObject = g_pGame.GetGameRun().GetWorld().GetObject(idTarget, 1);
CECObject pObject = EC_ManMessageMono.Instance.GetObject(idTarget, 1);
if (!pObject)
return -1;
@@ -541,18 +552,18 @@ public class CECHostPlayer : EC_Player
{
CECNPC pNPC = (CECNPC)pObject;
int idMaster = pNPC.GetMasterID();
if (idMaster)
if (idMaster != 0)
{
// master¿ÉÄÜÊÇhostplayer
if (idMaster == m_PlayerInfo.cid)
return 0;
// Follow pet cannot be attacked
if (pNPC.IsPetNPC() && ((CECPet)pNPC).IsFollowPet())
return 0;
//// Follow pet cannot be attacked
//if (pNPC.IsPetNPC() && ((CECPet)pNPC).IsFollowPet())
// return 0;
idTarget = idMaster;
pObject = g_pGame.GetGameRun().GetWorld().GetObject(idTarget, 1);
pObject = EC_ManMessageMono.Instance.GetObject(idTarget, 1);
if (!pObject)
return -1;
}
@@ -565,12 +576,12 @@ public class CECHostPlayer : EC_Player
CECNPC pNPC = (CECNPC)pObject;
// If this npc is host's pet, cannot be attacked
if (pNPC.GetMasterID() == m_PlayerInfo.cid)
return 0;
//if (pNPC.GetMasterID() == m_PlayerInfo.cid)
// return 0;
// If it's a pet and can not be attacked, pet can be attacked only if it's a fighting pet
if (pNPC.IsPetNPC() && !((CECPet)pNPC).CanBeAttacked())
return 0;
//if (pNPC.IsPetNPC() && !((CECPet)pNPC).CanBeAttacked())
// return 0;
if (IsInBattle()) // Host is in battle
{
@@ -613,9 +624,9 @@ public class CECHostPlayer : EC_Player
//else if (GPDataTypeHelper.ISPLAYERID(idTarget))
//{
// // Check duel at first
// if (m_pvp.iDuelState == DUEL_ST_INDUEL && m_pvp.idDuelOpp == idTarget)
// if (m_pvp.iDuelState == Duel_state.DUEL_ST_INDUEL && m_pvp.idDuelOpp == idTarget)
// return 1;
// else if (m_pvp.iDuelState == DUEL_ST_STOPPING && m_pvp.idDuelOpp == idTarget)
// else if (m_pvp.iDuelState == Duel_state.DUEL_ST_STOPPING && m_pvp.idDuelOpp == idTarget)
// return 0;
// // In sanctuary we cannot attack other players
@@ -691,6 +702,8 @@ public class CECHostPlayer : EC_Player
return Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
}
public int GetCharacterID(){ return m_PlayerInfo.cid; }
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)
@@ -758,11 +771,63 @@ public class CECHostPlayer : EC_Player
A3DVECTOR3 vector = new A3DVECTOR3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
return CanTouchTarget(vector, vTargetPos, fTargetRad, iReason, fMaxCut);
}
bool IsRooting() {
public bool IsRooting() {
var mask = (uint)(Logic_Influence_Extned_states.LIES_ROOT
| Logic_Influence_Extned_states.LIES_SLEEP
| Logic_Influence_Extned_states.LIES_STUN);
return (m_dwLIES & mask) != 0; }
bool IsInFortress() { return m_fortressEnter.role_in_war != 0; }
bool IsPVPOpen() { return m_pvp.bEnable; }
// Get faction ID
int GetFactionID(){ return m_idFaction; }
public bool IsJumping() { return m_iJumpCount > 0; }
public bool IsPlayingAction(int iAction)
{
if (iAction == (int)PLAYER_ACTION_TYPE.ACT_WALK && _playerStateMachine.State is PlayerMoveState)
{
return true;
}
if (iAction == (int)PLAYER_ACTION_TYPE.ACT_STAND && _playerStateMachine.State is PlayerIdleState)
{
return true;
}
return false;
}
public void ResetJump() { m_iJumpCount = 0; m_bJumpInWater = false; }
// Get move speed
public float GetFlySpeed() { return m_ExtProps.mv.flight_speed; }
public float GetSwimSpeed() { return m_ExtProps.mv.swim_speed; }
//public float GetSwimSpeedSev()
//{
// float fSpeedSev = GetSwimSpeed();
// while (true)
// {
// if (!IsUnderWater()) break;
// //CECWorld* pWorld = g_pGame->GetGameRun()->GetWorld();
// //if (!pWorld) break;
// const A3DVECTOR3 vPos = GetPos();
// float fTerrainHeight = pWorld->GetTerrainHeight(vPos);
// float fWaterHeight = pWorld->GetWaterHeight(vPos);
// if (fWaterHeight <= fTerrainHeight) break;
// float fBorderLine = fWaterHeight - 2.0f;
// if (vPos.y <= fBorderLine) break;
// // ·þÎñÆ÷¶Ë½«Ë®ÃæÒÔÏÂ2Ã×ÒÔÉÏ´¦ÀíΪ run_speed£¨ÓÐÎÊÌ⣩
// // µ«Î´Ê¹ÓüÓËÙ¼¼ÄÜʱ swim_speed СÓÚ run_speed£¬
// // ¿ÉÒÔÔÚË®ÃæÒÔÏÂ2Ã×ÒÔÉÏ»ñÈ¡³¬¹ý swim_speed µÄËÙ¶È£¬Òò´Ë£¬´Ë´¦È¡Á½Õß½ÏСֵΪºÏÀí×ö·¨
// fSpeedSev = min(m_ExtProps.mv.run_speed, fSpeedSev);
// break;
// }
// return fSpeedSev;
//}
}
public enum StateAnim
@@ -785,3 +850,41 @@ public enum Logic_Influence_Extned_states
LIES_DISABLEFIGHT = 0x000B,
}
// ½øÈë»ùµØÐÅÏ¢
public struct FACTION_FORTRESS_ENTER
{
public int faction_id;
public int role_in_war; // 0 : ÖÐÁ¢»ò²»ÔÚ»ùµØ 1:¹¥·½ 2: ÊØ·½
public int end_time;
public FACTION_FORTRESS_ENTER(int faction_id, int role_in_war, int end_time)
{
this.faction_id = faction_id;
this.role_in_war = role_in_war;
this.end_time = end_time;
}
}
// PVP infomation
public struct PVPINFO
{
public bool bEnable; // PVP switch
public uint dwCoolTime;
public uint dwMaxCoolTime;
public bool bFreePVP; // Free PVP flag, ignore bEnable flag
public bool bInPVPCombat; // true, in PVP combat
public int iDuelState; // Duel state
public int idDuelOpp; // Duel opponent
public int iDuelTimeCnt; // Duel time counter
public int iDuelRlt; // Duel result. 0, no defined; 1-win; 2-lose; 3-draw
};
// Current ground information
public struct GNDINFO
{
public float fGndHei; // Ground height
public float fWaterHei; // Water height
public A3DVECTOR3 vGndNormal; // Terrain normal
public bool bOnGround; // On ground flag
};