1612 lines
74 KiB
C#
1612 lines
74 KiB
C#
using BrewMonster.ELEMENT_DATA;
|
||
using ModelRenderer.Scripts.GameData;
|
||
using BrewMonster;
|
||
using System.Runtime.InteropServices;
|
||
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<RAND_CLASS>(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls,
|
||
GEN_ADDON_MODE normal_addon ,item_tag_t tag,List<int> sa_list = null)
|
||
{
|
||
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_WEAPON_ESSENCE)
|
||
{
|
||
return -1;
|
||
}
|
||
WEAPON_ESSENCE ess = (WEAPON_ESSENCE)obj;
|
||
|
||
//$$$$$$$$$$$ ���ڼ�����Ʒû�ж��������Բ�������
|
||
|
||
if(ess.id_sub_type == 300 || ess.id_sub_type == 293 || ess.id_sub_type == 76 || ess.id_sub_type == 291)
|
||
{
|
||
return -1;
|
||
}
|
||
size =(uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(_item_content)) + Marshal.SizeOf(typeof(_weapon_essence)));
|
||
|
||
// �����?
|
||
uint hole_num = 0;
|
||
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<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<RAND_CLASS, LOWER>(make_probability_socket.ToList(), cls, LOWER.LOWER_TREND); //������Ŀ
|
||
}
|
||
size += hole_num*sizeof(int); // size ����hole_num������type
|
||
|
||
//����tag size
|
||
//ASSERT(tag_size >= sizeof(short));
|
||
size += tag.size;
|
||
|
||
|
||
// ���addons
|
||
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, ess.probability_addon_num5 };
|
||
//log each probability_addon_num
|
||
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)
|
||
// {
|
||
// addon_size = generate_equipment_addon_buffer_2(DT_WEAPON_ESSENCE, (int*)&(ess->addons[0]), sizeof(int)+sizeof(float),32, addon_buf,addon_num);
|
||
// }
|
||
// else
|
||
// {
|
||
// if(addon_num || normal_addon == element_data::ADDON_LIST_SPEC)
|
||
// {
|
||
// generate_template_addon(DT_WEAPON_ESSENCE,ess->probability_unique,
|
||
// (char*)ess->uniques,(char*)ess->rands,(char*)ess->addons,
|
||
// addon_buf,addon_num,addon_size,cls,normal_addon,sa_list);
|
||
// }
|
||
// else
|
||
// {
|
||
// if (normal_addon == element_data::ADDON_LIST_SPEC)
|
||
// {
|
||
// addon_size = generate_spec_addon_buffer(DT_WEAPON_ESSENCE,addon_buf,ELEMENTDATAMAN_MAX_NUM_ADDONS,addon_num,sa_list);
|
||
// }
|
||
// }
|
||
// }
|
||
if(ess.fixed_props!=0)
|
||
{
|
||
// this list store the addon id
|
||
// addon_size = generate_equipment_addon_buffer_2(DT_WEAPON_ESSENCE, (int*)&(ess->addons[0]), sizeof(int)+sizeof(float),32, addon_buf,addon_num);
|
||
List<int> addon_list = ess.addons.Select(a => (int)a.id_addon).ToList();
|
||
addon_size = itemdataman.generate_equipment_addon_buffer_2(DATA_TYPE.DT_WEAPON_ESSENCE, addon_list, addon_buf,0, addon_num);
|
||
}
|
||
else
|
||
{
|
||
if(addon_num > 0 || normal_addon == GEN_ADDON_MODE.ADDON_LIST_SPEC)
|
||
{
|
||
List<int> unique_list = ess.uniques.Select(a => (int)a.id_unique).ToList();
|
||
List<int> produce_list = ess.rands.Select(a => (int)a.id_rand).ToList();
|
||
List<int> addons_list = ess.addons.Select(a => (int)a.id_addon).ToList();
|
||
itemdataman.generate_template_addon(
|
||
DATA_TYPE.DT_WEAPON_ESSENCE,ess.probability_unique,
|
||
unique_list,produce_list,addons_list,
|
||
addon_buf,ref addon_num,ref addon_size,cls,normal_addon,sa_list);
|
||
}
|
||
else
|
||
{
|
||
if (normal_addon == GEN_ADDON_MODE.ADDON_LIST_SPEC)
|
||
{
|
||
addon_size = itemdataman.generate_spec_addon_buffer(DATA_TYPE.DT_WEAPON_ESSENCE,addon_buf,0,itemdataman.ELEMENTDATAMAN_MAX_NUM_ADDONS, addon_num,sa_list);
|
||
}
|
||
}
|
||
}
|
||
|
||
size += addon_size;
|
||
|
||
// allocate the buffer with exact length
|
||
// *data = (char *)abase::fastalloc(size);
|
||
|
||
data = new byte[size];
|
||
//byte[] buf = data;
|
||
int offset = 0;
|
||
|
||
// *(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_WEAPON|(addon_num?0x40000000:0); buf += sizeof(int); //��Ʒ�Ŀ�װ����־���̶�ֵ����
|
||
// *(int*)buf = ess->proc_type; buf += sizeof(int); //��Ʒ�Ĵ�����ʽ
|
||
// *(int*)buf = DT_WEAPON_ESSENCE; buf += sizeof(int); //��Ʒ��Ӧ�����ID
|
||
WriteUInt(data, ref offset, id);
|
||
WriteUInt(data, ref offset, 1);
|
||
WriteInt(data, ref offset, ess.pile_num_max);
|
||
WriteInt(data, ref offset,(int)(itemdataman.ELEMENTDATAMAN_EQUIP_MASK_WEAPON|(addon_num>0?0x40000000:0)));
|
||
WriteUInt(data, ref offset, ess.proc_type);
|
||
WriteInt(data, ref offset, (int)DATA_TYPE.DT_WEAPON_ESSENCE);
|
||
// 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); //����ʱ��
|
||
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);
|
||
}
|
||
WriteInt(data, ref offset, ess.price);
|
||
WriteInt(data, ref offset, 0);
|
||
|
||
// size_t* content_length = (size_t*)buf; buf += sizeof(size_t); //��סbuf��ָ�룬�Ժ�����
|
||
// char ** item_content = (char **)buf; buf += sizeof(char *); //��סbuf��ָ�룬�Ժ�����
|
||
// *item_content = buf;
|
||
// *content_length = (char *)(*data)+size-buf;
|
||
|
||
// Then content_length store the length of the content.
|
||
// The item_content store the position of the start point of the content.
|
||
// Skip content_length and item_content pointer. So the remain is the content.
|
||
// After that we can calculate the content_length and item_content pointer.
|
||
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);
|
||
|
||
// 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 require_ptr = offset;
|
||
WriteShort(data, ref offset, (short)ess.require_level);
|
||
WriteShort(data, ref offset, (short)(ess.character_combo_id&0xFFFF));
|
||
WriteShort(data, ref offset, (short)ess.require_strength);
|
||
WriteShort(data, ref offset, (short)ess.require_tili);
|
||
WriteShort(data, ref offset, (short)ess.require_agility);
|
||
WriteShort(data, ref offset, (short)ess.require_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 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)
|
||
{
|
||
temp = temp2;
|
||
}
|
||
else
|
||
{
|
||
temp = element_data.RandNormal<RAND_CLASS, UPPER>(ess.durability_drop_min, ess.durability_drop_max, cls, UPPER.UPPER_TREND);
|
||
if(temp > temp2) temp = temp2;
|
||
}
|
||
|
||
// *(int*)buf = temp; buf += sizeof(int); //prerequisition durability
|
||
// *(int*)buf = temp2; buf += sizeof(int); //prerequisition max_durability
|
||
WriteInt(data, ref offset, temp); // durability
|
||
WriteInt(data, ref offset, temp2); // max_durability
|
||
|
||
// //���������߱�ǩע���ǩ���ڱ����С�ͱ�������֮��
|
||
// *(short*)buf = sizeof(_weapon_essence); buf += sizeof(short); //װ�������С���ֽڣ�?
|
||
// 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, (byte)tag.size);
|
||
|
||
//essence //char ����[]; //ÿ�ֲ�ͬװ���ı���ṹ���?
|
||
// char * essence_ptr = buf;
|
||
int essence_ptr = offset;
|
||
// switch(ess->short_range_mode)
|
||
// {
|
||
// default:
|
||
// case 0: *(short*)buf = 1; break; //Զ��
|
||
// case 1: *(short*)buf = 0; break; //����
|
||
// case 2: *(short*)buf = 2; break; //�̿ͽ���
|
||
// }
|
||
// buf += sizeof(short); //�������? ��Ӧģ����Ľ���Զ�̱��?
|
||
switch(ess.short_range_mode)
|
||
{
|
||
default:
|
||
case 0:
|
||
WriteShort(data, ref offset, (short)1);
|
||
break;
|
||
case 1:
|
||
WriteShort(data, ref offset, (short)0);
|
||
break;
|
||
case 2:
|
||
WriteShort(data, ref offset, (short)2);
|
||
break;
|
||
}
|
||
// *(short*)buf = 0; buf += sizeof(short); //���ֵ����ʹ��?
|
||
// *(int*)buf = ess->id_major_type; buf += sizeof(int); //�������� ��Ӧģ����Ĵ���? ���絶�� ������
|
||
// *(int*)buf = ess->level; buf += sizeof(int); //�������� ijЩ������Ҫ��������
|
||
// *(int*)buf = ess->require_projectile; buf += sizeof(int); //��Ҫ��ҩ������
|
||
// *(int*)buf = ess->damage_low; buf += sizeof(int); //����������С��ֵ
|
||
// *(int*)buf = element_data::RandNormal(ess->damage_high_min, ess->damage_high_max, cls,element_data::LOWER_TREND); buf += sizeof(int); //������������ֵ
|
||
// *(int*)buf = ess->magic_daage_low; buf += sizeof(int); //ħ����������?
|
||
// *(int*)buf = element_data::RandNormal(ess->magic_damage_high_min, ess->magic_damage_high_max, cls,element_data::LOWER_TREND); buf += sizeof(int); //ħ������
|
||
WriteShort(data, ref offset, (short)0);
|
||
WriteUInt(data, ref offset, ess.id_major_type);
|
||
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<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<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)
|
||
// {
|
||
// // assert(false);
|
||
// *(int*)buf = 0; buf += sizeof(int);
|
||
// }
|
||
// else
|
||
// {
|
||
// unsigned int index = element_data::RandSelect(&(subtype->probability_fastest), sizeof(float), 5, cls,element_data::MIDDLE_TREND);
|
||
// *(int*)buf = (int)(subtype->attack_speed*20.f + 0.1f) + (index - 2); buf += sizeof(int); //ģ���е���0.05����?
|
||
// }
|
||
WEAPON_SUB_TYPE subtype = new WEAPON_SUB_TYPE();
|
||
object sub_type_temp = itemdataman._edm.get_data_ptr(ess.id_sub_type, ID_SPACE.ID_SPACE_ESSENCE, ref datatype);
|
||
if(sub_type_temp == null || datatype != DATA_TYPE.DT_WEAPON_SUB_TYPE)
|
||
{
|
||
WriteInt(data, ref offset, 0);
|
||
}
|
||
else
|
||
{
|
||
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<RAND_CLASS, MIDDLE>(probability_attack_speed.ToList(), cls, MIDDLE.MIDDLE_TREND);
|
||
WriteInt(data, ref offset, (int)(subtype.attack_speed*20f + 0.1f) + (index - 2));
|
||
}
|
||
|
||
// *(float*)buf = ess->attack_range; buf += sizeof(float);
|
||
// *(float*)buf = subtype->attack_short_range; buf += sizeof(float);
|
||
// *(short*)buf = hole_num; buf += sizeof(short); //������Ŀ
|
||
// *(short*)buf = 0; buf += sizeof(short); //����������������
|
||
// for(i=0; i<hole_num; i++)
|
||
// {
|
||
// *(int*)buf = 0; buf += sizeof(int); //����Ƕ��������ͣ�û�ж���?0
|
||
// }
|
||
WriteFloat(data, ref offset, ess.attack_range);
|
||
WriteFloat(data, ref offset, subtype.attack_short_range);
|
||
WriteShort(data, ref offset, (short)hole_num);
|
||
WriteShort(data, ref offset, (short)0);
|
||
for(i = 0; i < hole_num; i++)
|
||
{
|
||
WriteInt(data, ref offset, 0);
|
||
}
|
||
|
||
// addons
|
||
// *(int*)buf = addon_num; buf += sizeof(int);
|
||
WriteInt(data, ref offset, (int)addon_num);
|
||
// char * addon_sld = addon_buf;
|
||
int addon_sld = offset;
|
||
// for(i=0; i<addon_num; i++)
|
||
// {
|
||
// int id = *(int*)addon_sld;
|
||
// addon_update_ess_data(*(addon_data*)addon_sld, essence_ptr, sizeof(_weapon_essence), (prerequisition*)require_ptr);
|
||
// addon_sld += ((id & 0x6000)>>13)*sizeof(int)+sizeof(int);
|
||
// }
|
||
addon_data addon_data = new addon_data();
|
||
prerequisition prerequisition = new prerequisition();
|
||
// Read prerequisition from data buffer (where it was written) once before the loop
|
||
int require_ptr_copy = require_ptr;
|
||
ReadPrerequisition(data, ref require_ptr_copy, out prerequisition);
|
||
for(i = 0; i < addon_num; i++)
|
||
{
|
||
ReadInt(addon_buf, ref addon_sld, out addon_data.id);
|
||
ReadAddonData(addon_buf, ref addon_sld, out addon_data);
|
||
itemdataman.addon_update_ess_data(addon_data, essence_ptr, Marshal.SizeOf(typeof(_weapon_essence)), prerequisition);
|
||
addon_sld += ((addon_data.id & 0x6000)>>13)*sizeof(int)+sizeof(int);
|
||
}
|
||
|
||
// memcpy(buf, addon_buf, addon_size);
|
||
// set_to_classid(DT_WEAPON_ESSENCE, (item_data*)(*data), -1);
|
||
itemdataman.update_require_data(ref prerequisition);
|
||
// Write updated prerequisition back to data buffer
|
||
int require_ptr_write = require_ptr;
|
||
WritePrerequisition(data, ref require_ptr_write, prerequisition);
|
||
// Copy the entire addon buffer instead of writing a single addon_data
|
||
if(addon_size > 0)
|
||
{
|
||
Array.Copy(addon_buf, 0, data, offset, (int)addon_size);
|
||
offset += (int)addon_size;
|
||
}
|
||
itemdataman.set_to_classid(DATA_TYPE.DT_WEAPON_ESSENCE, data, -1);
|
||
return 0;
|
||
}
|
||
private static void generate_magic_defense<RAND_CLASS>(int[] res, List<MagicDefence> res_list , RAND_CLASS cls,
|
||
bool b_fixed = false) //
|
||
{
|
||
float[] count_prop = {0.35f,0.25f,0.20f,0.15f,0.05f,0.051f};
|
||
float[] md_adjust = {1.0f,1.1f,1.3f,1.6f,2.0f};
|
||
int RE_num = 0;
|
||
if(!b_fixed)
|
||
{
|
||
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)
|
||
if(RE_num < 0 || RE_num >= md_adjust.Length)
|
||
{
|
||
return;
|
||
}
|
||
int[] md = {0,1,2,3,4};
|
||
for(int i = 0; i < RE_num; i++)
|
||
{
|
||
int r = abase.Rand(i,4);
|
||
int t = md[i];
|
||
md[i] = md[r];
|
||
md[r] = t;
|
||
}
|
||
float adj = md_adjust[RE_num];
|
||
for(int i = 0; i < 5 - RE_num; i++)
|
||
{
|
||
int index = md[i];
|
||
int low = res_list[index].low;
|
||
int high= res_list[index].high;
|
||
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,
|
||
GEN_ADDON_MODE normal_addon ,item_tag_t tag,List<int> sa_list = null)
|
||
{
|
||
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_ARMOR_ESSENCE)
|
||
{
|
||
return -1;
|
||
}
|
||
ARMOR_ESSENCE ess = (ARMOR_ESSENCE)obj;
|
||
size =(uint) (Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(_item_content)) + Marshal.SizeOf(typeof(ARMOR_ESSENCE)));
|
||
data = new byte[size];
|
||
int offset = 0;
|
||
short hole_num = 0;
|
||
|
||
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<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<RAND_CLASS, MIDDLE>(make_probability_socket.ToList(), cls, MIDDLE.MIDDLE_TREND); //������Ŀ
|
||
}
|
||
size += (uint)(hole_num*sizeof(int)); // size ����hole_num������type
|
||
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<RAND_CLASS, LOWER>(probability_addon_num.ToList(), cls, LOWER.LOWER_TREND); //���Ա���Ŀ����Ŀ
|
||
uint addon_size = 0;
|
||
if(ess.fixed_props!=0)
|
||
{
|
||
List<int> addon_list = ess.addons.Select(a => (int)a.id_addon).ToList();
|
||
addon_size = itemdataman.generate_equipment_addon_buffer_2(DATA_TYPE.DT_ARMOR_ESSENCE, addon_list, addon_buf,0, addon_num);
|
||
}
|
||
else
|
||
{
|
||
if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_DROP)
|
||
{
|
||
List<int> addon_list = ess.addons.Select(a => (int)a.id_addon).ToList();
|
||
addon_size = itemdataman.generate_equipment_addon_buffer(DATA_TYPE.DT_ARMOR_ESSENCE, addon_list, (int)candidate_num, addon_buf,0, addon_num);
|
||
}
|
||
else if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_PRODUCE)
|
||
{
|
||
List<int> addon_list = ess.rands.Select(a => (int)a.id_rand).ToList();
|
||
addon_size = itemdataman.generate_equipment_addon_buffer(DATA_TYPE.DT_ARMOR_ESSENCE, addon_list, (int)candidate_num, addon_buf,0, addon_num);
|
||
}
|
||
else if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_SPEC)
|
||
{
|
||
addon_size = itemdataman.generate_spec_addon_buffer(DATA_TYPE.DT_ARMOR_ESSENCE,addon_buf,0,itemdataman.ELEMENTDATAMAN_MAX_NUM_ADDONS, addon_num,sa_list);
|
||
}
|
||
else
|
||
{
|
||
addon_size = 0;
|
||
addon_num = 0;
|
||
}
|
||
}
|
||
size += addon_size;
|
||
data = new byte[size];
|
||
WriteUInt(data, ref offset, id);
|
||
WriteUInt(data, ref offset, 1);
|
||
WriteInt(data, ref offset, ess.pile_num_max);
|
||
object sub_type_temp = itemdataman._edm.get_data_ptr(ess.id_sub_type, ID_SPACE.ID_SPACE_ESSENCE, ref datatype);
|
||
if(sub_type_temp == null || datatype != DATA_TYPE.DT_ARMOR_SUB_TYPE)
|
||
{
|
||
return -1;
|
||
}
|
||
else
|
||
{
|
||
ARMOR_SUB_TYPE sub_type = (ARMOR_SUB_TYPE)sub_type_temp;
|
||
WriteUInt(data, ref offset, sub_type.equip_mask|((addon_num > 0)?itemdataman.ELEMENTDATAMAN_EQUIP_MASK_HAS_ADDON:0));
|
||
}
|
||
WriteUInt(data, ref offset, ess.proc_type);
|
||
WriteInt(data, ref offset, (int)DATA_TYPE.DT_ARMOR_ESSENCE);
|
||
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);
|
||
}
|
||
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);
|
||
|
||
int require_ptr = offset;
|
||
WriteShort(data, ref offset, (short)ess.require_level);
|
||
WriteShort(data, ref offset, (short)(ess.character_combo_id&0xFFFF));
|
||
WriteShort(data, ref offset, (short)ess.require_strength);
|
||
WriteShort(data, ref offset, (short)ess.require_tili);
|
||
WriteShort(data, ref offset, (short)ess.require_agility);
|
||
WriteShort(data, ref offset, (short)ess.require_energy);
|
||
|
||
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)
|
||
{
|
||
temp = temp2;
|
||
}
|
||
else
|
||
{
|
||
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)));
|
||
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<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<MagicDefence> res_list = ess.magic_defences.ToList();
|
||
generate_magic_defense(res, res_list, cls, ess.force_all_magic_defences != 0 || ess.fixed_props!=0);
|
||
WriteInt(data, ref offset, res[0]);
|
||
WriteInt(data, ref offset, res[1]);
|
||
WriteInt(data, ref offset, res[2]);
|
||
WriteInt(data, ref offset, res[3]);
|
||
WriteInt(data, ref offset, res[4]);
|
||
WriteShort(data, ref offset, hole_num);
|
||
WriteShort(data, ref offset, 0);
|
||
for(i = 0; i < hole_num; i++)
|
||
{
|
||
WriteInt(data, ref offset, 0);
|
||
}
|
||
WriteInt(data, ref offset, (int)addon_num);
|
||
int addon_sld = offset;
|
||
addon_data addon_data = new addon_data();
|
||
prerequisition prerequisition = new prerequisition();
|
||
// Read prerequisition from data buffer (where it was written) once before the loop
|
||
int require_ptr_copy_armor = require_ptr;
|
||
ReadPrerequisition(data, ref require_ptr_copy_armor, out prerequisition);
|
||
for(i = 0; i < addon_num; i++)
|
||
{
|
||
ReadInt(addon_buf, ref addon_sld, out addon_data.id);
|
||
ReadAddonData(addon_buf, ref addon_sld, out addon_data);
|
||
itemdataman.addon_update_ess_data(addon_data, essence_ptr, Marshal.SizeOf(typeof(_weapon_essence)), prerequisition);
|
||
addon_sld += ((addon_data.id & 0x6000)>>13)*sizeof(int)+sizeof(int);
|
||
}
|
||
itemdataman.update_require_data(ref prerequisition);
|
||
// Write updated prerequisition back to data buffer
|
||
int require_ptr_write_armor = require_ptr;
|
||
WritePrerequisition(data, ref require_ptr_write_armor, prerequisition);
|
||
if(addon_size > 0)
|
||
{
|
||
Array.Copy(addon_buf, 0, data, offset, (int)addon_size);
|
||
offset += (int)addon_size;
|
||
}
|
||
itemdataman.set_to_classid(DATA_TYPE.DT_ARMOR_ESSENCE, data, -1);
|
||
return 0;
|
||
}
|
||
public static int generate_decoration<RAND_CLASS>(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls,
|
||
GEN_ADDON_MODE normal_addon ,item_tag_t tag,List<int> sa_list = null)
|
||
{
|
||
DATA_TYPE datatype = DATA_TYPE.DT_INVALID;
|
||
int i=0;
|
||
data = new byte[0];
|
||
size = 0;
|
||
object obj = itemdataman._edm.get_data_ptr(id, idspace, ref datatype);
|
||
if(obj == null || datatype != DATA_TYPE.DT_DECORATION_ESSENCE)
|
||
{
|
||
return -1;
|
||
}
|
||
DECORATION_ESSENCE ess = (DECORATION_ESSENCE)obj;
|
||
|
||
size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(_item_content)) + Marshal.SizeOf(typeof(DECORATION_ESSENCE)));
|
||
// ��
|
||
uint hole_num = 0; //������Ŀ
|
||
|
||
// ���addons
|
||
byte[] addon_buf = new byte[itemdataman.ELEMENTDATAMAN_MAX_NUM_ADDONS*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<RAND_CLASS, LOWER>(probability_addon_num.ToList(), cls, LOWER.LOWER_TREND); //���Ա���Ŀ����Ŀ
|
||
|
||
uint addon_size = 0;
|
||
if(ess.fixed_props != 0)
|
||
{
|
||
addon_size = itemdataman.generate_equipment_addon_buffer_2(DATA_TYPE.DT_DECORATION_ESSENCE, ess.addons.Select(a => (int)a.id_addon).ToList(), addon_buf,0, addon_num);
|
||
}
|
||
else
|
||
{
|
||
if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_DROP)
|
||
addon_size = itemdataman.generate_equipment_addon_buffer(DATA_TYPE.DT_DECORATION_ESSENCE, ess.addons.Select(a => (int)a.id_addon).ToList(), 32, addon_buf,0, addon_num);
|
||
else if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_PRODUCE)
|
||
addon_size = itemdataman.generate_equipment_addon_buffer(DATA_TYPE.DT_DECORATION_ESSENCE, ess.rands.Select(a => (int)a.id_rand).ToList(), 32, addon_buf,0, addon_num);
|
||
else if (normal_addon == GEN_ADDON_MODE.ADDON_LIST_SPEC)
|
||
{
|
||
addon_size = itemdataman.generate_spec_addon_buffer(DATA_TYPE.DT_DECORATION_ESSENCE,addon_buf,0,itemdataman.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 = 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); //��Ʒ�Ķѵ�����
|
||
|
||
object sub_type_temp = itemdataman._edm.get_data_ptr(ess.id_sub_type, ID_SPACE.ID_SPACE_ESSENCE, ref datatype);
|
||
if(sub_type_temp == null || datatype != DATA_TYPE.DT_DECORATION_SUB_TYPE)
|
||
{
|
||
return -1;
|
||
}
|
||
DECORATION_SUB_TYPE sub_type = (DECORATION_SUB_TYPE)sub_type_temp;
|
||
|
||
WriteInt(data, ref offset, (int)(sub_type.equip_mask|(addon_num>0?0x40000000:0))); //��Ʒ�Ŀ�װ����־
|
||
WriteUInt(data, ref offset, ess.proc_type); //��Ʒ�Ĵ�����ʽ
|
||
WriteInt(data, ref offset, (int)DATA_TYPE.DT_DECORATION_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);
|
||
|
||
// prerequisition
|
||
int require_ptr = offset;
|
||
WriteShort(data, ref offset, (short)ess.require_level);
|
||
WriteShort(data, ref offset, (short)(ess.character_combo_id&0xFFFF));
|
||
WriteShort(data, ref offset, (short)ess.require_strength);
|
||
WriteShort(data, ref offset, (short)ess.require_tili);
|
||
WriteShort(data, ref offset, (short)ess.require_agility);
|
||
WriteShort(data, ref offset, (short)ess.require_energy);
|
||
|
||
int temp2 = element_data.RandNormal<RAND_CLASS, LOWER>(ess.durability_min, ess.durability_max, cls, LOWER.LOWER_TREND);
|
||
int temp;
|
||
if(normal_addon != GEN_ADDON_MODE.ADDON_LIST_DROP || (ess.proc_type & 0x1000) != 0)
|
||
{
|
||
temp = temp2;
|
||
}
|
||
else
|
||
{
|
||
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); //prerequisition durability
|
||
WriteInt(data, ref offset, temp2); //prerequisition max_durability
|
||
|
||
//���������߱�ǩע���ǩ���ڱ����С�ͱ�������֮��
|
||
WriteShort(data, ref offset, (short)Marshal.SizeOf(typeof(DECORATION_ESSENCE))); //װ�������С���ֽڣ�
|
||
|
||
WriteByte(data, ref offset, tag.type); // MadeFrom
|
||
WriteByte(data, ref offset, (byte)tag.size);
|
||
|
||
|
||
// ����
|
||
int essence_ptr = offset;
|
||
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.damage_low, ess.damage_high, cls, LOWER.LOWER_TREND)); //int damage;
|
||
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.magic_damage_low, ess.magic_damage_high, cls, LOWER.LOWER_TREND)); //int magic_damage;
|
||
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.defence_low, ess.defence_high, cls, LOWER.LOWER_TREND)); //int defense;
|
||
WriteInt(data, ref offset, element_data.RandNormal<RAND_CLASS, LOWER>(ess.armor_enhance_low, ess.armor_enhance_high, cls, LOWER.LOWER_TREND)); //int armor;
|
||
|
||
//����
|
||
int[] res = {0,0,0,0,0};
|
||
List<MagicDefence> res_list = ess.magic_defences.ToList<MagicDefence>();
|
||
generate_magic_defense(res,res_list,cls,ess.fixed_props!=0);
|
||
|
||
WriteInt(data, ref offset, res[0]);
|
||
WriteInt(data, ref offset, res[1]);
|
||
WriteInt(data, ref offset, res[2]);
|
||
WriteInt(data, ref offset, res[3]);
|
||
WriteInt(data, ref offset, res[4]);
|
||
|
||
// ��
|
||
WriteShort(data, ref offset, (short)hole_num); //������Ŀ
|
||
WriteShort(data, ref offset, (short)0); //����������������
|
||
|
||
// addon
|
||
WriteInt(data, ref offset, (int)addon_num);
|
||
int addon_sld = offset;
|
||
|
||
addon_data addon_data = new addon_data();
|
||
prerequisition prerequisition = new prerequisition();
|
||
// Read prerequisition from data buffer (where it was written) once before the loop
|
||
int require_ptr_copy = require_ptr;
|
||
ReadPrerequisition(data, ref require_ptr_copy, out prerequisition);
|
||
for(i = 0; i < addon_num; i++)
|
||
{
|
||
ReadInt(addon_buf, ref addon_sld, out addon_data.id);
|
||
ReadAddonData(addon_buf, ref addon_sld, out addon_data);
|
||
itemdataman.addon_update_ess_data(addon_data, essence_ptr, Marshal.SizeOf(typeof(_weapon_essence)), prerequisition);
|
||
addon_sld += ((addon_data.id & 0x6000)>>13)*sizeof(int)+sizeof(int);
|
||
}
|
||
itemdataman.update_require_data(ref prerequisition);
|
||
int require_ptr_write = require_ptr;
|
||
WritePrerequisition(data, ref require_ptr_write, prerequisition);
|
||
if(addon_size > 0)
|
||
{
|
||
Array.Copy(addon_buf, 0, data, offset, (int)addon_size);
|
||
offset += (int)addon_size;
|
||
}
|
||
itemdataman.set_to_classid(DATA_TYPE.DT_DECORATION_ESSENCE, data, -1);
|
||
//if id == 335 log all addon data
|
||
if(id == 335)
|
||
{
|
||
BMLogger.Log("Log for item with id: " + id);
|
||
for(int j = 0; j < addon_num; j++)
|
||
{
|
||
ReadInt(addon_buf, ref addon_sld, out addon_data.id);
|
||
ReadAddonData(addon_buf, ref addon_sld, out addon_data);
|
||
BMLogger.Log("addon_data.id: " + addon_data.id);
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
public static int generate_projectile<RAND_CLASS>(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_PROJECTILE_ESSENCE)
|
||
{
|
||
return -1;
|
||
}
|
||
PROJECTILE_ESSENCE ess = (PROJECTILE_ESSENCE)obj;
|
||
size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(_item_content)) + Marshal.SizeOf(typeof(PROJECTILE_ESSENCE)));
|
||
|
||
byte[] addon_buf = new byte[itemdataman.ELEMENTDATAMAN_MAX_NUM_ADDONS*Marshal.SizeOf(typeof(itemdataman._addon))];
|
||
uint addon_num = 4; //���Ա���Ŀ����Ŀ�̶� 4
|
||
uint addon_size = 0;
|
||
|
||
addon_size = itemdataman.generate_equipment_addon_buffer_2(DATA_TYPE.DT_PROJECTILE_ESSENCE, new List<int> { (int)ess.id_addon0, (int)ess.id_addon1, (int)ess.id_addon2, (int)ess.id_addon3 }, addon_buf,0, addon_num);
|
||
size += addon_size;
|
||
|
||
//����tag size
|
||
size += sizeof(short);
|
||
|
||
// 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, (int)(itemdataman.ELEMENTDATAMAN_EQUIP_MASK_PROJECTILE|(addon_num>0?0x40000000:0))); //��Ʒ�Ŀ�װ����־
|
||
WriteInt(data, ref offset, (int)ess.proc_type); //��Ʒ�Ĵ�����ʽ
|
||
WriteInt(data, ref offset, (int)DATA_TYPE.DT_PROJECTILE_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);
|
||
|
||
// prerequisition
|
||
int require_ptr = offset;
|
||
//����int����6��
|
||
WriteShort(data, ref offset, 0); //prerequisition level
|
||
WriteShort(data, ref offset, -1); // 0xFFFF = -1
|
||
WriteShort(data, ref offset, 0);
|
||
WriteShort(data, ref offset, 0); //prerequisition strength
|
||
WriteShort(data, ref offset, 0); //prerequisition agility
|
||
WriteShort(data, ref offset, 0); //prerequisition energy
|
||
|
||
WriteInt(data, ref offset, 1); //prerequisition durability
|
||
WriteInt(data, ref offset, 1); //prerequisition max_durability
|
||
WriteShort(data, ref offset, (short)Marshal.SizeOf(typeof(PROJECTILE_ESSENCE))); //װ�������С���ֽڣ�
|
||
WriteByte(data, ref offset, (byte)ITEM_MAKE_TAG.IMT_NULL);
|
||
WriteByte(data, ref offset, 0);
|
||
|
||
// projectile_essence ����
|
||
int essence_ptr = offset;
|
||
WriteInt(data, ref offset, (int)ess.type); //��ҩ����
|
||
WriteInt(data, ref offset, ess.damage_enhance); //��������������
|
||
WriteInt(data, ref offset, ess.damage_scale_enhance); //���ձ������ӹ�����
|
||
WriteInt(data, ref offset, ess.require_weapon_level_min); //��Ҫ�����ȼ�
|
||
WriteInt(data, ref offset, ess.require_weapon_level_max); //��Ҫ�����ȼ�
|
||
|
||
// ��
|
||
WriteShort(data, ref offset, (short)0);
|
||
WriteShort(data, ref offset, (short)0);
|
||
|
||
|
||
// addon
|
||
WriteInt(data, ref offset, (int)addon_num);
|
||
|
||
int addon_sld = offset;
|
||
addon_data addon_data = new addon_data();
|
||
prerequisition prerequisition = new prerequisition();
|
||
// Read prerequisition from data buffer (where it was written) once before the loop
|
||
int require_ptr_copy = require_ptr;
|
||
ReadPrerequisition(data, ref require_ptr_copy, out prerequisition);
|
||
for(int i = 0; i < addon_num; i++)
|
||
{
|
||
ReadInt(addon_buf, ref addon_sld, out addon_data.id);
|
||
ReadAddonData(addon_buf, ref addon_sld, out addon_data);
|
||
itemdataman.addon_update_ess_data(addon_data, essence_ptr, Marshal.SizeOf(typeof(_weapon_essence)), prerequisition);
|
||
addon_sld += ((addon_data.id & 0x6000)>>13)*sizeof(int)+sizeof(int);
|
||
}
|
||
itemdataman.update_require_data(ref prerequisition);
|
||
int require_ptr_write = require_ptr;
|
||
WritePrerequisition(data, ref require_ptr_write, prerequisition);
|
||
if(addon_size > 0)
|
||
{
|
||
Array.Copy(addon_buf, 0, data, offset, (int)addon_size);
|
||
offset += (int)addon_size;
|
||
}
|
||
itemdataman.set_to_classid(DATA_TYPE.DT_PROJECTILE_ESSENCE, data, -1);
|
||
|
||
return 0;
|
||
}
|
||
public static int generate_fashion_item<RAND_CLASS>(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls, item_tag_t tag)
|
||
{
|
||
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_FASHION_ESSENCE)
|
||
{
|
||
return -1;
|
||
}
|
||
FASHION_ESSENCE ess = (FASHION_ESSENCE)obj;
|
||
size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(FASHION_ESSENCE)));
|
||
|
||
//ASSERT(tag_size >= 2);
|
||
size += tag.size;
|
||
object obj_sub_type = itemdataman._edm.get_data_ptr(ess.id_sub_type, idspace, ref datatype);
|
||
if(obj_sub_type == null || datatype != DATA_TYPE.DT_FASHION_SUB_TYPE)
|
||
{
|
||
return -1;
|
||
}
|
||
FASHION_SUB_TYPE sub_type = (FASHION_SUB_TYPE)obj_sub_type;
|
||
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); //��Ʒ�Ķѵ�����
|
||
WriteUInt(data, ref offset, sub_type.equip_fashion_mask); //��Ʒ�Ŀ�װ����־���̶�ֵ����
|
||
WriteInt(data, ref offset, (int)ess.proc_type); //��Ʒ�Ĵ�����ʽ
|
||
WriteInt(data, ref offset, (int)DATA_TYPE.DT_FASHION_ESSENCE); //��Ʒ��Ӧ�����ID
|
||
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);
|
||
}
|
||
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);
|
||
|
||
short color = (short)element_data.RandNormal<RAND_CLASS, ANY>(0, 0x7FFF, cls, ANY.ANY_TREND);
|
||
WriteShort(data, ref offset, (short)ess.require_level);
|
||
|
||
WriteShort(data, ref offset, color);
|
||
WriteShort(data, ref offset, (short)ess.gender);
|
||
|
||
WriteByte(data, ref offset, tag.type);
|
||
WriteByte(data, ref offset, (byte)tag.size);
|
||
|
||
itemdataman.set_to_classid(DATA_TYPE.DT_FASHION_ESSENCE, data, -1);
|
||
return 0;
|
||
}
|
||
public static int generate_taskdice<RAND_CLASS>(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_TASKDICE_ESSENCE)
|
||
{
|
||
return -1;
|
||
}
|
||
TASKDICE_ESSENCE ess = (TASKDICE_ESSENCE)obj;
|
||
size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(TASKDICE_ESSENCE)));
|
||
data = new byte[size];
|
||
int offset = 0;
|
||
WriteUInt(data, ref offset, 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_TASKDICE_ESSENCE);
|
||
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);
|
||
}
|
||
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_TASKDICE_ESSENCE, data, -1);
|
||
return 0;
|
||
}
|
||
public static int generate_tasknormalmatter<RAND_CLASS>(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls,
|
||
GEN_ADDON_MODE normal_addon ,item_tag_t tag,List<int> sa_list = null)
|
||
{
|
||
// DATA_TYPE datatype;
|
||
DATA_TYPE datatype = DATA_TYPE.DT_INVALID;
|
||
data = new byte[0];
|
||
size = 0;
|
||
int i=0;
|
||
// TASKNORMALMATTER_ESSENCE * ess = (TASKNORMALMATTER_ESSENCE *)get_data_ptr(id, idspace, datatype);
|
||
object obj = itemdataman._edm.get_data_ptr(id, idspace,ref datatype);
|
||
if(obj == null || datatype != DATA_TYPE.DT_TASKNORMALMATTER_ESSENCE)
|
||
{
|
||
return -1;
|
||
}
|
||
TASKNORMALMATTER_ESSENCE ess = (TASKNORMALMATTER_ESSENCE)obj;
|
||
size =(uint) (Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(TASKNORMALMATTER_ESSENCE)));
|
||
data = new byte[size];
|
||
int offset = 0;
|
||
WriteUInt(data, ref offset, ess.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_TASKNORMALMATTER_ESSENCE);
|
||
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);
|
||
}
|
||
WriteInt(data, ref offset, ess.price);
|
||
WriteInt(data, ref offset, 0);
|
||
|
||
int content_length;
|
||
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_TASKNORMALMATTER_ESSENCE, data, -1);
|
||
return 0;
|
||
}
|
||
public static int generate_wingmanwing<RAND_CLASS>(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls, item_tag_t tag)
|
||
{
|
||
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_WINGMANWING_ESSENCE)
|
||
{
|
||
return -1;
|
||
}
|
||
WINGMANWING_ESSENCE ess = (WINGMANWING_ESSENCE)obj;
|
||
size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(WINGMANWING_ESSENCE)));
|
||
data = new byte[size];
|
||
size += tag.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, (int)itemdataman.ELEMENTDATAMAN_EQUIP_MASK_FLYSWORD);
|
||
WriteInt(data, ref offset, (int)ess.proc_type);
|
||
WriteInt(data, ref offset, (int)DATA_TYPE.DT_WINGMANWING_ESSENCE);
|
||
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);
|
||
}
|
||
|
||
WriteInt(data, ref offset, ess.price);
|
||
WriteInt(data, ref offset, 0);
|
||
|
||
int content_length;
|
||
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.require_player_level_min);
|
||
WriteInt(data, ref offset, ess.mp_launch);
|
||
WriteInt(data, ref offset, ess.mp_per_second);
|
||
float inc_speed = ess.speed_increase;
|
||
if(inc_speed >10.0f) inc_speed = 10.0f;
|
||
WriteFloat(data, ref offset, (float)inc_speed);
|
||
|
||
WriteByte(data, ref offset, tag.type);
|
||
WriteByte(data, ref offset, (byte)tag.size);
|
||
|
||
itemdataman.set_to_classid(DATA_TYPE.DT_WINGMANWING_ESSENCE, data, -1);
|
||
return 0;
|
||
}
|
||
public static int generate_medicine<RAND_CLASS>(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<RAND_CLASS>(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;
|
||
}
|
||
public static int generate_skilltome<RAND_CLASS>(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 static int generate_pet_egg<RAND_CLASS>(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<RAND_CLASS>(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;
|
||
}
|
||
public static int generate_flysword<RAND_CLASS>(uint id, ID_SPACE idspace, out byte[] data, out uint size, RAND_CLASS cls,item_tag_t tag)
|
||
{
|
||
data = new byte[0];
|
||
size = 0;
|
||
|
||
DATA_TYPE datatype = DATA_TYPE.DT_INVALID;
|
||
object obj = itemdataman._edm.get_data_ptr(id, idspace, ref datatype);
|
||
if(obj == null || datatype != DATA_TYPE.DT_FLYSWORD_ESSENCE)
|
||
return -1;
|
||
FLYSWORD_ESSENCE ess = (FLYSWORD_ESSENCE)obj;
|
||
size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(FLYSWORD_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, (int)itemdataman.ELEMENTDATAMAN_EQUIP_MASK_FLYSWORD);
|
||
WriteInt(data, ref offset, (int)ess.proc_type);
|
||
WriteInt(data, ref offset, (int)DATA_TYPE.DT_FLYSWORD_ESSENCE);
|
||
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, 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);
|
||
|
||
int t = element_data.RandNormal<RAND_CLASS, LOWER>((int)ess.time_max_min, (int)ess.time_max_max, cls, LOWER.LOWER_TREND);
|
||
|
||
// essence
|
||
WriteInt(data, ref offset, (int)(t*0.5f));
|
||
WriteInt(data, ref offset, (int)t);
|
||
WriteShort(data, ref offset, (short)ess.require_player_level_min);
|
||
WriteByte(data, ref offset, (byte)ess.level);
|
||
WriteByte(data, ref offset, 0);
|
||
WriteInt(data, ref offset, (int)ess.character_combo_id);
|
||
WriteInt(data, ref offset, (int)ess.time_increase_per_element);
|
||
|
||
float speed = element_data.Rand<RAND_CLASS, LOWER>(ess.speed_increase_min, ess.speed_increase_max, cls, LOWER.LOWER_TREND);
|
||
WriteFloat(data, ref offset, speed);
|
||
speed = element_data.Rand<RAND_CLASS, LOWER>(ess.speed_rush_increase_min, ess.speed_rush_increase_max, cls, LOWER.LOWER_TREND);
|
||
WriteFloat(data, ref offset, speed);
|
||
|
||
//���������߱�ǩ
|
||
WriteByte(data, ref offset, tag.type);
|
||
WriteByte(data, ref offset, (byte)tag.size);
|
||
|
||
itemdataman.set_to_classid(DATA_TYPE.DT_FLYSWORD_ESSENCE, data, -1);
|
||
return 0;
|
||
}
|
||
public static int generate_townscroll<RAND_CLASS>(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_TOWNSCROLL_ESSENCE)
|
||
return -1;
|
||
TOWNSCROLL_ESSENCE ess = (TOWNSCROLL_ESSENCE)obj;
|
||
size = (uint)(Marshal.SizeOf(typeof(item_data)) + Marshal.SizeOf(typeof(TOWNSCROLL_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_TOWNSCROLL_ESSENCE);
|
||
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);
|
||
}
|
||
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, (int )(ess.use_time * 20)); //ʹ��ʱ��
|
||
|
||
itemdataman.set_to_classid(DATA_TYPE.DT_TOWNSCROLL_ESSENCE, data, -1);
|
||
return 0;
|
||
}
|
||
|
||
#region Write Functions
|
||
private static void WriteUInt(byte[] buf, ref int offset, uint value)
|
||
{
|
||
Array.Copy(BitConverter.GetBytes(value), 0, buf, offset, 4);
|
||
offset = offset + 4;
|
||
}
|
||
private static void WriteInt(byte[] buf, ref int offset, int value)
|
||
{
|
||
Array.Copy(BitConverter.GetBytes(value), 0, buf, offset, 4);
|
||
offset = offset + 4;
|
||
}
|
||
private static void WriteShort(byte[] buf, ref int offset, short value)
|
||
{
|
||
Array.Copy(BitConverter.GetBytes(value), 0, buf, offset, 2);
|
||
offset = offset + 2;
|
||
}
|
||
private static void WriteFloat(byte[] buf, ref int offset, float value)
|
||
{
|
||
Array.Copy(BitConverter.GetBytes(value), 0, buf, offset, 4);
|
||
offset = offset + 4;
|
||
}
|
||
private static void WriteTag(byte[] buf, ref int offset, item_tag_t tag)
|
||
{
|
||
buf[offset] = tag.type;
|
||
offset = offset + 1;
|
||
buf[offset] = tag.size;
|
||
offset = offset + 1;
|
||
}
|
||
private static void WriteAddonData(byte[] buf, ref int offset, addon_data value)
|
||
{
|
||
WriteInt(buf, ref offset, value.id);
|
||
for(int i = 0; i < 3; i++)
|
||
{
|
||
WriteInt(buf, ref offset, value.arg[i]);
|
||
}
|
||
}
|
||
private static void WriteByte(byte[] buf, ref int offset, byte value)
|
||
{
|
||
buf[offset] = value;
|
||
offset = offset + 1;
|
||
}
|
||
#endregion
|
||
#region Read Functions
|
||
private static void ReadInt(byte[] buf, ref int offset, out int value)
|
||
{
|
||
value = BitConverter.ToInt32(buf, offset);
|
||
offset = offset + 4;
|
||
}
|
||
private static void ReadAddonData(byte[] buf, ref int offset, out addon_data value)
|
||
{
|
||
value = new addon_data();
|
||
value.id = BitConverter.ToInt32(buf, offset);
|
||
offset = offset + 4;
|
||
value.arg = new int[3];
|
||
for(int i = 0; i < 3; i++)
|
||
{
|
||
value.arg[i] = BitConverter.ToInt32(buf, offset);
|
||
offset = offset + 4;
|
||
}
|
||
}
|
||
private static void ReadPrerequisition(byte[] buf, ref int offset, out prerequisition value)
|
||
{
|
||
value = new prerequisition();
|
||
value.level = BitConverter.ToInt16(buf, offset);
|
||
offset = offset + 2;
|
||
value.race = BitConverter.ToInt16(buf, offset);
|
||
offset = offset + 2;
|
||
value.strength = BitConverter.ToInt16(buf, offset);
|
||
offset = offset + 2;
|
||
value.vitality = BitConverter.ToInt16(buf, offset);
|
||
offset = offset + 2;
|
||
value.agility = BitConverter.ToInt16(buf, offset);
|
||
offset = offset + 2;
|
||
value.energy = BitConverter.ToInt16(buf, offset);
|
||
offset = offset + 2;
|
||
value.durability = BitConverter.ToInt32(buf, offset);
|
||
offset = offset + 4;
|
||
value.max_durability = BitConverter.ToInt32(buf, offset);
|
||
offset = offset + 4;
|
||
}
|
||
private static void WritePrerequisition(byte[] buf, ref int offset, prerequisition value)
|
||
{
|
||
WriteShort(buf, ref offset, value.level);
|
||
WriteShort(buf, ref offset, value.race);
|
||
WriteShort(buf, ref offset, value.strength);
|
||
WriteShort(buf, ref offset, value.vitality);
|
||
WriteShort(buf, ref offset, value.agility);
|
||
WriteShort(buf, ref offset, value.energy);
|
||
WriteInt(buf, ref offset, value.durability);
|
||
WriteInt(buf, ref offset, value.max_durability);
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
|