feat: add struct for normal atk.
This commit is contained in:
+200
-12
@@ -10,7 +10,6 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -32,6 +31,9 @@ public class CECHostPlayer : EC_Player
|
||||
PlayerIdleState _idleState;
|
||||
CECHostMove m_MoveCtrl;
|
||||
|
||||
CECHPWorkMan m_pWorkMan; // Host work manager
|
||||
uint m_dwLIES; // Logic-influence extend states
|
||||
|
||||
float playerSpeed = 5.0f;
|
||||
float jumpHeight = 1.5f;
|
||||
float gravityValue = -9.81f;
|
||||
@@ -361,6 +363,13 @@ public class CECHostPlayer : EC_Player
|
||||
{
|
||||
visual.InitHostPlayerEventDoneHandler();
|
||||
}
|
||||
|
||||
// Create work manager
|
||||
m_pWorkMan = new CECHPWorkMan(this);
|
||||
if (m_pWorkMan == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void JoystickStartDrag(JoystickPressEvent joystickPressEvent)
|
||||
@@ -397,7 +406,7 @@ public class CECHostPlayer : EC_Player
|
||||
//cmd_task_data* pCmd = (cmd_task_data*)Msg.dwParam1;
|
||||
//ASSERT(pCmd);
|
||||
|
||||
//int iActiveListSize = (int)pCmd->active_list_size;
|
||||
//int iActiveListSize = (int)pCmd.active_list_size;
|
||||
//BYTE* pData = (BYTE*)pCmd + sizeof(size_t);
|
||||
//void* pActiveListbuf = pData;
|
||||
//pData += iActiveListSize;
|
||||
@@ -437,16 +446,16 @@ public class CECHostPlayer : EC_Player
|
||||
//m_pTaskInterface.CheckPQEnterWorldInit();
|
||||
|
||||
//// check if player has equipped goblin
|
||||
//if (m_pEquipPack->GetItem(EQUIPIVTR_GOBLIN) != NULL)
|
||||
//if (m_pEquipPack.GetItem(EQUIPIVTR_GOBLIN) != NULL)
|
||||
//{
|
||||
// CECIvtrGoblin* pIvtrGoblin = (CECIvtrGoblin*)m_pEquipPack->GetItem(EQUIPIVTR_GOBLIN);
|
||||
// CECIvtrGoblin* pIvtrGoblin = (CECIvtrGoblin*)m_pEquipPack.GetItem(EQUIPIVTR_GOBLIN);
|
||||
// m_pGoblin = new CECHostGoblin();
|
||||
// m_pGoblin->Init(pIvtrGoblin->GetTemplateID(), pIvtrGoblin, this);
|
||||
// m_pGoblin.Init(pIvtrGoblin.GetTemplateID(), pIvtrGoblin, this);
|
||||
//}
|
||||
|
||||
//// Note: this command now is also used as the end flag of responding
|
||||
//// for GET_ALL_DATA request
|
||||
//g_pGame->GetGameSession()->LoadConfigData();
|
||||
//g_pGame.GetGameSession().LoadConfigData();
|
||||
|
||||
//// ¸ù¾Ý×°±¸°ü¹ü¸üÐÂ×°±¸¼¼Äܵ½¼¼ÄÜÁбí
|
||||
//if (UpdateEquipSkills())
|
||||
@@ -457,7 +466,7 @@ public class CECHostPlayer : EC_Player
|
||||
//cmd_task_var_data* pCmd = (cmd_task_var_data*)Msg.dwParam1;
|
||||
//ASSERT(pCmd);
|
||||
//if (m_pTaskInterface)
|
||||
// OnServerNotify(m_pTaskInterface, pCmd->data, pCmd->size);
|
||||
// OnServerNotify(m_pTaskInterface, pCmd.data, pCmd.size);
|
||||
//else
|
||||
// ASSERT(m_pTaskInterface);
|
||||
}
|
||||
@@ -471,22 +480,22 @@ public class CECHostPlayer : EC_Player
|
||||
// We should have check target isn't dead
|
||||
return false;
|
||||
}
|
||||
//if (!g_pGame->GetGameRun()->GetWorld()->GetObject(idTarget, 1))
|
||||
//if (!g_pGame.GetGameRun().GetWorld().GetObject(idTarget, 1))
|
||||
// return false;
|
||||
bool bStartNewWork = false;
|
||||
|
||||
bool bUseAutoPF = false;
|
||||
//CECPlayerWrapper* pWrapper = CECAutoPolicy::GetInstance().GetPlayerWrapper();
|
||||
//if (CECAutoPolicy::GetInstance().IsAutoPolicyEnabled() && pWrapper->GetAttackError() >= 2)
|
||||
//if (CECAutoPolicy::GetInstance().IsAutoPolicyEnabled() && pWrapper.GetAttackError() >= 2)
|
||||
bUseAutoPF = true;
|
||||
|
||||
CECHPWorkTrace pWorkTrace = null;
|
||||
CECHPWork pWork = null;
|
||||
if (pWork = m_pWorkMan.GetWork(CECHPWork.Host_work_ID.WORK_TRACEOBJECT))
|
||||
if ((pWork = m_pWorkMan.GetWork(CECHPWork.Host_work_ID.WORK_TRACEOBJECT)) != null)
|
||||
{
|
||||
pWorkTrace = pWork as CECHPWorkTrace;
|
||||
}
|
||||
else if (pWork = m_pWorkMan.GetWork(CECHPWork.Host_work_ID.WORK_HACKOBJECT))
|
||||
else if ((pWork = m_pWorkMan.GetWork(CECHPWork.Host_work_ID.WORK_HACKOBJECT)) != null)
|
||||
{
|
||||
if ((pWork as CECHPWorkMelee).GetTarget() == idTarget)
|
||||
return false; // Host is attacking the target
|
||||
@@ -500,7 +509,7 @@ public class CECHostPlayer : EC_Player
|
||||
bStartNewWork = true;
|
||||
}
|
||||
|
||||
if (pWorkTrace)
|
||||
if (pWorkTrace != null)
|
||||
{
|
||||
pWorkTrace.SetTraceTarget(pWorkTrace.CreatTraceTarget(idTarget, CECHPWorkTrace.Trace_reason.TRACE_ATTACK, bForceAttack), bUseAutoPF);
|
||||
pWorkTrace.SetMoveCloseFlag(bMoreClose);
|
||||
@@ -511,6 +520,172 @@ public class CECHostPlayer : EC_Player
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int AttackableJudge(int idTarget, bool bForceAttack)
|
||||
{
|
||||
if (CannotAttack())
|
||||
return 0;
|
||||
|
||||
//if (CDlgAutoHelp::IsAutoHelp())
|
||||
// return 0;
|
||||
|
||||
if (idTarget == 0 || idTarget == m_PlayerInfo.cid)
|
||||
return -1;
|
||||
|
||||
CECObject pObject = g_pGame.GetGameRun().GetWorld().GetObject(idTarget, 1);
|
||||
if (!pObject)
|
||||
return -1;
|
||||
|
||||
// If target is pet, it's attacked possibility depends on it's monster
|
||||
if (ISNPCID(idTarget))
|
||||
{
|
||||
CECNPC* pNPC = (CECNPC*)pObject;
|
||||
int idMaster = pNPC.GetMasterID();
|
||||
if (idMaster)
|
||||
{
|
||||
// master¿ÉÄÜÊÇhostplayer
|
||||
if (idMaster == m_PlayerInfo.cid)
|
||||
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);
|
||||
if (!pObject)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int iRet = 0;
|
||||
|
||||
if (ISNPCID(idTarget))
|
||||
{
|
||||
CECNPC* pNPC = (CECNPC*)pObject;
|
||||
|
||||
// If this npc is host's pet, cannot be attacked
|
||||
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 (IsInBattle()) // Host is in battle
|
||||
{
|
||||
if (InSameBattleCamp(pNPC))
|
||||
iRet = 0;
|
||||
else
|
||||
{
|
||||
if (pNPC.IsMonsterNPC())
|
||||
iRet = 1;
|
||||
else if (pNPC.IsServerNPC() && (IsInFortress() || pNPC.GetRoleInBattle() == 8)) // ¶Ô·þÎñÐÍNPCµÄ¹¥»÷£¬°ïÅÉ»ùµØ»ò³Çսʱ¿ÉÓÃ
|
||||
iRet = 1;
|
||||
else
|
||||
iRet = 0;
|
||||
}
|
||||
}
|
||||
else if (pNPC.IsServerNPC())
|
||||
{
|
||||
// In sanctuary we cannot attack NPCs
|
||||
if (!IsPVPOpen() || m_bInSanctuary || !bForceAttack)
|
||||
iRet = 0;
|
||||
else
|
||||
iRet = 1;
|
||||
}
|
||||
else // Is monster
|
||||
{
|
||||
iRet = 1;
|
||||
}
|
||||
if (iRet == 1 && pNPC.GetOwnerFaction() > 0)
|
||||
{
|
||||
// Õë¶Ô°ïÅÉ PVP Õ½ÕùÖнûÖ¹²¿·Ö¹¥»÷
|
||||
if (GetFactionID() == pNPC.GetOwnerFaction() || // ²»¹¥»÷ͬ°ï¹Ö
|
||||
pNPC.IsFactionPVPMineCar() && !CanAttackFactionPVPMineCar() || // ÎÞ·¨ÔÙ¹¥»÷Ëû°ï¿ó³µÇé¿ö
|
||||
pNPC.IsFactionPVPMineBase() && !CanAttackFactionPVPMineBase())
|
||||
{ // ÎÞ·¨ÔÙ¹¥»÷Ëû°ï´æ¿óµãÇé¿ö
|
||||
iRet = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ISPLAYERID(idTarget))
|
||||
{
|
||||
// Check duel at first
|
||||
if (m_pvp.iDuelState == DUEL_ST_INDUEL && m_pvp.idDuelOpp == idTarget)
|
||||
return 1;
|
||||
else if (m_pvp.iDuelState == DUEL_ST_STOPPING && m_pvp.idDuelOpp == idTarget)
|
||||
return 0;
|
||||
|
||||
// In sanctuary we cannot attack other players
|
||||
if (m_bInSanctuary)
|
||||
return 0;
|
||||
|
||||
ASSERT(pObject.GetClassID() == CECObject::OCID_ELSEPLAYER);
|
||||
CECElsePlayer* pPlayer = (CECElsePlayer*)pObject;
|
||||
const ROLEBASICPROP&bp = pPlayer.GetBasicProps();
|
||||
const EC_GAME_SETTING&gs = g_pGame.GetConfigs().GetGameSettings();
|
||||
|
||||
if (m_pvp.bFreePVP)
|
||||
{
|
||||
if (IsTeamMember(idTarget))
|
||||
return 0;
|
||||
|
||||
// In free pvp mode, for example, host is in arena.
|
||||
if (bForceAttack)
|
||||
iRet = 1;
|
||||
else if (gs.bAtk_NoMafia && IsFactionMember(pPlayer.GetFactionID()))
|
||||
iRet = 0;
|
||||
else if (gs.bAtk_NoWhite && !pPlayer.IsInvader() && !pPlayer.IsPariah())
|
||||
iRet = 0;
|
||||
else if (gs.bAtk_NoAlliance && g_pGame.GetFactionMan().IsFactionAlliance(pPlayer.GetFactionID()))
|
||||
iRet = 0;
|
||||
else if (gs.bAtk_NoForce && GetForce() > 0 && GetForce() == pPlayer.GetForce())
|
||||
iRet = 0;
|
||||
else
|
||||
iRet = 1;
|
||||
}
|
||||
else if (m_iBattleCamp != GP_BATTLE_CAMP_NONE)
|
||||
{
|
||||
// Host is in battle
|
||||
int iCamp = pPlayer.GetBattleCamp();
|
||||
if (iCamp != GP_BATTLE_CAMP_NONE && iCamp != m_iBattleCamp)
|
||||
iRet = 1;
|
||||
else
|
||||
iRet = 0;
|
||||
}
|
||||
else // Normal mode
|
||||
{
|
||||
if (IsTeamMember(idTarget))
|
||||
return 0;
|
||||
|
||||
if (!IsPVPOpen() || !pPlayer.IsPVPOpen() || m_BasicProps.iLevel < EC_MAXNOPKLEVEL || bp.iLevel < EC_MAXNOPKLEVEL)
|
||||
iRet = 0;
|
||||
else if (bForceAttack)
|
||||
iRet = 1;
|
||||
else if (!gs.bAtk_Player)
|
||||
iRet = 0;
|
||||
else if (gs.bAtk_NoMafia && IsFactionMember(pPlayer.GetFactionID()))
|
||||
iRet = 0;
|
||||
else if (gs.bAtk_NoWhite && !pPlayer.IsInvader() && !pPlayer.IsPariah())
|
||||
iRet = 0;
|
||||
else if (gs.bAtk_NoAlliance && g_pGame.GetFactionMan().IsFactionAlliance(pPlayer.GetFactionID()))
|
||||
iRet = 0;
|
||||
else if (gs.bAtk_NoForce && GetForce() > 0 && GetForce() == pPlayer.GetForce())
|
||||
iRet = 0;
|
||||
else
|
||||
iRet = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
public bool CannotAttack() { return (m_dwLIES & (uint)Logic_Influence_Extned_states.LIES_DISABLEFIGHT) != 0; }
|
||||
}
|
||||
|
||||
public enum StateAnim
|
||||
@@ -520,3 +695,16 @@ public enum StateAnim
|
||||
Run = 3,
|
||||
Jump = 4
|
||||
}
|
||||
|
||||
// Mask of some special extend states which will influence host game logic.
|
||||
// Logic Influence Extned states
|
||||
[Flags]
|
||||
public enum Logic_Influence_Extned_states
|
||||
{
|
||||
LIES_SLEEP = 0x0001,
|
||||
LIES_STUN = 0x0002,
|
||||
LIES_ROOT = 0x0004,
|
||||
LIES_NOFGIHT = 0x0008,
|
||||
|
||||
LIES_DISABLEFIGHT = 0x000B,
|
||||
}
|
||||
|
||||
@@ -9,10 +9,11 @@ public abstract class EC_Player : MonoBehaviour
|
||||
private static PLAYER_ACTION[] _default_actions;
|
||||
private static PLAYER_ACTION[] _turning_actions;
|
||||
PLAYER_ACTION[] m_PlayerActions;
|
||||
[SerializeField] protected INFO m_PlayerInfo;
|
||||
[SerializeField] internal INFO m_PlayerInfo;
|
||||
protected GameObject m_pPlayerModel;
|
||||
protected float rotationSpeed = 5;
|
||||
protected int m_iMoveMode; // Player's move mode
|
||||
internal int m_iMoveMode; // Player's move mode
|
||||
internal int m_idSelTarget; // Ñ¡ÖÐÄ¿±êµÄID
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user