fix: update logic dlg pet.

This commit is contained in:
Tungdv
2026-01-28 19:31:14 +07:00
parent 4c51d6bf19
commit ef07a39964
14 changed files with 759 additions and 387 deletions
+44
View File
@@ -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
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8022adc119619b34fb2192efbff367d1
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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
@@ -317,7 +317,7 @@ namespace BrewMonster
bAtk_NoForce = false;
bBls_NoForce = false;
bLockQuickBar = false;
bPetAutoSkill = false;
bPetAutoSkill = true;
bAutoTeamForTask = true;
bDisableAutoWikiHelp = false;
bExclusiveAwardMode = true;
@@ -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<int, ItemMsgMapEntry> m_ItemMsgMap; // TemplateId -> (MessageId, DisplayMode)
private static CECConfigs m_pConfigs;
private static int m_iCurCursor; // Current cursor
private static List<int> 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.txtC++Configs/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<bool> 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<TextAsset> 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<TextAsset>(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
}
}
@@ -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;
@@ -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);
}
@@ -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;
};
}
+19 -19
View File
@@ -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;
@@ -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<cmd_gain_pet>((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<cmd_free_pet>((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<cmd_summon_pet>((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<cmd_recall_pet>((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<cmd_player_start_pet_op>((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<cmd_pet_receive_exp>((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<cmd_pet_levelup>((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<cmd_pet_room>((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<cmd_pet_room_capacity>((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<cmd_pet_honor_point>((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<cmd_pet_hunger_gauge>((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<cmd_pet_dead>((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<cmd_pet_revive>((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<cmd_pet_hp_notify>((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<cmd_pet_ai_state>((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<cmd_pet_set_cooldown>((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<cmd_summon_plant_pet>();
if (((byte[])Msg.dwParam1).Length >= size)
{
cmd_summon_plant_pet pCmd = GPDataTypeHelper.FromBytes<cmd_summon_plant_pet>((byte[])Msg.dwParam1);
m_pPetCorral.PlantPetEnter(pCmd);
}
break;
}
case CommandID.PLANT_PET_DISAPPEAR:
{
int size = Marshal.SizeOf<cmd_plant_pet_disapper>();
if (((byte[])Msg.dwParam1).Length >= size)
{
cmd_plant_pet_disapper pCmd = GPDataTypeHelper.FromBytes<cmd_plant_pet_disapper>((byte[])Msg.dwParam1);
m_pPetCorral.PlantPetDisappear(pCmd);
}
break;
}
case CommandID.PLANT_PET_HP_NOTIFY:
{
int size = Marshal.SizeOf<cmd_plant_pet_hp_notify>();
if (((byte[])Msg.dwParam1).Length >= size)
{
cmd_plant_pet_hp_notify pCmd = GPDataTypeHelper.FromBytes<cmd_plant_pet_hp_notify>((byte[])Msg.dwParam1);
m_pPetCorral.PlantPetInfo(pCmd);
}
break;
}
case CommandID.PET_PROPERTY:
{
cmd_pet_property pCmd = GPDataTypeHelper.FromBytes<cmd_pet_property>((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;
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a80761da7f1dc184b8117b7170fd98f2
@@ -84,5 +84,9 @@ namespace BrewMonster.Scripts.World
public CECAssureMove GetAssureMove()
{ return m_pAssureMove; }
public CECNPCMan GetNPCMan()
{
return EC_ManMessageMono.Instance.CECNPCMan;
}
}
}
+1
View File
@@ -1,4 +1,5 @@
using BrewMonster;
using BrewMonster.Managers;
using BrewMonster.Network;
using BrewMonster.Scripts;
using BrewMonster.Scripts.World;
+6 -364
View File
@@ -1,9 +1,7 @@
using BrewMonster;
using BrewMonster.Assets.PerfectWorld.Scripts.Players;
using 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<int, COOLTIME> m_skillCoolTime = new Dictionary<int, COOLTIME>();
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;
}
}
}
}