From 093c257f7435eb1aee4da4852dc224bafbd80d2a Mon Sep 17 00:00:00 2001 From: Chomper9981 Date: Mon, 19 Jan 2026 16:16:51 +0700 Subject: [PATCH 1/2] Load more ItemType --- .../Common/DataProcess/generate_item_temp.cs | 133 ++++++ .../Scripts/Common/DataProcess/itemdataman.cs | 6 + .../PerfectWorld/Scripts/GameData/ExpTypes.cs | 42 +- .../PerfectWorld/Scripts/MainFiles/EC_Game.cs | 1 - .../Managers/EC_IvtrItem/EC_IvtrArmor.cs | 21 +- .../Managers/EC_IvtrItem/EC_IvtrArmorrune.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrArrow.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrAutoHp.cs | 163 ++++++- .../Managers/EC_IvtrItem/EC_IvtrAutoMp.cs | 162 ++++++- .../Managers/EC_IvtrItem/EC_IvtrBible.cs | 5 + .../EC_IvtrItem/EC_IvtrCertificate.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrCongregate.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrDamagerune.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrDecoration.cs | 443 +++++++++++++++++- .../EC_IvtrItem/EC_IvtrDestroyingEssence.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrDoubleExp.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrDyeTicket.cs | 5 + .../EC_IvtrItem/EC_IvtrDynSkillEquip.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrElement.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrEquip.cs | 104 +--- .../Managers/EC_IvtrItem/EC_IvtrFacePill.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrFaceTicket.cs | 5 + .../EC_IvtrItem/EC_IvtrFactionMaterial.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrFashion.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrFirework.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrFlysword.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrForceToken.cs | 5 + .../EC_IvtrItem/EC_IvtrGeneralCard.cs | 5 + .../EC_IvtrItem/EC_IvtrGeneralCardDice.cs | 5 + .../EC_IvtrItem/EC_IvtrGmGenerator.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrGoblin.cs | 5 + .../EC_IvtrItem/EC_IvtrGoblinEquip.cs | 5 + .../EC_IvtrItem/EC_IvtrGoblinExpPill.cs | 5 + .../EC_IvtrItem/EC_IvtrIncSkillAbility.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrItem.cs | 212 +++++++-- .../EC_IvtrItem/EC_IvtrLookInfoItem.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrMaterial.cs | 94 +++- .../Managers/EC_IvtrItem/EC_IvtrMedicine.cs | 177 +++++++ .../EC_IvtrItem/EC_IvtrMoneyConvertible.cs | 5 + .../EC_IvtrItem/EC_IvtrMonsterSpirit.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrPetEgg.cs | 5 + .../EC_IvtrItem/EC_IvtrPetFaceTicket.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrPetFood.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrRecipe.cs | 5 + .../EC_IvtrItem/EC_IvtrRefineTicket.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrRevScroll.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrSharpener.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrShopToken.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrSkillMat.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrSkilltome.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrSpeaker.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrStone.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrTargetItem.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrTaskDice.cs | 5 + .../EC_IvtrItem/EC_IvtrTaskNmMatter.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrTaskmatter.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrTossMat.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrTownscroll.cs | 5 + .../EC_IvtrItem/EC_IvtrTransmitScroll.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrType.cs | 32 +- .../EC_IvtrItem/EC_IvtrUnionscroll.cs | 5 + .../EC_IvtrItem/EC_IvtrUniversalToken.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrUnknown.cs | 5 + .../EC_IvtrItem/EC_IvtrWarTankCallin.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrWeapon.cs | 17 +- .../EC_IvtrItem/EC_IvtrWeddingBookCard.cs | 5 + .../EC_IvtrItem/EC_IvtrWeddingInviteCard.cs | 5 + .../Managers/EC_IvtrItem/EC_IvtrWing.cs | 5 + Assets/Prefabs/UI/item_info.prefab | 4 +- 69 files changed, 1705 insertions(+), 176 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/generate_item_temp.cs b/Assets/PerfectWorld/Scripts/Common/DataProcess/generate_item_temp.cs index 36685b2f41..5e569683e4 100644 --- a/Assets/PerfectWorld/Scripts/Common/DataProcess/generate_item_temp.cs +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/generate_item_temp.cs @@ -608,7 +608,140 @@ public static class generate_item_temp itemdataman.set_to_classid(DATA_TYPE.DT_TASKNORMALMATTER_ESSENCE, data, -1); return 0; } + public static int generate_medicine(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls) + { + DATA_TYPE datatype = DATA_TYPE.DT_INVALID; + data = new byte[0]; + size = 0; + int i=0; + object obj = itemdataman._edm.get_data_ptr(id, idspace, ref datatype); + if(obj == null || datatype != DATA_TYPE.DT_MEDICINE_ESSENCE) + { + return -1; + } + MEDICINE_ESSENCE ess = (MEDICINE_ESSENCE)obj; + + size = (uint)(Marshal.SizeOf(typeof(item_data))); + switch(ess.id_major_type) + { + case 1794: // ��Ѫ���� + case 1802: // ��ħ���� + case 1810: // ��Ѫ��ħ���� + size += (uint)(Marshal.SizeOf(typeof(uint)) + Marshal.SizeOf(typeof(uint)) + Marshal.SizeOf(typeof(uint)) + Marshal.SizeOf(typeof(int))); + break; + case 1815: // �ⶾҩ + case 2038: // ˲��ⶾҩ + size += sizeof(int) + sizeof(int); + break; + default: + return -1; + } + + data = new byte[size]; + int offset = 0; + WriteUInt(data, ref offset, id); //��Ʒ��ģ��ID + WriteUInt(data, ref offset, 1); //��Ʒ������ + WriteInt(data, ref offset, ess.pile_num_max); //��Ʒ�Ķѵ����� + WriteInt(data, ref offset, 0); //��Ʒ�Ŀ�װ����־ + WriteUInt(data, ref offset, ess.proc_type); //��Ʒ�Ĵ�����ʽ + WriteInt(data, ref offset, (int)DATA_TYPE.DT_MEDICINE_ESSENCE); //��Ʒ��Ӧ�����ID + if(ess.has_guid == 1) + { + int g1,g2; + itemdataman.get_item_guid(id,out g1,out g2); + WriteInt(data, ref offset, g1); //��Ʒ��Ӧ�����ID guid + WriteInt(data, ref offset, g2); //��Ʒ��Ӧ�����ID guid + } + else + { + WriteInt(data, ref offset, 0); //��Ʒ��Ӧ�����ID guid + WriteInt(data, ref offset, 0); //��Ʒ��Ӧ�����ID guid + } + WriteInt(data, ref offset, ess.price); //��Ʒ�ļ۸� + WriteInt(data, ref offset, 0); //����ʱ�� + + int content_length = 0; + int content_length_ptr = offset; + WriteInt(data, ref offset, 0); + int item_content = offset; + WriteInt(data, ref offset, 0); + content_length = (int)(size - offset); + WriteInt(data, ref content_length_ptr, content_length); + WriteInt(data, ref item_content, offset); + + switch(ess.id_major_type) + { + case 1794: // ��Ѫ���� + if(ess.cool_time < 1000) ess.cool_time *= 100; + WriteInt(data, ref offset, ess.hp_add_total); + WriteInt(data, ref offset, ess.hp_add_time); + WriteInt(data, ref offset, ess.cool_time); + WriteInt(data, ref offset, ess.require_level); + break; + case 1802: // ��ħ���� + if(ess.cool_time < 1000) ess.cool_time *= 100; + WriteInt(data, ref offset, ess.mp_add_total); + WriteInt(data, ref offset, ess.mp_add_time); + WriteInt(data, ref offset, ess.cool_time); + WriteInt(data, ref offset, ess.require_level); + break; + case 1810: // ��Ѫ��ħ���� + if(ess.cool_time < 1000) ess.cool_time *= 100; + WriteInt(data, ref offset, ess.mp_add_total); + WriteInt(data, ref offset, ess.hp_add_total); + WriteInt(data, ref offset, ess.cool_time); + WriteInt(data, ref offset, ess.require_level); + break; + case 1815: // �ⶾҩ + case 2038: // ˲��ⶾҩ + if(ess.cool_time < 1000) ess.cool_time *= 100; + WriteInt(data, ref offset, ess.cool_time); + WriteInt(data, ref offset, ess.require_level); + break; + default: + return -1; + } + itemdataman.set_to_classid(DATA_TYPE.DT_MEDICINE_ESSENCE, data, (int)ess.id_major_type); + + return 0; + } + public static int generate_material(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls) + { + DATA_TYPE datatype = DATA_TYPE.DT_INVALID; + object obj = itemdataman._edm.get_data_ptr(id, idspace, ref datatype); + data = new byte[0]; + size = 0; + if(obj == null || datatype != DATA_TYPE.DT_MATERIAL_ESSENCE) + { + return -1; + } + MATERIAL_ESSENCE ess = (MATERIAL_ESSENCE)obj; + size = (uint)(Marshal.SizeOf(typeof(item_data))); + data = new byte[size]; + int offset = 0; + if(ess.has_guid == 1){ + int g1,g2; + itemdataman.get_item_guid(id,out g1,out g2); + WriteInt(data, ref offset, g1); + WriteInt(data, ref offset, g2); + } + else{ + WriteInt(data, ref offset, 0); + WriteInt(data, ref offset, 0); + } + int content_length = 0; + int content_length_ptr = offset; + WriteInt(data, ref offset, 0); + int item_content = offset; + WriteInt(data, ref offset, 0); + content_length = (int)(size - offset); + WriteInt(data, ref content_length_ptr, content_length); + WriteInt(data, ref item_content, offset); + + itemdataman.set_to_classid(DATA_TYPE.DT_MATERIAL_ESSENCE, data, -1); + return 0; + } #region Write Functions private static void WriteUInt(byte[] buf, ref int offset, uint value) { diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/itemdataman.cs b/Assets/PerfectWorld/Scripts/Common/DataProcess/itemdataman.cs index b4085ec4c8..3fabf85195 100644 --- a/Assets/PerfectWorld/Scripts/Common/DataProcess/itemdataman.cs +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/itemdataman.cs @@ -462,6 +462,12 @@ namespace BrewMonster ret = generate_item_temp.generate_tasknormalmatter(id,ID_SPACE.ID_SPACE_ESSENCE, out item,out size,SPECIFIC.SPECIFIC_RAND,GEN_ADDON_MODE.ADDON_LIST_SHOP,tag); break; + case DATA_TYPE.DT_MEDICINE_ESSENCE: + ret = generate_item_temp.generate_medicine(id, ID_SPACE.ID_SPACE_ESSENCE, out item, out size, SPECIFIC.SPECIFIC_RAND); + break; + case DATA_TYPE.DT_MATERIAL_ESSENCE: + ret = generate_item_temp.generate_material(id, ID_SPACE.ID_SPACE_ESSENCE, out item, out size, SPECIFIC.SPECIFIC_RAND); + break; default: ret = -1; break; diff --git a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs index aa4482b4b9..8c85eb0caf 100644 --- a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs +++ b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs @@ -55,12 +55,15 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Weapon sub-type name + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_hitgfx; // Hit effect file path + public string FileHitGfx => ByteToStringUtils.ByteArrayToCP936String(file_hitgfx); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_hitsfx; // Hit sound effect file path - + public string FileHitSfx => ByteToStringUtils.ByteArrayToCP936String(file_hitsfx); public float probability_fastest; // Attack frequency probability: Fastest -0.1 public float probability_fast; // Attack frequency probability: Fast -0.05 public float probability_normal; // Attack frequency probability: Normal 0 @@ -258,6 +261,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Armor major type name + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -267,6 +271,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Armor sub-type name + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); public uint equip_mask; // Equipment slot mask } @@ -433,6 +438,8 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Decoration sub-type name + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); + public uint equip_mask; // Equipment slot mask } @@ -447,16 +454,24 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Decoration name, max 15 characters + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); + // Display information [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_model; // Model file path + public string FileModel => ByteToStringUtils.ByteArrayToCP936String(file_model); + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_matter; // Matter model file path + public string FileMatter => ByteToStringUtils.ByteArrayToCP936String(file_matter); + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon; // Icon file path + public string FileIcon => ByteToStringUtils.ByteArrayToCP936String(file_icon); + public int level; // Decoration level // Equipment requirements @@ -827,6 +842,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Medicine major type name + public string Name => ByteToStringUtils.UshortArrayToCP936String(name); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -847,13 +863,18 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Medicine name, max 15 characters + public string Name => ByteToStringUtils.UshortArrayToCP936String(name); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_matter; // Matter model file path + public string FileMatter => ByteToStringUtils.ByteArrayToCP936String(file_matter); + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon; // Icon file path + public string FileIcon => ByteToStringUtils.ByteArrayToCP936String(file_icon); + public int require_level; // Required level public int cool_time; // Cooldown time (seconds) @@ -933,12 +954,18 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Name, max 15 characters + public string Name => ByteToStringUtils.UshortArrayToCP936String(name); + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_matter; // Matter model file path + public string FileMatter => ByteToStringUtils.ByteArrayToCP936String(file_matter); + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon; // Icon file path + public string FileIcon => ByteToStringUtils.ByteArrayToCP936String(file_icon); + public int total_hp; // Total HP recovery public float trigger_amount; // Trigger HP threshold public int cool_time; // Cooldown time (seconds) @@ -959,13 +986,18 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Name, max 15 characters + public string Name => ByteToStringUtils.UshortArrayToCP936String(name); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public byte[] file_matter; // Matter model file path + public byte[] file_matter; // Matter model file path + + public string FileMatter => ByteToStringUtils.ByteArrayToCP936String(file_matter); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon; // Icon file path + public string FileIcon => ByteToStringUtils.ByteArrayToCP936String(file_icon); + public int total_mp; // Total MP recovery public float trigger_amount; // Trigger MP threshold public int cool_time; // Cooldown time (seconds) @@ -1038,6 +1070,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Material major type name + public string Name => ByteToStringUtils.UshortArrayToCP936String(name); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -1047,6 +1080,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Material sub-type name + public string Name => ByteToStringUtils.UshortArrayToCP936String(name); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -1058,13 +1092,15 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Material name, max 15 characters + public string Name => ByteToStringUtils.UshortArrayToCP936String(name); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_matter; // Matter model file path + public string FileMatter => ByteToStringUtils.ByteArrayToCP936String(file_matter); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon; // Icon file path - + public string FileIcon => ByteToStringUtils.ByteArrayToCP936String(file_icon); public int price; // Base price public int shop_price; // Shop price diff --git a/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs b/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs index c700460d61..35076d00e8 100644 --- a/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs +++ b/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs @@ -84,7 +84,6 @@ namespace BrewMonster.Network } public static Dictionary GetSuiteEquipTab() { - Debug.Log("[EC_Game] GetSuiteEquipTab: " + m_SuiteEquipTab.Count); return m_SuiteEquipTab; } public static bool TryGetItemMsg(int templateId, out int messageId, out int displayMode) diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmor.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmor.cs index 7342e66121..ccda52735a 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmor.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmor.cs @@ -64,7 +64,9 @@ using BrewMonster.Scripts; namespace PerfectWorld.Scripts.Managers { - + /// + /// Armor item class (Mu + Ao + Quan + Giay) / Armor item class (Helmet + Armor + Pants + Boots) + /// public class EC_IvtrArmor : EC_IvtrEquip { //Attributes @@ -75,6 +77,11 @@ namespace PerfectWorld.Scripts.Managers protected ARMOR_SUB_TYPE m_pDBSubType; protected ARMOR_ESSENCE m_pDBEssence; + /// + /// Constructor for armor item (Mu + Ao + Quan + Giay) / Constructor for armor item (Helmet + Armor + Pants + Boots) + /// + /// Template id + /// Expire date public EC_IvtrArmor(int tid, int expire_date) : base(tid, expire_date) { m_iCID = (int)InventoryClassId.ICID_ARMOR; @@ -93,6 +100,10 @@ namespace PerfectWorld.Scripts.Managers RepairFee = m_pDBEssence.repairfee; ReputationReq = m_pDBEssence.require_reputation; } + /// + /// Copy constructor for armor item (Mu + Ao + Quan + Giay) / Copy constructor for armor item (Helmet + Armor + Pants + Boots) + /// + /// Other armor item to copy from public EC_IvtrArmor(EC_IvtrArmor other) : base(other) { m_pDBEssence = other.m_pDBEssence; @@ -382,14 +393,18 @@ namespace PerfectWorld.Scripts.Managers m_strDesc += "\\r"; AddIDDescText(); AddBindDescText(); + BMLogger.Log("AddBindDescText: " + m_strDesc); // Is destroying? AddDestroyingDesc((int)m_pDBEssence.id_drop_after_damaged, m_pDBEssence.num_drop_after_damaged); + BMLogger.Log("AddDestroyingDesc: " + m_strDesc); AddExpireTimeDesc(); + BMLogger.Log("AddExpireTimeDesc: " + m_strDesc); // Sub class name - AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_CLASSNAME), m_pDBSubType.name.ToString()); + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_CLASSNAME), m_pDBSubType.Name); + BMLogger.Log("AddDescText: " + m_strDesc); // Weapon level AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), m_pDBEssence.level); - + BMLogger.Log("AddDescText: " + m_strDesc); // Physical defence if (m_Essence.defense - aPEEVals[PEEI_PHYDEF] + aRefines[REFINE_PHYDEF] != 0) { diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmorrune.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmorrune.cs index d6265d5373..f9ae470646 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmorrune.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmorrune.cs @@ -4,6 +4,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrArmorrune : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrArmorrune(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArrow.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArrow.cs index b539ae2fd2..0dbbef4231 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArrow.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArrow.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrArrow : EC_IvtrEquip { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrArrow(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrAutoHp.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrAutoHp.cs index 72f8f163fa..e65bb72aab 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrAutoHp.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrAutoHp.cs @@ -1,15 +1,174 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Define and Macro +// +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// +// Reference to External variables and functions +// +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// +// Local Types and Variables and Global variables +// +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// +// Local functions +// +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// +// Implement CECIvtrDecoration +// +/////////////////////////////////////////////////////////////////////////// +using BrewMonster; +using ModelRenderer.Scripts.GameData; +using System.Collections.Generic; +using BrewMonster.Network; using BrewMonster.Scripts.Managers; +using BrewMonster.Scripts; +using System.Runtime.InteropServices; +using System; +using CSNetwork.GPDataType; namespace PerfectWorld.Scripts.Managers { - public class EC_IvtrAutoHp : EC_IvtrItem + /// + /// Auto HP item class (tu dong hoi mau). This is a part of CEC_IvtrEquipMatter(C++) + /// + public class EC_IvtrAutoHp : EC_IvtrEquip { + public IVTR_ESSENCE_AUTOHP m_Essence; + + // Data in database + public AUTOHP_ESSENCE m_pDBEssence; + /// + /// Constructor for auto HP item (tu dong hoi mau) / Constructor for auto HP item (automatic HP recovery) + /// + /// Template id + /// Expire date public EC_IvtrAutoHp(int tid, int expire_date) : base(tid, expire_date) { + m_iCID = (int)InventoryClassId.ICID_AUTOHP; + + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + m_pDBEssence = (AUTOHP_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_iPileLimit = m_pDBEssence.pile_num_max; + m_iPrice = m_pDBEssence.price; + m_iShopPrice = m_pDBEssence.shop_price; + m_iProcType = (int)m_pDBEssence.proc_type; + m_i64EquipMask = (long)EC_IvtrType.EQUIP_MASK64_AUTOHP; } + /// + /// Copy constructor for auto HP item (tu dong hoi mau) / Copy constructor for auto HP item (automatic HP recovery) + /// + /// Other auto HP item to copy from public EC_IvtrAutoHp(EC_IvtrAutoHp other) : base(other) { + m_pDBEssence = other.m_pDBEssence; + m_Essence = other.m_Essence; + } + + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + + if (pInfoData == null || iDataLen == 0) + return true; + + try + { + CECDataReader dr = new CECDataReader(pInfoData, iDataLen); + + m_Essence = new IVTR_ESSENCE_AUTOHP(dr.ReadData(Marshal.SizeOf())); + } + catch (Exception e) + { + BMLogger.LogError("CECIvtrAutoHP::SetItemInfo, data read error (" + e.GetType() + ")"); + return false; + } + + return true; + } + + // Get item icon file name + public override string GetIconFile() + { + return m_pDBEssence.FileIcon; + } + +// Get item name + public override string GetName() + { + return m_pDBEssence.Name; + } + + + // Get item description text + protected override string GetNormalDesc(bool bRepair) + { + if (m_bNeedUpdate) + return null; + + m_strDesc = string.Empty; + + // Try to build item description + CECStringTab pDescTab = EC_Game.GetItemDesc(); + CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer(); + + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + int red = (int)DescriptipionMsg.ITEMDESC_COL_RED; + + if (m_iCount > 1) + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount); + else + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName()); + + AddIDDescText(); + + AddBindDescText(); + + AddExpireTimeDesc(); + + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AUTOHP1), m_Essence.hp_left, m_pDBEssence.total_hp); + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AUTOHP2), (int)(m_pDBEssence.trigger_amount * 100.0f + 0.5f)); + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_COOLTIME), m_pDBEssence.cool_time / 1000); + + // Price + AddPriceDesc(white, bRepair); + + // Suite description + AddSuiteDesc(); + + // Extend description + AddExtDescText(); + + return m_strDesc; + } + + // Get drop model for shown + public override string GetDropModel() + { + return m_pDBEssence.FileMatter; + } + + // Get item cool time + public int GetCoolTime(ref int piMax) + { + CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer(); + return pHost != null ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_AUTOHP, ref piMax) : 0; } } } - diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrAutoMp.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrAutoMp.cs index 5bb5775c17..f9deb706de 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrAutoMp.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrAutoMp.cs @@ -1,14 +1,174 @@ +/////////////////////////////////////////////////////////////////////////// +// +// Define and Macro +// +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// +// Reference to External variables and functions +// +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// +// Local Types and Variables and Global variables +// +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// +// Local functions +// +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +// +// Implement CECIvtrDecoration +// +/////////////////////////////////////////////////////////////////////////// +using BrewMonster; +using ModelRenderer.Scripts.GameData; +using System.Collections.Generic; +using BrewMonster.Network; using BrewMonster.Scripts.Managers; +using BrewMonster.Scripts; +using System.Runtime.InteropServices; +using System; +using CSNetwork.GPDataType; namespace PerfectWorld.Scripts.Managers { - public class EC_IvtrAutoMp : EC_IvtrItem + /// + /// Auto MP item class (tu dong hoi mana). This is a part of CEC_IvtrEquipMatter(C++) + /// + public class EC_IvtrAutoMp : EC_IvtrEquip { + public IVTR_ESSENCE_AUTOMP m_Essence; + + // Data in database + public AUTOMP_ESSENCE m_pDBEssence; + /// + /// Constructor for auto MP item (tu dong hoi mana) / Constructor for auto MP item (automatic MP recovery) + /// + /// Template id + /// Expire date public EC_IvtrAutoMp(int tid, int expire_date) : base(tid, expire_date) { + m_iCID = (int)InventoryClassId.ICID_AUTOMP; + + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + m_pDBEssence = (AUTOMP_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_iPileLimit = m_pDBEssence.pile_num_max; + m_iPrice = m_pDBEssence.price; + m_iShopPrice = m_pDBEssence.shop_price; + m_iProcType = (int)m_pDBEssence.proc_type; + m_i64EquipMask = (long)EC_IvtrType.EQUIP_MASK64_AUTOMP; } + /// + /// Copy constructor for auto MP item (tu dong hoi mana) / Copy constructor for auto MP item (automatic MP recovery) + /// + /// Other auto MP item to copy from public EC_IvtrAutoMp(EC_IvtrAutoMp other) : base(other) { + m_pDBEssence = other.m_pDBEssence; + m_Essence = other.m_Essence; + } + + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + + if (pInfoData == null || iDataLen == 0) + return true; + + try + { + CECDataReader dr = new CECDataReader(pInfoData, iDataLen); + + m_Essence = new IVTR_ESSENCE_AUTOMP(dr.ReadData(Marshal.SizeOf())); + } + catch (Exception e) + { + BMLogger.LogError("CECIvtrAutoHP::SetItemInfo, data read error (" + e.GetType() + ")"); + return false; + } + + return true; + } + + // Get item icon file name + public override string GetIconFile() + { + return m_pDBEssence.FileIcon; + } + +// Get item name + public override string GetName() + { + return m_pDBEssence.Name; + } + + + // Get item description text + protected override string GetNormalDesc(bool bRepair) + { + if (m_bNeedUpdate) + return null; + + m_strDesc = string.Empty; + + // Try to build item description + CECStringTab pDescTab = EC_Game.GetItemDesc(); + CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer(); + + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + int red = (int)DescriptipionMsg.ITEMDESC_COL_RED; + + if (m_iCount > 1) + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount); + else + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName()); + + AddIDDescText(); + + AddBindDescText(); + + AddExpireTimeDesc(); + + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AUTOMP1), m_Essence.mp_left, m_pDBEssence.total_mp); + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AUTOMP2), (int)(m_pDBEssence.trigger_amount * 100.0f + 0.5f)); + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_COOLTIME), m_pDBEssence.cool_time / 1000); + + // Price + AddPriceDesc(white, bRepair); + + // Suite description + AddSuiteDesc(); + + // Extend description + AddExtDescText(); + + return m_strDesc; + } + + // Get drop model for shown + public override string GetDropModel() + { + return m_pDBEssence.FileMatter; + } + + // Get item cool time + public int GetCoolTime(ref int piMax) + { + CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer(); + return pHost != null ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_AUTOMP, ref piMax) : 0; } } } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrBible.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrBible.cs index 3a1e3607c3..a34a4190bc 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrBible.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrBible.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrBible : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrBible(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrCertificate.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrCertificate.cs index 17af84f155..043e017336 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrCertificate.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrCertificate.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrCertificate : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrCertificate(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrCongregate.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrCongregate.cs index 0508913946..8fbde128f4 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrCongregate.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrCongregate.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrCongregate : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrCongregate(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDamagerune.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDamagerune.cs index 405849bb17..a56e251ac8 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDamagerune.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDamagerune.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrDamagerune : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrDamagerune(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDecoration.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDecoration.cs index bd2bc8d3e5..0bf3a45000 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDecoration.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDecoration.cs @@ -39,7 +39,9 @@ using BrewMonster.Scripts.Managers; using BrewMonster.Scripts; namespace PerfectWorld.Scripts.Managers { - + /// + /// Decoration item class (boi + nhan + ) / Decoration item class (various types of decorations) + /// public class EC_IvtrDecoration : EC_IvtrEquip { protected IVTR_ESSENCE_DECORATION m_Essence; @@ -47,6 +49,11 @@ namespace PerfectWorld.Scripts.Managers protected DECORATION_SUB_TYPE m_pDBSubType; protected DECORATION_ESSENCE m_pDBEssence; + /// + /// Constructor for decoration item (cac loai trang suc) / Constructor for decoration item (various types of decorations) + /// + /// Template id + /// Expire date public EC_IvtrDecoration(int tid, int expire_date) : base(tid, expire_date) { m_iCID = (int)InventoryClassId.ICID_DECORATION; @@ -66,6 +73,10 @@ namespace PerfectWorld.Scripts.Managers ReputationReq = m_pDBEssence.require_reputation; } + /// + /// Copy constructor for decoration item (cac loai trang suc) / Copy constructor for decoration item (various types of decorations) + /// + /// Other decoration item to copy from public EC_IvtrDecoration(EC_IvtrDecoration other) : base(other) { m_pDBEssence = other.m_pDBEssence; @@ -73,7 +84,435 @@ namespace PerfectWorld.Scripts.Managers m_pDBSubType = other.m_pDBSubType; m_Essence = other.m_Essence; } - + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + if(pInfoData == null || iDataLen == 0) + { + return true; + } + + try + { + CECDataReader dr = new CECDataReader(pInfoData ,iDataLen); + // Skip equip requirements and endurance + dr.Offset(6 * sizeof(short), CECDataReader.SEEK_CUR); + dr.Offset(2 * sizeof(int), CECDataReader.SEEK_CUR); + int iEssenceSize = dr.ReadShort(); + // Skip maker's information + dr.ReadByte(); + int iMakerLen = dr.ReadByte(); + dr.Offset(iMakerLen, CECDataReader.SEEK_CUR); + byte[] iEssenceData = dr.ReadData(iEssenceSize); + m_Essence = new IVTR_ESSENCE_DECORATION(iEssenceData); + // ���븽������˵�� + if(m_pDBEssence.fixed_props != 0 && m_pDBEssence.probability_addon_num0 != 1.0f) + { + // Get database data + elementdataman pDataMan = ElementDataManProvider.GetElementDataMan(); + CECStringTab PropTab = EC_Game.GetItemExtProp(); + int i, iSize = 0; + for(i=0;i<32;i++) + { + if(m_pDBEssence.addons[i].id_addon != 0) + iSize++; + } + if(iSize > 0 && Props.Count == 0) + { + Props.Capacity = iSize; + for(i=0;i<32;i++) + { + if(m_pDBEssence.addons[i].id_addon != 0) + { + Property Prop = new Property(); + Prop.Type = (int)m_pDBEssence.addons[i].id_addon; + Prop.Embed = false; + Prop.Suite = false; + Prop.Engraved = false; + Prop.Local = false; + byte bType = PropTab.GetWideString(Prop.Type) != null ? (byte)0xff : (byte)0xff; + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + object pData = pDataMan.get_data_ptr(m_pDBEssence.addons[i].id_addon, ID_SPACE.ID_SPACE_ADDON, ref DataType); + if (DataType != DATA_TYPE.DT_EQUIPMENT_ADDON) + { + return false; + } + EQUIPMENT_ADDON pAddon = (EQUIPMENT_ADDON)pData; + Prop.NumParam = pAddon.num_params; + for(int j=0; j < Prop.NumParam; j++) + { + if(j==0) + { + Prop.Params[0] = pAddon.param1; + } + else if(j==1) + { + Prop.Params[1] = pAddon.param2; + } + else if(j==2) + { + Prop.Params[2] = pAddon.param3; + } + } + Props.Add(Prop); + } + } + } + } + return true; + } + catch ( System.Exception e) + { + return false; + } + } + public override void DefaultInfo() + { + LevelReq = m_pDBEssence.require_level; + StrengthReq = 0; + AgilityReq = 0; + ReputationReq = m_pDBEssence.require_reputation; + CurEndurance = m_pDBEssence.durability_min * ENDURANCE_SCALE; + MaxEndurance = m_pDBEssence.durability_min * ENDURANCE_SCALE; + } + public override string GetIconFile() + { + return m_pDBEssence.FileIcon; + } + // Get item name + public override string GetName() + { + return m_pDBEssence.Name; + } + public override string GetPreviewInfo() + { + int[] aPEEVals = new int[MAX_PEEINDEX]; + int[] aRefines = new int[MAX_REFINEINDEX]; + for(int i=0; i 0) + AddDescText(-1, true, "{0} +{1}", pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), RefineLvl); + else + m_strDesc += "\\r"; + AddIDDescText(); + AddBindDescText(); + // Is destroying? + AddDestroyingDesc((int)m_pDBEssence.id_drop_after_damaged, m_pDBEssence.num_drop_after_damaged); + AddExpireTimeDesc(); + // Sub class name + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_CLASSNAME), m_pDBSubType.Name); + // Decoration level + AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), m_pDBEssence.level); + + //add Physical damage + if (m_Essence.damage - aPEEVals[PEEI_PHYDAMAGE] + aRefines[REFINE_PHYDAMAGE] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PHYDAMAGE)); + AddDescText(white, true, " +{0}", m_Essence.damage - aPEEVals[PEEI_PHYDAMAGE] + aRefines[REFINE_PHYDAMAGE]); + } + //add Magic damage + if (m_Essence.magic_damage - aPEEVals[PEEI_MAGICDAMAGE] + aRefines[REFINE_MAGICDAMAGE] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_MAGICDAMAGE)); + AddDescText(white, true, " +{0}", m_Essence.magic_damage - aPEEVals[PEEI_MAGICDAMAGE] + aRefines[REFINE_MAGICDAMAGE]); + } + // Physical defence + if (m_Essence.defense - aPEEVals[PEEI_PHYDEF] + aRefines[REFINE_PHYDEF] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PHYDEFENCE)); + AddDescText(white, true, " +{0}", m_Essence.defense - aPEEVals[PEEI_PHYDEF] + aRefines[REFINE_PHYDEF]); + } + // Dodge + if (m_Essence.armor - aPEEVals[PEEI_DODGE] + aRefines[REFINE_DODGE] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_DODGE)); + AddDescText(white, true, " +{0}", m_Essence.armor - aPEEVals[PEEI_DODGE] + aRefines[REFINE_DODGE]); + } + // Gold Resistance + if (m_Essence.resistance[0] - aPEEVals[PEEI_GOLDDEF] + aRefines[REFINE_GOLDDEF] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOLDDEFENCE)); + AddDescText(white, true, " +{0}", m_Essence.resistance[0] - aPEEVals[PEEI_GOLDDEF] + aRefines[REFINE_GOLDDEF]); + } + // Wood Resistance + if (m_Essence.resistance[1] - aPEEVals[PEEI_WOODDEF] + aRefines[REFINE_WOODDEF] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_WOODDEFENCE)); + AddDescText(white, true, " +{0}", m_Essence.resistance[1] - aPEEVals[PEEI_WOODDEF] + aRefines[REFINE_WOODDEF]); + } + // Water Resistance + if (m_Essence.resistance[2] - aPEEVals[PEEI_WATERDEF] + aRefines[REFINE_WATERDEF] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_WATERDEFENCE)); + AddDescText(white, true, " +{0}", m_Essence.resistance[2] - aPEEVals[PEEI_WATERDEF] + aRefines[REFINE_WATERDEF]); + } + // Fire Resistance + if (m_Essence.resistance[3] - aPEEVals[PEEI_FIREDEF] + aRefines[REFINE_FIREDEF] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_FIREDEFENCE)); + AddDescText(white, true, " +{0}", m_Essence.resistance[3] - aPEEVals[PEEI_FIREDEF] + aRefines[REFINE_FIREDEF]); + } + // Earth Resistance + if (m_Essence.resistance[4] - aPEEVals[PEEI_EARTHDEF] + aRefines[REFINE_EARTHDEF] != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_EARTHDEFENCE)); + AddDescText(white, true, " +{0}", m_Essence.resistance[4] - aPEEVals[PEEI_EARTHDEF] + aRefines[REFINE_EARTHDEF]); + } + // Endurance + int col = white; + if (CurEndurance == 0) + col = red; + else if ((dwPEE & PEE_ENDURANCE) != 0) + col = lblue; + AddDescText(col, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ENDURANCE)); + AddDescText(col, true, " {0}/{1}", VisualizeEndurance(CurEndurance), VisualizeEndurance(MaxEndurance)); + + // Profession requirement + AddProfReqDesc((uint)ProfReq); + // Level requirment + if (LevelReq != 0) + { + col = pHost.GetMaxLevelSofar() >= LevelReq ? white : red; + AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVELREQ), LevelReq); + } + // Strength requirment + if (StrengthReq != 0) + { + col = pHost.GetExtendProps().bs.strength < StrengthReq ? red : ((dwPEE & PEE_STRENGTHREQ) != 0 ? lblue : white); + AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_STRENGTHREQ), StrengthReq); + } + // Agility requirment + if (AgilityReq != 0) + { + col = pHost.GetExtendProps().bs.agility < AgilityReq ? red : ((dwPEE & PEE_AGILITYREQ) != 0 ? lblue : white); + AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AGILITYREQ), AgilityReq); + } + // Vitality requirment + if (VitalityReq != 0) + { + col = pHost.GetExtendProps().bs.vitality < VitalityReq ? red : ((dwPEE & PEE_VITALITYREQ) != 0 ? lblue : white); + AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_VITALITYREQ), VitalityReq); + } + // Energy requirment + if (EnergyReq != 0) + { + col = pHost.GetExtendProps().bs.energy < EnergyReq ? red : ((dwPEE & PEE_ENERGYREQ) != 0 ? lblue : white); + AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ENERGYREQ), EnergyReq); + } + // Reputation requirement + AddReputationReqDesc(); + // Add addon properties + if (!string.IsNullOrEmpty(strAddon)) + m_strDesc += strAddon; + // Build tessera description + BuildTesseraDesc(); + if(m_pDBEssence.fixed_props == 0 && m_bIsInNPCPack) + AddDescText((int)DescriptipionMsg.ITEMDESC_COL2_BRIGHTBLUE, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_HASRANDOM_PROP)); + // Price + AddPriceDesc(white, bRepair); + AddSharpenerDesc(); + AddEngravedDesc(); + AddMakerDesc(); + m_strDesc += "\\r"; + AddSuiteDesc(); + AddExtDescText(); + return m_strDesc; + } + public bool HasRandomProp() + { + for (int i = 0; i < Props.Count; i++) + { + if (!Props[i].Embed && !Props[i].Engraved && Props[i].Type == 472) + return true; + } + return false; + } + public int GetRefineMaterialNum() + { + return m_pDBEssence.material_need; + } + public override uint GetRefineAddOn() + { + return (uint)m_pDBEssence.levelup_addon; + } + public override string GetDropModel() + { + return m_pDBEssence.FileMatter; + } + public override bool IsRare() + { + return base.IsRare() || m_pDBEssence.level >= 6; + } + public override int GetItemLevel() + { + return m_pDBEssence.level; + } } + } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDestroyingEssence.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDestroyingEssence.cs index 6e05875dd8..46aea629db 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDestroyingEssence.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDestroyingEssence.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrDestroyingEssence : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrDestroyingEssence(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDoubleExp.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDoubleExp.cs index 52778da300..9723fb0966 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDoubleExp.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDoubleExp.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrDoubleExp : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrDoubleExp(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDyeTicket.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDyeTicket.cs index 11d8162ba5..833643040b 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDyeTicket.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDyeTicket.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrDyeTicket : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrDyeTicket(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDynSkillEquip.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDynSkillEquip.cs index 4e18b6edc4..a69242f043 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDynSkillEquip.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrDynSkillEquip.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrDynSkillEquip : EC_IvtrEquip { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrDynSkillEquip(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrElement.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrElement.cs index f667324b31..abd218aa70 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrElement.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrElement.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrElement : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrElement(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrEquip.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrEquip.cs index c2e77eb454..260b3a7a3a 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrEquip.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrEquip.cs @@ -2346,106 +2346,20 @@ namespace PerfectWorld.Scripts.Managers /// protected override void AddDescText(int color, bool newLine, string format, params object[] args) { + // Add color prefix if color is specified if (color >= 0) { string colorStr = GetColorString((DescriptipionMsg)color); m_strDesc += colorStr; } - if (args.Length > 0) - { - // Accept both C#-style ("{0}") and printf-style ("%d", "%+d", "%.2f", "%%") formats - string output; - if (format.IndexOf('%') >= 0 && format.IndexOf('{') < 0) - { - output = FormatPrintfLike(format, args); - } - else - { - output = string.Format(format, args); - } - m_strDesc += output; - } - else - { - m_strDesc += format; - } + // Call base implementation for format conversion (handles both {0} and %d styles) + base.AddDescText(-1, false, format, args); + // Add newline if requested (base class uses "\n", but equip uses "\\r") if (newLine) m_strDesc += "\\r"; } - - private static string FormatPrintfLike(string fmt, object[] args) - { - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - int argIndex = 0; - for (int i = 0; i < fmt.Length; i++) - { - char c = fmt[i]; - if (c != '%') - { - sb.Append(c); - continue; - } - - if (i + 1 < fmt.Length && fmt[i + 1] == '%') - { - sb.Append('%'); - i += 1; - continue; - } - - bool plus = false; - int precision = -1; - int j = i + 1; - if (j < fmt.Length && fmt[j] == '+') { plus = true; j++; } - if (j < fmt.Length && fmt[j] == '.') - { - // precision like %.2f - j++; - int start = j; - while (j < fmt.Length && char.IsDigit(fmt[j])) j++; - int.TryParse(fmt.Substring(start, j - start), out precision); - } - - if (j < fmt.Length) - { - char spec = fmt[j]; - if (spec == 'd') - { - object val = argIndex < args.Length ? args[argIndex++] : 0; - long iv = Convert.ToInt64(val); - string s = iv.ToString(); - if (plus && iv >= 0) s = "+" + s; - sb.Append(s); - i = j; - continue; - } - else if (spec == 'f') - { - object val = argIndex < args.Length ? args[argIndex++] : 0.0; - double dv = Convert.ToDouble(val); - string s = precision >= 0 ? dv.ToString("F" + precision) : dv.ToString("F"); - if (plus && dv >= 0) s = "+" + s; - sb.Append(s); - i = j; - continue; - } - else if (spec == 's') - { - object val = argIndex < args.Length ? args[argIndex++] : ""; - string s = val != null ? val.ToString() : ""; - sb.Append(s); - i = j; - continue; - } - } - - // Fallback: treat '%' as literal if format not recognized - sb.Append('%'); - } - return sb.ToString(); - } /// /// Get color string for color ID @@ -4277,8 +4191,8 @@ namespace PerfectWorld.Scripts.Managers if (!bShowDetail) { - m_strDesc = "\\r\\r"; - AddDescText(iNameCol, true, "{0} {1}/{2}", pSuiteEss.Name, 0, pSuiteEss.max_equips); + m_strDesc = ""; + AddDescText(iNameCol, false, "{0} {1}/{2}", pSuiteEss.Name, 0, pSuiteEss.max_equips); m_strDesc = strCurDesc + m_strDesc; return; } @@ -4310,7 +4224,7 @@ namespace PerfectWorld.Scripts.Managers iItemCnt = hostPlayer.GetEquippedSuiteItem(idSuite,ref aEquipped); if(iItemCnt == 0) return; - m_strDesc += "\\r\\r"; + //m_strDesc += "\\r\\r"; // Build suite addon properties at first for (int i = 0; i < MAX_NUM; i++) { @@ -4392,7 +4306,7 @@ namespace PerfectWorld.Scripts.Managers AddDescText(red, true, GetItemDescString(DescriptipionMsg.ITEMDESC_EQUIP_DESTROYING)); AddDescText(red, true, GetItemDescString(DescriptipionMsg.ITEMDESC_EQUIP_REPAIR_NEED_ITEM), essenceName); - AddDescText(red, true, GetItemDescString(DescriptipionMsg.ITEMDESC_EQUIP_REPAIR_NEED_ITEMCNT), (int)(Math.Ceiling(num * 1.2))); + AddDescText(red, true, GetItemDescString(DescriptipionMsg.ITEMDESC_EQUIP_REPAIR_NEED_ITEMCNT), (int)Math.Ceiling(num * 1.2)); } /// @@ -4647,7 +4561,7 @@ namespace PerfectWorld.Scripts.Managers if (string.IsNullOrEmpty(Maker)) return; - m_strDesc += "\\r"; + m_strDesc += "\\r"; // For signed marks (IMT_SIGN), Maker already contains color codes and formatted text. if (MadeFrom == (byte)ITEM_MAKE_TAG.IMT_SIGN) { diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFacePill.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFacePill.cs index 815c598198..204f6c30f5 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFacePill.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFacePill.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrFacePill : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrFacePill(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFaceTicket.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFaceTicket.cs index 9c1fd6ccaa..79dd7fc463 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFaceTicket.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFaceTicket.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrFaceTicket : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrFaceTicket(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFactionMaterial.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFactionMaterial.cs index 3429a0b219..d1ab1f1a26 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFactionMaterial.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFactionMaterial.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrFactionMaterial : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrFactionMaterial(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFashion.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFashion.cs index a6c1751657..8b319c9e68 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFashion.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFashion.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrFashion : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrFashion(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFirework.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFirework.cs index 71d75113d0..53de98e6c4 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFirework.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFirework.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrFirework : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrFirework(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFlysword.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFlysword.cs index 210d40eda0..5e37a8b04c 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFlysword.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrFlysword.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrFlysword : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrFlysword(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrForceToken.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrForceToken.cs index 26dc9fed3e..dd7c6db0f6 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrForceToken.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrForceToken.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrForceToken : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrForceToken(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGeneralCard.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGeneralCard.cs index de46434948..bbc1cd4fee 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGeneralCard.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGeneralCard.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrGeneralCard : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrGeneralCard(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGeneralCardDice.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGeneralCardDice.cs index df28fd9d9a..a18c70d014 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGeneralCardDice.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGeneralCardDice.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrGeneralCardDice : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrGeneralCardDice(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGmGenerator.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGmGenerator.cs index 75f77cf24c..bd2f7818c0 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGmGenerator.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGmGenerator.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrGmGenerator : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrGmGenerator(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblin.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblin.cs index 44878eb090..16a91bcd9e 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblin.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblin.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrGoblin : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrGoblin(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblinEquip.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblinEquip.cs index 26374a3219..bfed287446 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblinEquip.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblinEquip.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrGoblinEquip : EC_IvtrEquip { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrGoblinEquip(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblinExpPill.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblinExpPill.cs index b6c49d6aaa..24a6cd08ae 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblinExpPill.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblinExpPill.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrGoblinExpPill : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrGoblinExpPill(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrIncSkillAbility.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrIncSkillAbility.cs index 93c8043715..6baa876812 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrIncSkillAbility.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrIncSkillAbility.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrIncSkillAbility : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrIncSkillAbility(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrItem.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrItem.cs index 8f3142b426..c2678925c1 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrItem.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrItem.cs @@ -807,7 +807,7 @@ namespace BrewMonster.Scripts.Managers var pItem = new EC_IvtrItem(tid, expire_date); DATA_TYPE DataType = DATA_TYPE.DT_INVALID; object data = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); - Debug.Log("DataType: " + DataType); + Debug.Log("Create item data: DataType: " + DataType); switch(DataType) { case DATA_TYPE.DT_WEAPON_ESSENCE: @@ -1199,9 +1199,11 @@ namespace BrewMonster.Scripts.Managers /// Add item amount. Returns new amount of item. public int AddAmount(int iAmount) { + Debug.Log($"[EC_IvtrItem] Old Amount: {m_iCount}"); m_iCount += iAmount; if (m_iCount < 0) m_iCount = 0; - if (m_iCount > m_iPileLimit) m_iCount = m_iPileLimit; + //if (m_iCount > m_iPileLimit) m_iCount = m_iPileLimit; + Debug.Log($"[EC_IvtrItem] New Amount: {m_iCount}"); return m_iCount; } @@ -1383,6 +1385,8 @@ namespace BrewMonster.Scripts.Managers CECStringTab pDescTab = EC_Game.GetItemDesc(); AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ERRORITEM)); AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, "({0})", m_tid); + m_strDesc += "\\r"; + AddDescText((int)DescriptipionMsg.ITEMDESC_COL_RED, false, "This Item Type is not implemented yet. Type of {0}", this.GetType().Name); TrimLastReturn(); return m_strDesc; @@ -1401,9 +1405,63 @@ namespace BrewMonster.Scripts.Managers protected virtual void AddPriceDesc(int col, bool bRepair) { // Basic price string using scaled price; color is ignored at this level. - int price = GetScaledPrice(); - if (price <= 0) return; - AddDescText(col, true, "Price: {0}", price); + if ((!IsEquipment() && bRepair) || m_iPrice == 0 || m_fPriceScale == 0.0f) + { + TrimLastReturn(); + return; + } + + // use specific color for the item price + if((int)DescriptipionMsg.ITEMDESC_COL_WHITE == col) + { + if( m_iPrice >= 100000000) // 100 million + col = (int)DescriptipionMsg.ITEMDESC_COL_GREEN; + else if ( m_iPrice >= 10000000) // 10 million + col = (int)DescriptipionMsg.ITEMDESC_COL_DARKGOLD; + else if ( m_iPrice >= 1000000) // 1 million + col = (int)DescriptipionMsg.ITEMDESC_COL_YELLOW; + } + + CECStringTab pDescTab = EC_Game.GetItemDesc(); + if (m_iScaleType == (int)ScaleType.SCALE_OFFLINESHOP) + { + AddDescText(col, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PRICE)); + + string s1,s2; + BuildPriceNumberStr(m_iPrice, out s1); + if (GetCount()>1) + { + s2 = (m_iPrice * (long)GetCount()).ToString(); + AddDescText(-1, false, " %s (%s)", s1, s2); + } + else + AddDescText(-1, false, " %s", s1); + } + else if (m_iScaleType == (int)ScaleType.SCALE_BOOTH || m_tid == 21652) // 21651: yinpiao + { + string s1; + BuildPriceNumberStr(m_iPrice, out s1); + + AddDescText(col, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_UNITPRICE)); + AddDescText(-1, false, " %s", s1); + } + else if (m_iScaleType == (int)ScaleType.SCALE_SELL && m_iCount > 1 && m_tid != 21652) + { + string s1, s2; + BuildPriceNumberStr(m_iPrice, out s1); + BuildPriceNumberStr(GetScaledPrice(), out s2); + + AddDescText(col, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PRICE)); + AddDescText(-1, false, " %s (%s)", s1, s2); + } + else + { + string s1; + BuildPriceNumberStr(GetScaledPrice(), out s1); + + AddDescText(col, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PRICE)); + AddDescText(-1, false, " %s", s1); + } } protected virtual void AddProfReqDesc(uint iProfReq) @@ -1445,12 +1503,104 @@ namespace BrewMonster.Scripts.Managers protected virtual void AddDescText(int iCol, bool bRet, string szText, params object[] args) { - string line = (args != null && args.Length > 0) ? string.Format(szText, args) : szText; + string line; + if (args != null && args.Length > 0) + { + // Accept both C#-style ("{0}") and printf-style ("%d", "%+d", "%.2f", "%%") formats + if (szText.IndexOf('%') >= 0 && szText.IndexOf('{') < 0) + { + line = FormatPrintfLike(szText, args); + } + else + { + line = string.Format(szText, args); + } + } + else + { + line = szText; + } m_strDesc += line; if (bRet) m_strDesc += "\n"; } + /// + /// Format string using printf-style format specifiers (%d, %+d, %.2f, %s, etc.) + /// Converts printf-style formats to C# string formatting + /// + private static string FormatPrintfLike(string fmt, object[] args) + { + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + int argIndex = 0; + for (int i = 0; i < fmt.Length; i++) + { + char c = fmt[i]; + if (c != '%') + { + sb.Append(c); + continue; + } + + if (i + 1 < fmt.Length && fmt[i + 1] == '%') + { + sb.Append('%'); + i += 1; + continue; + } + + bool plus = false; + int precision = -1; + int j = i + 1; + if (j < fmt.Length && fmt[j] == '+') { plus = true; j++; } + if (j < fmt.Length && fmt[j] == '.') + { + // precision like %.2f + j++; + int start = j; + while (j < fmt.Length && char.IsDigit(fmt[j])) j++; + int.TryParse(fmt.Substring(start, j - start), out precision); + } + + if (j < fmt.Length) + { + char spec = fmt[j]; + if (spec == 'd') + { + object val = argIndex < args.Length ? args[argIndex++] : 0; + long iv = Convert.ToInt64(val); + string s = iv.ToString(); + if (plus && iv >= 0) s = "+" + s; + sb.Append(s); + i = j; + continue; + } + else if (spec == 'f') + { + object val = argIndex < args.Length ? args[argIndex++] : 0.0; + double dv = Convert.ToDouble(val); + string s = precision >= 0 ? dv.ToString("F" + precision) : dv.ToString("F"); + if (plus && dv >= 0) s = "+" + s; + sb.Append(s); + i = j; + continue; + } + else if (spec == 's') + { + object val = argIndex < args.Length ? args[argIndex++] : ""; + string s = val != null ? val.ToString() : ""; + sb.Append(s); + i = j; + continue; + } + } + + // Fallback: treat '%' as literal if format not recognized + sb.Append('%'); + } + return sb.ToString(); + } + // Add extend description to description string / 添加扩展描述到描述字符串 protected void AddExtDescText() { @@ -1467,22 +1617,9 @@ namespace BrewMonster.Scripts.Managers var pDescTab = EC_Game.GetItemDesc(); // Note: ITEMDESC_COL2_BRIGHTBLUE constant - adjust based on actual string table / 注意:ITEMDESC_COL2_BRIGHTBLUE常量 - 根据实际字符串表调整 int green = (int)DescriptipionMsg.ITEMDESC_COL2_BRIGHTBLUE; // ITEMDESC_COL2_BRIGHTBLUE placeholder - adjust this value - if(typeof(EC_IvtrArmor) == this.GetType()) - { - Debug.Log("This is an armor"); - } - - Debug.Log("armor m_iCID: " + m_iCID); - Debug.Log("armor m_iProcType: " + m_iProcType); + if (m_iCID != (int)InventoryClassId.ICID_GOBLIN) // goblin does not need to display these special properties / 地精不需要显示这些特殊属性 { - Debug.Log("m_iCID != (int)InventoryClassId.ICID_GOBLIN"); - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_NO_USER_TRASH: " + (m_iProcType & (int)ProcType.PROC_NO_USER_TRASH)); - Debug.Log("!((m_iProcType & (int)ProcType.PROC_BINDING) != 0): " + !((m_iProcType & (int)ProcType.PROC_BINDING) != 0)); - Debug.Log("((m_iProcType & (int)ProcType.PROC_DROPWHENDIE) != 0): " + ((m_iProcType & (int)ProcType.PROC_DROPWHENDIE) != 0)); - Debug.Log("((m_iProcType & (int)ProcType.PROC_DROPPABLE) != 0): " + ((m_iProcType & (int)ProcType.PROC_DROPPABLE) != 0)); - Debug.Log("((m_iProcType & (int)ProcType.PROC_SELLABLE) != 0): " + ((m_iProcType & (int)ProcType.PROC_SELLABLE) != 0)); // Exact C++ logic: (PROC_NO_USER_TRASH) || (!PROC_BINDING && (PROC_DROPWHENDIE || ...)) // 精确的C++逻辑:(PROC_NO_USER_TRASH) || (!PROC_BINDING && (PROC_DROPWHENDIE || ...)) if ((m_iProcType & (int)ProcType.PROC_NO_USER_TRASH) != 0 @@ -1506,8 +1643,6 @@ namespace BrewMonster.Scripts.Managers m_strDesc += szCol; } } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_DROPWHENDIE: " + (m_iProcType & (int)ProcType.PROC_DROPWHENDIE)); if ((m_iProcType & (int)ProcType.PROC_DROPWHENDIE) != 0) { m_strDesc += "\\r"; @@ -1517,10 +1652,7 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_DROPPABLE: " + (m_iProcType & (int)ProcType.PROC_DROPPABLE)); if ((m_iProcType & (int)ProcType.PROC_DROPPABLE) != 0) { m_strDesc += "\\r"; @@ -1532,8 +1664,6 @@ namespace BrewMonster.Scripts.Managers } Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_SELLABLE: " + (m_iProcType & (int)ProcType.PROC_SELLABLE)); if ((m_iProcType & (int)ProcType.PROC_SELLABLE) != 0) { m_strDesc += "\\r"; @@ -1543,10 +1673,7 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_TRADEABLE: " + (m_iProcType & (int)ProcType.PROC_TRADEABLE)); if ((m_iProcType & (int)ProcType.PROC_TRADEABLE) != 0) { m_strDesc += "\\r"; @@ -1556,10 +1683,7 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_DISAPEAR: " + (m_iProcType & (int)ProcType.PROC_DISAPEAR)); if ((m_iProcType & (int)ProcType.PROC_DISAPEAR) != 0) { m_strDesc += "\\r"; @@ -1569,10 +1693,7 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_USE: " + (m_iProcType & (int)ProcType.PROC_USE)); if ((m_iProcType & (int)ProcType.PROC_USE) != 0) { m_strDesc += "\\r"; @@ -1582,10 +1703,7 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_DEADDROP: " + (m_iProcType & (int)ProcType.PROC_DEADDROP)); if ((m_iProcType & (int)ProcType.PROC_DEADDROP) != 0) { m_strDesc += "\\r"; @@ -1595,10 +1713,7 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_OFFLINE: " + (m_iProcType & (int)ProcType.PROC_OFFLINE)); if ((m_iProcType & (int)ProcType.PROC_OFFLINE) != 0) { m_strDesc += "\\r"; @@ -1608,10 +1723,7 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_UNREPAIRABLE: " + (m_iProcType & (int)ProcType.PROC_UNREPAIRABLE)); if ((m_iProcType & (int)ProcType.PROC_UNREPAIRABLE) != 0) { m_strDesc += "\\r"; @@ -1621,10 +1733,7 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } - Debug.Log("m_iProcType: " + m_iProcType); - Debug.Log("m_iProcType & (int)ProcType.PROC_NO_USER_TRASH: " + (m_iProcType & (int)ProcType.PROC_NO_USER_TRASH)); if ((m_iProcType & (int)ProcType.PROC_NO_USER_TRASH) != 0) { m_strDesc += "\\r"; @@ -1634,12 +1743,10 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } } else { - Debug.Log("m_iCID == (int)InventoryClassId.ICID_GOBLIN"); TrimLastReturn(); } } @@ -1673,7 +1780,10 @@ namespace BrewMonster.Scripts.Managers protected void AddIDDescText() { // Optional: show internal id for debugging - AddDescText(0, true, "ID: {0}", m_tid); + #if UNITY_EDITOR + AddDescText(0, true, "ID: {0}", m_tid); + #endif + } protected void AddBindDescText() diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrLookInfoItem.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrLookInfoItem.cs index 4ea2355ccf..17268fd3c8 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrLookInfoItem.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrLookInfoItem.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrLookInfoItem : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrLookInfoItem(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMaterial.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMaterial.cs index 9880098373..8c19d7a8ca 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMaterial.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMaterial.cs @@ -1,15 +1,105 @@ using BrewMonster.Scripts.Managers; +using BrewMonster; +using BrewMonster.Scripts; +using ModelRenderer.Scripts.GameData; +using ModelRenderer.Scripts.Common; +using BrewMonster.Network; namespace PerfectWorld.Scripts.Managers { public class EC_IvtrMaterial : EC_IvtrItem { + protected MATERIAL_MAJOR_TYPE m_pDBMajorType; + protected MATERIAL_SUB_TYPE m_pDBSubType; + protected MATERIAL_ESSENCE m_pDBEssence; + + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrMaterial(int tid, int expire_date) : base(tid, expire_date) { + m_iCID = (int)InventoryClassId.ICID_MATERIAL; + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + m_pDBEssence = (MATERIAL_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_pDBMajorType = (MATERIAL_MAJOR_TYPE)pDB.get_data_ptr(m_pDBEssence.id_major_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_pDBSubType = (MATERIAL_SUB_TYPE)pDB.get_data_ptr(m_pDBEssence.id_sub_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_iPileLimit = m_pDBEssence.pile_num_max; + m_iPrice = m_pDBEssence.price; + m_iShopPrice = m_pDBEssence.shop_price; + m_iProcType = (int)m_pDBEssence.proc_type; + m_i64EquipMask = 0; + m_bNeedUpdate = false; } public EC_IvtrMaterial(EC_IvtrMaterial other) : base(other) { + m_pDBEssence = other.m_pDBEssence; + m_pDBMajorType = other.m_pDBMajorType; + m_pDBSubType = other.m_pDBSubType; + } + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + return true; + } + + // Get item icon file name + public override string GetIconFile() + { + return m_pDBEssence.FileIcon; + } + + // Get item name + public override string GetName() + { + // Try Unicode first (for Vietnamese/wide char names), then fallback to CP936 + if (m_pDBEssence.name != null && m_pDBEssence.name.Length > 0) + { + string s = ByteToStringUtils.UshortArrayToUnicodeString(m_pDBEssence.name); + if (!string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s)) + return s; + // Fallback to legacy CP936 if Unicode was empty + s = ByteToStringUtils.UshortArrayToCP936String(m_pDBEssence.name); + if (!string.IsNullOrEmpty(s)) + return s; + } + return base.GetName(); // Fallback to base class method + } + + // Get item description text + protected override string GetNormalDesc(bool bRepair) + { + m_strDesc = ""; + + // Try to build item description + CECStringTab pDescTab = EC_Game.GetItemDesc(); + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + int namecol = DecideNameCol(); + BMLogger.Log("GetNormalDesc: m_pDBEssence.Name:" + m_pDBEssence.Name + " m_iCount:" + m_iCount); + if (m_iCount > 1) + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount); + else + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName()); + + AddIDDescText(); + + AddExpireTimeDesc(); + + // Price + AddPriceDesc(white, bRepair); + + // Extend description + AddExtDescText(); + + return m_strDesc; + } + + // Get drop model for shown + public override string GetDropModel() + { + return m_pDBEssence.FileMatter; } } -} - +} \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMedicine.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMedicine.cs index 43bcfd2d13..a71a55c1a3 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMedicine.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMedicine.cs @@ -1,15 +1,192 @@ +using BrewMonster; +using ModelRenderer.Scripts.GameData; +using System.Collections.Generic; +using BrewMonster.Network; using BrewMonster.Scripts.Managers; +using BrewMonster.Scripts; +using CSNetwork.GPDataType; namespace PerfectWorld.Scripts.Managers { + /// + /// Medicine item class (cac loai thuoc). + /// This is a part of CEC_IvtrConsume(C++) + /// public class EC_IvtrMedicine : EC_IvtrItem { + protected MEDICINE_MAJOR_TYPE m_pDBMajorType; + protected MEDICINE_SUB_TYPE m_pDBSubType; + protected MEDICINE_ESSENCE m_pDBEssence; + + protected int m_iLevelReq; + /// + /// Create medicine item (cac loai thuoc) + /// + /// Template id + /// Expire date public EC_IvtrMedicine(int tid, int expire_date) : base(tid, expire_date) { + m_iCID = (int)InventoryClassId.ICID_MEDICINE; + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + m_pDBEssence = (MEDICINE_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_pDBMajorType = (MEDICINE_MAJOR_TYPE)pDB.get_data_ptr(m_pDBEssence.id_major_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_pDBSubType = (MEDICINE_SUB_TYPE)pDB.get_data_ptr(m_pDBEssence.id_sub_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_iPileLimit = m_pDBEssence.pile_num_max; + m_iPrice = m_pDBEssence.price; + m_iShopPrice = m_pDBEssence.shop_price; + m_i64EquipMask = 0; + m_iLevelReq = m_pDBEssence.require_level; + m_iProcType = (int)m_pDBEssence.proc_type; + m_bUseable = true; + m_bNeedUpdate = false; } public EC_IvtrMedicine(EC_IvtrMedicine other) : base(other) { + m_pDBEssence = other.m_pDBEssence; + m_pDBMajorType = other.m_pDBMajorType; + m_pDBSubType = other.m_pDBSubType; + m_iLevelReq = other.m_iLevelReq; } + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + return true; + } + + // Get item icon file name + public override string GetIconFile() + { + return m_pDBEssence.FileIcon; + } + + // Get item name + public override string GetName() + { + return m_pDBEssence.Name; + } + public int GetCoolTime(ref int piMax/* NULL */) + { + CECHostPlayer pHost = CECGameRun.Instance.GetHostPlayer(); + if (!pHost) + return 0; + + int iTime = 0; + + switch (m_pDBMajorType.id) + { + case 1810: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_REJUVENATION_POTION, ref piMax); break; + case 1794: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_HP_POTION, ref piMax); break; + case 1802: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_MP_POTION, ref piMax); break; + case 1815: + case 2038: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_ANTIDOTE_POTION, ref piMax); break; + } + + return iTime; + } + // Get item description text + protected override string GetNormalDesc(bool bRepair) + { + m_strDesc = string.Empty; + + BMLogger.Log("EC_IvtrMedicine: GetNormalDesc: m_iLevelReq: " + m_iLevelReq); + // Level requirement + if (m_iLevelReq > 0) + { + BMLogger.Log("EC_IvtrMedicine: m_iLevelReq: " + m_iLevelReq); + BMLogger.Log("EC_IvtrMedicine: GetMaxLevelSofar: " + CECGameRun.Instance.GetHostPlayer().GetMaxLevelSofar()); + int col = CECGameRun.Instance.GetHostPlayer().GetMaxLevelSofar() >= m_iLevelReq ? (int)DescriptipionMsg.ITEMDESC_COL_WHITE : (int)DescriptipionMsg.ITEMDESC_COL_RED; + AddDescText(col, true, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_LEVELREQ), m_iLevelReq); + } + + // Build effect description + BuildEffectDesc(); + + // Price + AddPriceDesc((int)DescriptipionMsg.ITEMDESC_COL_WHITE, bRepair); + + // Extend description + AddExtDescText(); + + return m_strDesc; + } + + // Build medicine effect description + protected void BuildEffectDesc() + { + CECStringTab pDescTab = EC_Game.GetItemDesc(); + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_USEEFFECT)); + + switch (m_pDBMajorType.id) + { + case 1794: // Recruit HP + + if (m_pDBEssence.hp_add_total > 0) + { + BMLogger.Log("EC_IvtrMedicine: BuildEffectDesc: m_pDBEssence.hp_add_total: " + m_pDBEssence.hp_add_total); + BMLogger.Log("EC_IvtrMedicine: BuildEffectDesc: m_pDBEssence.hp_add_time: " + m_pDBEssence.hp_add_time); + if (m_pDBEssence.hp_add_time > 0) + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ADDHPINTIME), m_pDBEssence.hp_add_time, m_pDBEssence.hp_add_total); + else + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_RECRUITHP), m_pDBEssence.hp_add_total); + } + + break; + + case 1802: // Recruit MP + + if (m_pDBEssence.mp_add_total > 0) + { + if (m_pDBEssence.mp_add_time > 0) + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ADDMPINTIME), m_pDBEssence.mp_add_time, m_pDBEssence.mp_add_total); + else + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_RECRUITMP), m_pDBEssence.mp_add_total); + } + + break; + + case 1810: // Recruit HP and MP + + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_RECRUITHPMP), m_pDBEssence.hp_add_total, m_pDBEssence.mp_add_total); + break; + + case 1815: + + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_DECHALFPOISON)); + break; + + case 2038: + + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ANTIDOTE)); + break; + + default: + + BMLogger.LogError("EC_IvtrMedicine: Unknown major type: " + m_pDBMajorType.id); + return; + } + } + + // Check item use condition + protected bool CheckUseCondition() + { + CECHostPlayer pHost = CECGameRun.Instance.GetHostPlayer(); + + if (pHost.GetMaxLevelSofar() < m_iLevelReq) + return false; + + return true; + } + + // Get drop model for shown + public override string GetDropModel() + { + return m_pDBEssence.FileMatter; + } + + } } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMoneyConvertible.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMoneyConvertible.cs index 0706daf572..8b63f1de47 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMoneyConvertible.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMoneyConvertible.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrMoneyConvertible : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrMoneyConvertible(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMonsterSpirit.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMonsterSpirit.cs index e214eee652..bd6764a593 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMonsterSpirit.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrMonsterSpirit.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrMonsterSpirit : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrMonsterSpirit(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetEgg.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetEgg.cs index df0cbbd059..ca4575a50e 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetEgg.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetEgg.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrPetEgg : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrPetEgg(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFaceTicket.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFaceTicket.cs index 61f0e12023..b63611c18a 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFaceTicket.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFaceTicket.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrPetFaceTicket : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrPetFaceTicket(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFood.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFood.cs index 8a52b6b14e..df9ad11d21 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFood.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFood.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrPetFood : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrPetFood(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRecipe.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRecipe.cs index f03d3efb62..30c8ef0c29 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRecipe.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRecipe.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrRecipe : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrRecipe(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRefineTicket.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRefineTicket.cs index 054a81b253..f05d3b4185 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRefineTicket.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRefineTicket.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrRefineTicket : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrRefineTicket(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRevScroll.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRevScroll.cs index d3a8b51c1e..87f463fa93 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRevScroll.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrRevScroll.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrRevScroll : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrRevScroll(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSharpener.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSharpener.cs index 3cb60d730e..67c92ec17d 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSharpener.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSharpener.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrSharpener : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrSharpener(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrShopToken.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrShopToken.cs index df78933a96..18737cd4fb 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrShopToken.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrShopToken.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrShopToken : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrShopToken(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkillMat.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkillMat.cs index 70163c6aec..75b283885f 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkillMat.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkillMat.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrSkillMat : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrSkillMat(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkilltome.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkilltome.cs index 4198416cce..d5fd9ba0e8 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkilltome.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkilltome.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrSkilltome : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrSkilltome(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSpeaker.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSpeaker.cs index ecfb1b0ed9..325312ca78 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSpeaker.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSpeaker.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrSpeaker : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrSpeaker(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrStone.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrStone.cs index f8347605b2..9b2c49e0f3 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrStone.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrStone.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrStone : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrStone(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTargetItem.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTargetItem.cs index a050b3d567..b883136866 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTargetItem.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTargetItem.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrTargetItem : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrTargetItem(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskDice.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskDice.cs index 8640b0f0f8..ea1a6c2c09 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskDice.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskDice.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrTaskDice : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrTaskDice(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskNmMatter.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskNmMatter.cs index beacce0272..b76fe9960a 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskNmMatter.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskNmMatter.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrTaskNmMatter : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrTaskNmMatter(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskmatter.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskmatter.cs index 4a47bd6643..902b9688bd 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskmatter.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTaskmatter.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrTaskmatter : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrTaskmatter(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTossMat.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTossMat.cs index 3d2f7480c3..df9880e781 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTossMat.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTossMat.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrTossMat : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrTossMat(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTownscroll.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTownscroll.cs index 8067c0d98e..2c7934f0cf 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTownscroll.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTownscroll.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrTownscroll : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrTownscroll(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTransmitScroll.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTransmitScroll.cs index 1d06d9a69f..fd8e25ba6b 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTransmitScroll.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrTransmitScroll.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrTransmitScroll : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrTransmitScroll(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrType.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrType.cs index 9b8c404d10..5cac2f55cc 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrType.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrType.cs @@ -95,11 +95,11 @@ namespace BrewMonster.Scripts.Managers }; public struct IVTR_ESSENCE_DECORATION { - int damage; - int magic_damage; - int defense; - int armor; - int[] resistance; + public int damage; + public int magic_damage; + public int defense; + public int armor; + public int[] resistance; public IVTR_ESSENCE_DECORATION(byte[] data) { Debug.Log("IVTR_ESSENCE_DECORATION: data.Length: " + data.Length); @@ -168,15 +168,25 @@ namespace BrewMonster.Scripts.Managers }; public struct IVTR_ESSENCE_AUTOHP { - // TODO : implement data later - // int hp_left; - // float trigger; + public int hp_left; + public float trigger; + public IVTR_ESSENCE_AUTOHP(byte[] data) + { + CECDataReader dr = new (data, data.Length); + hp_left = dr.ReadInt(); + trigger = dr.ReadFloat(); + } }; public struct IVTR_ESSENCE_AUTOMP { - // TODO : implement data later - // int mp_left; - // float trigger; + public int mp_left; + public float trigger; + public IVTR_ESSENCE_AUTOMP(byte[] data) + { + CECDataReader dr = new (data, data.Length); + mp_left = dr.ReadInt(); + trigger = dr.ReadFloat(); + } }; public struct IVTR_ESSENCE_PETEGG { diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUnionscroll.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUnionscroll.cs index bfbd189bc8..284bfee4b0 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUnionscroll.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUnionscroll.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrUnionscroll : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrUnionscroll(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUniversalToken.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUniversalToken.cs index b92d7dc6d9..ccbb54084a 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUniversalToken.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUniversalToken.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrUniversalToken : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrUniversalToken(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUnknown.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUnknown.cs index 9a11faf95d..88fa159127 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUnknown.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrUnknown.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrUnknown : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrUnknown(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWarTankCallin.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWarTankCallin.cs index b64255cb43..36c6b6ebbe 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWarTankCallin.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWarTankCallin.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrWarTankCallin : EC_IvtrItem { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrWarTankCallin(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeapon.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeapon.cs index e790fb4139..3a4715020b 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeapon.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeapon.cs @@ -64,7 +64,9 @@ using BrewMonster.Scripts; namespace PerfectWorld.Scripts.Managers { - + /// + /// Weapon item class (cac loai vu khi) + /// public class EC_IvtrWeapon : EC_IvtrEquip { //Attributes @@ -75,6 +77,10 @@ namespace PerfectWorld.Scripts.Managers protected WEAPON_SUB_TYPE m_pDBSubType; protected WEAPON_ESSENCE m_pDBEssence; + /// + /// Constructor for weapon item (cac loai vu khi) + /// + /// Template id public EC_IvtrWeapon(int tid, int expire_date) : base(tid, expire_date) { m_iCID = (int)InventoryClassId.ICID_WEAPON; @@ -126,7 +132,6 @@ namespace PerfectWorld.Scripts.Managers dr.Offset(iMakerLen, CECDataReader.SEEK_CUR); byte[] iEssenceData = dr.ReadData(iEssenceSize); m_Essence = new IVTR_ESSENCE_WEAPON(iEssenceData); - BMLogger.Log("[thn] weapon addon m_Essence: " + m_Essence.ToString()); // ���븽������˵�� if(m_pDBEssence.fixed_props != 0 && m_pDBEssence.probability_addon_num0 != 1.0f) { @@ -293,7 +298,7 @@ namespace PerfectWorld.Scripts.Managers AddDestroyingDesc((int)m_pDBEssence.id_drop_after_damaged, m_pDBEssence.num_drop_after_damaged); AddExpireTimeDesc(); // Sub class name - AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_CLASSNAME), m_pDBSubType.name.ToString()); + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_CLASSNAME), m_pDBSubType.Name); // Weapon level AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), m_Essence.weapon_level); // Attack speed @@ -380,11 +385,17 @@ namespace PerfectWorld.Scripts.Managers AddDescText((int)DescriptipionMsg.ITEMDESC_COL2_BRIGHTBLUE, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_HASRANDOM_PROP)); // Price AddPriceDesc(white, bRepair); + BMLogger.Log("AddPriceDesc: " + m_strDesc); AddSharpenerDesc(); + BMLogger.Log("AddSharpenerDesc: " + m_strDesc); AddEngravedDesc(); + BMLogger.Log("AddEngravedDesc: " + m_strDesc); AddMakerDesc(); + BMLogger.Log("AddMakerDesc: " + m_strDesc); AddSuiteDesc(); + BMLogger.Log("AddSuiteDesc: " + m_strDesc); AddExtDescText(); + BMLogger.Log("AddExtDescText: " + m_strDesc); return m_strDesc; } // Get weapon attack speed index diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeddingBookCard.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeddingBookCard.cs index 3830a3dc63..cfc59969f9 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeddingBookCard.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeddingBookCard.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrWeddingBookCard : EC_IvtrEquip { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrWeddingBookCard(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeddingInviteCard.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeddingInviteCard.cs index df35857e6e..6eb42b8782 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeddingInviteCard.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeddingInviteCard.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrWeddingInviteCard : EC_IvtrEquip { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrWeddingInviteCard(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWing.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWing.cs index a5569ff068..6f869ea202 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWing.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWing.cs @@ -3,6 +3,11 @@ namespace PerfectWorld.Scripts.Managers { public class EC_IvtrWing : EC_IvtrEquip { + /// + /// Not create logic yet (add summary later) + /// + /// Template id + /// Expire date public EC_IvtrWing(int tid, int expire_date) : base(tid, expire_date) { } diff --git a/Assets/Prefabs/UI/item_info.prefab b/Assets/Prefabs/UI/item_info.prefab index 95db462baf..870a1ce906 100644 --- a/Assets/Prefabs/UI/item_info.prefab +++ b/Assets/Prefabs/UI/item_info.prefab @@ -223,7 +223,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 0 + m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -631,7 +631,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 0 + m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: From 273f353ddc7e9f2bf4bf4d45693c4ba29fc3b067 Mon Sep 17 00:00:00 2001 From: Chomper9981 Date: Tue, 20 Jan 2026 16:31:57 +0700 Subject: [PATCH 2/2] add more item detail in inventory. Create some place holder for pet item so that those item can be shown --- .../Common/DataProcess/generate_item_temp.cs | 724 +++++------------ .../Scripts/Common/DataProcess/itemdataman.cs | 9 + .../PerfectWorld/Scripts/GameData/ExpTypes.cs | 34 +- .../Scripts/Inventory/EC_IvtrType.cs | 10 + .../Managers/EC_IvtrItem/EC_IvtrArmor.cs | 5 - .../Managers/EC_IvtrItem/EC_IvtrGoblin.cs | 749 +++++++++++++++++- .../Managers/EC_IvtrItem/EC_IvtrItem.cs | 28 +- .../Managers/EC_IvtrItem/EC_IvtrPetEgg.cs | 342 +++++++- .../Managers/EC_IvtrItem/EC_IvtrPetFood.cs | 134 +++- .../Managers/EC_IvtrItem/EC_IvtrSkilltome.cs | 102 ++- .../Managers/EC_IvtrItem/EC_IvtrType.cs | 113 ++- .../Managers/EC_IvtrItem/EC_IvtrWeapon.cs | 6 - .../Scripts/Managers/EC_PetCorral.cs | 121 +++ .../Scripts/Managers/EC_PetCorral.cs.meta | 2 + .../Scripts/Network/CSNetwork/GPDataType.cs | 84 ++ .../Scripts/Skills/ElementSkill.cs | 54 ++ .../PerfectWorld/Scripts/Utils/CECRTDebug.cs | 17 + Assets/Scripts/CECHostPlayer.cs | 5 + Assets/Scripts/CECUIManager.cs | 4 + 19 files changed, 1959 insertions(+), 584 deletions(-) create mode 100644 Assets/PerfectWorld/Scripts/Managers/EC_PetCorral.cs create mode 100644 Assets/PerfectWorld/Scripts/Managers/EC_PetCorral.cs.meta diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/generate_item_temp.cs b/Assets/PerfectWorld/Scripts/Common/DataProcess/generate_item_temp.cs index 5e569683e4..484ff2555f 100644 --- a/Assets/PerfectWorld/Scripts/Common/DataProcess/generate_item_temp.cs +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/generate_item_temp.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System; using BrewMonster.abase; +using CSNetwork.GPDataType; public static class generate_item_temp { public static int generate_weapon(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls, @@ -705,7 +706,6 @@ public static class generate_item_temp return 0; } - public static int generate_material(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls) { DATA_TYPE datatype = DATA_TYPE.DT_INVALID; @@ -742,6 +742,214 @@ public static class generate_item_temp itemdataman.set_to_classid(DATA_TYPE.DT_MATERIAL_ESSENCE, data, -1); return 0; } + public static int generate_skilltome(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls) + { + DATA_TYPE datatype = DATA_TYPE.DT_INVALID; + data = new byte[0]; + size = 0; + object obj = itemdataman._edm.get_data_ptr(id, idspace, ref datatype); + if(obj == null || datatype != DATA_TYPE.DT_SKILLTOME_ESSENCE) + { + return -1; + } + SKILLTOME_ESSENCE ess = (SKILLTOME_ESSENCE)obj; + size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(SKILLTOME_ESSENCE))); + data = new byte[size]; + int offset = 0; + + WriteUInt(data, ref offset, id); + WriteUInt(data, ref offset, 1); + WriteUInt(data, ref offset, (uint)ess.pile_num_max); //��Ʒ�Ķѵ����� + WriteInt(data, ref offset, 0); //��Ʒ�Ŀ�װ����־ + WriteInt(data, ref offset, (int)ess.proc_type); //��Ʒ�Ĵ�����ʽ + WriteInt(data, ref offset, (int)DATA_TYPE.DT_SKILLTOME_ESSENCE); //��Ʒ��Ӧ�����ID + if(ess.has_guid == 1){ + int g1,g2; + itemdataman.get_item_guid(id,out g1,out g2); + WriteInt(data, ref offset, g1); //��Ʒ��Ӧ�����ID guid + WriteInt(data, ref offset, g2); //��Ʒ��Ӧ�����ID guid + } + else{ + WriteInt(data, ref offset, 0); //��Ʒ��Ӧ�����ID guid + WriteInt(data, ref offset, 0); //��Ʒ��Ӧ�����ID guid + } + WriteInt(data, ref offset, ess.price); //��Ʒ�ļ۸� + WriteInt(data, ref offset, 0); //����ʱ�� + + int content_length = 0; + int content_length_ptr = offset; + WriteInt(data, ref offset, 0); + int item_content = offset; + WriteInt(data, ref offset, 0); + content_length = (int)(size - offset); + WriteInt(data, ref content_length_ptr, content_length); + WriteInt(data, ref item_content, offset); + + + itemdataman.set_to_classid(DATA_TYPE.DT_SKILLTOME_ESSENCE, data, -1); + return 0; + } + + public struct PetSkill { + public int skill; + public int level; + } + public static int generate_pet_egg(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls) + { + DATA_TYPE datatype = DATA_TYPE.DT_INVALID; + data = new byte[0]; + size = 0; + + object obj = itemdataman._edm.get_data_ptr(id, idspace, ref datatype); + if(obj == null || datatype != DATA_TYPE.DT_PET_EGG_ESSENCE) + return -1; + PET_EGG_ESSENCE ess = (PET_EGG_ESSENCE)obj; + + object petessobj = itemdataman._edm.get_data_ptr((uint)ess.id_pet, idspace, ref datatype); + if(petessobj == null || datatype != DATA_TYPE.DT_PET_ESSENCE) + return -1; + PET_ESSENCE petess = (PET_ESSENCE)petessobj; + + size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(PET_EGG_ESSENCE))); + + //������ܵı䳤���� + + PetSkill[] skills = new PetSkill[32]; + int skill_count = 0; + int i; + for(i = 0; i < 32; i ++) + { + if(ess.skills[i].id_skill <= 0 + || ess.skills[i].level <= 0 ) continue; + skills[skill_count].skill = ess.skills[i].id_skill; + skills[skill_count].level = ess.skills[i].level; + skill_count ++; + } + + size += (uint)(Marshal.SizeOf(typeof(int))*2 * skill_count); + + // allocate the buffer with exact length + data = new byte[size]; + int offset = 0; + + WriteUInt(data, ref offset, id); //��Ʒ��ģ��ID + WriteUInt(data, ref offset, 1); //��Ʒ������ + WriteUInt(data, ref offset, (uint)ess.pile_num_max); //��Ʒ�Ķѵ����� + WriteInt(data, ref offset, 0); //��Ʒ�Ŀ�װ����־ + WriteInt(data, ref offset, (int)ess.proc_type); //��Ʒ�Ĵ�����ʽ + WriteInt(data, ref offset, (int)DATA_TYPE.DT_PET_EGG_ESSENCE); //��Ʒ��Ӧ�����ID + if(ess.has_guid == 1){ + int g1,g2; + itemdataman.get_item_guid(id,out g1,out g2); + WriteInt(data, ref offset, g1); //��Ʒ��Ӧ�����ID guid + WriteInt(data, ref offset, g2); //��Ʒ��Ӧ�����ID guid + } + else{ + WriteInt(data, ref offset, 0); //��Ʒ��Ӧ�����ID guid + WriteInt(data, ref offset, 0); //��Ʒ��Ӧ�����ID guid + } + WriteInt(data, ref offset, petess.level_require); + WriteInt(data, ref offset, (int)(petess.character_combo_id&0xFFFF)); + WriteInt(data, ref offset, ess.honor_point); + WriteInt(data, ref offset, (int)ess.id_pet); + WriteInt(data, ref offset, 0); + WriteInt(data, ref offset, (int)ess.id); + + int pet_class; + switch(petess.id_type) + { + case 8781: // ��� + pet_class = 0; + break; + case 8782: // ս������ + pet_class = 1; + break; + case 8783: // ���ͳ��� + pet_class = 2; + break; + case 28752: // �ٻ��� + pet_class = 3; + break; + case 28913: // ֲ�� + pet_class = 4; + break; + default: + pet_class = 4; + break; + } + + WriteInt(data, ref offset, pet_class); + WriteShort(data, ref offset, (short)ess.level); + WriteShort(data, ref offset, 0); + WriteInt(data, ref offset, ess.exp); + WriteInt(data, ref offset, ess.skill_point); + WriteShort(data, ref offset, 0); + WriteShort(data, ref offset, (short)skill_count); + Array.Clear(data, offset, 16); + offset += 16; + + for(i = 0; i < skill_count; i ++) + { + WriteInt(data, ref offset, skills[i].skill); + WriteInt(data, ref offset, skills[i].level); + } + if(pet_class == 5) + { + Array.Clear(data, offset, Marshal.SizeOf(typeof(_evo_prop))); + } + //ASSERT( (buf - (char*)*data) == (int)size); + + itemdataman.set_to_classid(DATA_TYPE.DT_PET_EGG_ESSENCE, data, -1); + return 0; + } + + public static int generate_pet_food(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls) + { + DATA_TYPE datatype = DATA_TYPE.DT_INVALID; + data = new byte[0]; + size = 0; + object obj = itemdataman._edm.get_data_ptr(id, idspace, ref datatype); + if(obj == null || datatype != DATA_TYPE.DT_PET_FOOD_ESSENCE) + return -1; + PET_FOOD_ESSENCE ess = (PET_FOOD_ESSENCE)obj; + size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(PET_FOOD_ESSENCE))); + data = new byte[size]; + int offset = 0; + WriteUInt(data, ref offset, id); //��Ʒ��ģ��ID + WriteUInt(data, ref offset, 1); //��Ʒ������ + WriteUInt(data, ref offset, (uint)ess.pile_num_max); //��Ʒ�Ķѵ����� + WriteInt(data, ref offset, 0); //��Ʒ�Ŀ�װ����־ + WriteInt(data, ref offset, (int)ess.proc_type); //��Ʒ�Ĵ�����ʽ + WriteInt(data, ref offset, (int)DATA_TYPE.DT_PET_EGG_ESSENCE); //��Ʒ��Ӧ�����ID + if(ess.has_guid == 1){ + int g1,g2; + itemdataman.get_item_guid(id,out g1,out g2); + WriteInt(data, ref offset, g1); //��Ʒ��Ӧ�����ID guid + WriteInt(data, ref offset, g2); //��Ʒ��Ӧ�����ID guid + } + else{ + WriteInt(data, ref offset, 0); //��Ʒ��Ӧ�����ID guid + WriteInt(data, ref offset, 0); //��Ʒ��Ӧ�����ID guid + } + WriteInt(data, ref offset, ess.price); //��Ʒ�ļ۸� + WriteInt(data, ref offset, 0); //����ʱ�� + + int content_length = 0; + int content_length_ptr = offset; + WriteInt(data, ref offset, 0); + int item_content = offset; + WriteInt(data, ref offset, 0); + content_length = (int)(size - offset); + WriteInt(data, ref content_length_ptr, content_length); + WriteInt(data, ref item_content, offset); + WriteInt(data, ref offset, ess.food_type); //��Ʒ�Ŀ�װ����־ + WriteInt(data, ref offset, ess.hornor); //��Ʒ��Ӧ�����ID guid + + //ASSERT( (buf - (char*)*data) == (int)size); + + itemdataman.set_to_classid(DATA_TYPE.DT_PET_FOOD_ESSENCE, data, -1); + return 0; + } #region Write Functions private static void WriteUInt(byte[] buf, ref int offset, uint value) { @@ -851,517 +1059,3 @@ public static class generate_item_temp } } -#region unimplemented - -// template -// int generate_projectile(unsigned int id, ID_SPACE idspace, char ** data, size_t& size, RAND_CLASS cls) -// { -// DATA_TYPE datatype; -// PROJECTILE_ESSENCE * ess = (PROJECTILE_ESSENCE *)get_data_ptr(id, idspace, datatype); -// if(ess == NULL || datatype != DT_PROJECTILE_ESSENCE) return -1; - -// size = sizeof(item_data) + sizeof(_item_content) + sizeof(_projectile_essence); -// // �޿׶� -// // �̶�addons 4�� -// char addon_buf[ELEMENTDATAMAN_MAX_NUM_ADDONS*sizeof(_addon)]; -// unsigned int addon_num = 4; //���Ա���Ŀ����Ŀ�̶� 4 - -// size_t addon_size = generate_equipment_addon_buffer_2(DT_PROJECTILE_ESSENCE, (int*)&(ess->id_addon0),sizeof(int), 4, addon_buf,addon_num); -// size += addon_size; - -// //����tag size -// size += sizeof(short); - -// // allocate the buffer with exact length -// *data = (char *)abase::fastalloc(size); -// char * buf = *data; - -// *(unsigned int*)buf = id; buf += sizeof(unsigned int); //��Ʒ��ģ��ID -// *(size_t*)buf = 1; buf += sizeof(size_t); //��Ʒ������ -// *(size_t*)buf = ess->pile_num_max; buf += sizeof(size_t); //��Ʒ�Ķѵ����� -// *(int*)buf = ELEMENTDATAMAN_EQUIP_MASK_PROJECTILE|(addon_num?0x40000000:0); buf += sizeof(int); //��Ʒ�Ŀ�װ����־ -// *(int*)buf = ess->proc_type; buf += sizeof(int); //��Ʒ�Ĵ�����ʽ -// *(int*)buf = DT_PROJECTILE_ESSENCE; buf += sizeof(int); //��Ʒ��Ӧ�����ID -// if(ess->has_guid == 1){ -// int g1,g2; -// get_item_guid(id,g1,g2); -// *(int*)buf = g1; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = g2; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// else{ -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// *(int*)buf = ess->price; buf += sizeof(int); //��Ʒ�ļ۸� -// *(int*)buf = 0; buf += sizeof(int); //����ʱ�� -// size_t* content_length = (size_t*)buf; buf += sizeof(size_t); //��סbuf��ָ�룬�Ժ����� -// char ** item_content = (char **)buf; buf += sizeof(char *); //��סbuf��ָ�룬�Ժ����� -// *content_length = (char*)(*data)+size-buf; -// *item_content = buf; - -// // prerequisition -// char * require_ptr = buf; -// //����int����6�� -// *(short*)buf = 0; buf += sizeof(short); //prerequisition level -// *(short*)buf = (short)0xFFFF; buf += sizeof(short); -// *(short*)buf = 0; buf += sizeof(short); //prerequisition strength -// *(short*)buf = 0; buf += sizeof(short); -// *(short*)buf = 0; buf += sizeof(short); //prerequisition agility -// *(short*)buf = 0; buf += sizeof(short); - -// *(int*)buf = 1; buf += sizeof(int); //prerequisition durability -// *(int*)buf = 1; buf += sizeof(int); //prerequisition max_durability -// *(short*)buf = sizeof(_projectile_essence); buf += sizeof(short); //װ�������С���ֽڣ� -// *(char*)buf = element_data::IMT_NULL;buf += sizeof(char); -// *(char*)buf = 0; buf += sizeof(char); - -// // projectile_essence ���� -// char * essence_ptr = buf; -// *(int*)buf = ess->type; buf += sizeof(int); //��ҩ���� -// *(int*)buf = ess->damage_enhance; buf += sizeof(int); //���������Ĺ����� -// *(int*)buf = ess->damage_scale_enhance; buf += sizeof(int); //���ձ������ӹ����� -// *(int*)buf = ess->require_weapon_level_min; buf += sizeof(int); //��Ҫ�����ȼ� -// *(int*)buf = ess->require_weapon_level_max; buf += sizeof(int); //��Ҫ�����ȼ� - -// // �׶� -// *(short*)buf = 0; buf += sizeof(short); -// *(short*)buf = 0; buf += sizeof(short); - - -// // addon -// *(int*)buf = addon_num; buf += sizeof(int); - -// char * addon_sld = addon_buf; -// for(size_t i=0; i>13)*sizeof(int)+sizeof(int); -// } -// update_require_data((prerequisition*)require_ptr); -// memcpy(buf, addon_buf, addon_size); -// set_to_classid(DT_PROJECTILE_ESSENCE, (item_data*)(*data), -1); - -// return 0; -// } -// template -// int generate_quiver(unsigned int id, ID_SPACE idspace, char ** data, size_t& size, RAND_CLASS cls) -// { -// DATA_TYPE datatype; -// QUIVER_ESSENCE * ess = (QUIVER_ESSENCE *)get_data_ptr(id, ID_SPACE_ESSENCE, datatype); -// if(ess == NULL || datatype != DT_QUIVER_ESSENCE) return -1; -// datatype = DT_PROJECTILE_ESSENCE; -// //���ﲻ����dup��ʽ -// // if(generate_projectile(ess->id_projectile, ID_SPACE_ESSENCE, (char **)data, size, cls) == 0) -// int ret = duplicate_static_item(id, data,size); -// if(ret == 0) -// { -// ASSERT(ess->num_max < (int)((item_data*)(*data))->pile_limit); -// ((item_data*)(*data))->count = element_data::RandNormal(ess->num_min,ess->num_max,cls,element_data::LOWER_TREND); -// return 0; -// } -// else -// return -1; -// /* { -// ASSERT(ess->num_max < (int)((item_data*)(*data))->pile_limit); -// ((item_data*)(*data))->count = element_data::RandNormal(ess->num_min,ess->num_max,cls); -// return 0; -// } -// else -// return -1; -// */ -// } - - -// template -// int generate_quiver_for_sell(unsigned int id, ID_SPACE idspace, char ** data, size_t& size, RAND_CLASS cls) -// { -// DATA_TYPE datatype; -// QUIVER_ESSENCE * ess = (QUIVER_ESSENCE *)get_data_ptr(id, ID_SPACE_ESSENCE, datatype); -// if(ess == NULL || datatype != DT_QUIVER_ESSENCE) return -1; -// datatype = DT_PROJECTILE_ESSENCE; -// //�����޷���dup����Ϊ���� -// if(generate_projectile(ess->id_projectile, ID_SPACE_ESSENCE, (char **)data, size, cls) == 0) -// { -// ASSERT(ess->num_max < (int)((item_data*)(*data))->pile_limit); -// ((item_data*)(*data))->count = element_data::RandNormal(ess->num_min,ess->num_max,cls,element_data::LOWER_TREND); -// return 0; -// } -// else -// return -1; -// } - -// template -// int generate_decoration(unsigned int id, ID_SPACE idspace, char ** data, size_t& size, RAND_CLASS cls,element_data::GEN_ADDON_MODE normal_addon,const void * tag,size_t tag_size, int * sa_list = NULL) -// { -// DATA_TYPE datatype; -// size_t i=0; -// DECORATION_ESSENCE * ess = (DECORATION_ESSENCE *)get_data_ptr(id, idspace, datatype); -// if(ess == NULL || datatype != DT_DECORATION_ESSENCE) return -1; - -// size = sizeof(item_data) + sizeof(_item_content) + sizeof(_decoration_essence); -// // �׶� -// unsigned int hole_num = 0; //�׶�����Ŀ - -// // ���addons -// char addon_buf[ELEMENTDATAMAN_MAX_NUM_ADDONS*sizeof(_addon)]; -// unsigned int addon_num = element_data::RandSelect(&(ess->probability_addon_num0),sizeof(float), 5,cls,element_data::LOWER_TREND); //���Ա���Ŀ����Ŀ - -// size_t addon_size = 0; -// if(ess->fixed_props) -// { -// addon_size = generate_equipment_addon_buffer_2(DT_DECORATION_ESSENCE, (int*)&(ess->addons[0]), sizeof(int)+sizeof(float),32, addon_buf,addon_num); -// } -// else -// { -// if(normal_addon == element_data::ADDON_LIST_DROP) -// addon_size = generate_equipment_addon_buffer(DT_DECORATION_ESSENCE, (char*)&(ess->addons[0]), 32, addon_buf,addon_num); -// else if(normal_addon == element_data::ADDON_LIST_PRODUCE) -// addon_size = generate_equipment_addon_buffer(DT_DECORATION_ESSENCE, (char*)&(ess->rands[0]), 32, addon_buf,addon_num); -// else if (normal_addon == element_data::ADDON_LIST_SPEC) -// { -// addon_size = generate_spec_addon_buffer(DT_DECORATION_ESSENCE,addon_buf,ELEMENTDATAMAN_MAX_NUM_ADDONS,addon_num,sa_list); -// } -// else -// { -// addon_size = 0; -// addon_num = 0; -// } -// } -// size += addon_size; - -// //����tag size -// ASSERT(tag_size >= sizeof(short)); -// size += tag_size; - - -// // allocate the buffer with exact length -// *data = (char *)abase::fastalloc(size); -// char * buf = (*data); - - -// *(unsigned int*)buf = id; buf += sizeof(unsigned int); //��Ʒ��ģ��ID -// *(size_t*)buf = 1; buf += sizeof(size_t); //��Ʒ������ -// *(size_t*)buf = ess->pile_num_max; buf += sizeof(size_t); //��Ʒ�Ķѵ����� -// DECORATION_SUB_TYPE* sub_type = (DECORATION_SUB_TYPE*)get_data_ptr(ess->id_sub_type, ID_SPACE_ESSENCE, datatype); -// if(sub_type == NULL || datatype != DT_DECORATION_SUB_TYPE) // error -// return -1; -// *(int*)buf = sub_type->equip_mask|(addon_num?ELEMENTDATAMAN_EQUIP_MASK_HAS_ADDON:0); buf += sizeof(int); //��Ʒ�Ŀ�װ����־ -// *(int*)buf = ess->proc_type; buf += sizeof(int); //��Ʒ�Ĵ�����ʽ -// *(int*)buf = DT_DECORATION_ESSENCE; buf += sizeof(int); //��Ʒ��Ӧ�����ID -// if(ess->has_guid == 1){ -// int g1,g2; -// get_item_guid(id,g1,g2); -// *(int*)buf = g1; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = g2; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// else{ -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// *(int*)buf = ess->price; buf += sizeof(int); //��Ʒ�ļ۸� -// *(int*)buf = 0; buf += sizeof(int); //����ʱ�� -// size_t* content_length = (size_t*)buf; buf += sizeof(size_t); //��סbuf��ָ�룬�Ժ����� -// char ** item_content = (char **)buf; buf += sizeof(char *); //��סbuf��ָ�룬�Ժ����� -// *content_length = (char*)(*data)+size-buf; -// *item_content = buf; - -// // prerequisition -// char * require_ptr = buf; -// *(short*)buf = ess->require_level; buf += sizeof(short); //prerequisition level -// *(short*)buf = ess->character_combo_id&0xFFFF; buf += sizeof(short); //prerequisition race -// *(short*)buf = ess->require_strength; buf += sizeof(short); //prerequisition strength -// *(short*)buf = ess->require_tili; buf += sizeof(short); //prerequisition val -// *(short*)buf = ess->require_agility; buf += sizeof(short); //prerequisition agility -// *(short*)buf = ess->require_energy; buf += sizeof(short); //prerequisition energy - -// int temp2 = element_data::RandNormal(ess->durability_min, ess->durability_max, cls,element_data::LOWER_TREND); -// int temp; -// if(normal_addon != element_data::ADDON_LIST_DROP || ess->proc_type & 0x1000) -// { -// temp = temp2; -// } -// else -// { -// temp = element_data::RandNormal(ess->durability_drop_min, ess->durability_drop_max, cls,element_data::UPPER_TREND); -// if(temp > temp2) temp = temp2; -// } -// *(int*)buf = temp; buf += sizeof(int); //prerequisition durability -// *(int*)buf = temp2; buf += sizeof(int); //prerequisition max_durability - -// //���������߱�ǩע���ǩ���ڱ����С�ͱ�������֮�� -// *(short*)buf = sizeof(_decoration_essence); buf += sizeof(short); //װ�������С���ֽڣ� -// memcpy(buf,tag,tag_size); -// buf += tag_size; - - -// // ���� -// char * essence_ptr = buf; -// *(int*)buf = element_data::RandNormal(ess->damage_low, ess->damage_high, cls,element_data::LOWER_TREND); buf += sizeof(int); //int damage; -// *(int*)buf = element_data::RandNormal(ess->magic_damage_low, ess->magic_damage_high, cls,element_data::LOWER_TREND); buf += sizeof(int); //int magic_damage; -// *(int*)buf = element_data::RandNormal(ess->defence_low, ess->defence_high, cls,element_data::LOWER_TREND); buf += sizeof(int); //int defense; -// *(int*)buf = element_data::RandNormal(ess->armor_enhance_low, ess->armor_enhance_high, cls,element_data::LOWER_TREND); buf += sizeof(int); //int armor; - -// //���� -// int res[5] = {0,0,0,0,0}; -// generate_magic_defense(res,(int*)(ess->magic_defences),cls,ess->fixed_props!=0); - -// *(int*)buf = res[0]; buf += sizeof(int); -// *(int*)buf = res[1]; buf += sizeof(int); -// *(int*)buf = res[2]; buf += sizeof(int); -// *(int*)buf = res[3]; buf += sizeof(int); -// *(int*)buf = res[4]; buf += sizeof(int); - -// // �׶� -// *(short*)buf = hole_num; buf += sizeof(short); //�׶�����Ŀ -// *(short*)buf = 0; buf += sizeof(short); //�׶��������������� - -// // addon -// *(int*)buf = addon_num; buf += sizeof(int); -// char * addon_sld = addon_buf; -// for(i=0; i>13)*sizeof(int)+sizeof(int); -// } -// update_require_data((prerequisition*)require_ptr); -// memcpy(buf, addon_buf, addon_size); -// set_to_classid(DT_DECORATION_ESSENCE, (item_data*)(*data), -1); - -// return 0; -// } - -// template -// int generate_stone(unsigned int id, ID_SPACE idspace, char ** data, size_t& size, RAND_CLASS cls) -// { -// DATA_TYPE datatype; -// STONE_ESSENCE * ess = (STONE_ESSENCE *)get_data_ptr(id, idspace, datatype); -// if(ess == NULL || datatype != DT_STONE_ESSENCE) return -1; - - -// char addon_buf[ELEMENTDATAMAN_MAX_NUM_ADDONS*sizeof(_addon)]; -// int *pBuf = (int*)addon_buf; -// *pBuf = 1; //only one weapon addon now -// size_t addon_size = generate_addon_buffer(datatype,ess->id_addon_damage, (char*)(pBuf + 1)); -// if(addon_size) -// { -// pBuf = (int*)(((char*)(pBuf+1)) + addon_size); -// } -// else -// { -// ASSERT(false); -// return -1; -// } - -// *pBuf = 1; //only one armor addon now -// addon_size = generate_addon_buffer(datatype,ess->id_addon_defence, (char*)(pBuf + 1)); -// if(addon_size) -// { -// pBuf = (int*)(((char*)(pBuf+1)) + addon_size); -// } -// else -// { -// ASSERT(false); -// return -1; -// } - -// size_t ess_size = ((char*)pBuf) - addon_buf; -// size = sizeof(item_data) + ess_size; - -// // allocate the buffer with exact length -// *data = (char *)abase::fastalloc(size); -// char *buf = *data; -// *(unsigned int*)buf = id; buf += sizeof(unsigned int); //��Ʒ��ģ��ID -// *(size_t*)buf = 1; buf += sizeof(size_t); //��Ʒ������ -// *(size_t*)buf = ess->pile_num_max;buf += sizeof(size_t); //��Ʒ�Ķѵ����� -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ�Ŀ�װ����־ -// *(int*)buf = ess->proc_type; buf += sizeof(int); //��Ʒ�Ĵ�����ʽ -// *(int*)buf = DT_STONE_ESSENCE; buf += sizeof(int); //��Ʒ��Ӧ�����ID -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = ess->price; buf += sizeof(int); //��Ʒ�ļ۸� -// *(int*)buf = 0; buf += sizeof(int); //����ʱ�� -// size_t* content_length = (size_t*)buf; buf += sizeof(size_t); //��סbuf��ָ�룬�Ժ����� -// char ** item_content = (char **)buf; buf += sizeof(char *); //��סbuf��ָ�룬�Ժ����� -// *content_length = size - (buf - (char*)(*data)); -// *item_content = buf; -// memcpy(buf, addon_buf, ess_size); -// set_to_classid(DT_STONE_ESSENCE, (item_data*)(*data), -1); -// return 0; -// } - -// template -// int generate_medicine(unsigned int id, ID_SPACE idspace, char ** data, size_t& size, RAND_CLASS cls) -// { -// DATA_TYPE datatype; -// MEDICINE_ESSENCE * ess = (MEDICINE_ESSENCE *)get_data_ptr(id, idspace, datatype); -// if(ess == NULL || datatype != DT_MEDICINE_ESSENCE) return -1; - -// size = sizeof(item_data); - -// switch(ess->id_major_type) -// { -// case 1794: // ��Ѫ���� -// case 1802: // ��ħ���� -// case 1810: // ��Ѫ��ħ���� -// size += sizeof(size_t) + sizeof(int) + sizeof(int) + sizeof(int); -// break; -// case 1815: // �ⶾҩ -// case 2038: // ˲��ⶾҩ -// size += sizeof(int) + sizeof(int); -// break; -// default: -// return -1; -// } - -// // allocate the buffer with exact length -// *data = (char *)abase::fastalloc(size); -// char * buf = (*data); - -// *(unsigned int*)buf = id; buf += sizeof(unsigned int); //��Ʒ��ģ��ID -// *(size_t*)buf = 1; buf += sizeof(size_t); //��Ʒ������ -// *(size_t*)buf = ess->pile_num_max; buf += sizeof(size_t); //��Ʒ�Ķѵ����� -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ�Ŀ�װ����־ -// *(int*)buf = ess->proc_type; buf += sizeof(int); //��Ʒ�Ĵ�����ʽ -// *(int*)buf = DT_MEDICINE_ESSENCE; buf += sizeof(int); //��Ʒ��Ӧ�����ID -// if(ess->has_guid == 1){ -// int g1,g2; -// get_item_guid(id,g1,g2); -// *(int*)buf = g1; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = g2; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// else{ -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// *(int*)buf = ess->price; buf += sizeof(int); //��Ʒ�ļ۸� -// *(int*)buf = 0; buf += sizeof(int); //����ʱ�� -// size_t* content_length = (size_t*)buf; buf += sizeof(size_t); //��סbuf��ָ�룬�Ժ����� -// char ** item_content = (char **)buf; buf += sizeof(char *); //��סbuf��ָ�룬�Ժ����� -// *content_length = (char*)(*data)+size-buf; -// *item_content = buf; - -// switch(ess->id_major_type) -// { -// case 1794: // ��Ѫ���� -// if(ess->cool_time < 1000) ess->cool_time *= 100; -// *(int*)buf = ess->hp_add_total; buf += sizeof(int); -// *(int*)buf = ess->hp_add_time; buf += sizeof(int); -// *(int*)buf = ess->cool_time; buf += sizeof(int); -// *(int*)buf = ess->require_level; buf += sizeof(int); -// ASSERT(ess->hp_add_time && ess->hp_add_total); -// ASSERT(ess->hp_add_total/ess->hp_add_time); -// break; -// case 1802: // ��ħ���� -// if(ess->cool_time < 1000) ess->cool_time *= 100; -// *(int*)buf = ess->mp_add_total; buf += sizeof(int); -// *(int*)buf = ess->mp_add_time; buf += sizeof(int); -// *(int*)buf = ess->cool_time; buf += sizeof(int); -// *(int*)buf = ess->require_level; buf += sizeof(int); -// ASSERT(ess->mp_add_time && ess->mp_add_total); -// ASSERT(ess->mp_add_total/ess->mp_add_time); -// break; -// case 1810: // ��Ѫ��ħ���� -// if(ess->cool_time < 1000) ess->cool_time *= 100; -// *(int*)buf = ess->mp_add_total; buf += sizeof(int); -// *(int*)buf = ess->hp_add_total; buf += sizeof(int); -// *(int*)buf = ess->cool_time; buf += sizeof(int); -// *(int*)buf = ess->require_level; buf += sizeof(int); -// ASSERT(ess->hp_add_time || ess->mp_add_total); -// break; -// case 1815: // �ⶾҩ -// case 2038: // ˲��ⶾҩ -// if(ess->cool_time < 1000) ess->cool_time *= 100; -// *(int*)buf = ess->cool_time; buf += sizeof(int); -// *(int*)buf = ess->require_level; buf += sizeof(int); -// break; -// default: -// return -1; -// } -// set_to_classid(DT_MEDICINE_ESSENCE, (item_data*)(*data), ess->id_major_type); - -// return 0; -// } - -// template -// int generate_material(unsigned int id, ID_SPACE idspace, char ** data, size_t& size, ESSENCE * p, DATA_TYPE DTYPE) -// { -// DATA_TYPE datatype; -// ESSENCE * ess = (ESSENCE *)get_data_ptr(id, idspace, datatype); -// if(ess == NULL || datatype != DTYPE) return -1; - -// size = sizeof(item_data) ; - -// // allocate the buffer with exact length -// *data = (char *)abase::fastalloc(size); -// char * buf = (*data); - -// *(unsigned int*)buf = id; buf += sizeof(unsigned int); //��Ʒ��ģ��ID -// *(size_t*)buf = 1; buf += sizeof(size_t); //��Ʒ������ -// *(size_t*)buf = ess->pile_num_max; buf += sizeof(size_t); //��Ʒ�Ķѵ����� -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ�Ŀ�װ����־ -// *(int*)buf = ess->proc_type; buf += sizeof(int); //��Ʒ�Ĵ�����ʽ -// *(int*)buf = DTYPE; buf += sizeof(int); //��Ʒ��Ӧ�����ID -// if(ess->has_guid == 1){ -// int g1,g2; -// get_item_guid(id,g1,g2); -// *(int*)buf = g1; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = g2; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// else{ -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// *(int*)buf = ess->price; buf += sizeof(int); //��Ʒ�ļ۸� -// *(int*)buf = 0; buf += sizeof(int); //����ʱ�� -// size_t* content_length = (size_t*)buf; buf += sizeof(size_t); //��סbuf��ָ�룬�Ժ����� -// char ** item_content = (char **)buf; buf += sizeof(char *); //��סbuf��ָ�룬�Ժ����� -// *content_length = (char*)(*data)+size-buf; -// *item_content = buf; - -// set_to_classid(DTYPE, (item_data*)(*data), -1); -// return 0; -// } - -// template -// int generate_skilltome(unsigned int id, ID_SPACE idspace, char ** data, size_t& size, RAND_CLASS cls) -// { -// DATA_TYPE datatype; -// SKILLTOME_ESSENCE * ess = (SKILLTOME_ESSENCE *)get_data_ptr(id, idspace, datatype); -// if(ess == NULL || datatype != DT_SKILLTOME_ESSENCE) return -1; - -// size = sizeof(item_data); - -// // allocate the buffer with exact length -// *data = (char *)abase::fastalloc(size); -// char * buf = (*data); - -// *(unsigned int*)buf = id; buf += sizeof(unsigned int); //��Ʒ��ģ��ID -// *(size_t*)buf = 1; buf += sizeof(size_t); //��Ʒ������ -// *(size_t*)buf = ess->pile_num_max; buf += sizeof(size_t); //��Ʒ�Ķѵ����� -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ�Ŀ�װ����־ -// *(int*)buf = ess->proc_type; buf += sizeof(int); //��Ʒ�Ĵ�����ʽ -// *(int*)buf = DT_SKILLTOME_ESSENCE; buf += sizeof(int); //��Ʒ��Ӧ�����ID -// if(ess->has_guid == 1){ -// int g1,g2; -// get_item_guid(id,g1,g2); -// *(int*)buf = g1; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = g2; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// else{ -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// *(int*)buf = 0; buf += sizeof(int); //��Ʒ��Ӧ�����ID guid -// } -// *(int*)buf = ess->price; buf += sizeof(int); //��Ʒ�ļ۸� -// *(int*)buf = 0; buf += sizeof(int); //����ʱ�� -// size_t* content_length = (size_t*)buf; buf += sizeof(size_t); //��סbuf��ָ�룬�Ժ����� -// char ** item_content = (char **)buf; buf += sizeof(char *); //��סbuf��ָ�룬�Ժ����� -// *content_length = (char*)(*data)+size-buf; -// *item_content = buf; - -// set_to_classid(DT_SKILLTOME_ESSENCE, (item_data*)(*data), -1); -// return 0; -// } - -#endregion \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/itemdataman.cs b/Assets/PerfectWorld/Scripts/Common/DataProcess/itemdataman.cs index 3fabf85195..d5338b2ced 100644 --- a/Assets/PerfectWorld/Scripts/Common/DataProcess/itemdataman.cs +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/itemdataman.cs @@ -468,6 +468,15 @@ namespace BrewMonster case DATA_TYPE.DT_MATERIAL_ESSENCE: ret = generate_item_temp.generate_material(id, ID_SPACE.ID_SPACE_ESSENCE, out item, out size, SPECIFIC.SPECIFIC_RAND); break; + case DATA_TYPE.DT_SKILLTOME_ESSENCE: + ret = generate_item_temp.generate_skilltome(id, ID_SPACE.ID_SPACE_ESSENCE, out item, out size, SPECIFIC.SPECIFIC_RAND); + break; + case DATA_TYPE.DT_PET_EGG_ESSENCE: + ret = generate_item_temp.generate_pet_egg(id, ID_SPACE.ID_SPACE_ESSENCE, out item, out size, SPECIFIC.SPECIFIC_RAND); + break; + case DATA_TYPE.DT_PET_FOOD_ESSENCE: + ret = generate_item_temp.generate_pet_food(id, ID_SPACE.ID_SPACE_ESSENCE, out item, out size, SPECIFIC.SPECIFIC_RAND); + break; default: ret = -1; break; diff --git a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs index 8c85eb0caf..1a9494f9e8 100644 --- a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs +++ b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs @@ -62,7 +62,7 @@ namespace BrewMonster public string FileHitGfx => ByteToStringUtils.ByteArrayToCP936String(file_hitgfx); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] - public byte[] file_hitsfx; // Hit sound effect file path + public byte[] file_hitsfx; // Hit sound effect file pathpublic string FileHitSfx => ByteToStringUtils.ByteArrayToCP936String(file_hitsfx); public string FileHitSfx => ByteToStringUtils.ByteArrayToCP936String(file_hitsfx); public float probability_fastest; // Attack frequency probability: Fastest -0.1 public float probability_fast; // Attack frequency probability: Fast -0.05 @@ -260,8 +260,8 @@ namespace BrewMonster public uint id; // Armor major type ID [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public ushort[] name; // Armor major type name - public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); + public ushort[] name; // Armor major type name public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -459,9 +459,7 @@ namespace BrewMonster // Display information [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_model; // Model file path - public string FileModel => ByteToStringUtils.ByteArrayToCP936String(file_model); - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_matter; // Matter model file path @@ -766,12 +764,10 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Fashion name, max 15 characters - public string Name => ByteToStringUtils.UshortArrayToCP936String(name); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] realname; // Real fashion name - public string RealName => ByteToStringUtils.ByteArrayToUnicodeString(realname); // Display information @@ -808,7 +804,6 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] wear_action; // Wear action - public string WearAction => ByteToStringUtils.ByteArrayToUnicodeString(wear_action); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] @@ -842,7 +837,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Medicine major type name - public string Name => ByteToStringUtils.UshortArrayToCP936String(name); + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -1070,7 +1065,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Material major type name - public string Name => ByteToStringUtils.UshortArrayToCP936String(name); + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -1080,7 +1075,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // Material sub-type name - public string Name => ByteToStringUtils.UshortArrayToCP936String(name); + public string Name => ByteToStringUtils.UshortArrayToUnicodeString(name); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -1340,10 +1335,10 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_matter; // Matter model file path - + public string FileMatter => ByteToStringUtils.ByteArrayToCP936String(file_matter); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon; // Icon file path - + public string FileIcon => ByteToStringUtils.ByteArrayToCP936String(file_icon); public int price; // Base price public int shop_price; // Shop price @@ -2120,6 +2115,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon; // icon file path + public string FileIcon { get { return ByteToStringUtils.ByteArrayToCP936String(file_icon); } } public int id_pet; // pet ID @@ -2158,9 +2154,11 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_matter; // matter file path + public string FileMatter { get { return ByteToStringUtils.ByteArrayToCP936String(file_matter); } } [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon; // icon file path + public string FileIcon { get { return ByteToStringUtils.ByteArrayToCP936String(file_icon); } } public int level; // level @@ -2999,31 +2997,27 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; // name, max 15 characters + public string Name => ByteToStringUtils.UshortArrayToCP936String(name); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_model1; // state 1 model file - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_model2; // state 2 model file - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_model3; // state 3 model file - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_model4; // state 4 model file - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_matter; // matter model path - + public string FileMatter => ByteToStringUtils.ByteArrayToCP936String(file_matter); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon1; // state 1 icon path - + public string FileIcon1 => ByteToStringUtils.ByteArrayToCP936String(file_icon1); [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon2; // state 2 icon path [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon3; // state 3 icon path - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public byte[] file_icon4; // state 4 icon path diff --git a/Assets/PerfectWorld/Scripts/Inventory/EC_IvtrType.cs b/Assets/PerfectWorld/Scripts/Inventory/EC_IvtrType.cs index 27a4b3dcf8..2f7240ff90 100644 --- a/Assets/PerfectWorld/Scripts/Inventory/EC_IvtrType.cs +++ b/Assets/PerfectWorld/Scripts/Inventory/EC_IvtrType.cs @@ -80,4 +80,14 @@ namespace BrewMonster.Scripts SIZE_FASHIONSCSET = 240, }; + // Pet food type + enum PetFoodType + { + PET_FOOD_GRASS = 0, + PET_FOOD_MEAT, + PET_FOOD_VEGETABLE, + PET_FOOD_FRUIT, + PET_FOOD_WATER, + MAX_PET_FOOD, + }; } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmor.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmor.cs index ccda52735a..7f6124202b 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmor.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrArmor.cs @@ -393,18 +393,13 @@ namespace PerfectWorld.Scripts.Managers m_strDesc += "\\r"; AddIDDescText(); AddBindDescText(); - BMLogger.Log("AddBindDescText: " + m_strDesc); // Is destroying? AddDestroyingDesc((int)m_pDBEssence.id_drop_after_damaged, m_pDBEssence.num_drop_after_damaged); - BMLogger.Log("AddDestroyingDesc: " + m_strDesc); AddExpireTimeDesc(); - BMLogger.Log("AddExpireTimeDesc: " + m_strDesc); // Sub class name AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_CLASSNAME), m_pDBSubType.Name); - BMLogger.Log("AddDescText: " + m_strDesc); // Weapon level AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), m_pDBEssence.level); - BMLogger.Log("AddDescText: " + m_strDesc); // Physical defence if (m_Essence.defense - aPEEVals[PEEI_PHYDEF] + aRefines[REFINE_PHYDEF] != 0) { diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblin.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblin.cs index 16a91bcd9e..4d6f69ee70 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblin.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrGoblin.cs @@ -1,20 +1,763 @@ using BrewMonster.Scripts.Managers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.IO; +using BrewMonster; +using ModelRenderer.Scripts.Common; +using ModelRenderer.Scripts.GameData; +using UnityEngine; +using PerfectWorld.Scripts.Managers; +using BrewMonster.Network; +using CSNetwork.GPDataType; +using System.Runtime.InteropServices; +using BrewMonster.Scripts; +using BrewMonster.Scripts.Skills; namespace PerfectWorld.Scripts.Managers { - public class EC_IvtrGoblin : EC_IvtrItem + /// + /// The goblin item class (cac loai tinh linh).(not completed, need generate class). + /// This feature is skip for now. + /// + public class EC_IvtrGoblin : EC_IvtrEquip { + #region const, enum and struct + const int MAX_ELF_REFINE_LEVEL = 36; + const int INITIAL_MAX_VIGOR = 1000; + + enum ElfSkillNum + { + MAX_SKILLNUM = 8, // Max skill num + SKILL_LEARN_PT = 40, // ����ÿ���SKILL_LEARN_PT�㣨����+װ��+ģ�壩���ܶ�ѧһ������ (�ѹ�ʱ 2009-08-24) + INIT_SKILL_NUM = 4, // ��ʼ�������� + }; + public struct GOBLINSKILL + { + public ushort skill; + public short level; + } + #endregion + #region Array and List declaration + // Refine effect of goblin + int[,] m_iRefineEffect = new int[MAX_ELF_REFINE_LEVEL, 3] { + {45,0,0}, + {100,0,0}, + {165,0,0}, + {240,0,0}, + {325,0,0}, + + {420,0,0}, + {420,1,0}, + {420,2,0}, + {420,2,1}, + {420,2,2}, // 10 + {420,3,3}, + {420,4,4}, + {420,6,5}, + {420,9,6}, + {420,12,7}, + + {420,16,8}, + {420,20,9}, + {420,24,11}, + {420,28,13}, + {420,32,15}, // 20 + + {420,36,17}, + {420,41,19}, + {420,46,21}, + {420,51,24}, + {420,56,27}, + + {420,61,30}, + {420,66,33}, + {420,72,36}, + {420,78,39}, + {420,84,42}, // 30 + + {420,90,45}, + {420,96,48}, + {420,102,51}, + {420,108,54}, + {420,114,57}, + + {420,120,60} + }; + int[] m_iRefineMaterial = new int[MAX_ELF_REFINE_LEVEL] { + 1, 2, 7, 20, 50, 110, 220, 390, 500, 550, // 10 + 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, // 20 + 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500, 1550, // 30 + 1600, 1650, 1700, 1750, 1800, 1850, + }; + static int[] elf_exp_loss_constant = new int[151] {0, //no use + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + 100, 100, 100, 100, 100, //105 + + // Ϊ�����ڷ����Գ��������ȼ�������150 + 100, 100, 100, 100, 100, //110 + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, //120 + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, //130 + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, //140 + 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, //150 + }; + //��ʹ��rmb����Ŀ�꾫���ȼ���Ӧ�ijɹ��� + float[] elf_refine_succ_prob_ticket0 = new float[MAX_ELF_REFINE_LEVEL+1] { + 1.0f, 0.4f, 0.315789474f, 0.338983051f, 0.377358491f, 0.417754569f, 0.463208685f, 0.510769231f, 0.55f, 0.55f, + 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, + 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, + 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, 0.55f, + 0.0f}; // [36]: cannot refine any more + //ʹ�����絤(��߳ɹ��ʣ�ʧ�ܵȼ���0)Ŀ�꾫���ȼ���Ӧ�ijɹ��� + static float[] elf_refine_succ_prob_ticket1 = new float[MAX_ELF_REFINE_LEVEL+1]{ + 1.0f, 0.6f, 0.368421053f, 0.355932203f, 0.383647799f, 0.420365535f, 0.464414958f, 0.511384615f, 0.557001027f, 0.60032861f, + 0.640836732f, 0.678052261f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, + 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, + 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, + 0.0f + }; + //ʹ�����ϵ�(���ɹ��ʣ�ʧ�ܵȼ���1)Ŀ�꾫���ȼ���Ӧ�ijɹ��� + static float[] elf_refine_succ_prob_ticket2 = new float[MAX_ELF_REFINE_LEVEL+1]{ + 1.0f, 0.6f, 0.333333333f, 0.296296296f, 0.3f, 0.314814815f, 0.337313433f, 0.360708535f, 0.381453155f, 0.4f, + 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, + 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, + 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, + 0.0f + }; + //ʹ���λõ�(�ɹ�����ʹ�ø����������и������ޣ�ʧ�ܵȼ�����)Ŀ�꾫���ȼ���Ӧ�����ʹ�������ɹ���=��������/���Էŵ�������� + static int[] elf_refine_max_use_ticket3 = new int[MAX_ELF_REFINE_LEVEL+1]{ + 1 , 2 , 7 , 20 , 50 , 112 , 223 , 398 , 648 , 974 , + 1366 , 1806 , 2271 , 2739 , 3191 , 3612 , 3993 , 4331 , 4623 , 4873 , + 5084 , 5260 , 5405 , 5525 , 5623 , 5702 , 5767 , 5819 , 5861 , 5895 , + 5923 , 5945 , 5962 , 5977 , 5988 , 5997, + 100000000 + }; + #endregion + List m_aSkills; + List m_aEquipID; + + IVTR_ESSENCE_GOBLIN m_Essence; // Goblin essence data + // Data in database + GOBLIN_ESSENCE m_pDBEssence; /// - /// Not create logic yet (add summary later) + /// Create goblin item (cac loai tinh linh). /// /// Template id /// Expire date public EC_IvtrGoblin(int tid, int expire_date) : base(tid, expire_date) { + m_iCID = (int)InventoryClassId.ICID_GOBLIN; + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + m_pDBEssence = (GOBLIN_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_iPileLimit = m_pDBEssence.pile_num_max; + Price = m_pDBEssence.price; + m_iShopPrice = m_pDBEssence.shop_price; + m_iProcType = (int)m_pDBEssence.proc_type; + m_bNeedUpdate = false; + m_i64EquipMask = (long)EC_IvtrType.EQUIP_MASK64_GOBLIN; + + CurEndurance = 1; + MaxEndurance = 1; } public EC_IvtrGoblin(EC_IvtrGoblin other) : base(other) { + m_pDBEssence = other.m_pDBEssence; + m_Essence = other.m_Essence; // Copy essence + + // Copy skills + int i, iNumSkill = other.m_aSkills.Count; + m_aSkills = new List(iNumSkill); + + for (i=0; i < iNumSkill; i++) + m_aSkills[i] = other.m_aSkills[i]; + + // Copy equipments + int iNumEquip = other.m_aEquipID.Count; + m_aEquipID = new List(iNumEquip); + + for(i=0; i< iNumEquip; i++) + m_aEquipID[i] = other.m_aEquipID[i]; } + + public IVTR_ESSENCE_GOBLIN GetEssence() { return m_Essence; } + + // Get database data + public GOBLIN_ESSENCE GetDBEssence() { return m_pDBEssence; } + + // Get skill number + public int GetSkillNum() { return m_aSkills.Count; } + + public GOBLINSKILL GetSkill(int id) { if(id>=0 && id MAX_ELF_REFINE_LEVEL) + { + throw new Exception("iLevel is out of range"); + } + return elf_refine_succ_prob_ticket1[iLevel]; + } + float GetRefineSuccProb2(int iLevel) + { + if (iLevel < 0 || iLevel > MAX_ELF_REFINE_LEVEL) + { + throw new Exception("iLevel is out of range"); + } + return elf_refine_succ_prob_ticket2[iLevel]; + } + float GetRefineSuccProb3(int iLevel, int iNum) + { + if (iLevel < 0 || iLevel > MAX_ELF_REFINE_LEVEL) + { + throw new Exception("iLevel is out of range"); + } + if (iNum >= elf_refine_max_use_ticket3[iLevel]) + { + return 1.0f; + } + if (iLevel == MAX_ELF_REFINE_LEVEL) + { + return 0.0f; + } + return (float)iNum / (float)elf_refine_max_use_ticket3[iLevel]; + } + int GetRefineLife(int iLevel) + { + if (iLevel < 1 || iLevel > MAX_ELF_REFINE_LEVEL) + { + throw new Exception("iLevel is out of range"); + } + return m_iRefineEffect[iLevel-1, 0]; + } + int GetRefineAtkLvl(int iLevel) + { + if (iLevel < 1 || iLevel > MAX_ELF_REFINE_LEVEL) + { + throw new Exception("iLevel is out of range"); + } + return m_iRefineEffect[iLevel-1, 1]; + } + int GetRefineDfsLvl(int iLevel) + { + if (iLevel < 1 || iLevel > MAX_ELF_REFINE_LEVEL) + { + throw new Exception("iLevel is out of range"); + } + return m_iRefineEffect[iLevel-1, 2]; + } + int GetRefineMaterial(int iLevel) + { + if (iLevel < 1 || iLevel > MAX_ELF_REFINE_LEVEL) + { + throw new Exception("iLevel is out of range"); + } + return m_iRefineMaterial[iLevel-1]; + } + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + + if (pInfoData == null || iDataLen == 0) + return true; + + try + { + CECDataReader dr = new CECDataReader(pInfoData, iDataLen); + + // Set _GOBLIN_DATA info + // Calculate size manually: uint(4) + 7*short(14) + short[5](10) + short(2) + 2*int(8) = 40 bytes + const int GOBLIN_DATA_SIZE = 40; + m_Essence.data = new IVTR_ESSENCE_GOBLIN._GOBLIN_DATA(dr.ReadData(GOBLIN_DATA_SIZE)); + + // Change proc type + if(m_Essence.data.status_value < 0) + { + m_iProcType |= (int)ProcType.PROC_SELLABLE; + m_iProcType |= (int)ProcType.PROC_TRADEABLE; + } + else + { + m_iProcType &= ~(int)ProcType.PROC_SELLABLE; + m_iProcType &= ~(int)ProcType.PROC_TRADEABLE; + } + + // Set equipment info + int i, iEquipCnt = dr.ReadInt(); + m_Essence.equip_cnt = iEquipCnt; + + m_aEquipID = new List(iEquipCnt); + for(i=0; i< iEquipCnt; i++) + { + m_aEquipID[i] = (uint)dr.ReadInt(); + } + + // Set skill info + int iSkillCnt = dr.ReadInt(); + m_Essence.skill_cnt = iSkillCnt; + + m_aSkills = new List(iSkillCnt); + for(i=0; i< iSkillCnt; i++) + { + GOBLINSKILL s = m_aSkills[i]; + s.skill = (ushort)dr.ReadShort(); + s.level = (short)dr.ReadShort(); + } + } + catch (Exception e) + { + Debug.LogError("CECIvtrGoblin::SetItemInfo, data read error (" + e.GetType() + ")"); + return false; + } + + return true; + } + public override void DefaultInfo() + { + base.DefaultInfo(); + } + public override string GetIconFile() + { + return m_pDBEssence.FileIcon1; + } + public override string GetName() + { + return m_pDBEssence.Name; + } + protected override string GetNormalDesc(bool bRepair) + { + if (m_bNeedUpdate) + { + return string.Empty; + } + + m_strDesc = ""; + + // Try to build item description + CECStringTab pDescTab = EC_Game.GetItemDesc(); + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + int yellow = (int)DescriptipionMsg.ITEMDESC_COL_YELLOW; + int green = (int)DescriptipionMsg.ITEMDESC_COL_GREEN; + int color = white; + int i; + int namecol = DecideNameCol(); + + // Item name: always use the name in template + if(m_Essence.data.refine_level != 0) + { + AddDescText(namecol, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), m_pDBEssence.Name); + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_REFINE_LEVEL), m_Essence.data.refine_level); + } + else + { + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), m_pDBEssence.Name); + } + + AddIDDescText(); + + // Goblin level + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_LEVEL), m_Essence.data.level); + + // Strength, Agility, Vitality, Energy + gained from equipment + int iEquipStrength = 0; + int iEquipAgility = 0; + int iEquipTili = 0; + int iEquipEnergy = 0; + + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + GOBLIN_EQUIP_ESSENCE pDBEssence; + + for(i=0; i< m_aEquipID.Count; i++) + { + pDBEssence = (GOBLIN_EQUIP_ESSENCE)pDB.get_data_ptr(m_aEquipID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + iEquipStrength += pDBEssence.strength; + iEquipAgility += pDBEssence.agility; + iEquipTili += pDBEssence.tili; + iEquipEnergy += pDBEssence.energy; + } + + color = (iEquipStrength == 0) ? white : green; + AddDescText(color, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_STRENGTH), iEquipStrength + m_Essence.data.strength + m_pDBEssence.init_strength); + color = (iEquipAgility == 0) ? white : green; + AddDescText(color, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AGILITY), iEquipAgility + m_Essence.data.agility + m_pDBEssence.init_agility); + color = (iEquipTili == 0) ? white : green; + AddDescText(color, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_VITALITY), iEquipTili + m_Essence.data.vitality + m_pDBEssence.init_tili); + color = (iEquipEnergy == 0) ? white : green; + AddDescText(color, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ENERGY), iEquipEnergy + m_Essence.data.energy + m_pDBEssence.init_energy); + + // Grow degree + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_GROW_DEGREE), GetGrowDegree()); + + // Random status point + int iMaxRandPt = GetMaxRandomStatusPt(); + if(iMaxRandPt != 0) + { + int iRandPt = GetRandomStatusPt(); + + int iGrowDegree = GetGrowDegree(); + int iRandomPt = GetRandomStatusPt(); + int iMaxPt= GetMaxStautsPt(); + + if(iRandomPt <= iGrowDegree*0.8) + color = (int)DescriptipionMsg.ITEMDESC_COL_GREEN; + else if(iRandomPt <= iGrowDegree) + color = (int)DescriptipionMsg.ITEMDESC_COL_LIGHTBLUE; + else if(iRandomPt <= (iMaxPt - iGrowDegree)*0.2 + iGrowDegree) + color = (int)DescriptipionMsg.ITEMDESC_COL_PURPLE; + else if(iRandomPt < iMaxPt) + color = (int)DescriptipionMsg.ITEMDESC_COL_YELLOW; + else if(iRandomPt == iMaxPt) + color = (int)DescriptipionMsg.ITEMDESC_COL_DARKGOLD; + + AddDescText(color, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_RANDPT), iRandPt, iMaxRandPt); + } + + // Energy + int iEnergy = INITIAL_MAX_VIGOR + GetBasicProp(2); + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_ENERGY), iEnergy); + + // Energy restore speed + float fRestoreSpeed = 1.0f + GetBasicProp(3)*0.02f; + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_ENERGY_RESTORE), fRestoreSpeed); + + // Current stamina + int iCurrStamina = m_Essence.data.stamina; + if(iCurrStamina > 999999) + iCurrStamina = 999999; + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_STAMINA), iCurrStamina); + + // Current refine effect + if(m_Essence.data.refine_level != 0) + { + int iAttackLevel, iDefenceLevel, iLife; + iLife = GetRefineLife(m_Essence.data.refine_level); + iAttackLevel = GetRefineAtkLvl(m_Essence.data.refine_level); + iDefenceLevel = GetRefineDfsLvl(m_Essence.data.refine_level); + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_REFINE_EFFECT), iLife, iAttackLevel, iDefenceLevel); + } + + // Trade state + int iTradeState = m_Essence.data.status_value; + if(iTradeState == 0) + AddDescText(white,true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_TRADE_PROTECT)); + else if(iTradeState > 0) + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_TRADE_UNPROTECT)); + else if(iTradeState < 0) + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLIN_CANTRADE)); + + // Price + AddPriceDesc(white, bRepair); + + // Equipment info + if(m_aEquipID.Count != 0) + m_strDesc += "\\r"; + for(i=0; i< m_aEquipID.Count; i++) + { + pDBEssence = (GOBLIN_EQUIP_ESSENCE)pDB.get_data_ptr(m_aEquipID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_GOBLINEQUIP_POS_1 + pDBEssence.equip_type)); + AddDescText(white, true, " %s", pDBEssence.name); + } + + // Skill list + if(m_aSkills.Count != 0 && m_aEquipID.Count == 0) + m_strDesc += "\\r"; + for (i=0; i < m_aSkills.Count; i++) + { + GOBLINSKILL gSkill = m_aSkills[i]; + string szName = EC_Game.GetSkillDesc().GetWideString(gSkill.skill * 10); + if(i==m_aSkills.Count-1) + AddDescText((int)DescriptipionMsg.ITEMDESC_COL_YELLOW, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PETSKILL), szName != null ? szName : "", gSkill.level); + else + AddDescText((int)DescriptipionMsg.ITEMDESC_COL_YELLOW, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PETSKILL), szName != null ? szName : "", gSkill.level); + } + + AddExtDescText(); + + return m_strDesc; + } + + // Get grow degree + int GetGrowDegree() + { + float fGrowDegree = 0.0f; + for(int i=0;i<10;i++) + { + fGrowDegree += m_pDBEssence.rand_prop[i].rand_num * m_pDBEssence.rand_prop[i].rand_rate; + } + return (int)(fGrowDegree*10 + 0.5f); + } + // Max random status points that this goblin can get, depending on player's RP value + int GetMaxRandomStatusPt() + { + return (GetMaxStautsPt()/10) * (m_Essence.data.level/10); + } + // Max status points that this goblin can get + int GetMaxStautsPt() + { + int iMaxPt = 0; + for(int i= 0;i<10;i++) + { + if(iMaxPt < m_pDBEssence.rand_prop[i].rand_num) + iMaxPt = m_pDBEssence.rand_prop[i].rand_num; + } + + return iMaxPt * 10; + } + // Current random status point + int GetRandomStatusPt() + { + return m_Essence.data.total_attribute - (m_Essence.data.level-1); + } + // Get basic property + int GetBasicProp(int iIndex) + { + if(iIndex < 0 || iIndex >= 4) + { + throw new Exception("iIndex is out of range"); + } + int i, iRet = 0; + + // Strength, Agility, Vitality, Energy + gained from equipment + int iEquipStrength = 0; + int iEquipAgility = 0; + int iEquipTili = 0; + int iEquipEnergy = 0; + + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + GOBLIN_EQUIP_ESSENCE pDBEssence; + + for(i=0; i< m_aEquipID.Count; i++) + { + pDBEssence = (GOBLIN_EQUIP_ESSENCE)pDB.get_data_ptr(m_aEquipID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + iEquipStrength += pDBEssence.strength; + iEquipAgility += pDBEssence.agility; + iEquipTili += pDBEssence.tili; + iEquipEnergy += pDBEssence.energy; + } + + if(iIndex == 0) + iRet = iEquipStrength + m_Essence.data.strength + m_pDBEssence.init_strength; + else if(iIndex == 1) + iRet = iEquipAgility + m_Essence.data.agility + m_pDBEssence.init_agility; + else if(iIndex == 2) + iRet = iEquipTili + m_Essence.data.vitality + m_pDBEssence.init_tili; + else if(iIndex == 3) + iRet = iEquipEnergy + m_Essence.data.energy + m_pDBEssence.init_energy; + + return iRet; + } + uint GetDestroyExp() + { + double dRetExp = 0; + int iLevel = m_Essence.data.level; + uint iCurrExp = m_Essence.data.exp; + double factor = 0.0f; + + for(int i=1;i4200000000.0) ? 4200000000 : (uint)dRetExp; + } + // Check whether goblin can trade + public override bool IsTradeable() + { + return (m_iProcType & (int)ProcType.PROC_TRADEABLE) != 0; + } + // Get drop model for shown + public override string GetDropModel() => m_pDBEssence.FileMatter; + // Get Equipment id + public uint GetEquip(int id) + { + if(id<0 || id>=4) + throw new Exception("id is out of range"); + int iEquipPos = (int)m_aEquipID[id]; + if(iEquipPos == id) + return m_aEquipID[id]; + return 0; + } + + + + + // Check whether goblin can learn specified skill + // 0:�ɹ� 1:����SP���� 2:�����츳�㲻�� + // 3:���� 4:���ܸ������� 5:����ID + // 6:��Ǯ���� 7:��С���鼼�� 8:û�м����� + // 9:�ȼ����� 10:�������޲��� 11:ְҵ��ƥ�� + // 12:�������޲��㣬��ְҵ��ƥ�� + int CheckSkillLearnCondition(int idSkill, bool bCheckBook) + { + int iLevel = 1, i; + for(i=0;i GetCurrMaxSkillNum()) || + (GetSkillNum() == GetCurrMaxSkillNum() && iLevel == 1)) + return 4; + } + + return iRet; + } + + // Get genius point + int GetGenius(int iIndex) + { + if(iIndex < 0 || iIndex >= 5) + { + throw new Exception("iIndex is out of range"); + } + int i, iRet = m_Essence.data.genius[iIndex]; + + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + GOBLIN_EQUIP_ESSENCE pDBEssence; + + for(i=0; i< m_aEquipID.Count; i++) + { + pDBEssence = (GOBLIN_EQUIP_ESSENCE)pDB.get_data_ptr(m_aEquipID[i], ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + iRet += pDBEssence.magic[iIndex]; + } + + return (iRet > 8) ? 8 : iRet; + } + int GetCurrMaxSkillNum() + { + int iRandPt = GetRandomStatusPt(); + + if(iRandPt > 90) + return 8; + else if(iRandPt > 80) + return 7; + else if(iRandPt > 70) + return 6; + else if(iRandPt > 50) + return 5; + + return (int)ElfSkillNum.INIT_SKILL_NUM; + } + //Check whether goblin can cast specified skill + /// + /// implement later + /// + /// + /// + bool CheckSkillCastCondition(int index) + { + return true; + // if(index<0 || index >= m_aSkills.Count) + // { + // throw new Exception("index is out of range"); + // return false; + // } + // if (EC_Game.GetGameRun().GetHostPlayer().GetBattleInfo().IsChariotWar()) + // return false; // ս��ս�� ��ֹ���鼼�� + + + // GNET::GoblinUseRequirement Info; + // memset(&Info, 0, sizeof(Info)); + + // for(int i=0;i<5;i++) + // { + // Info.genius[i] = GetGenius(i); + // } + + // Info.level = m_Essence.data.level; + // Info.move_env = g_pGame->GetGameRun()->GetHostPlayer()->GetMoveEnv(); + + // GOBLINSKILL pSkill = GetSkill(index); + // int ret = GNET::ElementSkill::GoblinCondition(pSkill.skill, Info, pSkill.level); + + // if(ret == 4) + // return false; + // return true; + } + + int GetModelLevel() + { + int iGrowDegree = GetGrowDegree(); + int iRandomPt = GetRandomStatusPt(); + int iMaxPt= GetMaxStautsPt(); + int iModelLvl = 0; + + // �ɳ��ȡ���������뼸��ģ�͵Ĺ�ϵ����������֪������ͬ������ + if(iRandomPt <= iGrowDegree*0.8) + iModelLvl = 1; + else if(iRandomPt <= iGrowDegree) + iModelLvl = 2; + else if(iRandomPt <= (iMaxPt - iGrowDegree)*0.2 + iGrowDegree) + iModelLvl = 3; + else + iModelLvl = 4; + + return iModelLvl; + } } } - +// Get current max skill number diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrItem.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrItem.cs index c2678925c1..67ab258250 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrItem.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrItem.cs @@ -1503,6 +1503,13 @@ namespace BrewMonster.Scripts.Managers protected virtual void AddDescText(int iCol, bool bRet, string szText, params object[] args) { + // Add color prefix if color is specified + if (iCol >= 0) + { + string colorStr = GetColorString((DescriptipionMsg)iCol); + m_strDesc += colorStr; + } + string line; if (args != null && args.Length > 0) { @@ -1525,6 +1532,26 @@ namespace BrewMonster.Scripts.Managers m_strDesc += "\n"; } + /// + /// Get color string for color ID + /// Returns color codes in ^RRGGBB format (6 hex digits) for text formatting + /// + protected virtual string GetColorString(DescriptipionMsg colorId) + { + switch (colorId) + { + case DescriptipionMsg.ITEMDESC_COL_WHITE: return "^FFFFFF"; // White + case DescriptipionMsg.ITEMDESC_COL_GREEN: return "^00FF00"; // Green + case DescriptipionMsg.ITEMDESC_COL_YELLOW: return "^FFFF00"; // Yellow + case DescriptipionMsg.ITEMDESC_COL_DARKGOLD: return "^FF8C00"; // Dark Gold / Orange + case DescriptipionMsg.ITEMDESC_COL_LIGHTBLUE: return "^5998FF"; // Light Blue + case DescriptipionMsg.ITEMDESC_COL_CYANINE: return "^00FFFF"; // Cyan + case DescriptipionMsg.ITEMDESC_COL_RED: return "^FF0000"; // Red + case DescriptipionMsg.ITEMDESC_COL_GRAY: return "^808080"; // Gray + default: return "^FFFFFF"; // Default to white + } + } + /// /// Format string using printf-style format specifiers (%d, %+d, %.2f, %s, etc.) /// Converts printf-style formats to C# string formatting @@ -1662,7 +1689,6 @@ namespace BrewMonster.Scripts.Managers if (!string.IsNullOrEmpty(desc)) m_strDesc += desc; } - Debug.Log("m_strDesc: " + m_strDesc); } if ((m_iProcType & (int)ProcType.PROC_SELLABLE) != 0) { diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetEgg.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetEgg.cs index ca4575a50e..4b1c0917e4 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetEgg.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetEgg.cs @@ -1,20 +1,360 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.IO; +using BrewMonster; +using ModelRenderer.Scripts.Common; +using ModelRenderer.Scripts.GameData; +using UnityEngine; +using PerfectWorld.Scripts.Managers; +using BrewMonster.Network; using BrewMonster.Scripts.Managers; +using BrewMonster.Scripts; +using CSNetwork.GPDataType; +using System.Runtime.InteropServices; namespace PerfectWorld.Scripts.Managers { + public struct PETSKILL + { + public int idSkill; + public int iLevel; + }; + /// + /// Class for Pet Egg(cac loai trung pet(thu cuoi, chien dau, di theo, p2w pet)). This is a part of IvtrPetItem(C++) + /// public class EC_IvtrPetEgg : EC_IvtrItem { + List m_aSkills; + + IVTR_ESSENCE_PETEGG m_Essence; + string m_strName; + + // Data in database + PET_EGG_ESSENCE m_pDBEssence; + PET_ESSENCE m_pPetEssence; + PET_ESSENCE m_pEvoPetEssence; + PET_EVOLVED_SKILL_CONFIG m_pEvoNatureConfig; + _evo_prop m_EvoProp; // ������̳����� /// - /// Not create logic yet (add summary later) + /// Constructor for Pet Egg(cac loai trung pet(thu cuoi, chien dau, di theo, p2w pet)) /// /// Template id /// Expire date public EC_IvtrPetEgg(int tid, int expire_date) : base(tid, expire_date) { + m_iCID = (int)InventoryClassId.ICID_PETEGG; + + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + m_pDBEssence = (PET_EGG_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_pPetEssence = (PET_ESSENCE)pDB.get_data_ptr((uint)m_pDBEssence.id_pet, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + // ASSERT(m_pPetEssence); + + //struct can't be null + //m_pEvoPetEssence = null; + m_pEvoPetEssence = new PET_ESSENCE(); + if (m_pPetEssence.id >=0) + { + object pTempDBEssenceObj = pDB.get_data_ptr((uint)m_pPetEssence.id_pet_egg_evolved, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + if (pTempDBEssenceObj != null) + { + PET_EGG_ESSENCE pTempDBEssence = (PET_EGG_ESSENCE)pTempDBEssenceObj; + if (pTempDBEssence.id >=0) + { + object pEvoPetEssenceObj = pDB.get_data_ptr((uint)pTempDBEssence.id_pet, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + if (pEvoPetEssenceObj != null) + m_pEvoPetEssence = (PET_ESSENCE)pEvoPetEssenceObj; + } + } + } + + + m_iPileLimit = m_pDBEssence.pile_num_max; + m_iPrice = m_pDBEssence.price; + m_iShopPrice = m_pDBEssence.shop_price; + m_iProcType = (int)m_pDBEssence.proc_type; + m_i64EquipMask = 0; + // m_bUseable = true; + // m_dwUseFlags = USE_PERSIST; + + m_Essence = new IVTR_ESSENCE_PETEGG(); + m_EvoProp = new _evo_prop{ + r_attack = 0, + r_defense = 0, + r_hp = 0, + r_atk_lvl = 0, + r_def_lvl = 0, + nature = 0 + }; + + m_pEvoNatureConfig = new PET_EVOLVED_SKILL_CONFIG(); } public EC_IvtrPetEgg(EC_IvtrPetEgg other) : base(other) { + m_pDBEssence = other.m_pDBEssence; + m_pPetEssence = other.m_pPetEssence; + m_Essence = other.m_Essence; + m_strName = other.m_strName; + + // Copy skills + int i, iNumSkill = other.m_aSkills.Count; + m_aSkills = new List(iNumSkill); + + for (i=0; i < iNumSkill; i++) + m_aSkills[i] = other.m_aSkills[i]; + + m_EvoProp = other.m_EvoProp; + m_pEvoNatureConfig = other.m_pEvoNatureConfig; + m_pEvoPetEssence = other.m_pEvoPetEssence; } + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + + if (pInfoData == null || iDataLen == 0) + return true; + + try { + CECDataReader dr = new CECDataReader(pInfoData, iDataLen); + m_Essence = new IVTR_ESSENCE_PETEGG(dr.ReadData(Marshal.SizeOf())); + + if (m_Essence.name_len != 0) + { + m_strName = ByteToStringUtils.UshortArrayToUnicodeString(m_Essence.name); + EC_Game.GetGameRun().GetUIManager().FilterBadWords(m_strName); + } + + m_aSkills = new List(m_Essence.skill_count); + for (int i=0; i < m_Essence.skill_count; i++) + { + PETSKILL s = new PETSKILL(); + s.idSkill = dr.ReadInt(); + s.iLevel = dr.ReadInt(); + m_aSkills.Add(s); + } + + if (m_Essence.pet_class == (int)GP_PET_TYPE.GP_PET_CLASS_EVOLUTION) + { + m_EvoProp.r_attack = dr.ReadInt(); + m_EvoProp.r_defense = dr.ReadInt(); + m_EvoProp.r_hp = dr.ReadInt(); + m_EvoProp.r_atk_lvl = dr.ReadInt(); + m_EvoProp.r_def_lvl = dr.ReadInt(); + m_EvoProp.nature = dr.ReadInt(); + + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + object pDBData = pDB.get_data_ptr((uint)m_EvoProp.nature, ID_SPACE.ID_SPACE_CONFIG, ref DataType); + if (pDBData != null && DataType == DATA_TYPE.DT_PET_EVOLVED_SKILL_CONFIG) + m_pEvoNatureConfig = (PET_EVOLVED_SKILL_CONFIG)pDBData; + } + } + catch (Exception e) + { + Debug.LogError("EC_IvtrPetEgg::SetItemInfo, data read error (" + e.GetType() + e.StackTrace + ")"); + return false; + } + + return true; + } + public override string GetIconFile() + { + return m_pDBEssence.FileIcon; + } + + public override string GetName() + { + // Try Unicode first (for Vietnamese/wide char names), then fallback to CP936 + if (m_pDBEssence.name != null && m_pDBEssence.name.Length > 0) + { + string s = ByteToStringUtils.UshortArrayToUnicodeString(m_pDBEssence.name); + if (!string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s)) + return s; + // Fallback to legacy CP936 if Unicode was empty + s = ByteToStringUtils.UshortArrayToCP936String(m_pDBEssence.name); + if (!string.IsNullOrEmpty(s)) + return s; + } + return base.GetName(); // Fallback to base class method + } + protected override string GetNormalDesc(bool bRepair) + { + string szDesc = ""; + switch (m_Essence.pet_class) + { + case (int)GP_PET_TYPE.GP_PET_CLASS_MOUNT: szDesc = GetRidingPetDesc(bRepair); break; + case (int)GP_PET_TYPE.GP_PET_CLASS_COMBAT: szDesc = GetCombatPetDesc(bRepair); break; + case (int)GP_PET_TYPE.GP_PET_CLASS_FOLLOW: szDesc = GetFollowPetDesc(bRepair); break; + case (int)GP_PET_TYPE.GP_PET_CLASS_EVOLUTION:szDesc = GetEvolutionPetDesc(bRepair); break; + } + + return szDesc; + } + private string GetRidingPetDesc(bool bRepair) + { + Debug.Log("GetRidingPetDesc. This is not implemented yet."); + return ""; + } + private string GetCombatPetDesc(bool bRepair) + { + if (m_bNeedUpdate) + return ""; + + m_strDesc = ""; + + // Try to build item description + CECStringTab pDescTab = EC_Game.GetItemDesc(); + CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer(); + + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + int red = (int)DescriptipionMsg.ITEMDESC_COL_RED; + int namecol = DecideNameCol(); + + // Item name: always use the name in template + if (m_iCount > 1) + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount); + else + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName()); + + AddIDDescText(); + + AddBindDescText(); + + AddExpireTimeDesc(); + + // Food type requirement + AddFoodTypeDesc(); + + if (m_pPetEssence.id != 0) + { + // Pet level + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PETLEVEL), m_Essence.level); + + // Physical damage + int iVal = (int)(((PET_ESSENCE)m_pPetEssence).damage_a * (((PET_ESSENCE)m_pPetEssence).damage_b * m_Essence.level * m_Essence.level + ((PET_ESSENCE)m_pPetEssence).damage_c * m_Essence.level + ((PET_ESSENCE)m_pPetEssence).damage_d)); + AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_DAMAGE), iVal); + + // Attack speed + AddDescText(-1, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ATKSPEED)); + AddDescText(-1, true, " %.2f", 1.0f / ((PET_ESSENCE)m_pPetEssence).attack_speed); + + //Attack rating + iVal = (int)(((PET_ESSENCE)m_pPetEssence).attack_a * (m_Essence.level - ((PET_ESSENCE)m_pPetEssence).attack_b * ((PET_ESSENCE)m_pPetEssence).level_require + ((PET_ESSENCE)m_pPetEssence).attack_c)); + AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ATTACKRATE), iVal); + + // Physical defence + iVal = (int)(((PET_ESSENCE)m_pPetEssence).physic_defence_a * (((PET_ESSENCE)m_pPetEssence).physic_defence_b * (m_Essence.level - ((PET_ESSENCE)m_pPetEssence).physic_defence_c * ((PET_ESSENCE)m_pPetEssence).level_require) + ((PET_ESSENCE)m_pPetEssence).physic_defence_d)); + AddDescText(-1, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PHYDEFENCE)); + AddDescText(-1, true, " %d", iVal); + + // Magic defence + iVal = (int)(((PET_ESSENCE)m_pPetEssence).magic_defence_a * (((PET_ESSENCE)m_pPetEssence).magic_defence_b * (m_Essence.level - ((PET_ESSENCE)m_pPetEssence).magic_defence_c * ((PET_ESSENCE)m_pPetEssence).level_require) + ((PET_ESSENCE)m_pPetEssence).magic_defence_d)); + AddDescText(-1, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ALLMAGICDEF)); + AddDescText(-1, true, " %d", iVal); + + // Dodge + iVal = (int)(((PET_ESSENCE)m_pPetEssence).armor_a * (m_Essence.level - ((PET_ESSENCE)m_pPetEssence).armor_b * ((PET_ESSENCE)m_pPetEssence).level_require + ((PET_ESSENCE)m_pPetEssence).armor_c)); + AddDescText(-1, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_DODGE)); + AddDescText(-1, true, " %d", iVal); + + // hp + iVal = (int)(((PET_ESSENCE)m_pPetEssence).hp_a * (m_Essence.level - ((PET_ESSENCE)m_pPetEssence).hp_b * ((PET_ESSENCE)m_pPetEssence).level_require + ((PET_ESSENCE)m_pPetEssence).hp_c)); + AddDescText(-1, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ADDHP)); + AddDescText(-1, true, " %d", iVal); + + // Profession requirement + AddProfReqDesc(((PET_ESSENCE)m_pPetEssence).character_combo_id); + } + + // Level requirement + int iLevelReq = Mathf.Max((int)m_Essence.level, m_Essence.req_level); + if (iLevelReq > 0) + { + int col = pHost.GetMaxLevelSofar() >= iLevelReq ? white : red; + AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVELREQ), iLevelReq); + } + + // Skill list + for (int i=0; i < m_aSkills.Count; i++) + { + PETSKILL skill = m_aSkills[i]; + string szName = EC_Game.GetSkillDesc().GetWideString(skill.idSkill * 10); + AddDescText((int)DescriptipionMsg.ITEMDESC_COL_YELLOW, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PETSKILL), szName != null ? szName : "", skill.iLevel); + + } + + // �ɽ��� + if (m_pEvoPetEssence.id != 0) + { + AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PET_EVO_NAME), ByteToStringUtils.UshortArrayToUnicodeString(((PET_ESSENCE)m_pEvoPetEssence).name)); + } + + // Price + AddPriceDesc(white, bRepair); + + // Extend description + AddExtDescText(); + + return m_strDesc; + } + private string GetFollowPetDesc(bool bRepair) + { + Debug.Log("[THN]GetFollowPetDesc. This is not implemented yet."); + return ""; + } + private string GetEvolutionPetDesc(bool bRepair) + { + Debug.Log("[THN]GetEvolutionPetDesc. This is not implemented yet."); + return ""; + } + private void AddFoodTypeDesc() + { + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + object pPetEssence = pDB.get_data_ptr((uint)m_Essence.pet_tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + if (pPetEssence == null) + return; + + CECStringTab pDescTab = EC_Game.GetItemDesc(); + AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_FOODTYPE)); + + for (int i=0; i < (int)PetFoodType.MAX_PET_FOOD; i++) + { + if ((((PET_ESSENCE)pPetEssence).food_mask & (1 << i)) != 0) + { + m_strDesc += " "; + AddDescText(-1, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_FOOD_GRASS+i)); + } + } + + m_strDesc += "\\r"; + } + // Get item description for booth buying + protected override string GetBoothBuyDesc() + { + m_strDesc = ""; + + CECStringTab pDescTab = EC_Game.GetItemDesc(); + + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + + // Item name + AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), ByteToStringUtils.UshortArrayToUnicodeString(m_pDBEssence.name)); + + // Price + AddPriceDesc(white, false); + + return m_strDesc; + } + + // Get drop model for shown + public override string GetDropModel() + { + return ByteToStringUtils.ByteArrayToCP936String(m_pDBEssence.file_matter); + } + } } diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFood.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFood.cs index df9ad11d21..f5dd7ab1fe 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFood.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrPetFood.cs @@ -1,8 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.IO; +using BrewMonster; +using ModelRenderer.Scripts.Common; +using ModelRenderer.Scripts.GameData; +using UnityEngine; +using PerfectWorld.Scripts.Managers; +using BrewMonster.Network; using BrewMonster.Scripts.Managers; +using BrewMonster.Scripts; +using CSNetwork.GPDataType; +using System.Runtime.InteropServices; namespace PerfectWorld.Scripts.Managers { public class EC_IvtrPetFood : EC_IvtrItem { + + protected PET_FOOD_ESSENCE m_pDBEssence; /// /// Not create logic yet (add summary later) /// @@ -10,11 +25,128 @@ namespace PerfectWorld.Scripts.Managers /// Expire date public EC_IvtrPetFood(int tid, int expire_date) : base(tid, expire_date) { + m_iCID = (int)InventoryClassId.ICID_PETFOOD; + + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + m_pDBEssence = (PET_FOOD_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_iPileLimit = m_pDBEssence.pile_num_max; + m_iPrice = m_pDBEssence.price; + m_iShopPrice = m_pDBEssence.shop_price; + m_iProcType = (int)m_pDBEssence.proc_type; + m_i64EquipMask = 0; + m_bUseable = true; + m_bNeedUpdate = false; } public EC_IvtrPetFood(EC_IvtrPetFood other) : base(other) { + m_pDBEssence = other.m_pDBEssence; + } + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + return true; + } + + // Get item icon file name + public override string GetIconFile() + { + return m_pDBEssence.FileIcon; + } + + // Get item name + public override string GetName() + { + // Try Unicode first (for Vietnamese/wide char names), then fallback to CP936 + if (m_pDBEssence.name != null && m_pDBEssence.name.Length > 0) + { + string s = ByteToStringUtils.UshortArrayToUnicodeString(m_pDBEssence.name); + if (!string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s)) + return s; + // Fallback to legacy CP936 if Unicode was empty + s = ByteToStringUtils.UshortArrayToCP936String(m_pDBEssence.name); + if (!string.IsNullOrEmpty(s)) + return s; + } + return base.GetName(); // Fallback to base class method + } + +// Get item cool time + public int GetCoolTime(ref int piMax) + { + CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer(); + if (!pHost) + return 0; + + int iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_FEED_PET, ref piMax); + return iTime; + } + + // Check item use condition + public override bool CheckUseCondition() + { + CECPetData pPet = EC_Game.GetGameRun().GetHostPlayer().GetPetCorral().GetActivePet(); + if (pPet == null) + return false; + + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + + object temp = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)pPet.GetTemplateID(), ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + + if (temp == null) + return false; + PET_ESSENCE pPetEssence = (PET_ESSENCE)temp; + + return ((m_pDBEssence.food_type & pPetEssence.food_mask) != 0) ? true : false; + } + + // Get item description text + protected override string GetNormalDesc(bool bRepair) + { + m_strDesc = ""; + + // Try to build item description + CECStringTab pDescTab = EC_Game.GetItemDesc(); + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + int namecol = DecideNameCol(); + + // Item name + if (m_iCount > 1) + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount); + else + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName()); + + AddIDDescText(); + + AddExpireTimeDesc(); + + // Food type + for (int i=0; i < (int)PetFoodType.MAX_PET_FOOD; i++) + { + if ((m_pDBEssence.food_type & (1 << i)) != 0) + { + AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_FOODTYPE)); + m_strDesc += " "; + AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_FOOD_GRASS+i)); + break; + } + } + + // Price + AddPriceDesc(white, bRepair); + + // Extend description + AddExtDescText(); + + return m_strDesc; + } + + // Get drop model for shown + public override string GetDropModel() + { + return m_pDBEssence.FileMatter; } } } - diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkilltome.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkilltome.cs index d5fd9ba0e8..c5752a7091 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkilltome.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrSkilltome.cs @@ -1,20 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.IO; +using BrewMonster; +using ModelRenderer.Scripts.Common; +using ModelRenderer.Scripts.GameData; +using UnityEngine; +using PerfectWorld.Scripts.Managers; +using BrewMonster.Network; using BrewMonster.Scripts.Managers; +using BrewMonster.Scripts; namespace PerfectWorld.Scripts.Managers { + /// + /// Skill tome item class(sach ky nang). This is a part of CEC_IvtrScroll(C++) + /// public class EC_IvtrSkilltome : EC_IvtrItem { + + protected SKILLTOME_ESSENCE m_pDBEssence; + protected SKILLTOME_SUB_TYPE m_pDBSubType; /// - /// Not create logic yet (add summary later) + /// Create skill tome item(sach ky nang) /// /// Template id /// Expire date public EC_IvtrSkilltome(int tid, int expire_date) : base(tid, expire_date) { + m_iCID = (int)InventoryClassId.ICID_SKILLTOME; + + // Get database data + elementdataman pDB = ElementDataManProvider.GetElementDataMan(); + DATA_TYPE DataType = DATA_TYPE.DT_INVALID; + m_pDBEssence = (SKILLTOME_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_pDBSubType = (SKILLTOME_SUB_TYPE)pDB.get_data_ptr(m_pDBEssence.id_sub_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); + m_iPileLimit = m_pDBEssence.pile_num_max; + m_iPrice = m_pDBEssence.price; + m_iShopPrice = m_pDBEssence.shop_price; + m_iProcType = (int)m_pDBEssence.proc_type; + m_i64EquipMask = 0; + m_bNeedUpdate = false; } + /// + /// Copy constructor for skill tome item(sach ky nang) + /// + /// Other skill tome item public EC_IvtrSkilltome(EC_IvtrSkilltome other) : base(other) { + m_pDBEssence = other.m_pDBEssence; + m_pDBSubType = other.m_pDBSubType; + } + + public override bool SetItemInfo(byte[] pInfoData, int iDataLen) + { + base.SetItemInfo(pInfoData, iDataLen); + return true; + } + + public override string GetIconFile() + { + return m_pDBEssence.FileIcon; + } + + // Get item name + public override string GetName() + { + // Try Unicode first (for Vietnamese/wide char names), then fallback to CP936 + if (m_pDBEssence.name != null && m_pDBEssence.name.Length > 0) + { + string s = ByteToStringUtils.UshortArrayToUnicodeString(m_pDBEssence.name); + if (!string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s)) + return s; + // Fallback to legacy CP936 if Unicode was empty + s = ByteToStringUtils.UshortArrayToCP936String(m_pDBEssence.name); + if (!string.IsNullOrEmpty(s)) + return s; + } + return base.GetName(); // Fallback to base class method + } + + protected override string GetNormalDesc(bool bRepair) + { + m_strDesc = ""; + + // Try to build item description + CECStringTab pDescTab = EC_Game.GetItemDesc(); + int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE; + int namecol = DecideNameCol(); + + if (m_iCount > 1) + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMENUMBER), GetName(), m_iCount); + else + AddDescText(namecol, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName()); + + AddIDDescText(); + + AddExpireTimeDesc(); + + // Price + AddPriceDesc(white, bRepair); + + // Extend description + AddExtDescText(); + + return m_strDesc; + } + + public override string GetDropModel() + { + return m_pDBEssence.FileMatter; } } -} - +} \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrType.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrType.cs index 5cac2f55cc..67085b3509 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrType.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrType.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; using UnityEngine; using ModelRenderer.Scripts.GameData; using BrewMonster; @@ -190,21 +191,43 @@ namespace BrewMonster.Scripts.Managers }; public struct IVTR_ESSENCE_PETEGG { - // TODO : implement data later - // int req_level; - // int req_class; - // int honor_point; - // int pet_tid; - // int pet_vis_tid; - // int pet_egg_tid; - // int pet_class; - // short level; - // unsigned short color; - // int exp; - // int skill_point; - // unsigned short name_len; - // unsigned short skill_count; - // wchar_t name[8]; + public int req_level; + public int req_class; + public int honor_point; + public int pet_tid; + public int pet_vis_tid; + public int pet_egg_tid; + public int pet_class; + public short level; + public ushort color; + public int exp; + public int skill_point; + public ushort name_len; + public ushort skill_count; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public ushort[] name; + public IVTR_ESSENCE_PETEGG(byte[] data) + { + CECDataReader dr = new (data, data.Length); + req_level = dr.ReadInt(); + req_class = dr.ReadInt(); + honor_point = dr.ReadInt(); + pet_tid = dr.ReadInt(); + pet_vis_tid = dr.ReadInt(); + pet_egg_tid = dr.ReadInt(); + pet_class = dr.ReadInt(); + level = dr.ReadShort(); + color = dr.ReadUShort(); + exp = dr.ReadInt(); + skill_point = dr.ReadInt(); + name_len = dr.ReadUShort(); + skill_count = dr.ReadUShort(); + name = new ushort[8]; + for(int i = 0; i < 8; i++) + { + name[i] = dr.ReadUShort(); + } + } }; public struct IVTR_ESSENCE_DESTROYING { @@ -213,22 +236,54 @@ namespace BrewMonster.Scripts.Managers }; public struct IVTR_ESSENCE_GOBLIN { - struct _GOBLIN_DATA + public struct _GOBLIN_DATA { // TODO : implement data later - // unsigned int exp; - // short level; - // short total_attribute; - // short strength; - // short agility; - // short vitality; - // short energy; - // short total_genius; - // short genius[5]; - // short refine_level; - // int stamina; - // int status_value; - }; + public uint exp; + public short level; + public short total_attribute; + public short strength; + public short agility; + public short vitality; + public short energy; + public short total_genius; + public short[] genius ; + public short refine_level; + public int stamina; + public int status_value; + public _GOBLIN_DATA(byte[] data) + { + CECDataReader dr = new (data, data.Length); + exp = dr.ReadUInt(); + level = dr.ReadShort(); + total_attribute = dr.ReadShort(); + strength = dr.ReadShort(); + agility = dr.ReadShort(); + vitality = dr.ReadShort(); + energy = dr.ReadShort(); + total_genius = dr.ReadShort(); + genius = new short[5]; + for(int i = 0; i < 5; i++) + { + genius[i] = dr.ReadShort(); + } + refine_level = dr.ReadShort(); + stamina = dr.ReadInt(); + status_value = dr.ReadInt(); + } + } + public _GOBLIN_DATA data; + public int equip_cnt; + public int skill_cnt; + public IVTR_ESSENCE_GOBLIN(byte[] data) + { + CECDataReader dr = new (data, data.Length); + // Calculate size manually: uint(4) + 7*short(14) + short[5](10) + short(2) + 2*int(8) = 40 bytes + const int GOBLIN_DATA_SIZE = 40; + this.data = new _GOBLIN_DATA(dr.ReadData(GOBLIN_DATA_SIZE)); + equip_cnt = dr.ReadInt(); + skill_cnt = dr.ReadInt(); + } // TODO : implement data later // _GOBLIN_DATA data; diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeapon.cs b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeapon.cs index 3a4715020b..270faff894 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeapon.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_IvtrItem/EC_IvtrWeapon.cs @@ -385,17 +385,11 @@ namespace PerfectWorld.Scripts.Managers AddDescText((int)DescriptipionMsg.ITEMDESC_COL2_BRIGHTBLUE, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_HASRANDOM_PROP)); // Price AddPriceDesc(white, bRepair); - BMLogger.Log("AddPriceDesc: " + m_strDesc); AddSharpenerDesc(); - BMLogger.Log("AddSharpenerDesc: " + m_strDesc); AddEngravedDesc(); - BMLogger.Log("AddEngravedDesc: " + m_strDesc); AddMakerDesc(); - BMLogger.Log("AddMakerDesc: " + m_strDesc); AddSuiteDesc(); - BMLogger.Log("AddSuiteDesc: " + m_strDesc); AddExtDescText(); - BMLogger.Log("AddExtDescText: " + m_strDesc); return m_strDesc; } // Get weapon attack speed index diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_PetCorral.cs b/Assets/PerfectWorld/Scripts/Managers/EC_PetCorral.cs new file mode 100644 index 0000000000..f5ddbb260a --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Managers/EC_PetCorral.cs @@ -0,0 +1,121 @@ +using CSNetwork.GPDataType; +using PerfectWorld.Scripts; +using BrewMonster; +using BrewMonster.Scripts; + +public struct PETSKILL +{ + public int idSkill; + public int iLevel; + public int iCoolCnt; + public int iCoolMax; +}; + +public enum SkillType +{ + EM_SKILL_DEFAULT = 0, // �������Ը��� + EM_SKILL_NORMAL, // ��ͨ���� + EM_SKILL_NATURE, // �Ը��� + EM_SKILL_SPECIAL, // ר������ +} +public class EC_PetCorral +{ + public enum MaxSlotNum + { + MAX_SLOTNUM = 20, // ��ͨ���������� + MAX_SLOTNUM2 = 21, // ���г��������� + }; + // Moving mode + public enum MoveMode + { + MOVE_FOLLOW = 0, + MOVE_STAND, + }; + + // Attacking mode + public enum AttackMode + { + ATK_DEFENSE = 0, + ATK_POSITIVE, + ATK_PASSIVE, + }; + protected int m_iIntimacy; // �øж� + protected int m_iHunger; // ������ + protected int m_tid; // �����ģ��ID + protected int m_tidVis; // ���������ģ��ID�����Ϊ0�����ʾ������ɼ�ID�� + protected int m_idEgg; // ���ﵰ��ID + protected int m_iClass; // �������� ս�裬��裬���ͳ� + protected float m_fHPFactor; // Ѫ��������������ջ�ʱʹ�ã� 0��Ϊ���� + protected float m_fMPFactor; // MP��������������ջ�ʱʹ�ã� 0��Ϊ���� + protected int m_iLevel; // ���V�� + protected bool m_isBind; // �Ƿ����˺�һ + protected bool m_canWebTrade; // �Ƿ�Ѱ�����ɽ��� + protected ushort m_color; // ���Ⱦɫ��ɫ����λΪ1ʱ��Ч + protected int m_iExp; // ���ﵱǰ���� + protected int m_iSkillPt; // ʣ�༼�ܵ� + protected string m_strName; + + protected int m_iHP; // Only fight pets have this + protected int m_iMP; + protected PETSKILL[] m_aSkills = new PETSKILL[(int)GP_PET_SKILL_NUM.GP_PET_SKILL_NUM]; + + protected int[] m_vecNorSkillIndex; // ��ֹ�Ը��ܺ���ͨ����˳����ҵ���������漼���� m_aSkills������ + protected int[] m_vecDynSkillIndex; + protected int m_iSpecialSkillIndex; // ����ר��������m_aSkills�����ţ�ֻ�н�������һ���˼��� + + protected CECCounter m_cntAutoSkill; + protected int[] m_aAutoSkills; + + protected ROLEEXTPROP m_ExtProps; + protected PET_ESSENCE m_pDBEssence = new PET_ESSENCE(); + + protected int m_iAtkRation; + protected int m_iDefRation; + protected int m_iHpRation; + protected int m_iAtkLvlRation; + protected int m_iDefLvlRation; + protected int m_iNature; + public CECPetData GetActivePet() + { + //Place holder for ivtrPetFood + return null; + } +} + +public class CECPetData +{ + #region enum + public enum HungerLevel + { + HUNGER_LEVEL_0, // ��ʳ + HUNGER_LEVEL_1, // ���� + HUNGER_LEVEL_2, // ���̶�һ�� + HUNGER_LEVEL_3, + HUNGER_LEVEL_4, // ���̶ȶ��� + HUNGER_LEVEL_5, + HUNGER_LEVEL_6, + HUNGER_LEVEL_7, // ���̶����� + HUNGER_LEVEL_8, + HUNGER_LEVEL_9, + HUNGER_LEVEL_10, + HUNGER_LEVEL_11, // ���̶��ļ� + HUNGER_LEVEL_COUNT, + }; + // Intimacy level + public enum IntimacyLevel + { + INTIMACY_LEVEL_0, // Ұ����ѱ, 0-50 + INTIMACY_LEVEL_1, // �����޳�, 51-150 + INTIMACY_LEVEL_2, // ��������, 151-500 + INTIMACY_LEVEL_3, // ���Ĺ���, 501-999 + INTIMACY_LEVEL_COUNT, + INTIMACY_POINT_MAX = 999, + }; + #endregion + + public int GetTemplateID() + { + //Place holder for ivtrPetFood + return -1; + } +} \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_PetCorral.cs.meta b/Assets/PerfectWorld/Scripts/Managers/EC_PetCorral.cs.meta new file mode 100644 index 0000000000..b4dac2903c --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Managers/EC_PetCorral.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c41c880dbc2344f819944899348d5124 \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs index 61b616ef62..d2df7d32fc 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs @@ -2195,5 +2195,89 @@ namespace CSNetwork.GPDataType return buf_size >= sz; } }; + + // Pet type + public enum GP_PET_TYPE + { + GP_PET_CLASS_INVALID = -1, + GP_PET_CLASS_MOUNT = 0, // ��� + GP_PET_CLASS_COMBAT, // ս������ + GP_PET_CLASS_FOLLOW, // ������� + GP_PET_CLASS_SUMMON, // �ٻ����� + GP_PET_CLASS_PLANT, // ֲ�ֻ��Ϊ�˺ͷ�������ֵ����һ�£��ͻ���û���õ� + GP_PET_CLASS_EVOLUTION, // ������ + GP_PET_CLASS_MAX, + }; + + public struct PetSkill + { + public int skill; + public int level; + + } + public struct _evo_prop + { + public int r_attack; + public int r_defense; + public int r_hp; + public int r_atk_lvl; + public int r_def_lvl; + public int nature; + } + public enum GP_PET_SKILL_NUM + { + GP_PET_SKILL_NUM = 8 + }; + public struct info_pet + { + public int honor_point; // �øж� + public int hunger; // ������ + public int feed_time; // �ϴ�ι�������ڵ�ʱ�� + public int pet_tid; // �����ģ��ID + public int pet_vis_tid; // ����Ŀɼ�ID�����Ϊ0�����ʾ������ɼ�ID�� + public int pet_egg_tid; // ���ﵰ��ID + public int pet_class; // �������� ս�裬��裬���ͳ� + public float hp_factor; // Ѫ��������������ջ�ʱʹ�ã� 0��Ϊ���� + public short level; // ���V�� + public ushort color; // ������ɫ�����λΪ1��ʾ��Ч��Ŀǰ���������Ч + public int exp; // ���ﵱǰ���� + public int skill_point; // ʣ�༼�ܵ� + public char is_bind; // �Ƿ����˺�һ��������һ��Mask��0x01 ���˺�һ��0x02 Ѱ�����ɽ��� + public char unused; // Ŀǰ������Ч + public ushort name_len; // ���ֳ��� Ŀǰ������Ч����Ϊ�߻������������� + public char[] name; // �������� + public PetSkill[] skills; + public _evo_prop evo_prop; + public int[] reserved; // δ�� + public info_pet(bool isDefault = true) + { + honor_point = 0; + hunger = 0; + feed_time = 0; + pet_tid = 0; + pet_vis_tid = 0; + pet_egg_tid = 0; + pet_class = 0; + hp_factor = 0; + level = 0; + color = 0; + exp = 0; + skill_point = 0; + is_bind = (char)0x00; + unused = (char)0x00; + name_len = 0; + name = new char[16]; + skills = new PetSkill[(int)GP_PET_SKILL_NUM.GP_PET_SKILL_NUM]; + evo_prop = new _evo_prop{ + r_attack = 0, + r_defense = 0, + r_hp = 0, + r_atk_lvl = 0, + r_def_lvl = 0, + nature = 0 + }; + reserved = new int[10]; + } + }; } diff --git a/Assets/PerfectWorld/Scripts/Skills/ElementSkill.cs b/Assets/PerfectWorld/Scripts/Skills/ElementSkill.cs index 8e1e01e415..59e750ca8f 100644 --- a/Assets/PerfectWorld/Scripts/Skills/ElementSkill.cs +++ b/Assets/PerfectWorld/Scripts/Skills/ElementSkill.cs @@ -425,5 +425,59 @@ namespace BrewMonster.Scripts.Skills return ret; } + // 0:�ɹ� 1:����SP���� 2:�����츳�㲻�� + // 3:���� 4:���ܸ������� 5:����ID + // 6:��Ǯ���� 7:��С���鼼�� 8:û�м����� + // 9:�ȼ����� 10:�������޲��� 11:ְҵ��ƥ�� + // 12:�������޲��㣬��ְҵ��ƥ�� + public static int GoblinLearn(uint id, GoblinRequirement info, int level) + { + Skill s = Skill.Create(id, level); + if(s == null) + return 5; + if(level<1 || level> s.GetMaxLevel()) + return 3; + if(s.GetCls() != 258) + return 7; + + int ret = 0; + + int[] iReqGen = new int[5] {0, 0, 0, 0, 0}; + int iReqLevel = s.GetRequiredLevel(); + // iReqLevelΪ7λ�����������λΪ�ȼ���ǰ5λΪ�츳���������λΪ�� + int iLevelRequirement = iReqLevel%100; + if(info.level < iLevelRequirement) + return 9; + + iReqLevel /= 100; + + int i; + for(i=0;i<5;i++) + { + iReqGen[4-i] = iReqLevel%10; + iReqLevel /= 10; + } + + for(i=0;i<5;i++) + { + if(info.genius[i] < iReqGen[4-i]) + return 2; + } + + if(info.sp < s.GetRequiredSp()) + ret = 1; + //else if(info.moneyGetRequiredMoney(id, level)) + // ret = 6; + + if(info.mp < s.GetMpCost() && + ((s.GetCls() != 0) && (((1 << info.profession) & s.GetCls()) == 0))) + ret = 12; + else if(info.mp < s.GetMpCost()) + ret = 10; + else if((s.GetCls() != 0) && (((1 << info.profession) & s.GetCls()) == 0)) + ret = 11; + + return ret; + } } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Utils/CECRTDebug.cs b/Assets/PerfectWorld/Scripts/Utils/CECRTDebug.cs index f59f79ac45..c61c542454 100644 --- a/Assets/PerfectWorld/Scripts/Utils/CECRTDebug.cs +++ b/Assets/PerfectWorld/Scripts/Utils/CECRTDebug.cs @@ -64,6 +64,23 @@ namespace BrewMonster m_pCur += sizeof(short); return value; } + public ushort ReadUShort() + { + BoundCheck(sizeof(ushort)); + + ushort value = System.BitConverter.ToUInt16(data, m_pCur); + m_pCur += sizeof(ushort); + return value; + } + public ushort[] ReadUShortArray(int size) + { + BoundCheck(size * sizeof(ushort)); + + ushort[] result = new ushort[size]; + System.Array.Copy(data, m_pCur, result, 0, size * sizeof(ushort)); + m_pCur += size * sizeof(ushort); + return result; + } public uint ReadUInt() { BoundCheck(sizeof(uint)); diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index f6e7227a3e..504615a00a 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -59,6 +59,7 @@ namespace BrewMonster private int m_iRoleLastLoginTime; // Role last login time private int m_iAccountTotalCash; + private EC_PetCorral m_pPetCorral; private List m_aTabSels = new List(); private List m_aPtSkills = new List(); private List m_aPsSkills = new List(); @@ -6879,5 +6880,9 @@ namespace BrewMonster } return iReason == 0? true : false; } + public EC_PetCorral GetPetCorral() + { + return m_pPetCorral; + } } } diff --git a/Assets/Scripts/CECUIManager.cs b/Assets/Scripts/CECUIManager.cs index cd04fb06b6..b481e4ea08 100644 --- a/Assets/Scripts/CECUIManager.cs +++ b/Assets/Scripts/CECUIManager.cs @@ -359,4 +359,8 @@ public class CECUIManager : MonoSingleton pDlg = dlg; } } + public void FilterBadWords(string str) + { + // TODO: Implement bad word filtering + } } \ No newline at end of file