diff --git a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs index 38e4576d16..86a83d1621 100644 --- a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs +++ b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs @@ -4870,7 +4870,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // name - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)] public uint[] action_mask; // fashion weapon action masks } diff --git a/Assets/PerfectWorld/Scripts/Managers/CECAttacksMan.cs b/Assets/PerfectWorld/Scripts/Managers/CECAttacksMan.cs new file mode 100644 index 0000000000..871ec70191 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Managers/CECAttacksMan.cs @@ -0,0 +1,219 @@ +using BrewMonster; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEngine; +using static CECAttacksMan; + +public class CECAttacksMan : MonoSingleton +{ + private readonly List m_AttackList = new List(); + + public CECAttackerEvents FindAttackByAttacker(int idHost) + { + CECAttackerEvents result = new CECAttackerEvents(); + + foreach (var attack in m_AttackList) + { + if (attack.m_idHost == idHost) + { + result.Add(attack); + } + } + + return result; + } + + public CECAttackEvent AddMeleeAttack(int idHost, int idTarget, int idWeapon, uint dwModifier, int nDamage, int nTimeFly = 10) + { + var newEvent = new CECAttackEvent( + this, + idHost, + 0, // idCastTarget + idTarget, + idWeapon, + 0, // idSkill + 0, // nSkillLevel + dwModifier, + nDamage, + 200, // timeToBeFired + nTimeFly // timeToDoDamage + ); + m_AttackList.Add(newEvent); + + newEvent.UpdateTargetFlag(); + return m_AttackList[m_AttackList.Count - 1]; + } + + public CECAttackEvent AddSkillAttack(int idHost, int idCastTarget, int idTarget, int idWeapon, int idSkill, int nSkillLevel, uint dwModifier, int nDamage) + { + var newEvent = new CECAttackEvent( + this, + idHost, + idCastTarget, + idTarget, + idWeapon, + idSkill, + nSkillLevel, + dwModifier, + nDamage, + 200, // timeToBeFired + 1000 // timeToDoDamage + ); + m_AttackList.Add(newEvent); + + newEvent.UpdateTargetFlag(); + return m_AttackList[m_AttackList.Count - 1]; + } + + // === thêm tạm để code có thể compile === + public void AddAttack(CECAttackEvent evt) + { + m_AttackList.Add(evt); + } + public class TARGET_DATA + { + public int idTarget; + public uint dwModifier; + public int nDamage; + } + + +} +public class CECAttackEvent +{ + public CECAttacksMan? m_pManager; + + public bool m_bSignaled; + public bool m_bDoFired; + public bool m_bDoDamaged; + public bool m_bFinished; + + public uint m_timeLived; + public uint m_timeToBeFired; + public uint m_timeToDoDamage; + + public int m_idHost; + public int m_idCastTarget; + public List m_targets = new List(); + + public int m_idWeapon; + public int m_idSkill; + public int m_nSkillLevel; + public int m_nSkillSection; + + public CECAttackEvent() { } + + public CECAttackEvent(CECAttacksMan? pManager, int idHost, int idCastTarget, int idTarget, + int idWeapon, int idSkill, int nSkillLevel, uint dwModifier, + int nDamage, int nTimeToBeFired, int nTimeToDoDamage) + { + m_pManager = pManager; + m_idHost = idHost; + m_idCastTarget = idCastTarget; + m_idWeapon = idWeapon; + m_idSkill = idSkill; + m_nSkillLevel = nSkillLevel; + m_timeToBeFired = (uint)nTimeToBeFired; + m_timeToDoDamage = (uint)nTimeToDoDamage; + + AddTarget(idTarget, dwModifier, nDamage); + } + + public bool AddTarget(int idTarget, uint dwModifier, int nDamage) + { + m_targets.Add(new TARGET_DATA + { + idTarget = idTarget, + dwModifier = dwModifier, + nDamage = nDamage + }); + return true; + } + public bool UpdateTargetFlag() + { + // update all targets' bAboutToDie flag + + int nNumTargets = m_targets.Count; + for (int i = 0; i < nNumTargets; i++) + { + TARGET_DATA data = m_targets[i]; + /* + if( data.dwModifier & MOD_DEADLYSTRIKE ) + { + int idTarget = data.idTarget; + if (ISNPCID(idTarget)) + { + CECNPC* pNPC = g_pGame->GetGameRun()->GetWorld()->GetNPCMan()->GetNPC(idTarget); + if (!pNPC) + return true; + + pNPC->SetAboutToDie(true); + } + else if (ISPLAYERID(idTarget)) + { + CECPlayer* pPlayer = g_pGame->GetGameRun()->GetWorld()->GetPlayerMan()->GetPlayer(idTarget); + if (!pPlayer) + return true; + + pPlayer->SetAboutToDie(true); + } + }*/ + } + + return true; + } +} +public class CECAttackerEvents +{ + private readonly List m_list = new List(); + + public void Add(CECAttackEvent? evt) + { + if (evt != null) + m_list.Add(evt); + } + + public bool IsEmpty() => m_list.Count == 0; + public int Count() => m_list.Count; + + public CECAttackEvent? Find(int idSkill = 0, int nSkillSection = 0) + { + foreach (var evt in m_list) + { + if (evt.m_idSkill == idSkill && evt.m_nSkillSection == nSkillSection) + return evt; + } + return null; + } + + public void Signal() + { + foreach (var evt in m_list) + evt.m_bSignaled = true; + m_list.Clear(); + } + + public static implicit operator bool(CECAttackerEvents events) + { + return !events.IsEmpty(); + } +} +enum MOD + + { + MOD_PHYSIC_ATTACK_RUNE = 0x0001, // ÎïÀí¹¥»÷ÓÅ»¯·ûÉúЧ + MOD_MAGIC_ATTACK_RUNE = 0x0002, // ·¨Êõ¹¥»÷ÓÅ»¯·ûÉúЧ + MOD_PHYSIC_DEFENCE_RUNE = 0x0004, // ÎïÀí·ÀÓùÓÅ»¯·ûÉúЧ + MOD_MAGIC_DEFENCE_RUNE = 0x0008, // ·¨Êõ·ÀÓùÓÅ»¯·ûÉúЧ + MOD_CRITICAL_STRIKE = 0x0010, // ±¬»÷ + MOD_RETORT = 0x0020, // ·´Õð + MOD_NULLITY = 0x0040, // ÎÞЧ¹¥»÷ + MOD_IMMUNE = 0x0080, // ÃâÒßÁ˴˴ι¥»÷£¬ÓÅÏȼ¶¸ßÓÚÎÞЧ + MOD_ENCHANT_FAILED = 0x0100, // enchant ʧ°Ü + MOD_SUCCESS = 0x0200, // ³É¹¦ + MOD_DODGE_DAMAGE = 0x0400, // É˺¦¶ãÉÁ + MOD_DODGE_DEBUFF = 0x0800, // ״̬¶ãÉÁ + MOD_ATTACK_AURA = 0x1000, // ¹â»·¹¥»÷ + MOD_REBOUND = 0x2000, // ·´µ¯ + MOD_BEAT_BACK = 0x4000, // ·´»÷ +}; \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Managers/CECAttacksMan.cs.meta b/Assets/PerfectWorld/Scripts/Managers/CECAttacksMan.cs.meta new file mode 100644 index 0000000000..1de015f587 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Managers/CECAttacksMan.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 92009c5b4b0fd894790865cf674545fa \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkMelee.cs b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkMelee.cs index 126b9e1c93..a9f954569f 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkMelee.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkMelee.cs @@ -148,7 +148,7 @@ class CECHPWorkMelee : CECHPWork protected virtual void OnFirstTick() { m_pHost.m_iMoveMode = (int)MoveMode.MOVE_STAND; - m_pHost.PlayAction((int)EC_Player.PLAYER_ACTION_TYPE.ACT_ATTACK_1 + Random.Range(0, 3), true, 200, false); + m_pHost.PlayAction((int)CECPlayer.PLAYER_ACTION_TYPE.ACT_ATTACK_1 + Random.Range(0, 3), true, 200, false); m_idTarget = m_pHost.m_idSelTarget; } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkTrace.cs b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkTrace.cs index d4a70c39fb..3ad2080f30 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkTrace.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HPWorkTrace.cs @@ -139,7 +139,7 @@ public abstract class CECTracedObject } else { - EC_Player pPlayer = pObject.GetComponent(); + CECPlayer pPlayer = pObject.GetComponent(); fTouchRadius = pPlayer.GetTouchRadius(); } return m_pHost.CanTouchTarget(vHostPos, vTargetPos, fTouchRadius, iTouchReason, fMaxCut); @@ -384,7 +384,7 @@ public class CECTracedPlayer : CECTracedObject { return true; } - EC_Player pPlayer = GetTargetObject() as EC_Player; + CECPlayer pPlayer = GetTargetObject() as CECPlayer; if (pPlayer.IsElsePlayer()) { if (pPlayer.IsDead()) @@ -612,10 +612,10 @@ public class CECHPWorkTrace : CECHPWork { // Continue tracing object float fDeltaTime = dwDeltaTime /** 0.001f*/; - if (m_pHost.m_iMoveEnv == EC_Player.Move_environment.MOVEENV_GROUND) + if (m_pHost.m_iMoveEnv == CECPlayer.Move_environment.MOVEENV_GROUND) { // Play appropriate actions - if (!m_pHost.IsJumping() && !m_pHost.IsPlayingAction((int)EC_Player.PLAYER_ACTION_TYPE.ACT_TRICK_RUN) && + if (!m_pHost.IsJumping() && !m_pHost.IsPlayingAction((int)CECPlayer.PLAYER_ACTION_TYPE.ACT_TRICK_RUN) && m_pHost.m_iMoveMode != (int)MoveMode.MOVE_SLIDE) { int iAction = m_pHost.GetMoveStandAction(true); @@ -807,7 +807,7 @@ public class CECHPWorkTrace : CECHPWork if (m_pHost.m_iMoveMode == (int)MoveMode.MOVE_SLIDE) { - m_pHost.PlayAction((int)EC_Player.PLAYER_ACTION_TYPE.ACT_JUMP_LOOP, false, 200, false); + m_pHost.PlayAction((int)CECPlayer.PLAYER_ACTION_TYPE.ACT_JUMP_LOOP, false, 200, false); // This will cause stop moming after we slide down. A3DVECTOR3 vDir = vTargetPos - vCurPos; diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs b/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs index 0db2223156..08ccef2f90 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs @@ -470,7 +470,7 @@ namespace PerfectWorld.Scripts.Managers } // Get a player (may be host or else player) by id - public EC_Player GetPlayer(int cid, uint dwBornStamp = 0) + public CECPlayer GetPlayer(int cid, uint dwBornStamp = 0) { CECHostPlayer pHost = GetHostPlayer(); if (pHost && pHost.GetCharacterID() == cid) diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_Object.cs b/Assets/PerfectWorld/Scripts/Managers/EC_Object.cs index f6f58bbfb4..7e17d81164 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_Object.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_Object.cs @@ -185,7 +185,7 @@ public class CECObject : MonoBehaviour return 0; if (pObject.IsPlayer()) - return ((EC_Player)pObject).GetCharacterID(); + return ((CECPlayer)pObject).GetCharacterID(); else if (pObject.IsNPC()) return ((CECNPC)pObject).GetNPCID(); //else if (pObject.IsMatter()) diff --git a/Assets/PerfectWorld/Scripts/Move/CECHostMove.cs b/Assets/PerfectWorld/Scripts/Move/CECHostMove.cs index b38926fe57..5825457d0b 100644 --- a/Assets/PerfectWorld/Scripts/Move/CECHostMove.cs +++ b/Assets/PerfectWorld/Scripts/Move/CECHostMove.cs @@ -85,7 +85,7 @@ public class CECHostMove float fSpeed = 0f; switch (m_pHost.GetMoveEnv()) { - case EC_Player.Move_environment.MOVEENV_AIR: + case CECPlayer.Move_environment.MOVEENV_AIR: iMoveMode |= (int)GPMoveMode.GP_MOVE_AIR; fSpeed = m_pHost.GetFlySpeed(); diff --git a/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs b/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs index dd27f381f5..7e35ab349b 100644 --- a/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs +++ b/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs @@ -5,9 +5,10 @@ using PerfectWorld.Scripts.Managers; using PerfectWorld.Scripts.Player; using System; using System.Collections.Generic; +using Unity.VisualScripting; using UnityEngine; -public abstract class EC_Player : CECObject +public abstract class CECPlayer : CECObject { private static PLAYER_ACTION[] _default_actions; private static PLAYER_ACTION[] _turning_actions; @@ -29,6 +30,12 @@ public abstract class EC_Player : CECObject public int m_iMoveEnv = Move_environment.MOVEENV_GROUND; // Move environment public bool m_bWalkRun; public A3DAABB m_aabbServer; // Óë·þÎñÆ÷±£³ÖÒ»ÖµÄaabb£¬ ²»ÊÜËõ·ÅÓ°Ïì + + + const int NUM_WEAPON_TYPE = 15; + + + protected void Awake() { m_PlayerActions = _default_actions; @@ -52,12 +59,9 @@ public abstract class EC_Player : CECObject 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; } -<<<<<<<< HEAD:Assets/PerfectWorld/Scripts/Move/CECPlayer.cs public int GetCharacterID() { return m_PlayerInfo.cid; } -======== ->>>>>>>> origin/develop:Assets/PerfectWorld/Scripts/Move/EC_Player.cs private static void BuildActionList() { if (_default_actions == null) @@ -297,7 +301,288 @@ public abstract class EC_Player : CECObject ACT_MAX, ACT_CASTSKILL // Chỉ là placeholder cho skill actions } + /* public void PlayAttackEffect(int idTarget, int idSkill, int skillLevel, int nDamage, + uint dwModifier, int nAttackSpeed, ref int piAttackTime*//* NULL *//*, int nSection = 0) + { + if (!IsAllResReady()) + return; + if (idSkill == 0) + { + int idWeapon = IsShapeChanged() ? 0 : GetWeaponID(); + + int nTimeFly = 10; + if (idWeapon != 0) + { + // ¿´¿´ÊDz»ÊÇÔ¶³ÌÎäÆ÷ + DATA_TYPE dt = default; + WEAPON_ESSENCE? pWeapon = (WEAPON_ESSENCE)ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)idWeapon, ID_SPACE.ID_SPACE_ESSENCE, ref dt); + + if (dt == DATA_TYPE.DT_WEAPON_ESSENCE && pWeapon != null && pWeapon.Value.require_projectile != 0) + { + nTimeFly = 700; + + if (m_aEquips[(int)EC_IvtrType.IndexOfIteminEquipmentInventory.EQUIPIVTR_PROJECTILE] != 0) + idWeapon = m_aEquips[(int)EC_IvtrType.IndexOfIteminEquipmentInventory.EQUIPIVTR_PROJECTILE]; + } + } + + if (CECAttacksMan.Instance.FindAttackByAttacker(GetPlayerInfo().cid)) + { + // Unity animation làm hộ r + //ClearComActFlagAllRankNodes(true); + } + + // melee attack + CECAttackEvent pAttack = CECAttacksMan.Instance.AddMeleeAttack( + GetPlayerInfo().cid, idTarget, idWeapon, dwModifier, nDamage, nTimeFly); + + if (pAttack != null) + { + if (!IsDead() && (dwModifier & (uint)MOD.MOD_RETORT) == 0 + && (dwModifier & (uint)MOD.MOD_ATTACK_AURA) == 0 + && PlayAttackAction(nAttackSpeed, piAttackTime, pAttack.m_bSignaled) + && (dwModifier & (uint)MOD.MOD_BEAT_BACK) == 0) + { + } + else + { + pAttack.m_bSignaled = true; + } + } + } + else + { + if (skillLevel == 0) + { + if (m_pCurSkill) + skillLevel = m_pCurSkill->GetSkillLevel(); + else + skillLevel = 1; + } + + CECAttackEvent* pAttack = NULL; + + // first try to find if there is already a skill attack event in attackman + CECAttackerEvents attackerEvents = g_pGame->GetGameRun()->GetWorld()->GetAttacksMan()->FindAttackByAttacker(GetPlayerInfo().cid); + if (attackerEvents) + { + if (CECAttackEvent * pAttack = attackerEvents.Find(idSkill, nSection)) + { + // Ãæ¹¥»÷µÄ·ÇµÚÒ»´ÎÉ˺¦ÏûÏ¢ + pAttack->AddTarget(idTarget, dwModifier, nDamage); + goto EXIT; + } + else + { + attackerEvents.Signal(); + } + } + if (GNET::ElementSkill::IsGoblinSkill(idSkill) && + GNET::ElementSkill::GetType(idSkill) == 2) + { + pAttack = g_pGame->GetGameRun()->GetWorld()->GetAttacksMan()->AddSkillAttack( + GetPlayerInfo().cid, GetPlayerInfo().cid, idTarget, GetWeaponID(), idSkill, skillLevel, dwModifier, nDamage); + } + else + { + // begin a skill attack + pAttack = g_pGame->GetGameRun()->GetWorld()->GetAttacksMan()->AddSkillAttack( + GetPlayerInfo().cid, m_idCurSkillTarget, idTarget, GetWeaponID(), idSkill, skillLevel, dwModifier, nDamage); + } + + if (pAttack) + { + pAttack->SetSkillSection(nSection); + if (!IsDead() && (dwModifier & CECAttackEvent::MOD_RETORT) == 0 + && (dwModifier & CECAttackEvent::MOD_ATTACK_AURA) == 0 + && PlaySkillAttackAction(idSkill, nAttackSpeed, NULL, nSection, &pAttack->m_bSignaled) + && (dwModifier & CECAttackEvent::MOD_BEAT_BACK) == 0) + { + } + else + { + pAttack->m_bSignaled = true; + } + } + + EXIT: + // For skill attacking, time is always set to 0 + if (piAttackTime) + *piAttackTime = 0; + } + } + public bool PlayAttackAction(int nAttackSpeed, out int attackTime, ref bool? pActFlag) + { + attackTime = 0; + + if (m_pPlayerModel == null) + return false; + + int nRand = UnityEngine.Random.Range(0, 4); + string szAct = string.Empty; + + int weapon_type = GetShowingWeaponType(); + + int nTime1, nTime2; + int iAction = ACT_ATTACK_1 + nRand; + PLAYER_ACTION action = m_PlayerActions[iAction]; + + if (action.data == null || string.IsNullOrEmpty(action.data.action_prefix)) + return false; + + ShowWeaponByConfig(action.data); + + var pRightHandWeapon = GetRightHandWeapon(); + bool bHideFX = !CECOptimize.Instance.GFX.CanShowAttack(GetCharacterID(), GetClassID()); + + // ============================== + // Ground Attack + // ============================== + if (GetMoveEnv() == MOVEENV_GROUND) + { + // “起” 动作(挥起) + szAct = $"{action.data.action_prefix}_{action.data.action_weapon_suffix[weapon_type].suffix}Æð"; + PlayNonSkillActionWithName(iAction, szAct, true, 200, bHideFX, ref pActFlag, COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX); + + if (pRightHandWeapon != null && IsUsingMagicWeapon()) + pRightHandWeapon.PlayActionByName(_GenWeaponActionName(szAct, m_iGender), 1.0f, true, 200, true, iAction, bHideFX); + + nTime1 = m_pPlayerModel.GetComActTimeSpanByName(szAct); + + // “收” 动作(挥下) + szAct = $"{action.data.action_prefix}_{action.data.action_weapon_suffix[weapon_type].suffix}Âä"; + QueueNonSkillActionWithName(iAction, szAct, 0, false, bHideFX); + + if (pRightHandWeapon != null && IsUsingMagicWeapon()) + pRightHandWeapon.QueueAction(_GenWeaponActionName(szAct, m_iGender), 0, iAction, false, false, bHideFX); + + nTime2 = m_pPlayerModel.GetComActTimeSpanByName(szAct); + } + // ============================== + // Air Attack + // ============================== + else + { + string szActionMiddleName; + + if ((m_wingType == WINGTYPE_WING && IsFlying()) || + GetProfession() == PROF_ANGEL || + GetProfession() == PROF_ARCHOR || + GetProfession() == PROF_MONK || + GetProfession() == PROF_GHOST) + { + szActionMiddleName = "¿ÕÖгá°ò"; // tấn công trên không + } + else + { + szActionMiddleName = "¿ÕÖзɽ£"; // rơi xuống hoặc bay + } + + szAct = $"{action.data.action_prefix}_{szActionMiddleName}_{action.data.action_weapon_suffix[weapon_type].suffix}Æð"; + PlayNonSkillActionWithName(iAction, szAct, true, 200, bHideFX, ref pActFlag, COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX); + + if (pRightHandWeapon != null && IsUsingMagicWeapon()) + pRightHandWeapon.PlayActionByName(_GenWeaponActionName(szAct, m_iGender), 1.0f, true, 200, true, iAction, bHideFX); + + nTime1 = m_pPlayerModel.GetComActTimeSpanByName(szAct); + + szAct = $"{action.data.action_prefix}_{szActionMiddleName}_{action.data.action_weapon_suffix[weapon_type].suffix}Âä"; + QueueNonSkillActionWithName(iAction, szAct, 0, false, bHideFX); + + if (pRightHandWeapon != null && IsUsingMagicWeapon()) + pRightHandWeapon.QueueAction(_GenWeaponActionName(szAct, m_iGender), 0, iAction, false, false, bHideFX); + + nTime2 = m_pPlayerModel.GetComActTimeSpanByName(szAct); + } + + // ============================== + // Kết thúc bằng FightStand + // ============================== + PLAYER_ACTION stand_action = m_PlayerActions[ACT_FIGHTSTAND]; + szAct = $"{stand_action.data.action_prefix}_{stand_action.data.action_weapon_suffix[weapon_type].suffix}"; + + QueueNonSkillActionWithName(ACT_FIGHTSTAND, szAct, 300, false, bHideFX, true); + + if (pRightHandWeapon != null && IsUsingMagicWeapon()) + pRightHandWeapon.QueueAction(_GenWeaponActionName(szAct, m_iGender), 300, iAction, false, false, bHideFX, true); + + // ============================== + // Điều chỉnh tốc độ phát animation theo tốc độ tấn công + // ============================== + if (nAttackSpeed > 0) + { + float vScale = (nTime1 + nTime2) / (float)nAttackSpeed; + if (vScale > 0f) + { + m_pPlayerModel.SetPlaySpeed(vScale); + + if (pRightHandWeapon != null && IsUsingMagicWeapon()) + pRightHandWeapon.SetPlaySpeed(vScale); + } + } + + attackTime = nTime1 + nTime2; + + // ============================== + // Cập nhật vị trí weapon hanger (vũ khí) + // ============================== + UpdateWeaponHangerPosByAction(iAction); + + return true; + } + public int GetShowingWeaponType() + { + int weapon_type = 0; + if (CanShowFashionWeapon(m_uAttackType, m_iFashionWeaponType) && m_aEquips[EQUIPIVTR_FASHION_WEAPON] != 0) + { + weapon_type = (m_iFashionWeaponType == DEFAULT_ACTION_TYPE || !IsWeaponAttached()) ? + 10 : m_iFashionWeaponType; + } + else + { + weapon_type = (m_uAttackType == DEFAULT_ACTION_TYPE || !IsWeaponAttached()) ? + 10 : m_uAttackType; + } + return weapon_type; + } + public bool CanShowFashionWeapon(int weapon_type, int fashion_weapon_type) + { + return IsFashionWeaponTypeFit(weapon_type, fashion_weapon_type) && InFashionMode(); + } + public bool IsFashionWeaponTypeFit(int weapon_type, int fashion_weapon_type) + { + if (fashion_weapon_type < 0 || fashion_weapon_type >= NUM_WEAPON_TYPE) return false; + FASHION_WEAPON_CONFIG? pConfig = GetFashionConfig(); + if (null == pConfig) + { + BMLogger.LogError("CECPlayer::GetFashionConfig, Failed to load fashion weapon config"); + return false; + } + int fashion_weapon_mask = (int)pConfig.Value.action_mask[fashion_weapon_type]; + return (fashion_weapon_mask & (1 << GetWeaponType(weapon_type))) != 0; + } + public FASHION_WEAPON_CONFIG GetFashionConfig() + { + FASHION_WEAPON_CONFIG? pFashionConfig = null; + if (null == pFashionConfig) + { + elementdataman pDataMan = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType; + uint tid = pDataMan.get_first_data_id(ID_SPACE_CONFIG, DataType); + + while (tid) + { + if (DataType == DT_FASHION_WEAPON_CONFIG) + { + pFashionConfig = (FASHION_WEAPON_CONFIG*)pDataMan->get_data_ptr(tid, ID_SPACE_CONFIG, DataType); + break; + } + tid = pDataMan->get_next_data_id(ID_SPACE_CONFIG, DataType); + } + } + return pFashionConfig; + }*/ public float GetTouchRadius() { return m_fTouchRad; } // Is player in battle public bool IsInBattle() { return m_iBattleCamp != Player_camp_in_battle.GP_BATTLE_CAMP_NONE; } @@ -391,16 +676,11 @@ public abstract class EC_Player : CECObject } // Get move environment -<<<<<<<< HEAD:Assets/PerfectWorld/Scripts/Move/CECPlayer.cs public int GetMoveEnv() { return m_iMoveEnv; } public bool IsShapeChanged() { return m_iShape != 0; } public int GetWeaponID() { return m_aEquips[(int)EC_IvtrType.IndexOfIteminEquipmentInventory.EQUIPIVTR_WEAPON] & 0xffff; } public bool IsAllResReady() { return (m_dwResFlags & (uint)PlayerResourcesReadyFlag.RESFG_ALL) == (uint)PlayerResourcesReadyFlag.RESFG_ALL; } -======== - public int GetMoveEnv(){ return m_iMoveEnv; } // Get character ID - public int GetCharacterID(){ return m_PlayerInfo.cid; } ->>>>>>>> origin/develop:Assets/PerfectWorld/Scripts/Move/EC_Player.cs } public struct PlayActionEvent { diff --git a/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs b/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs index 57599c37b2..76741ba3a6 100644 --- a/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs +++ b/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs @@ -74,8 +74,8 @@ namespace BrewMonster if (!(pObject = EC_ManPlayer.GetPlayer(idObject))) return null; - if ((iAliveFlag == 1 && (pObject as EC_Player).IsDead()) || - (iAliveFlag == 2 && !(pObject as EC_Player).IsDead())) + if ((iAliveFlag == 1 && (pObject as CECPlayer).IsDead()) || + (iAliveFlag == 2 && !(pObject as CECPlayer).IsDead())) return null; } //else if (GPDataTypeHelper.ISMATTERID(idObject)) diff --git a/Assets/PerfectWorld/Scripts/PlayerState/PlayerIdleState.cs b/Assets/PerfectWorld/Scripts/PlayerState/PlayerIdleState.cs index dab799fc4a..00f87ae540 100644 --- a/Assets/PerfectWorld/Scripts/PlayerState/PlayerIdleState.cs +++ b/Assets/PerfectWorld/Scripts/PlayerState/PlayerIdleState.cs @@ -1,5 +1,5 @@ using UnityEngine; -using static EC_Player; +using static CECPlayer; public class PlayerIdleState : PlayerState { diff --git a/Assets/PerfectWorld/Scripts/PlayerState/PlayerMoveState.cs b/Assets/PerfectWorld/Scripts/PlayerState/PlayerMoveState.cs index e82e7f53a4..b46ef1e484 100644 --- a/Assets/PerfectWorld/Scripts/PlayerState/PlayerMoveState.cs +++ b/Assets/PerfectWorld/Scripts/PlayerState/PlayerMoveState.cs @@ -1,5 +1,5 @@ using UnityEngine; -using static EC_Player; +using static CECPlayer; public class PlayerMoveState : PlayerState { diff --git a/Assets/PerfectWorld/Scripts/Players/EC_ElsePlayer.cs b/Assets/PerfectWorld/Scripts/Players/EC_ElsePlayer.cs index 58c64ecb0d..5d124ade08 100644 --- a/Assets/PerfectWorld/Scripts/Players/EC_ElsePlayer.cs +++ b/Assets/PerfectWorld/Scripts/Players/EC_ElsePlayer.cs @@ -7,7 +7,7 @@ using UnityEngine; namespace PerfectWorld.Scripts.Player { - public class EC_ElsePlayer : EC_Player + public class EC_ElsePlayer : CECPlayer { A3DVECTOR3 m_vMoveDir; // Player's velocity A3DVECTOR3 m_vServerPos; // Player's real position on server diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 1a6d6af783..97facee398 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -21,7 +21,7 @@ using UnityEngine.SceneManagement; using UnityEngine.UI; using Scene = UnityEngine.SceneManagement.Scene; -public class CECHostPlayer : EC_Player +public class CECHostPlayer : CECPlayer { [SerializeField] private TextMeshPro txtName; [SerializeField] private CharacterController controller; diff --git a/Assets/Scripts/EC_Utility.cs b/Assets/Scripts/EC_Utility.cs index d1ef9f4cfb..ec337ae60d 100644 --- a/Assets/Scripts/EC_Utility.cs +++ b/Assets/Scripts/EC_Utility.cs @@ -4,7 +4,7 @@ using System; using System.Collections; using System.Runtime.InteropServices; using UnityEngine; -using static EC_Player; +using static CECPlayer; public static class EC_Utility { diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index bdd3c803f6..1a1f7dcfe9 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -54,7 +54,7 @@ public class GameController : MonoBehaviour Debug.LogError("null prefab"); return; } - EC_Player.InitStaticRes(); + CECPlayer.InitStaticRes(); hostPlayer = Instantiate(characterPrefab, transform); hostPlayer.InitCharacter(info); cinemachineCamera.Follow = hostPlayer.transform; diff --git a/Assets/Scripts/InitializePlayer.cs b/Assets/Scripts/InitializePlayer.cs index 74f9de84a2..ad87a38c5f 100644 --- a/Assets/Scripts/InitializePlayer.cs +++ b/Assets/Scripts/InitializePlayer.cs @@ -5,11 +5,11 @@ public class InitializePlayer /*: IAutoInitialize*/ { public void Dispose() { - EC_Player.Dispose(); + CECPlayer.Dispose(); } public void Initialize() { - EC_Player.InitStaticRes(); + CECPlayer.InitStaticRes(); } } diff --git a/Assets/Scripts/PlayerVisual.cs b/Assets/Scripts/PlayerVisual.cs index 08fab98c64..1046364ce4 100644 --- a/Assets/Scripts/PlayerVisual.cs +++ b/Assets/Scripts/PlayerVisual.cs @@ -23,7 +23,7 @@ public class PlayerVisual : MonoBehaviour BrewMonster.BMLogger.LogError("animancer == null"); return; } - var player = GetComponentInParent(); + var player = GetComponentInParent(); if(player == null) { BrewMonster.BMLogger.LogError("player == null");