From ef07a39964be49f31d99eab1dfbd45d31fb0a920 Mon Sep 17 00:00:00 2001 From: Tungdv Date: Wed, 28 Jan 2026 19:31:14 +0700 Subject: [PATCH] fix: update logic dlg pet. --- Assets/Addressable/petautoskill.txt | 44 ++ Assets/Addressable/petautoskill.txt.meta | 7 + .../AssetGroups/configuration.asset | 5 + .../PerfectWorld/Scripts/Common/EC_Configs.cs | 2 +- .../PerfectWorld/Scripts/MainFiles/EC_Game.cs | 74 ++- Assets/PerfectWorld/Scripts/Move/CECPlayer.cs | 1 + .../CSNetwork/C2SCommand/C2SCommandFactory.cs | 2 +- .../Scripts/Network/CSNetwork/GPDataType.cs | 123 +++++ .../PerfectWorld/Scripts/Pet/EC_PetCorral.cs | 38 +- .../Scripts/Players/EC_HostMsg.cs | 473 ++++++++++++++++++ .../Scripts/Players/EC_HostMsg.cs.meta | 2 + Assets/PerfectWorld/Scripts/World/CECWorld.cs | 4 + Assets/Scripts/CECGameRun.cs | 1 + Assets/Scripts/CECHostPlayer.cs | 370 +------------- 14 files changed, 759 insertions(+), 387 deletions(-) create mode 100644 Assets/Addressable/petautoskill.txt create mode 100644 Assets/Addressable/petautoskill.txt.meta create mode 100644 Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs create mode 100644 Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs.meta diff --git a/Assets/Addressable/petautoskill.txt b/Assets/Addressable/petautoskill.txt new file mode 100644 index 0000000000..a58f152cd4 --- /dev/null +++ b/Assets/Addressable/petautoskill.txt @@ -0,0 +1,44 @@ +// 宠物出场自动释放技能配置 +// 格式:技能1 技能2 技能3...... + +801 +802 +803 +804 +805 +1559 +1560 +1561 +1562 +1563 +2081 +2077 +2093 +2059 +2094 +2096 +2098 +2100 +2102 +2104 +2106 +2108 +2110 +2112 +2114 +2116 +2062 +2118 +2120 +2121 +2122 +2146 +2124 +2125 +2126 +2058 +2127 +2128 +2136 +2725 +3278 \ No newline at end of file diff --git a/Assets/Addressable/petautoskill.txt.meta b/Assets/Addressable/petautoskill.txt.meta new file mode 100644 index 0000000000..26e46779c7 --- /dev/null +++ b/Assets/Addressable/petautoskill.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8022adc119619b34fb2192efbff367d1 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/AddressableAssetsData/AssetGroups/configuration.asset b/Assets/AddressableAssetsData/AssetGroups/configuration.asset index 6ac918714b..a105de58ec 100644 --- a/Assets/AddressableAssetsData/AssetGroups/configuration.asset +++ b/Assets/AddressableAssetsData/AssetGroups/configuration.asset @@ -85,6 +85,11 @@ MonoBehaviour: m_ReadOnly: 0 m_SerializedLabels: [] FlaggedDuringContentUpdateRestriction: 0 + - m_GUID: 8022adc119619b34fb2192efbff367d1 + m_Address: Assets/Addressable/petautoskill.txt + m_ReadOnly: 0 + m_SerializedLabels: [] + FlaggedDuringContentUpdateRestriction: 0 - m_GUID: 863a9da1fd09c934ea870dc4cfd4a906 m_Address: Assets/Addressable/maps/a61/movemap/r1_1-c1_2-l0.prmap.txt m_ReadOnly: 0 diff --git a/Assets/PerfectWorld/Scripts/Common/EC_Configs.cs b/Assets/PerfectWorld/Scripts/Common/EC_Configs.cs index 51a94a36d9..80119738ce 100644 --- a/Assets/PerfectWorld/Scripts/Common/EC_Configs.cs +++ b/Assets/PerfectWorld/Scripts/Common/EC_Configs.cs @@ -317,7 +317,7 @@ namespace BrewMonster bAtk_NoForce = false; bBls_NoForce = false; bLockQuickBar = false; - bPetAutoSkill = false; + bPetAutoSkill = true; bAutoTeamForTask = true; bDisableAutoWikiHelp = false; bExclusiveAwardMode = true; diff --git a/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs b/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs index c700460d61..d78bdcbb39 100644 --- a/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs +++ b/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs @@ -1,13 +1,16 @@ using BrewMonster; using BrewMonster.Scripts.Task; using CSNetwork; +using Cysharp.Threading.Tasks; using ModelRenderer.Scripts.GameData; using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Threading.Tasks; using UnityEngine; using UnityEngine.AddressableAssets; +using UnityEngine.ResourceManagement.AsyncOperations; namespace BrewMonster.Network { public partial class EC_Game @@ -33,6 +36,7 @@ namespace BrewMonster.Network private static Dictionary m_ItemMsgMap; // TemplateId -> (MessageId, DisplayMode) private static CECConfigs m_pConfigs; private static int m_iCurCursor; // Current cursor + private static List m_PetAutoSkills; #endregion @@ -132,7 +136,7 @@ namespace BrewMonster.Network // Load coord_data.txt (C++: Configs/Coord_data.txt) for clickable task links auto-move. // 鍔犺浇 coord_data.txt锛圕++锛欳onfigs/Coord_data.txt锛夌敤浜庝换鍔″彲鐐瑰嚮閾炬帴鐨勮嚜鍔ㄧЩ鍔ㄣ LoadObjectCoord(); - + LoadPetAutoSkill(); return true; } public static CECConfigs GetConfigs() { return m_pConfigs; } @@ -531,7 +535,73 @@ namespace BrewMonster.Network return iIndex; } - + public static bool IsPetAutoSkill(int skill_id) + { + return m_PetAutoSkills.Contains(skill_id); + } + + // Load the pet auto skill table + public static async UniTask LoadPetAutoSkill() + { + string pszFilename = "Assets/Addressable/petautoskill.txt"; + var ta = await LoadStringTableTextAssetByAddressables(pszFilename); + if (ta == null || string.IsNullOrEmpty(ta.text)) + { + BMLogger.LogError($"[AUIManager] ImportStringTable failed: cannot load Addressables TextAsset for key='{pszFilename}'"); + return false; + } + + using (var sr = new StringReader(ta.text)) + { + string line; + while ((line = sr.ReadLine()) != null) + { + if (string.IsNullOrWhiteSpace(line)) + continue; + + if (int.TryParse(line, out int key)) + { + m_PetAutoSkills.Add(key); + } + } + } + + return true; + } + + private static async UniTask LoadStringTableTextAssetByAddressables(string key) + { + try + { + // Initialize Addressables if not already initialized (Unity-safe) + await Addressables.InitializeAsync().ToUniTask(); + + // Load using Addressables directly with WaitForCompletion (Unity-safe, won't deadlock) + // This matches the pattern used in EC_Game.cs + var handle = Addressables.LoadAssetAsync(key); + var textAsset = await handle.ToUniTask(); + + if (handle.Status == AsyncOperationStatus.Succeeded && textAsset != null) + { + // Keep the handle valid; string tables are used for the whole session + // Note: We don't release the handle here to keep the asset loaded + return textAsset; + } + + if (handle.IsValid()) + { + Addressables.Release(handle); + } + + BMLogger.LogError($"[AUIManager] Failed to load TextAsset for key='{key}'"); + return null; + } + catch (Exception e) + { + BMLogger.LogError($"[AUIManager] LoadStringTableTextAssetByAddressables exception for key='{key}': {e}"); + return null; + } + } #endregion } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs b/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs index 04b76b0d7e..38584ee7eb 100644 --- a/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs +++ b/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs @@ -91,6 +91,7 @@ namespace BrewMonster protected int m_iCurAction; bool m_bAboutToDie = false; public bool m_bCandHangerOn = false; + public bool m_bPetInSanctuary = false; // true, the pet pet of the player is in sanctuary public MOVECONST m_MoveConst; // Const used when moving control public Move_Mode m_MoveMode; diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs index 1d89b265a1..22b258bfe3 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs @@ -877,7 +877,7 @@ namespace CSNetwork.C2SCommand public static Octets CreatePetSummon(int iPetIdx) { - cmd_summon_pet pCmd = new cmd_summon_pet(); + S2CCommand.cmd_summon_pet pCmd = new S2CCommand.cmd_summon_pet(); pCmd.pet_index = (uint)iPetIdx; return SerializeCommand(CommandID.SUMMON_PET, pCmd); } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs index 404a2efc5f..d5c100bcc4 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs @@ -2311,5 +2311,128 @@ namespace CSNetwork.GPDataType public int slot_index; // 麓脣鲁猫脦茂路脜脫脷鲁猫脦茂脌赂脛脷碌脛脦禄脰脙 public info_pet data; // pet data }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_free_pet + { + public int slot_index; + public int pet_id; // 鲁猫脦茂碌脛id拢卢脦脼麓贸脫脙 + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_summon_pet + { + public int slot_index; + public int pet_tid; + public int pet_pid; + public int life_time; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_recall_pet + { + public int slot_index; + public int pet_id; + public char reason; + }; + + public enum PET_RECALL_REASON + { + PET_RECALL_DEFAULT, // 脛卢脠脧脮脵禄脴拢卢脰梅脪陋脭颅脪貌脦陋脥忙录脪脰梅露炉脮脵禄脴隆垄脥忙录脪脮脵禄陆鲁枚脝盲脣眉脭颅脪貌碌录脰脗脭颅脫脨鲁猫脦茂脮脵禄脴碌脠 + PET_RECALL_DEATH, // 鲁猫脦茂脣脌脥枚碌录脰脗脮脵禄脴脧没脧垄 + PET_RECALL_LIFE_EXHAUST, // 鲁猫脦茂脢卤脧脼碌陆 + PET_RECALL_SACRIFICE, // 鲁猫脦茂脦镁脡眉拢篓脥忙录脪脢鹿脫脙录录脛脺碌脠碌录脰脗拢漏 + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_player_start_pet_op + { + public int slot_index; + public int pet_id; + public int delay; // 脩脫鲁脵脢卤录盲拢卢碌楼脦禄脢脟50ms碌脛tick + public int op; // 虏脵脳梅脌脿脨脥 0:路脜鲁枚 1:脮脵禄脴 2:路脜脡煤 + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_receive_exp + { + public int slot_index; + public int pet_id; + public int exp; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_levelup + { + public int slot_index; + public int pet_id; + public int level; // 脨脗录露卤冒 + public int exp; // 碌卤脟掳碌脛戮颅脩茅脰碌 + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_room_capacity + { + public uint capacity; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_honor_point + { + public int index; + public int cur_honor_point; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_hunger_gauge + { + public int index; + public int cur_hunge_gauge; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_dead + { + public uint pet_index; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_revive + { + public uint pet_index; + public float hp_factor; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_hp_notify + { + public uint pet_index; + public float hp_factor; + public int cur_hp; + public float mp_factor; + public int cur_mp; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_ai_state + { + public byte attack; // 0 路脌脫霉脨脥; 1 脰梅露炉脨脥; 2 卤禄露炉脨脥 + public byte move; // 0 赂煤脣忙; 1 脭颅碌脴脥拢脕么 + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_set_cooldown + { + public int pet_index; + public int cooldown_index; + public int cooldown_time; + }; + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_pet_property + { + public int pet_index; + public BrewMonster.Scripts.ROLEEXTPROP prop; + }; } diff --git a/Assets/PerfectWorld/Scripts/Pet/EC_PetCorral.cs b/Assets/PerfectWorld/Scripts/Pet/EC_PetCorral.cs index 7055f94b85..5571e7a47b 100644 --- a/Assets/PerfectWorld/Scripts/Pet/EC_PetCorral.cs +++ b/Assets/PerfectWorld/Scripts/Pet/EC_PetCorral.cs @@ -181,7 +181,7 @@ namespace BrewMonster.Scripts.Pet public int GetActivePetNPCID() { return m_nidPet; } // Add a pet - bool AddPet(int iSlot, info_pet Info) + public bool AddPet(int iSlot, info_pet Info) { if (iSlot < 0 || iSlot >= m_iPetSlotNum && (iSlot < (int)ePet_MaxSlot.MAX_SLOTNUM || iSlot >= (int)ePet_MaxSlot.MAX_SLOTNUM2)) { @@ -211,7 +211,7 @@ namespace BrewMonster.Scripts.Pet } // Free a pet - void FreePet(int iSlot, int idPet) + public void FreePet(int iSlot, int idPet) { if (iSlot < 0 || iSlot >= m_iPetSlotNum && (iSlot < (int)ePet_MaxSlot.MAX_SLOTNUM || iSlot >= (int)ePet_MaxSlot.MAX_SLOTNUM2)) { @@ -243,7 +243,7 @@ namespace BrewMonster.Scripts.Pet m_Plants.Clear(); } // Update pets data in corral - void UpdatePets(cmd_pet_room cmd, byte[] data) + public void UpdatePets(cmd_pet_room cmd, byte[] data) { byte[] pData = new byte[data.Length - Marshal.SizeOf(cmd)]; Buffer.BlockCopy(data, (Marshal.SizeOf(cmd)), pData, 0, pData.Length); @@ -287,7 +287,7 @@ namespace BrewMonster.Scripts.Pet } // Magnify pet slots - void MagnifyPetSlots(int iNewNum) + public void MagnifyPetSlots(int iNewNum) { if (iNewNum > (int)ePet_MaxSlot.MAX_SLOTNUM || m_iPetSlotNum > iNewNum) { @@ -327,9 +327,9 @@ namespace BrewMonster.Scripts.Pet // Get current active pet's index public int GetActivePetIndex() { return m_iActivePet; } // Set current active pet's index - void SetActivePetIndex(int iIndex) { m_iActivePet = iIndex; } + public void SetActivePetIndex(int iIndex) { m_iActivePet = iIndex; } // Get current active pet's data - CECPetData GetActivePet() + public CECPetData GetActivePet() { if (m_iActivePet >= 0 && m_iActivePet < (int)ePet_MaxSlot.MAX_SLOTNUM2) return m_aPetSlots[m_iActivePet]; @@ -337,35 +337,35 @@ namespace BrewMonster.Scripts.Pet return null; } - void SetActivePetNPCID(int nid) { m_nidPet = nid; } + public void SetActivePetNPCID(int nid) { m_nidPet = nid; } // 查询、设置当前宠物的生存时长 - int GetActivePetLifeTime() { return m_iPetLifeTime; } - void SetActivePetLifetime(int lifetime) { m_iPetLifeTime = lifetime; } + public int GetActivePetLifeTime() { return m_iPetLifeTime; } + public void SetActivePetLifetime(int lifetime) { m_iPetLifeTime = lifetime; } // Get / Set moving mode - int GetMoveMode() { return m_iMoveMode; } - void SetMoveMode(int iMode) { m_iMoveMode = iMode; } + public int GetMoveMode() { return m_iMoveMode; } + public void SetMoveMode(int iMode) { m_iMoveMode = iMode; } // Get / Set attacking mode - int GetAttackMode() { return m_iAttackMode; } - void SetAttackMode(int iMode) { m_iAttackMode = iMode; } + public int GetAttackMode() { return m_iAttackMode; } + public void SetAttackMode(int iMode) { m_iAttackMode = iMode; } // Get / Set init flag - bool HasInit() { return m_bHasInit; } - void SetHasInit(bool bFlag) { m_bHasInit = bFlag; } + public bool HasInit() { return m_bHasInit; } + public void SetHasInit(bool bFlag) { m_bHasInit = bFlag; } - void PlantPetEnter(cmd_summon_plant_pet rhs) + public void PlantPetEnter(cmd_summon_plant_pet rhs) { CECPlantPetData plant = new CECPlantPetData(); plant.Init(rhs); m_Plants.Add(plant); } - void PlantPetDisappear(cmd_plant_pet_disapper rhs) + public void PlantPetDisappear(cmd_plant_pet_disapper rhs) { CECPlantPetData? pPlant = GetPlantByID(rhs.plant_nid); if (pPlant != null) m_Plants.Remove(pPlant.Value); } - void PlantPetInfo(cmd_plant_pet_hp_notify rhs) + public void PlantPetInfo(cmd_plant_pet_hp_notify rhs) { CECPlantPetData? pPlant = GetPlantByID(rhs.plant_nid); if (pPlant != null) @@ -718,7 +718,7 @@ namespace BrewMonster.Scripts.Pet return m_iExp; } // Level up - int LevelUp(int iLevel, int iNewExp) + public int LevelUp(int iLevel, int iNewExp) { m_iLevel = iLevel; m_iExp = iNewExp; diff --git a/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs b/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs new file mode 100644 index 0000000000..bfe4ef8fce --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs @@ -0,0 +1,473 @@ +using BrewMonster.Network; +using BrewMonster.Scripts; +using BrewMonster.Scripts.Pet; +using BrewMonster.UI; +using CSNetwork; +using CSNetwork.GPDataType; +using System.Runtime.InteropServices; +using UnityEngine; +using static BrewMonster.Scripts.Pet.CECPetData; + +namespace BrewMonster +{ + public partial class CECHostPlayer + { + // Update pet shortcut when pet freeed + void UpdateFreedPetSC(int iPetIndex) + { + // TO DO: fix later + //int i; + + //// Update shortcut sets 1 + //for (i = 0; i < (int)Shortcut.NUM_HOSTSCSETS1; i++) + //{ + // if (m_aSCSets1[i] != null) + // m_aSCSets1[i].UpdateFreedPetSC(iPetIndex); + //} + + //// Update shortcut sets 2 + //for (i = 0; i < (int)Shortcut.NUM_HOSTSCSETS2; i++) + //{ + // if (m_aSCSets2[i] != null) + // m_aSCSets2[i].UpdateFreedPetSC(iPetIndex); + //} + } + + bool OnPetSays(int tid, int nid, int type) + { + bool bSaid = false; + + //CECNPC pNPC = EC_Game.GetGameRun().GetWorld().GetNPCMan().GetNPCFromAll(nid); + //if (pNPC && pNPC.GetMasterID() == GetCharacterID()) + //{ + // const ACHAR* szWords = m_pPetWords.GetWords(tid, (CECPetWords::TYPE_WORDS)type); + // if (szWords) + // { + // pNPC.SetLastSaidWords(szWords, 5000); + // bSaid = true; + // } + //} + + return bSaid; + } + + /* Is host operating pet ? + return value: + + 0: host doesn't operating pet. + 1: host is summoning pet. + 2: host is recalling pet. + 3: host is banishing pet. + */ + int CIsOperatingPet() + { + CECHPWorkConcentrate pWork = (m_pWorkMan.GetRunningWork(CECHPWork.Host_work_ID.WORK_CONCENTRATE)) as CECHPWorkConcentrate; + if (pWork != null) + { + if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_SUMMONPET) + return 1; + else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_RECALLPET) + return 2; + else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_BANISHPET) + return 3; + else if (pWork.GetDoWhat() == (int)CECHPWorkConcentrate.eDO_PET.DO_RESTOREPET) + return 4; + } + return 0; + } + + void OnMsgHstPetOpt(ECMSG Msg) + { + + CECGameRun pGameRun = EC_Game.GetGameRun(); + + switch (Msg.dwParam2) + { + case CommandID.GAIN_PET: + { + cmd_gain_pet pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + m_pPetCorral.AddPet(pCmd.slot_index, pCmd.data); + + // Print a notify + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.slot_index); + if (pPet != null) + { + if (pPet.IsFollowPet() || pPet.IsCombatPet() || pPet.IsEvolutionPet()) + { + // TO DO: fix later + //pGameRun.AddFixedMessage(FIXMSG_PET_HATCH, pPet.GetName()); + } + else if (pPet.IsSummonPet()) + { + // TO DO: fix later + //pGameRun.AddFixedMessage(FIXMSG_SUMMON_PET_APPEAR, pPet.GetName()); + } + } + + break; + } + + case CommandID.FREE_PET: + { + cmd_free_pet pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + + // Print a notify + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.slot_index); + if (pPet != null) + { + if (pPet.IsFollowPet() || pPet.IsCombatPet() || pPet.IsEvolutionPet()) + { + // TO DO: fix later + //pGameRun.AddFixedMessage(FIXMSG_PET_FREE, pPet.GetName()); + } + else if (pPet.IsSummonPet()) + { + // TO DO: fix later + //pGameRun.AddFixedMessage(FIXMSG_SUMMON_PET_DISAPPEAR, pPet.GetName()); + } + } + + // Remove pet from corral + m_pPetCorral.FreePet(pCmd.slot_index, pCmd.pet_id); + // Update pet shortcuts + UpdateFreedPetSC(pCmd.slot_index); + + break; + } + case CommandID.SUMMON_PET: + { + cmd_summon_pet pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.slot_index); + //ASSERT(pPet && pPet.GetTemplateID() == pCmd.pet_tid); + m_pPetCorral.SetActivePetIndex(pCmd.slot_index); + m_pPetCorral.SetActivePetNPCID(pCmd.pet_pid); + m_pPetCorral.SetActivePetLifetime(pCmd.life_time); + + if (EC_Game.GetConfigs().GetGameSettings().bPetAutoSkill) + { + for (int i = 0; i < pPet.GetSkillNum(SKILLTYPE.EM_SKILL_DEFAULT); i++) + { + PETSKILL? pSkill = pPet.GetSkill(SKILLTYPE.EM_SKILL_DEFAULT, i); + if (pSkill != null && EC_Game.IsPetAutoSkill(pSkill.Value.idSkill)) + pPet.AddAutoSkill(pSkill.Value.idSkill); + } + } + + // TO DO: fix later + //OnPetSays(pCmd.pet_tid, pCmd.pet_pid, CECPetWords::TW_SUMMON); + //if (pPet.IsCombatPet() || pPet.IsSummonPet() || pPet.IsEvolutionPet()) + // CDlgQuickBarPet::ResetAutoCastSkill(); + break; + } + case CommandID.RECALL_PET: + { + cmd_recall_pet pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + //ASSERT(pCmd.slot_index == m_pPetCorral.GetActivePetIndex()); + + int tid = pCmd.pet_id; + int nid = m_pPetCorral.GetActivePetNPCID(); + + // 宠物有话说 + switch (pCmd.reason) + { + case (char)PET_RECALL_REASON.PET_RECALL_DEFAULT: + //OnPetSays(tid, nid, CECPetWords::TW_RECALL); + break; + + case (char)PET_RECALL_REASON.PET_RECALL_DEATH: + //OnPetSays(tid, nid, CECPetWords::TW_DEAD); + break; + + case (char)PET_RECALL_REASON.PET_RECALL_LIFE_EXHAUST: + //OnPetSays(tid, nid, CECPetWords::TW_DISAPPEAR); + break; + + case (char)PET_RECALL_REASON.PET_RECALL_SACRIFICE: + //OnPetSays(tid, nid, CECPetWords::TW_SACRIFICE); + break; + } + + CECPetData pPet = m_pPetCorral.GetActivePet(); + if (pPet != null) + pPet.OnPetDead(); + + m_pPetCorral.SetActivePetIndex(-1); + m_pPetCorral.SetActivePetNPCID(0); + m_bPetInSanctuary = false; + break; + } + case CommandID.PLAYER_START_PET_OP: + { + cmd_player_start_pet_op pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + int iDoWhat; + if (pCmd.op == 0) + iDoWhat = (int)CECHPWorkConcentrate.eDO_PET.DO_SUMMONPET; + else if (pCmd.op == 1) + iDoWhat = (int)CECHPWorkConcentrate.eDO_PET.DO_RECALLPET; + else if (pCmd.op == 2) + iDoWhat = (int)CECHPWorkConcentrate.eDO_PET.DO_BANISHPET; + else if (pCmd.op == 3) + iDoWhat = (int)CECHPWorkConcentrate.eDO_PET.DO_RESTOREPET; + else + iDoWhat = (int)CECHPWorkConcentrate.eDO_PET.DO_UNKNOWN; + + m_PetOptCnt.SetPeriod(pCmd.delay * 50); + m_PetOptCnt.Reset(); + + CECHPWorkConcentrate pWork = (CECHPWorkConcentrate)m_pWorkMan.CreateWork(CECHPWork.Host_work_ID.WORK_CONCENTRATE); + pWork.SetDoWhat(iDoWhat); + m_pWorkMan.StartWork_p1(pWork); + break; + } + case CommandID.PLAYER_STOP_PET_OP: + { + if (IsOperatingPet() != 0) + m_pWorkMan.FinishRunningWork(CECHPWork.Host_work_ID.WORK_CONCENTRATE); + + break; + } + case CommandID.PET_RECEIVE_EXP: + { + cmd_pet_receive_exp pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.slot_index); + if (pPet != null) + { + //ASSERT(pPet.GetTemplateID() == pCmd.pet_id); + pPet.AddExp(pCmd.exp); + } + + break; + } + case CommandID.PET_LEVELUP: + { + cmd_pet_levelup pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.slot_index); + if (pPet != null) + { + //ASSERT(pPet.GetTemplateID() == pCmd.pet_id); + pPet.LevelUp(pCmd.level, pCmd.exp); + } + + //pGameRun.AddFixedMessage(FIXMSG_PET_LEVELUP, pCmd.level); + break; + } + case CommandID.PET_ROOM: + { + cmd_pet_room pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + m_pPetCorral.UpdatePets(pCmd, (byte[])Msg.dwParam1); + + CECGameUIMan pGameUI = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); + + //if (pGameUI.GetDialog("Win_Teach").IsShow()) + // { + // //pGameUI.UpdateTeach(); + // } + + break; + } + case CommandID.PET_ROOM_CAPACITY: + { + cmd_pet_room_capacity pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + m_pPetCorral.MagnifyPetSlots((int)pCmd.capacity); + + if (m_pPetCorral.HasInit()) + { + //pGameRun.AddFixedMessage(FIXMSG_PET_ROOM_SIZE, pCmd.capacity); + } + else + m_pPetCorral.SetHasInit(true); + break; + } + case CommandID.PET_HONOR_POINT: + { + cmd_pet_honor_point pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.index); + if (pPet != null) + pPet.SetIntimacy(pCmd.cur_honor_point); + + break; + } + case CommandID.PET_HUNGER_GAUGE: + { + cmd_pet_hunger_gauge pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.index); + if (pPet != null) + pPet.SetHunger(pCmd.cur_hunge_gauge); + + break; + } + case CommandID.PET_DEAD: + { + cmd_pet_dead pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData((int)pCmd.pet_index); + if (pPet != null) + { + pPet.SetHPFactor(0.0f); + pPet.SetHP(0); + pPet.OnPetDead(); + } + + //pGameRun.AddFixedMessage(FIXMSG_PET_DEAD); + break; + } + case CommandID.PET_REVIVE: + { + cmd_pet_revive pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData((int)pCmd.pet_index); + if (pPet != null) + pPet.SetHPFactor(pCmd.hp_factor); + + break; + } + case CommandID.PET_HP_NOTIFY: + { + cmd_pet_hp_notify pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData((int)pCmd.pet_index); + if (pPet != null) + { + int lastHP = pPet.GetHP(); + + pPet.SetHPFactor(pCmd.hp_factor); + pPet.SetHP(pCmd.cur_hp); + + pPet.SetMPFactor(pCmd.mp_factor); + pPet.SetMP(pCmd.cur_mp); + + // If HP is too low, popup a warning on pet's head + int iLimit = (int)(pPet.CalcMaxHP() * 0.3f); + if (pCmd.cur_hp < lastHP && lastHP != 0 && pCmd.cur_hp < iLimit) + { + CECNPC pNPC = EC_Game.GetGameRun().GetWorld().GetNPCMan().GetNPC(m_pPetCorral.GetActivePetNPCID()); + if (pNPC && pNPC.GetMasterID() == GetCharacterID()) + { + //pNPC.BubbleText(CECNPC::BUBBLE_HPWARN, 0); + } + } + } + + break; + } + case CommandID.PET_AI_STATE: + { + cmd_pet_ai_state pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + + // 宠物有话说 + CECPetData pPetData = m_pPetCorral.GetActivePet(); + if (pPetData != null) + { + int tid = pPetData.GetTemplateID(); + int nid = m_pPetCorral.GetActivePetNPCID(); + if (m_pPetCorral.GetMoveMode() != pCmd.move) + { + switch (pCmd.move) + { + case (byte)CECPetCorral.ePet_MovingMode.MOVE_FOLLOW: + { + //OnPetSays(tid, nid, CECPetWords::TW_FOLLOW); + break; + } + case (byte)CECPetCorral.ePet_MovingMode.MOVE_STAND: + { + //OnPetSays(tid, nid, CECPetWords::TW_STOP); + break; + } + } + } + if (m_pPetCorral.GetAttackMode() != pCmd.attack) + { + switch (pCmd.attack) + { + case (byte)CECPetCorral.ePet_AttackingMode.ATK_DEFENSE: + //OnPetSays(tid, nid, CECPetWords::TW_DEFENSIVE); + break; + + case (byte)CECPetCorral.ePet_AttackingMode.ATK_POSITIVE: + //OnPetSays(tid, nid, CECPetWords::TW_OFFENSIVE); + break; + + case (byte)CECPetCorral.ePet_AttackingMode.ATK_PASSIVE: + //OnPetSays(tid, nid, CECPetWords::TW_PASSIVE); + break; + } + } + } + + m_pPetCorral.SetMoveMode(pCmd.move); + m_pPetCorral.SetAttackMode(pCmd.attack); + break; + } + case CommandID.PET_SET_COOLDOWN: + { + cmd_pet_set_cooldown pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.pet_index); + if (pPet != null) + pPet.SetSkillCoolTime(pCmd.cooldown_index, pCmd.cooldown_time); + + break; + } + + case CommandID.SUMMON_PLANT_PET: + { + int size = Marshal.SizeOf(); + if (((byte[])Msg.dwParam1).Length >= size) + { + cmd_summon_plant_pet pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + m_pPetCorral.PlantPetEnter(pCmd); + } + break; + } + + case CommandID.PLANT_PET_DISAPPEAR: + { + int size = Marshal.SizeOf(); + if (((byte[])Msg.dwParam1).Length >= size) + { + cmd_plant_pet_disapper pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + m_pPetCorral.PlantPetDisappear(pCmd); + } + break; + } + + case CommandID.PLANT_PET_HP_NOTIFY: + { + int size = Marshal.SizeOf(); + if (((byte[])Msg.dwParam1).Length >= size) + { + cmd_plant_pet_hp_notify pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + m_pPetCorral.PlantPetInfo(pCmd); + } + break; + } + + case CommandID.PET_PROPERTY: + { + cmd_pet_property pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + CECPetData pPet = m_pPetCorral.GetPetData(pCmd.pet_index); + if (pPet != null) + { + pPet.SetExtendProps(pCmd.prop); + } + break; + } + case CommandID.PET_REBUILD_INHERIT_START: + case CommandID.PET_REBUILD_INHERIT_INFO: + case CommandID.PET_REBUILD_INHERIT_END: + case CommandID.PET_EVOLUTION_DONE: + case CommandID.PET_REBUILD_NATURE_START: + case CommandID.PET_REBUILD_NATURE_INFO: + case CommandID.PET_REBUILD_NATURE_END: + { + CECGameUIMan pGameUI = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); + if (pGameUI != null) + { + //((CDlgPreviewPetRebuild*)pGameUI.GetDialog("Win_PreviewPet")).OnServerNotify(Msg.dwParam2, (void*)Msg.dwParam1); + } + break; + } + + default: + break; + } + } + } +} diff --git a/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs.meta b/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs.meta new file mode 100644 index 0000000000..78767ae81b --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Players/EC_HostMsg.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a80761da7f1dc184b8117b7170fd98f2 \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/World/CECWorld.cs b/Assets/PerfectWorld/Scripts/World/CECWorld.cs index 2c82e9042e..2248486913 100644 --- a/Assets/PerfectWorld/Scripts/World/CECWorld.cs +++ b/Assets/PerfectWorld/Scripts/World/CECWorld.cs @@ -84,5 +84,9 @@ namespace BrewMonster.Scripts.World public CECAssureMove GetAssureMove() { return m_pAssureMove; } + public CECNPCMan GetNPCMan() + { + return EC_ManMessageMono.Instance.CECNPCMan; + } } } diff --git a/Assets/Scripts/CECGameRun.cs b/Assets/Scripts/CECGameRun.cs index de16d44162..39ad5109e9 100644 --- a/Assets/Scripts/CECGameRun.cs +++ b/Assets/Scripts/CECGameRun.cs @@ -1,4 +1,5 @@ using BrewMonster; +using BrewMonster.Managers; using BrewMonster.Network; using BrewMonster.Scripts; using BrewMonster.Scripts.World; diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index c13f5c8a3b..03f966f86e 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -1,9 +1,7 @@ -锘縰sing BrewMonster; -using BrewMonster.Assets.PerfectWorld.Scripts.Players; +锘縰sing BrewMonster.Assets.PerfectWorld.Scripts.Players; using BrewMonster.Managers; using BrewMonster.Network; using BrewMonster.PerfectWorld.Scripts.Vfx; -using BrewMonster.PerfectWorld.Scripts.Vfx; using BrewMonster.Scripts; using BrewMonster.Scripts.Managers; using BrewMonster.Scripts.Pet; @@ -19,7 +17,6 @@ using PerfectWorld.Scripts.Managers; using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using UnityEngine; @@ -110,6 +107,8 @@ namespace BrewMonster Dictionary m_skillCoolTime = new Dictionary(); COOLTIME[] m_aCoolTimes = new COOLTIME[(int)CoolTimeIndex.GP_CT_MAX]; // Cool times CECPetCorral m_pPetCorral = null; + CECCounter m_PetOptCnt; // Pet operation time counter + // 脳陋脡煤麓脦脢媒 byte m_ReincarnationCount = 0; @@ -306,6 +305,8 @@ namespace BrewMonster m_GatherCnt ??= new CECCounter(); m_GatherCnt.SetPeriod(1000); m_GatherCnt.Reset(true); + m_PetOptCnt.SetPeriod(1000); + m_PetOptCnt.Reset(true); } public bool LoadResources() @@ -6314,6 +6315,7 @@ namespace BrewMonster if (m_IncantCnt.IncCounter(dwDeltaTime)) m_IncantCnt.Reset(true); + m_PetOptCnt.IncCounter(dwDeltaTime); // Bind command cool counter /* if (m_BindCmdCoolCnt.IncCounter(dwDeltaTime)) m_BindCmdCoolCnt.Reset(true); @@ -6991,365 +6993,5 @@ namespace BrewMonster return true; } - - void OnMsgHstPetOpt(ECMSG Msg) - { - - CECGameRun pGameRun = EC_Game.GetGameRun(); - - switch (Msg.dwParam2) - { - case CommandID.GAIN_PET: - { - cmd_gain_pet pCmd = (const cmd_gain_pet*)Msg.dwParam1; - m_pPetCorral.AddPet(pCmd.slot_index, pCmd.data); - - // Print a notify - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.slot_index); - if (pPet) - { - if (pPet.IsFollowPet() || pPet.IsCombatPet() || pPet.IsEvolutionPet()) - pGameRun.AddFixedMessage(FIXMSG_PET_HATCH, pPet.GetName()); - else if (pPet.IsSummonPet()) - pGameRun.AddFixedMessage(FIXMSG_SUMMON_PET_APPEAR, pPet.GetName()); - } - - break; - } - - case CommandID.FREE_PET: - { - const cmd_free_pet* pCmd = (const cmd_free_pet*)Msg.dwParam1; - - // Print a notify - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.slot_index); - if (pPet) - { - if (pPet.IsFollowPet() || pPet.IsCombatPet() || pPet.IsEvolutionPet()) - pGameRun.AddFixedMessage(FIXMSG_PET_FREE, pPet.GetName()); - else if (pPet.IsSummonPet()) - pGameRun.AddFixedMessage(FIXMSG_SUMMON_PET_DISAPPEAR, pPet.GetName()); - } - - // Remove pet from corral - m_pPetCorral.FreePet(pCmd.slot_index, pCmd.pet_id); - // Update pet shortcuts - UpdateFreedPetSC(pCmd.slot_index); - - break; - } - case CommandID.SUMMON_PET: - { - const cmd_summon_pet* pCmd = (const cmd_summon_pet*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.slot_index); - ASSERT(pPet && pPet.GetTemplateID() == pCmd.pet_tid); - m_pPetCorral.SetActivePetIndex(pCmd.slot_index); - m_pPetCorral.SetActivePetNPCID(pCmd.pet_pid); - m_pPetCorral.SetActivePetLifetime(pCmd.life_time); - - if (g_pGame.GetConfigs().GetGameSettings().bPetAutoSkill) - { - for (int i = 0; i < pPet.GetSkillNum(CECPetData::EM_SKILL_DEFAULT); i++) - { - const CECPetData::PETSKILL* pSkill = pPet.GetSkill(CECPetData::EM_SKILL_DEFAULT, i); - if (pSkill && g_pGame.IsPetAutoSkill(pSkill.idSkill)) - pPet.AddAutoSkill(pSkill.idSkill); - } - } - - OnPetSays(pCmd.pet_tid, pCmd.pet_pid, CECPetWords::TW_SUMMON); - if (pPet.IsCombatPet() || pPet.IsSummonPet() || pPet.IsEvolutionPet()) - CDlgQuickBarPet::ResetAutoCastSkill(); - break; - } - case CommandID.RECALL_PET: - { - const cmd_recall_pet* pCmd = (const cmd_recall_pet*)Msg.dwParam1; - ASSERT(pCmd.slot_index == m_pPetCorral.GetActivePetIndex()); - - int tid = pCmd.pet_id; - int nid = m_pPetCorral.GetActivePetNPCID(); - - // 鲁猫脦茂脫脨禄掳脣碌 - switch (pCmd.reason) - { - case PET_RECALL_DEFAULT: - OnPetSays(tid, nid, CECPetWords::TW_RECALL); - break; - - case PET_RECALL_DEATH: - OnPetSays(tid, nid, CECPetWords::TW_DEAD); - break; - - case PET_RECALL_LIFE_EXHAUST: - OnPetSays(tid, nid, CECPetWords::TW_DISAPPEAR); - break; - - case PET_RECALL_SACRIFICE: - OnPetSays(tid, nid, CECPetWords::TW_SACRIFICE); - break; - } - - CECPetData* pPet = m_pPetCorral.GetActivePet(); - if (pPet) - pPet.OnPetDead(); - - m_pPetCorral.SetActivePetIndex(-1); - m_pPetCorral.SetActivePetNPCID(0); - m_bPetInSanctuary = false; - break; - } - case CommandID.PLAYER_START_PET_OP: - { - const cmd_player_start_pet_op* pCmd = (const cmd_player_start_pet_op*)Msg.dwParam1; - int iDoWhat; - if (pCmd.op == 0) - iDoWhat = CECHPWorkConcentrate::DO_SUMMONPET; - else if (pCmd.op == 1) - iDoWhat = CECHPWorkConcentrate::DO_RECALLPET; - else if (pCmd.op == 2) - iDoWhat = CECHPWorkConcentrate::DO_BANISHPET; - else if (pCmd.op == 3) - iDoWhat = CECHPWorkConcentrate::DO_RESTOREPET; - else - iDoWhat = CECHPWorkConcentrate::DO_UNKNOWN; - - m_PetOptCnt.SetPeriod(pCmd.delay * 50); - m_PetOptCnt.Reset(); - - CECHPWorkConcentrate* pWork = (CECHPWorkConcentrate*)m_pWorkMan.CreateWork(CECHPWork::WORK_CONCENTRATE); - pWork.SetDoWhat(iDoWhat); - m_pWorkMan.StartWork_p1(pWork); - break; - } - case CommandID.PLAYER_STOP_PET_OP: - { - if (IsOperatingPet()) - m_pWorkMan.FinishRunningWork(CECHPWork::WORK_CONCENTRATE); - - break; - } - case CommandID.PET_RECEIVE_EXP: - { - const cmd_pet_receive_exp* pCmd = (const cmd_pet_receive_exp*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.slot_index); - if (pPet) - { - ASSERT(pPet.GetTemplateID() == pCmd.pet_id); - pPet.AddExp(pCmd.exp); - } - - break; - } - case CommandID.PET_LEVELUP: - { - const cmd_pet_levelup* pCmd = (const cmd_pet_levelup*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.slot_index); - if (pPet) - { - ASSERT(pPet.GetTemplateID() == pCmd.pet_id); - pPet.LevelUp(pCmd.level, pCmd.exp); - } - - pGameRun.AddFixedMessage(FIXMSG_PET_LEVELUP, pCmd.level); - break; - } - case CommandID.PET_ROOM: - { - const cmd_pet_room* pCmd = (const cmd_pet_room*)Msg.dwParam1; - m_pPetCorral.UpdatePets(*pCmd); - - CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan(); - - if (pGameUI.GetDialog("Win_Teach").IsShow()) - pGameUI.UpdateTeach(); - - break; - } - case CommandID.PET_ROOM_CAPACITY: - { - const cmd_pet_room_capacity* pCmd = (const cmd_pet_room_capacity*)Msg.dwParam1; - m_pPetCorral.MagnifyPetSlots(pCmd.capacity); - - if (m_pPetCorral.HasInit()) - pGameRun.AddFixedMessage(FIXMSG_PET_ROOM_SIZE, pCmd.capacity); - else - m_pPetCorral.SetHasInit(true); - break; - } - case CommandID.PET_HONOR_POINT: - { - const cmd_pet_honor_point* pCmd = (const cmd_pet_honor_point*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.index); - if (pPet) - pPet.SetIntimacy(pCmd.cur_honor_point); - - break; - } - case CommandID.PET_HUNGER_GAUGE: - { - const cmd_pet_hunger_gauge* pCmd = (const cmd_pet_hunger_gauge*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.index); - if (pPet) - pPet.SetHunger(pCmd.cur_hunge_gauge); - - break; - } - case CommandID.PET_DEAD: - { - const cmd_pet_dead* pCmd = (const cmd_pet_dead*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.pet_index); - if (pPet) - { - pPet.SetHPFactor(0.0f); - pPet.SetHP(0); - pPet.OnPetDead(); - } - - pGameRun.AddFixedMessage(FIXMSG_PET_DEAD); - break; - } - case CommandID.PET_REVIVE: - { - const cmd_pet_revive* pCmd = (const cmd_pet_revive*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.pet_index); - if (pPet) - pPet.SetHPFactor(pCmd.hp_factor); - - break; - } - case CommandID.PET_HP_NOTIFY: - { - const cmd_pet_hp_notify* pCmd = (const cmd_pet_hp_notify*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.pet_index); - if (pPet) - { - int lastHP = pPet.GetHP(); - - pPet.SetHPFactor(pCmd.hp_factor); - pPet.SetHP(pCmd.cur_hp); - - pPet.SetMPFactor(pCmd.mp_factor); - pPet.SetMP(pCmd.cur_mp); - - // If HP is too low, popup a warning on pet's head - int iLimit = (int)(pPet.CalcMaxHP() * 0.3f); - if (pCmd.cur_hp < lastHP && lastHP && pCmd.cur_hp < iLimit) - { - CECNPC* pNPC = g_pGame.GetGameRun().GetWorld().GetNPCMan().GetNPC(m_pPetCorral.GetActivePetNPCID()); - if (pNPC && pNPC.GetMasterID() == GetCharacterID()) - pNPC.BubbleText(CECNPC::BUBBLE_HPWARN, 0); - } - } - - break; - } - case CommandID.PET_AI_STATE: - { - const cmd_pet_ai_state* pCmd = (const cmd_pet_ai_state*)Msg.dwParam1; - - // 鲁猫脦茂脫脨禄掳脣碌 - const CECPetData* pPetData = m_pPetCorral.GetActivePet(); - if (pPetData) - { - int tid = pPetData.GetTemplateID(); - int nid = m_pPetCorral.GetActivePetNPCID(); - if (m_pPetCorral.GetMoveMode() != pCmd.move) - { - switch (pCmd.move) - { - case CECPetCorral::MOVE_FOLLOW: - OnPetSays(tid, nid, CECPetWords::TW_FOLLOW); - break; - case CECPetCorral::MOVE_STAND: - OnPetSays(tid, nid, CECPetWords::TW_STOP); - break; - } - } - if (m_pPetCorral.GetAttackMode() != pCmd.attack) - { - switch (pCmd.attack) - { - case CECPetCorral::ATK_DEFENSE: - OnPetSays(tid, nid, CECPetWords::TW_DEFENSIVE); - break; - - case CECPetCorral::ATK_POSITIVE: - OnPetSays(tid, nid, CECPetWords::TW_OFFENSIVE); - break; - - case CECPetCorral::ATK_PASSIVE: - OnPetSays(tid, nid, CECPetWords::TW_PASSIVE); - break; - } - } - } - - m_pPetCorral.SetMoveMode(pCmd.move); - m_pPetCorral.SetAttackMode(pCmd.attack); - break; - } - case CommandID.PET_SET_COOLDOWN: - { - const cmd_pet_set_cooldown* pCmd = (const cmd_pet_set_cooldown*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.pet_index); - if (pPet) - pPet.SetSkillCoolTime(pCmd.cooldown_index, pCmd.cooldown_time); - - break; - } - - case CommandID.SUMMON_PLANT_PET: - { - const cmd_summon_plant_pet* pCmd = (const cmd_summon_plant_pet*)Msg.dwParam1; - if (pCmd) - m_pPetCorral.PlantPetEnter(*pCmd); - break; - } - - case CommandID.PLANT_PET_DISAPPEAR: - { - const cmd_plant_pet_disapper* pCmd = (const cmd_plant_pet_disapper*)Msg.dwParam1; - if (pCmd) - m_pPetCorral.PlantPetDisappear(*pCmd); - break; - } - - case CommandID.PLANT_PET_HP_NOTIFY: - { - const cmd_plant_pet_hp_notify* pCmd = (const cmd_plant_pet_hp_notify*)Msg.dwParam1; - if (pCmd) - m_pPetCorral.PlantPetInfo(*pCmd); - break; - } - - case CommandID.PET_PROPERTY: - { - const cmd_pet_property* pCmd = (const cmd_pet_property*)Msg.dwParam1; - CECPetData* pPet = m_pPetCorral.GetPetData(pCmd.pet_index); - if (pPet) - { - pPet.SetExtendProps(pCmd.prop); - } - break; - } - case CommandID.PET_REBUILD_INHERIT_START: - case CommandID.PET_REBUILD_INHERIT_INFO: - case CommandID.PET_REBUILD_INHERIT_END: - case CommandID.PET_EVOLUTION_DONE: - case CommandID.PET_REBUILD_NATURE_START: - case CommandID.PET_REBUILD_NATURE_INFO: - case CommandID.PET_REBUILD_NATURE_END: - { - CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan(); - if (pGameUI) - ((CDlgPreviewPetRebuild*)pGameUI.GetDialog("Win_PreviewPet")).OnServerNotify(Msg.dwParam2, (void*)Msg.dwParam1); - break; - } - - default: - break; - } - } } }