add armor dialog for quest "chao hoi"

This commit is contained in:
Chomper9981
2026-01-12 15:52:09 +07:00
parent a9157bac7c
commit 22bf1bddcb
15 changed files with 734 additions and 157 deletions
@@ -1765,15 +1765,11 @@ namespace ModelRenderer.Scripts.GameData
break;
case ID_SPACE.ID_SPACE_ADDON:
BMLogger.Log("[thn] weapon addon map count: " + addon_id_data_map.Count);
BMLogger.Log("[thn] weapon addon id: " + id);
if (addon_id_data_map.TryGetValue(id, out data))
{
dataType = addon_id_data_type_map[id];
return data;
}
BMLogger.Log("[thn] weapon addon data: " + data);
break;
default:
@@ -35,12 +35,12 @@ public static class generate_item_temp
if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_DROP)
{
float[] drop_probability_socket = { ess.drop_probability_socket0, ess.drop_probability_socket1, ess.drop_probability_socket2 };
hole_num = (uint)element_data.RandSelect_SPECIFIC_LOWER(drop_probability_socket.ToList(), SPECIFIC.SPECIFIC_RAND, LOWER.LOWER_TREND); //׶Ŀ
hole_num = (uint)element_data.RandSelect<RAND_CLASS, LOWER>(drop_probability_socket.ToList(), cls, LOWER.LOWER_TREND); //׶Ŀ
}
else //if(normal_addon == element_data::ADDON_LIST_PRODUCE || normal_addon == element_data::ADDON_LIST_SPEC)
{
float[] make_probability_socket = { ess.make_probability_socket0, ess.make_probability_socket1, ess.make_probability_socket2 };
hole_num = (uint)element_data.RandSelect_SPECIFIC_LOWER(make_probability_socket.ToList(), SPECIFIC.SPECIFIC_RAND, LOWER.LOWER_TREND); //׶Ŀ
hole_num = (uint)element_data.RandSelect<RAND_CLASS, LOWER>(make_probability_socket.ToList(), cls, LOWER.LOWER_TREND); //׶Ŀ
}
size += hole_num*sizeof(int); // size hole_numtype
@@ -54,7 +54,7 @@ public static class generate_item_temp
byte[] addon_buf = new byte[candidate_num*Marshal.SizeOf(typeof(itemdataman._addon))];
float[] probability_addon_num = { ess.probability_addon_num0, ess.probability_addon_num1, ess.probability_addon_num2, ess.probability_addon_num3, ess.probability_addon_num4, ess.probability_addon_num5 };
//log each probability_addon_num
uint addon_num = (uint)element_data.RandSelect_NORMAL_LOWER(probability_addon_num.ToList(), NORMAL.NORMAL_RAND, LOWER.LOWER_TREND); //ԱĿĿ
uint addon_num = (uint)element_data.RandSelect<RAND_CLASS, LOWER>(probability_addon_num.ToList(), cls, LOWER.LOWER_TREND); //ԱĿĿ
uint addon_size = 0;
// if(ess->fixed_props)
@@ -106,7 +106,6 @@ public static class generate_item_temp
}
size += addon_size;
BMLogger.Log("[thn]generate_weapon, addon_size: " + addon_size);
// allocate the buffer with exact length
// *data = (char *)abase::fastalloc(size);
@@ -200,7 +199,7 @@ public static class generate_item_temp
// temp = element_data::RandNormal(ess->durability_drop_min, ess->durability_drop_max, cls,element_data::UPPER_TREND);
// if(temp > temp2) temp = temp2;
// }
int temp2 = element_data.RandNormal_NORMAL_LOWER(ess.durability_min, ess.durability_max, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND);
int temp2 = element_data.RandNormal<RAND_CLASS, LOWER>(ess.durability_min, ess.durability_max, cls, LOWER.LOWER_TREND);
int temp = temp2;
if(normal_addon != GEN_ADDON_MODE.ADDON_LIST_DROP || (ess.proc_type & 0x1000) != 0)
{
@@ -208,7 +207,7 @@ public static class generate_item_temp
}
else
{
temp = element_data.RandNormal_NORMAL_UPPER(ess.durability_drop_min, ess.durability_drop_max, NORMAL.NORMAL_RAND, UPPER.UPPER_TREND);
temp = element_data.RandNormal<RAND_CLASS, UPPER>(ess.durability_drop_min, ess.durability_drop_max, cls, UPPER.UPPER_TREND);
if(temp > temp2) temp = temp2;
}
@@ -222,8 +221,9 @@ public static class generate_item_temp
// memcpy(buf,tag,tag_size);
// buf += tag_size;
WriteShort(data, ref offset, (short)Marshal.SizeOf(typeof(_weapon_essence)));
WriteByte(data, ref offset, tag.type); // MadeFrom
WriteByte(data, ref offset, 0);
WriteByte(data, ref offset, (byte)tag.size);
//essence //char []; //ÿֲͬװı?
// char * essence_ptr = buf;
@@ -262,9 +262,9 @@ public static class generate_item_temp
WriteInt(data, ref offset, ess.level);
WriteUInt(data, ref offset, ess.require_projectile);
WriteInt(data, ref offset, ess.damage_low);
WriteInt(data, ref offset, element_data.RandNormal_NORMAL_LOWER(ess.damage_high_min, ess.damage_high_max, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.damage_high_min, ess.damage_high_max, cls, LOWER.LOWER_TREND));
WriteInt(data, ref offset, ess.magic_damage_low);
WriteInt(data, ref offset, element_data.RandNormal_NORMAL_LOWER(ess.magic_damage_high_min, ess.magic_damage_high_max, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.magic_damage_high_min, ess.magic_damage_high_max, cls, LOWER.LOWER_TREND));
// WEAPON_SUB_TYPE * subtype = (WEAPON_SUB_TYPE * )get_data_ptr(ess->id_sub_type, ID_SPACE_ESSENCE, datatype);
// if(subtype == NULL || datatype != DT_WEAPON_SUB_TYPE)
// {
@@ -286,7 +286,7 @@ public static class generate_item_temp
{
subtype = (WEAPON_SUB_TYPE)sub_type_temp;
float[] probability_attack_speed = { subtype.probability_fastest, subtype.probability_fast, subtype.probability_normal, subtype.probability_slow, subtype.probability_slowest };
int index = element_data.RandSelect_SPECIFIC_MIDDLE(probability_attack_speed.ToList(), SPECIFIC.SPECIFIC_RAND, MIDDLE.MIDDLE_TREND);
int index = element_data.RandSelect<RAND_CLASS, MIDDLE>(probability_attack_speed.ToList(), cls, MIDDLE.MIDDLE_TREND);
WriteInt(data, ref offset, (int)(subtype.attack_speed*20f + 0.1f) + (index - 2));
}
@@ -354,7 +354,7 @@ public static class generate_item_temp
int RE_num = 0;
if(!b_fixed)
{
RE_num = element_data.RandSelect_SPECIFIC_LOWER(count_prop.ToList(), SPECIFIC.SPECIFIC_RAND, LOWER.LOWER_TREND);
RE_num = element_data.RandSelect<RAND_CLASS, LOWER>(count_prop.ToList(), cls, LOWER.LOWER_TREND);
}
if(RE_num == 5) return;
// Ensure RE_num is within valid range for md_adjust array (0-4)
@@ -382,7 +382,7 @@ public static class generate_item_temp
}
int low = res_list[index *2].low;
int high= res_list[index *2+1].high;
res[index] = (int)(element_data.RandNormal_NORMAL_LOWER(low, high, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND) * adj);
res[index] = (int)(element_data.RandNormal<RAND_CLASS, LOWER>(low, high, cls, LOWER.LOWER_TREND) * adj);
}
}
public static int generate_armor<RAND_CLASS>(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls,
@@ -405,19 +405,19 @@ public static class generate_item_temp
if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_DROP)
{
float[] drop_probability_socket = { ess.drop_probability_socket0, ess.drop_probability_socket1, ess.drop_probability_socket2 };
hole_num = (short)element_data.RandSelect_SPECIFIC_LOWER(drop_probability_socket.ToList(), SPECIFIC.SPECIFIC_RAND, LOWER.LOWER_TREND); //׶Ŀ
hole_num = (short)element_data.RandSelect<RAND_CLASS, LOWER>(drop_probability_socket.ToList(), cls, LOWER.LOWER_TREND); //׶Ŀ
}
else //if(normal_addon == element_data::ADDON_LIST_PRODUCE || normal_addon == element_data::ADDON_LIST_SPEC)
{
float[] make_probability_socket = { ess.make_probability_socket0, ess.make_probability_socket1, ess.make_probability_socket2 };
hole_num = (short)element_data.RandSelect_SPECIFIC_MIDDLE(make_probability_socket.ToList(), SPECIFIC.SPECIFIC_RAND, MIDDLE.MIDDLE_TREND); //׶Ŀ
hole_num = (short)element_data.RandSelect<RAND_CLASS, MIDDLE>(make_probability_socket.ToList(), cls, MIDDLE.MIDDLE_TREND); //׶Ŀ
}
size += (uint)(hole_num*sizeof(int)); // size hole_numtype
size += (uint)Marshal.SizeOf(typeof(item_tag_t));
uint candidate_num = itemdataman.ELEMENTDATAMAN_MAX_NUM_ADDONS;
byte[] addon_buf = new byte[candidate_num*Marshal.SizeOf(typeof(itemdataman._addon))];
float[] probability_addon_num = { ess.probability_addon_num0, ess.probability_addon_num1, ess.probability_addon_num2, ess.probability_addon_num3, ess.probability_addon_num4 };
uint addon_num = (uint)element_data.RandSelect_SPECIFIC_LOWER(probability_addon_num.ToList(), SPECIFIC.SPECIFIC_RAND, LOWER.LOWER_TREND); //ԱĿĿ
uint addon_num = (uint)element_data.RandSelect<RAND_CLASS, LOWER>(probability_addon_num.ToList(), cls, LOWER.LOWER_TREND); //ԱĿĿ
uint addon_size = 0;
if(ess.fixed_props!=0)
{
@@ -495,7 +495,7 @@ public static class generate_item_temp
WriteShort(data, ref offset, (short)ess.require_agility);
WriteShort(data, ref offset, (short)ess.require_energy);
int temp2 = element_data.RandNormal_NORMAL_LOWER(ess.durability_min, ess.durability_max, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND);
int temp2 = element_data.RandNormal<RAND_CLASS, LOWER>(ess.durability_min, ess.durability_max, cls, LOWER.LOWER_TREND);
int temp = temp2;
if(normal_addon != GEN_ADDON_MODE.ADDON_LIST_DROP || (ess.proc_type & 0x1000) != 0)
{
@@ -503,19 +503,20 @@ public static class generate_item_temp
}
else
{
temp = element_data.RandNormal_NORMAL_UPPER(ess.durability_drop_min, ess.durability_drop_max, NORMAL.NORMAL_RAND, UPPER.UPPER_TREND);
temp = element_data.RandNormal<RAND_CLASS, UPPER>(ess.durability_drop_min, ess.durability_drop_max, cls, UPPER.UPPER_TREND);
if(temp > temp2) temp = temp2;
}
WriteInt(data, ref offset, temp); // durability
WriteInt(data, ref offset, temp2); // max_durability
WriteShort(data, ref offset, (short)Marshal.SizeOf(typeof(ARMOR_ESSENCE)));
WriteTag(data, ref offset, tag);
WriteByte(data, ref offset, (byte)tag.type); // MadeFrom
WriteByte(data, ref offset, (byte)tag.size);
int essence_ptr = offset;
WriteInt(data, ref offset, element_data.RandNormal_NORMAL_LOWER(ess.defence_low, ess.defence_high, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal_NORMAL_LOWER(ess.armor_enhance_low, ess.armor_enhance_high, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal_NORMAL_LOWER(ess.mp_enhance_low, ess.mp_enhance_high, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal_NORMAL_LOWER(ess.hp_enhance_low, ess.hp_enhance_high, NORMAL.NORMAL_RAND, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.defence_low, ess.defence_high, cls, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.armor_enhance_low, ess.armor_enhance_high, cls, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.mp_enhance_low, ess.mp_enhance_high, cls, LOWER.LOWER_TREND));
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.hp_enhance_low, ess.hp_enhance_high, cls, LOWER.LOWER_TREND));
int[] res = {0,0,0,0,0};
List<ARMOR_ESSENCE.MagicDefence> res_list = ess.magic_defences.ToList();
generate_magic_defense(res, res_list, cls, ess.force_all_magic_defences != 0 || ess.fixed_props!=0);
@@ -36,7 +36,7 @@ namespace BrewMonster
return lower + (upper - lower) * rng / (float)RAND_MAX;
}
public static int RandNormal(int lower, int upper) { return Rand(lower, upper); }
public static int RandNormal(float lower, float upper) { return (int)Rand(lower, upper); }
public static float RandUniform() { return Rand(0f, 1f); }
public static int RandSelect(List<float> option)
@@ -146,97 +146,115 @@ namespace BrewMonster
}
public static class element_data
{
public static int RandNormal<TCls, TTrend>(int lower, int upper, TCls c) where TCls : SpecCls
{
return c.RandNormal(lower, upper);
}
public static int RandSelect<TCls, TTrend>(List<float> option, TCls c) where TCls : SpecCls
{
return c.RandSelect(option);
}
public static float Rand<TCls, TTrend>(float lower, float upper, TCls c) where TCls : SpecCls
{
return c.Rand(lower, upper);
}
public static int RandSelect_NORMAL_LOWER(List<float> option, NORMAL normalType, LOWER lowerTrend)
{
return abase.abase.RandSelect(option);
}
public static int RandSelect_NORMAL_MIDDLE(List<float> option, NORMAL normalType, MIDDLE middleTrend)
{
return abase.abase.RandSelect(option);
}
public static int RandSelect_SPECIFIC_LOWER(List<float> option, SPECIFIC specificType, LOWER lowerTrend)
public static int RandNormal<TCls, TTrend>(int lower, int upper, TCls c ,TTrend trend)
{
if(c != null && c.Equals(NORMAL.NORMAL_RAND))
{
if (trend != null && trend.Equals(LOWER.LOWER_TREND))
{
return abase.abase.RandNormal(lower, upper);
}
else if (trend != null && trend.Equals(MIDDLE.MIDDLE_TREND))
{
return abase.abase.RandNormal(lower, upper);
}
else if (trend != null && trend.Equals(UPPER.UPPER_TREND))
{
return abase.abase.RandNormal(lower, upper);
}
else if (trend != null && trend.Equals(ANY.ANY_TREND))
{
return abase.abase.RandNormal(lower, upper);
}
}
else if(c != null && c.Equals(SPECIFIC.SPECIFIC_RAND))
{
if (trend != null && trend.Equals(LOWER.LOWER_TREND))
{
return lower;
}
else if (trend != null && trend.Equals(MIDDLE.MIDDLE_TREND))
{
return (lower + upper) / 2;
}
else if (trend != null && trend.Equals(UPPER.UPPER_TREND))
{
return upper;
}
else if (trend != null && trend.Equals(ANY.ANY_TREND))
{
return abase.abase.RandNormal(lower, upper);
}
}
return 0;
}
public static int RandSelect_SPECIFIC_MIDDLE(List<float> option, SPECIFIC specificType, MIDDLE middleTrend)
public static int RandSelect<TCls, TTrend>(List<float> option, TCls c, TTrend trend)
{
return option.Count / 2;
if(c != null && c.Equals(NORMAL.NORMAL_RAND))
{
if (trend != null && trend.Equals(LOWER.LOWER_TREND))
{
return abase.abase.RandSelect(option);
}
else if (trend != null && trend.Equals(MIDDLE.MIDDLE_TREND))
{
return abase.abase.RandSelect(option);
}
}
else if(c != null && c.Equals(SPECIFIC.SPECIFIC_RAND))
{
if (trend != null && trend.Equals(LOWER.LOWER_TREND))
{
return 0;
}
else if (trend != null && trend.Equals(MIDDLE.MIDDLE_TREND))
{
return option.Count /2;
}
}
return 0;
}
public static int RandNormal_NORMAL_LOWER(int lower, int upper, NORMAL normalType, LOWER lowerTrend)
public static float Rand<TCls, TTrend>(float lower, float upper, TCls c, TTrend trend)
{
return abase.abase.RandNormal(lower, upper);
}
public static int RandNormal_NORMAL_UPPER(int lower, int upper, NORMAL normalType, UPPER upperTrend)
{
return abase.abase.RandNormal(lower, upper);
}
public static int RandNormal_NORMAL_MIDDLE(int lower, int upper, NORMAL normalType, MIDDLE middleTrend)
{
return abase.abase.RandNormal(lower, upper);
}
public static int RandNormal_NORMAL_ANY(int lower, int upper, NORMAL normalType, ANY anyTrend)
{
return abase.abase.RandNormal(lower, upper);
}
public static int RandNormal_SPECIFIC_LOWER(int lower, int upper, SPECIFIC specificType, LOWER lowerTrend)
{
return lower;
}
public static int RandNormal_SPECIFIC_UPPER(int lower, int upper, SPECIFIC specificType, UPPER upperTrend)
{
return upper;
}
public static int RandNormal_SPECIFIC_MIDDLE(int lower, int upper, SPECIFIC specificType, MIDDLE middleTrend)
{
return (upper + lower) / 2;
}
public static int RandNormal_SPECIFIC_ANY(int lower, int upper, SPECIFIC specificType, ANY anyTrend)
{
return abase.abase.RandNormal(lower, upper);
}
public static float Rand_NORMAL_LOWER(float lower, float upper, NORMAL normalType, LOWER lowerTrend)
{
return abase.abase.Rand(lower, upper);
}
public static float Rand_NORMAL_MIDDLE(float lower, float upper, NORMAL normalType, MIDDLE middleTrend)
{
return abase.abase.Rand(lower, upper);
}
public static float Rand_NORMAL_UPPER(float lower, float upper, NORMAL normalType, UPPER upperTrend)
{
return abase.abase.Rand(lower, upper);
}
public static float Rand_NORMAL_ANY(float lower, float upper, NORMAL normalType, ANY anyTrend)
{
return abase.abase.Rand(lower, upper);
}
public static float Rand_SPECIFIC_LOWER(float lower, float upper, SPECIFIC specificType, LOWER lowerTrend)
{
return lower;
}
public static float Rand_SPECIFIC_MIDDLE(float lower, float upper, SPECIFIC specificType, MIDDLE middleTrend)
{
return (upper + lower) / 2;
}
public static float Rand_SPECIFIC_UPPER(float lower, float upper, SPECIFIC specificType, UPPER upperTrend)
{
return upper;
}
public static float Rand_SPECIFIC_ANY(float lower, float upper, SPECIFIC specificType, ANY anyTrend)
{
return abase.abase.Rand(lower, upper);
if(c != null && c.Equals(NORMAL.NORMAL_RAND))
{
if (trend != null && trend.Equals(LOWER.LOWER_TREND))
{
return abase.abase.Rand(lower, upper);
}
else if (trend != null && trend.Equals(MIDDLE.MIDDLE_TREND))
{
return abase.abase.Rand(lower, upper);
}
else if (trend != null && trend.Equals(UPPER.UPPER_TREND))
{
return abase.abase.Rand(lower, upper);
}
else if (trend != null && trend.Equals(ANY.ANY_TREND))
{
return abase.abase.Rand(lower, upper);
}
}
else if(c != null && c.Equals(SPECIFIC.SPECIFIC_RAND))
{
if (trend != null && trend.Equals(LOWER.LOWER_TREND))
{
return lower;
}
else if (trend != null && trend.Equals(MIDDLE.MIDDLE_TREND))
{
return (lower + upper) / 2;
}
else if (trend != null && trend.Equals(UPPER.UPPER_TREND))
{
return upper;
}
else if (trend != null && trend.Equals(ANY.ANY_TREND))
{
return abase.abase.Rand(lower, upper);
}
}
return 0;
}
}
public enum GEN_ADDON_MODE
@@ -424,9 +442,8 @@ namespace BrewMonster
uint size = 0;
int ret = 0;
DATA_TYPE datatype = DATA_TYPE.DT_INVALID;
item_tag_t tag = new item_tag_t((byte)ITEM_MAKE_TAG.IMT_SHOP, (byte)'0');
item_tag_t tag = new item_tag_t((byte)ITEM_MAKE_TAG.IMT_SHOP, (byte)0);
//uint id = _edm.get_first_data_id(ID_SPACE.ID_SPACE_ESSENCE,ref datatype);
BMLogger.Log("[THN]itemdataman: generate_item_for_sell: _edm.essence_id_data_type_map.Count: " + _edm.essence_id_data_type_map.Count);
for (int i = 0; i < _edm.essence_id_data_type_map.Count; i++)
{
ret = 0;
@@ -749,8 +766,7 @@ namespace BrewMonster
// }
#endregion
}
BMLogger.Log("[THN]itemdataman: generate_item_for_sell: sale_item_ptr_array.Count: " + sale_item_ptr_array.Count);
}
return 0;
}
@@ -833,8 +849,8 @@ namespace BrewMonster
{
//ɶaddonܻвʧ
if(addon_num == 0)
return 0;
//if(addon_num == 0)
//return 0;
byte[] addon_sld = addon_buffer;
int i,j;
int anum = 0;
@@ -910,7 +926,7 @@ namespace BrewMonster
{
uint un = 0;
//ASSERT(addon_size == 0);
if(element_data.Rand_NORMAL_LOWER(0f,1f,NORMAL.NORMAL_RAND,LOWER.LOWER_TREND) < unique_prob)
if(element_data.Rand<RAN_CLASS, LOWER>(0f,1f,cls,LOWER.LOWER_TREND) < unique_prob)
{
un = 1;
addon_size = generate_equipment_addon_buffer(dt, unique, 16, addon_buf,0, un);
@@ -923,7 +939,7 @@ namespace BrewMonster
{
uint un = 0;
//ASSERT(addon_size == 0);
if(element_data.Rand_NORMAL_LOWER(0f,1f,NORMAL.NORMAL_RAND,LOWER.LOWER_TREND) < unique_prob)
if(element_data.Rand<RAN_CLASS, LOWER>(0f,1f,cls,LOWER.LOWER_TREND) < unique_prob)
{
un = 1;
addon_size = generate_equipment_addon_buffer(dt, unique, 16, addon_buf,0, un);
@@ -2,7 +2,10 @@ namespace BrewMonster.Scripts
{
public class InventoryConst
{
// Equipment endurance scale
public const int ENDURANCE_SCALE = 100;
// NUM_MAGICCLASS
public const int NUM_MAGICCLASS = 5;
// Index of item in equipment inventory
public const int EQUIPIVTR_WEAPON = 0;
public const int EQUIPIVTR_HEAD = 1;
@@ -0,0 +1,537 @@
// /*
// * FILE: EC_IvtrWeapon.cpp
// *
// * DESCRIPTION:
// *
// * CREATED BY: Duyuxin, 2004/11/19
// *
// * HISTORY:
// *
// * Copyright (c) 2004 Archosaur Studio, All Rights Reserved.
// */
// #include "EC_Global.h"
// #include "EC_IvtrWeapon.h"
// #include "EC_Game.h"
// #include "EC_FixedMsg.h"
// #include "EC_GameRun.h"
// #include "EC_HostPlayer.h"
// #include "EC_RTDebug.h"
// #include "elementdataman.h"
// #include "EC_Configs.h"
using BrewMonster;
using ModelRenderer.Scripts.GameData;
using System.Collections.Generic;
using BrewMonster.Network;
using BrewMonster.Scripts.Managers;
using BrewMonster.Scripts;
#region C# regions
// #define new A_DEBUG_NEW
// ///////////////////////////////////////////////////////////////////////////
// //
// // Define and Macro
// //
// ///////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
// //
// // Reference to External variables and functions
// //
// ///////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
// //
// // Local Types and Variables and Global variables
// //
// ///////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
// //
// // Local functions
// //
// ///////////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////////
// //
// // Implement CECIvtrWeapon
// //
// ///////////////////////////////////////////////////////////////////////////
#endregion
namespace PerfectWorld.Scripts.Managers
{
public class EC_IvtrArmor : EC_IvtrEquip
{
//Attributes
//Weapon essence data
protected IVTR_ESSENCE_ARMOR m_Essence;
// data in database
protected ARMOR_MAJOR_TYPE m_pDBMajorType;
protected ARMOR_SUB_TYPE m_pDBSubType;
protected ARMOR_ESSENCE m_pDBEssence;
public EC_IvtrArmor(int tid, int expire_date) : base(tid, expire_date)
{
m_iCID = ICID_WEAPON;
elementdataman pDB = ElementDataManProvider.GetElementDataMan();
DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
m_pDBEssence = (ARMOR_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
m_pDBMajorType = (ARMOR_MAJOR_TYPE)pDB.get_data_ptr(m_pDBEssence.id_major_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
m_pDBSubType = (ARMOR_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 = EC_IvtrEquip.ICID_WEAPON;
m_iProcType = (int)m_pDBEssence.proc_type;
FixProps = m_pDBEssence.fixed_props;
RepairFee = m_pDBEssence.repairfee;
ReputationReq = m_pDBEssence.require_reputation;
}
public EC_IvtrArmor(EC_IvtrArmor other) : base(other)
{
m_pDBEssence = other.m_pDBEssence;
m_pDBMajorType = other.m_pDBMajorType;
m_pDBSubType = other.m_pDBSubType;
m_Essence = other.m_Essence;
}
// CECIvtrWeapon::~CECIvtrWeapon()
// {
// }
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_ARMOR(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;
}
}
// Get item default information from database
public override void DefaultInfo()
{
LevelReq = m_pDBEssence.require_level;
StrengthReq = m_pDBEssence.require_strength;
AgilityReq = m_pDBEssence.require_agility;
ReputationReq = m_pDBEssence.require_reputation;
CurEndurance = m_pDBEssence.durability_min * ENDURANCE_SCALE;
MaxEndurance = m_pDBEssence.durability_min * ENDURANCE_SCALE;
}
// 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 preview info
public override string GetPreviewInfo()
{
int[] aPEEVals = new int[MAX_PEEINDEX];
int[] aRefines = new int[MAX_REFINEINDEX];
for(int i=0; i<MAX_PEEINDEX; i++)
aPEEVals[i] = 0;
for(int i=0; i<MAX_REFINEINDEX; i++)
aRefines[i] = 0;
m_strDesc = "";
BuildAddOnPropDesc(aPEEVals, aRefines);
CECStringTab pDescTab = EC_Game.GetItemDesc();
// Physical defense
if (m_Essence.defense - aPEEVals[PEEI_PHYDEF] + aRefines[REFINE_PHYDEF] != 0)
{
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_PHYDEFENCE));
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, " %+d", m_Essence.defense - aPEEVals[PEEI_PHYDEF] + aRefines[REFINE_PHYDEF]);
}
// Dodge
if (m_Essence.armor - aPEEVals[PEEI_DODGE] + aRefines[REFINE_DODGE] != 0)
{
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_DODGE));
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, " %+d", m_Essence.armor - aPEEVals[PEEI_DODGE] + aRefines[REFINE_DODGE]);
}
// HP
if (m_Essence.hp_enhance - aPEEVals[PEEI_HP] + aRefines[REFINE_HP] != 0)
{
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_ADDHP));
}
// MP
if (m_Essence.mp_enhance - aPEEVals[PEEI_MP] != 0)
{
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_ADDMP));
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, " %+d", m_Essence.mp_enhance - aPEEVals[PEEI_MP]);
}
//Gold Resistance
if (m_Essence.resistance[0] - aPEEVals[PEEI_GOLDDEF] + aRefines[REFINE_GOLDDEF] != 0)
{
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_GOLDDEFENCE));
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, " %+d", 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((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_WOODDEFENCE));
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, " %+d", 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((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_WATERDEFENCE));
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, " %+d", 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((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_FIREDEFENCE));
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, " %+d", 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((int)DescriptipionMsg.ITEMDESC_COL_WHITE, false, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_EARTHDEFENCE));
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_WHITE, true, " %+d", m_Essence.resistance[4] - aPEEVals[PEEI_EARTHDEF] + aRefines[REFINE_EARTHDEF]);
}
return m_strDesc;
}
public override bool GetRefineEffectFor(string strEffect, RefineEffect rhs){
strEffect = "";
if (!m_bNeedUpdate){
switch (rhs.RefineIndex){
case REFINE_PHYDEF:
strEffect = string.Format("{0}{1} {2}(+{3})",
rhs.GetClrAttribute(),
EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_PHYDEFENCE),
m_Essence.defense - rhs.APEEVals[PEEI_PHYDEF] + rhs.ARefines[REFINE_PHYDEF] + rhs.GetIncEffect(),
rhs.GetClrEffect(),
rhs.GetIncEffect());
break;
case REFINE_DODGE:
strEffect = string.Format("{0}{1} {2}(+{3})",
rhs.GetClrAttribute(),
EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_DODGE),
m_Essence.armor - rhs.APEEVals[PEEI_DODGE] + rhs.ARefines[REFINE_DODGE] + rhs.GetIncEffect(),
rhs.GetClrEffect(),
rhs.GetIncEffect());
break;
case REFINE_HP:
strEffect = string.Format("{0}{1} {2}(+{3})",
rhs.GetClrAttribute(),
EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_ADDHP),
m_Essence.hp_enhance - rhs.APEEVals[PEEI_HP] + rhs.ARefines[REFINE_HP] + rhs.GetIncEffect(),
rhs.GetClrEffect(),
rhs.GetIncEffect());
break;
case REFINE_GOLDDEF:
strEffect = string.Format("{0}{1} {2}(+{3})",
rhs.GetClrAttribute(),
EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_GOLDDEFENCE),
m_Essence.resistance[0] - rhs.APEEVals[PEEI_GOLDDEF] + rhs.ARefines[REFINE_GOLDDEF] + rhs.GetIncEffect(),
rhs.GetClrEffect(),
rhs.GetIncEffect());
break;
case REFINE_WOODDEF:
strEffect = string.Format("{0}{1} {2}(+{3})",
rhs.GetClrAttribute(),
EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_WOODDEFENCE),
m_Essence.resistance[1] - rhs.APEEVals[PEEI_WOODDEF] + rhs.ARefines[REFINE_WOODDEF] + rhs.GetIncEffect(),
rhs.GetClrEffect(),
rhs.GetIncEffect());
break;
case REFINE_WATERDEF:
strEffect = string.Format("{0}{1} {2}(+{3})",
rhs.GetClrAttribute(),
EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_WATERDEFENCE),
m_Essence.resistance[2] - rhs.APEEVals[PEEI_WATERDEF] + rhs.ARefines[REFINE_WATERDEF] + rhs.GetIncEffect(),
rhs.GetClrEffect(),
rhs.GetIncEffect());
break;
case REFINE_FIREDEF:
strEffect = string.Format("{0}{1} {2}(+{3})",
rhs.GetClrAttribute(),
EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_FIREDEFENCE),
m_Essence.resistance[3] - rhs.APEEVals[PEEI_FIREDEF] + rhs.ARefines[REFINE_FIREDEF] + rhs.GetIncEffect(),
rhs.GetClrEffect(),
rhs.GetIncEffect());
break;
case REFINE_EARTHDEF:
strEffect = string.Format("{0}{1} {2}(+{3})",
rhs.GetClrAttribute(),
EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_EARTHDEFENCE),
m_Essence.resistance[4] - rhs.APEEVals[PEEI_EARTHDEF] + rhs.ARefines[REFINE_EARTHDEF] + rhs.GetIncEffect(),
rhs.GetClrEffect(),
rhs.GetIncEffect());
break;
}
}
return !string.IsNullOrEmpty(strEffect);
}
// Get item description text
protected override string GetNormalDesc(bool bRepair){
if (m_bNeedUpdate)
return null;
int[] aPEEVals = new int[MAX_PEEINDEX];
int[] aRefines = new int[MAX_REFINEINDEX];
for(int i=0; i<MAX_PEEINDEX; i++)
aPEEVals[i] = 0;
for(int i=0; i<MAX_REFINEINDEX; i++)
aRefines[i] = 0;
m_strDesc = "";
BuildAddOnPropDesc(aPEEVals, aRefines);
string strAddon = m_strDesc;
m_strDesc = "";
CECStringTab pDescTab = EC_Game.GetItemDesc();
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE;
int lblue = (int)DescriptipionMsg.ITEMDESC_COL_LIGHTBLUE;
int red = (int)DescriptipionMsg.ITEMDESC_COL_RED;
int namecol = DecideNameCol();
uint dwPEE = PropEffectEssence();
if (Holes != null && Holes.Count > 0)
{
AddDescText(namecol, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMESOCKET), GetName(), Holes.Count);
}
else
{
AddDescText(namecol, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName());
}
// Refine level
if (RefineLvl > 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.ToString());
// Weapon level
AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), m_pDBEssence.level);
// 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]);
}
// HP
if (m_Essence.hp_enhance - aPEEVals[PEEI_HP] + aRefines[REFINE_HP] != 0)
{
AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ADDHP));
AddDescText(white, true, " +{0}", m_Essence.hp_enhance - aPEEVals[PEEI_HP] + aRefines[REFINE_HP]);
}
// MP
if (m_Essence.mp_enhance - aPEEVals[PEEI_MP] != 0)
{
AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ADDMP));
AddDescText(white, true, " +{0}", m_Essence.mp_enhance - aPEEVals[PEEI_MP]);
}
// 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();
AddSuiteDesc();
AddExtDescText();
return m_strDesc;
}
// // Does this equipment has random property ?
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;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c94b2c779cdb94d398d4aa10eb44cac6
@@ -754,6 +754,8 @@ namespace PerfectWorld.Scripts.Managers
/// </summary>
private void ReadMakerInfo(CECDataReader dr)
{
// Debug: Log the bytes at current position before reading
// We need to check what bytes are actually at the reader position
MadeFrom = dr.ReadByte();
int makerLen = dr.ReadByte();
if (makerLen > 0)
@@ -764,8 +766,17 @@ namespace PerfectWorld.Scripts.Managers
makerLen -= sizeof(ushort);
byte[] makerData = dr.ReadData(makerLen);
string maker = System.Text.Encoding.Unicode.GetString(makerData, 0, makerData.Length);
// Find null terminator (0x00 0x00 for Unicode) and decode only up to that point
int actualLength = makerLen;
for (int i = 0; i < makerLen - 1; i += 2)
{
if (makerData[i] == 0 && makerData[i + 1] == 0)
{
actualLength = i;
break;
}
}
string maker = System.Text.Encoding.Unicode.GetString(makerData, 0, actualLength).TrimEnd('\0');
if (string.IsNullOrEmpty(maker))
{
return;
@@ -779,14 +790,23 @@ namespace PerfectWorld.Scripts.Managers
{
//m_strMaker = ACString((ACHAR*)dr.Read_Data(iMakerLen), iMakerLen / sizeof (ACHAR));
byte[] makerData = dr.ReadData(makerLen);
Maker = System.Text.Encoding.Unicode.GetString(makerData, 0, makerData.Length);
// Find null terminator (0x00 0x00 for Unicode) and decode only up to that point
int actualLength = makerLen;
for (int i = 0; i < makerLen - 1; i += 2)
{
if (makerData[i] == 0 && makerData[i + 1] == 0)
{
actualLength = i;
break;
}
}
Maker = System.Text.Encoding.Unicode.GetString(makerData, 0, actualLength).TrimEnd('\0');
}
}
else
{
Maker = "";
}
BMLogger.Log("[thn]CECIvtrEquip::ReadMakerInfo, Maker: " + Maker);
}
/// <summary>
@@ -2158,16 +2178,11 @@ namespace PerfectWorld.Scripts.Managers
RefineLvl = 0;
PropNum = 0;
EmbedNum = 0;
BMLogger.Log("[thn]CECIvtrEquip::ParseProperties, Props.Count: " + Props.Count);
if (Props.Count == 0)
return;
foreach (Property prop in Props)
{
Debug.Log("[thn]CECIvtrEquip::ParseProperties, prop.Type: " + prop.Type);
Debug.Log("[thn]CECIvtrEquip::ParseProperties, prop.Embed: " + prop.Embed);
Debug.Log("[thn]CECIvtrEquip::ParseProperties, prop.Suite: " + prop.Suite);
Debug.Log("[thn]CECIvtrEquip::ParseProperties, prop.Engraved: " + prop.Engraved);
int level = 0;
if (prop.Embed)
{
@@ -4104,24 +4119,18 @@ namespace PerfectWorld.Scripts.Managers
/// </summary>
protected void BuildAddOnPropDesc(int[] aPEEVals, int[] aRefines)
{
BMLogger.Log("[THN]EC_IvtrEquip: BuildAddOnPropDesc: Props.Count: " + Props.Count);
if (Props.Count == 0)
return;
// Change color
m_strDesc += GetColorString(DescriptipionMsg.ITEMDESC_COL_LIGHTBLUE);
BMLogger.Log("[THN]EC_IvtrEquip: BuildAddOnPropDesc: m_strDesc: " + m_strDesc);
Debug.Log("[THN]EC_IvtrEquip: BuildAddOnPropDesc: Props.Count: " + Props.Count);
foreach (Property prop in Props)
{
// Properties added by Embedded stone will be printed by BuildTesseraDesc() later
// Ignore suite properties also
if (prop.Embed || prop.Suite || prop.Engraved)
continue;
BMLogger.Log("[THN]EC_IvtrEquip: BuildAddOnPropDesc: prop.Type: " + prop.Type);
BMLogger.Log("[THN]EC_IvtrEquip: BuildAddOnPropDesc: prop.Params: " + prop.Params[0] + " " + prop.Params[1] + " " + prop.Params[2]);
AddOneAddOnPropDesc(prop.Type, prop.Params, aPEEVals, aRefines, prop.Local);
BMLogger.Log("[THN]EC_IvtrEquip: BuildAddOnPropDesc: m_strDesc: " + m_strDesc);
}
}
@@ -4131,7 +4140,6 @@ namespace PerfectWorld.Scripts.Managers
public int GetSoulPowerAdded()
{
int added = 0;
int propertyCount = Props.Count;
foreach (Property prop in Props)
{
@@ -4536,21 +4544,26 @@ namespace PerfectWorld.Scripts.Managers
if (string.IsNullOrEmpty(Maker))
return;
BMLogger.Log("[THN]EC_IvtrEquip: AddMakerDesc: Maker: " + Maker);
m_strDesc += "\\r";
// For signed marks (IMT_SIGN), Maker already contains color codes and formatted text.
if (MadeFrom == (byte)ITEM_MAKE_TAG.IMT_SIGN)
{
BMLogger.Log("[THN]EC_IvtrEquip: AddMakerDesc IF: Maker: " + Maker);
m_strDesc += Maker;
}
else
{
BMLogger.Log("[THN]EC_IvtrEquip: AddMakerDesc ELSE: Maker: " + Maker);
// Normal "made by" line using item-desc string if available
string fmt = GetItemDescString(DescriptipionMsg.ITEMDESC_MADEFROM);
if (string.IsNullOrEmpty(fmt))
{
fmt = "Made by {0}";
}
BMLogger.Log("[THN]EC_IvtrEquip: AddMakerDesc ELSE: fmt: " + fmt);
AddDescText((int)DescriptipionMsg.ITEMDESC_COL_GREEN, false, fmt, Maker);
BMLogger.Log("[THN]EC_IvtrEquip: AddMakerDesc ELSE: m_strDesc: " + m_strDesc);
}
}
@@ -818,10 +818,12 @@ namespace BrewMonster.Scripts.Managers
{
case DATA_TYPE.DT_WEAPON_ESSENCE:
pItem = new EC_IvtrWeapon(tid, expire_date);
BMLogger.Log("[THN]EC_IvtrItem: CreateItem: Weapon Item: tid: " + tid + ", expire_date: " + expire_date + ", pItem: " + pItem);
break;
case DATA_TYPE.DT_ARMOR_ESSENCE:
pItem = new EC_IvtrArmor(tid, expire_date);
break;
default:
BMLogger.Log("[THN]EC_IvtrItem: CreateItem: Default Item: tid: " + tid + ", expire_date: " + expire_date + ", pItem: " + pItem);
BMLogger.Log("[THN]EC_IvtrItem: CreateItem: Default Item: tid: " + tid + ", expire_date: " + expire_date + ", pItem: " + pItem.GetName());
break;
}
pItem.SetCount(iCount);
@@ -1472,8 +1474,6 @@ namespace BrewMonster.Scripts.Managers
{
// Optional: show internal id for debugging
AddDescText(0, true, "ID: {0}", m_tid);
BMLogger.Log("[THN]EC_IvtrItem: AddIDDescText: m_tid: " + m_tid);
BMLogger.Log("[THN]EC_IvtrItem: AddIDDescText: m_strDesc: " + m_strDesc);
}
protected void AddBindDescText()
@@ -107,11 +107,25 @@ namespace BrewMonster.Scripts.Managers
public struct IVTR_ESSENCE_ARMOR
{
// TODO : implement data later
// int defense;
// int armor;
// int mp_enhance;
// int hp_enhance;
// int resistance[NUM_MAGICCLASS];
public int defense;
public int armor;
public int mp_enhance;
public int hp_enhance;
public int[] resistance;
public IVTR_ESSENCE_ARMOR(byte[] data)
{
Debug.Log("IVTR_ESSENCE_ARMOR: data.Length: " + data.Length);
resistance = new int[InventoryConst.NUM_MAGICCLASS];
CECDataReader dr = new (data, data.Length);
defense = dr.ReadInt();
armor = dr.ReadInt();
mp_enhance = dr.ReadInt();
hp_enhance = dr.ReadInt();
for(int i = 0; i < InventoryConst.NUM_MAGICCLASS; i++)
{
resistance[i] = dr.ReadInt();
}
}
};
public struct IVTR_ESSENCE_FASHION
@@ -284,7 +284,7 @@ namespace PerfectWorld.Scripts.Managers
AddDescText(namecol, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName());
}
if (RefineLvl > 0)
AddDescText(-1, true, "{0} {1}", pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), RefineLvl);
AddDescText(-1, true, "{0} +{1}", pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), RefineLvl);
else
m_strDesc += "\\r";
AddIDDescText();
@@ -293,7 +293,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_Essence.weapon_type.ToString());
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_CLASSNAME), m_pDBSubType.name.ToString());
// Weapon level
AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), m_Essence.weapon_level);
// Attack speed
@@ -376,10 +376,10 @@ namespace PerfectWorld.Scripts.Managers
m_strDesc += strAddon;
// Build tessera description
BuildTesseraDesc();
// Price
AddPriceDesc(white, bRepair);
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();
@@ -368,7 +368,6 @@ namespace BrewMonster.Network
public static void GetRoleBaseInfo(int iNumRole, List<int> aRoleIDs)
{
BMLogger.Log($"GetRoleBaseInfo: {iNumRole} {string.Join(", ", aRoleIDs)}");
Instance._gameSession.GetRoleBaseInfo(iNumRole, aRoleIDs);
}
@@ -55,6 +55,7 @@ namespace BrewMonster.UI
return -1;
m_Item[nIndex].strDataName[nSubIndex] = strName;
m_Item[nIndex].dwData[nSubIndex] = dwItemData;
Debug.Log("[THN]AUIListBox: SetItemData: nIndex: " + nIndex + ", dwItemData: " + dwItemData + ", nSubIndex: " + nSubIndex + ", strName: " + strName);
m_Item[nIndex].SetActOnClickBtn(m_OnClickBtn, nIndex);
return nIndex;
@@ -3117,7 +3117,6 @@ namespace BrewMonster.UI
if (Enum.IsDefined(typeof(SERVICE_TYPE), idFunction))
{
SERVICE_TYPE k = (SERVICE_TYPE)idFunction;
BMLogger.Log($" PopupCorrespondingServiceDialog: {k}");
}
if (idFunction == (int)SERVICE_TYPE.NPC_SELL || idFunction == (int)SERVICE_TYPE.NPC_BUY)
@@ -128,7 +128,6 @@ namespace BrewMonster.Scripts.UI
{
idItem = ad.m_CandItems[i - 1].m_AwardItems[j - 1].m_ulItemTemplId;
pItem = EC_IvtrItem.CreateItem((int)idItem, 0, 1);
var pWeapon = pItem as EC_IvtrWeapon;
nNum = ad.m_CandItems[i - 1].m_AwardItems[j - 1].m_ulItemNum;
if (nNum > 1)
{
@@ -139,8 +138,8 @@ namespace BrewMonster.Scripts.UI
else
pImage.SetText(_AL(""));
pWeapon.GetDetailDataFromLocal();
string strDesc = pWeapon.GetDesc();
pItem.GetDetailDataFromLocal();
string strDesc = pItem.GetDesc();
pImage.SetHint(strDesc); // TODO
//Debug.Log("[THN]CDlgAward: pItem.GetDesc():" + pItem.GetDesc());
// af_GetFileTitle(pItem.GetIconFile(), strFile); // TODO
@@ -102,14 +102,11 @@ namespace BrewMonster.UI
/// </summary>
private void OnGetRoleListComplete(List<RoleInfo> roleInfos)
{
BMLogger.Log($"OnGetRoleListComplete {roleInfos.Count}");
_roleInfos = roleInfos;
}
private void OnClickSelectCharacter(RoleInfo roleInfo)
{
BMLogger.Log($"OnClickSelectCharacter {roleInfo.name}");
UnityGameSession.SelectRoleAsync(roleInfo, OnSelectRoleComplete);
}