943 lines
38 KiB
C#
943 lines
38 KiB
C#
using BrewMonster.ELEMENT_DATA;
|
||
using BrewMonster.Network;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
using UnityEngine;
|
||
using ModelRenderer.Scripts.GameData;
|
||
namespace BrewMonster
|
||
{
|
||
|
||
public struct LOCATION
|
||
{
|
||
public DATA_TYPE type;
|
||
public object pos;
|
||
};
|
||
|
||
namespace abase
|
||
{
|
||
public static class abase
|
||
{
|
||
const int RAND_MAX = 0x7fff;
|
||
public static int Rand(int lower, int upper)
|
||
{
|
||
if (upper == lower)
|
||
return lower;
|
||
else
|
||
return new System.Random().Next(lower, upper);
|
||
}
|
||
|
||
public static float Rand(float lower, float upper)
|
||
{
|
||
float rng = (float)new System.Random().NextDouble();
|
||
return lower + (upper - lower) * rng / (float)RAND_MAX;
|
||
}
|
||
|
||
public static int RandNormal(int lower, int upper) { return Rand(lower, upper); }
|
||
public static float RandUniform() { return Rand(0f, 1f); }
|
||
|
||
public static int RandSelect(List<float> option)
|
||
{
|
||
int num = option.Count;
|
||
float op = RandUniform();
|
||
for (int i = 0; i<num; i++)
|
||
{
|
||
float prob = (float)option[i];
|
||
if (op<prob)
|
||
return i;
|
||
op -= prob;
|
||
}
|
||
//assert(false);
|
||
return 0;
|
||
}
|
||
//static void* fastalloc(size_t size) { return malloc(size); }
|
||
//static void fastfree(void* buf, size_t size) { free(buf); }
|
||
}
|
||
};
|
||
|
||
namespace ELEMENT_DATA
|
||
{
|
||
public enum LOWER { LOWER_TREND };
|
||
public enum UPPER { UPPER_TREND };
|
||
public enum MIDDLE { MIDDLE_TREND };
|
||
public enum ANY { ANY_TREND };
|
||
|
||
public enum NORMAL { NORMAL_RAND };
|
||
public enum SPECIFIC { SPECIFIC_RAND };
|
||
|
||
//struct can not have a parameterless constructor
|
||
public class SpecRand
|
||
{
|
||
public List<int> IndexList;
|
||
public int IdxCap;
|
||
public int IdxIndex;
|
||
public List<float> RandList;
|
||
public int RandCap;
|
||
public int RandIndex;
|
||
//SpecRand() :IndexList(0),IdxCap(0),IdxIndex(0),RandList(0),RandCap(0),RandIndex(0) { }
|
||
|
||
public SpecRand() {
|
||
IndexList = new List<int>();
|
||
IdxCap = 0;
|
||
IdxIndex = 0;
|
||
RandList = new List<float>();
|
||
RandCap = 0;
|
||
RandIndex = 0;
|
||
|
||
}
|
||
public int RandSelect(int num)
|
||
{
|
||
if (IndexList == null || IndexList.Count == 0) return 0;
|
||
if (IdxIndex >= IdxCap) return 0;
|
||
if (num <= 0) return 0;
|
||
int idx = IndexList[IdxIndex++];
|
||
if (idx >= num) idx = num - 1;
|
||
return idx;
|
||
}
|
||
|
||
public int RandNormal(int lower, int upper)
|
||
{
|
||
if (RandList == null || RandList.Count == 0) return lower;
|
||
if (RandIndex >= RandCap) return lower;
|
||
float r = RandList[RandIndex++];
|
||
if (r < 0) r = 0f;
|
||
if (r >= 1.0f) r = 0.9999999f;
|
||
return (int)((upper - lower + 1) * r + lower);
|
||
}
|
||
|
||
public float Rand(float lower, float upper)
|
||
{
|
||
if (RandList == null || RandList.Count == 0) return lower;
|
||
if (RandIndex >= RandCap) return lower;
|
||
float r = RandList[RandIndex++];
|
||
if (r < 0) r = 0f;
|
||
if (r >= 1.0f) r = 0.9999999f;
|
||
return (float)((upper - lower) * r + lower);
|
||
}
|
||
}
|
||
public class SpecCls
|
||
{
|
||
SpecRand imp;
|
||
public SpecCls(SpecRand tmp) {
|
||
imp = tmp;
|
||
}
|
||
//Could be wrong, need to check
|
||
public int RandSelect(List<float> option)
|
||
{
|
||
int num = option.Count;
|
||
if(imp != null) return imp.RandSelect(num);
|
||
return 0;
|
||
}
|
||
|
||
public int RandNormal(int lower, int upper)
|
||
{
|
||
if (imp != null) return imp.RandNormal(lower, upper);
|
||
return lower;
|
||
}
|
||
|
||
public float Rand(float lower, float upper)
|
||
{
|
||
if (imp != null) return imp.Rand(lower, upper);
|
||
return lower;
|
||
}
|
||
}
|
||
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 uint RandSelect_SPECIFIC_LOWER(List<float> option, SPECIFIC specificType, LOWER lowerTrend)
|
||
{
|
||
return 0;
|
||
}
|
||
public static int RandSelect_SPECIFIC_MIDDLE(List<float> option, SPECIFIC specificType, MIDDLE middleTrend)
|
||
{
|
||
return option.Count / 2;
|
||
}
|
||
public static int RandNormal_NORMAL_LOWER(int lower, int upper, NORMAL normalType, LOWER lowerTrend)
|
||
{
|
||
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);
|
||
}
|
||
}
|
||
public enum GEN_ADDON_MODE
|
||
{
|
||
ADDON_LIST_SHOP,
|
||
ADDON_LIST_DROP,
|
||
ADDON_LIST_PRODUCE,
|
||
ADDON_LIST_SPEC,
|
||
};
|
||
public enum ITEM_MAKE_TAG
|
||
{
|
||
IMT_NULL,
|
||
IMT_CREATE,
|
||
IMT_DROP,
|
||
IMT_SHOP,
|
||
IMT_PRODUCE,
|
||
IMT_SIGN, //װ����ǩ��
|
||
};
|
||
//#pragma pack(1)
|
||
public class item_tag_t
|
||
{
|
||
public char type;
|
||
public char size;
|
||
public item_tag_t(char type, char size)
|
||
{
|
||
this.type = type;
|
||
this.size = size;
|
||
}
|
||
};
|
||
//#pragma pack()
|
||
|
||
};// name space element_data
|
||
public struct guid_t
|
||
{
|
||
public int guid1;
|
||
public int guid2;
|
||
}
|
||
public struct item_data
|
||
{
|
||
public uint type; //��Ʒ��ģ��ID
|
||
public int count; //��Ʒ������
|
||
public int pile_limit; //��Ʒ�Ķѵ�����
|
||
public int equip_mask; //��Ʒ�Ŀ�װ����־��0x8000��ʾ����Ƕ��
|
||
public int proc_type; //��Ʒ�Ĵ�����ʽ
|
||
public int classid; //��Ʒ��Ӧ�����ID
|
||
public guid_t guid; //��Ʒ��GUID
|
||
public int price; //��Ʒ�ļ۸�
|
||
public int expire_date; //����ʱ��
|
||
public int content_length;
|
||
public byte item_content;
|
||
};
|
||
// #pragma pack(1)
|
||
public struct _item_content
|
||
{
|
||
public prerequisition preq;
|
||
public short sizeofessence; //װ�������С���ֽڣ�;
|
||
// essence //char ����[]; //ÿ�ֲ�ͬװ���ı���ṹ��ͬ
|
||
public int num_hole; //������Ŀ��������;
|
||
// int hole_type[MAX_NUM_HOLES]; //����Ƕ���������[������Ŀ]; //�������ĿΪ0,���������
|
||
public int num_addon; //���Ա���Ŀ����Ŀ��������;
|
||
// _addon ad[MAX_NUM_ADDONS]; //[���Ա���Ŀ����Ŀ];
|
||
};
|
||
//#pragma pack()
|
||
|
||
public struct addon_data
|
||
{
|
||
public int id;
|
||
public int[] arg;
|
||
public addon_data(int id) {
|
||
this.id = id;
|
||
arg = new int[3];
|
||
}
|
||
};
|
||
public struct prerequisition
|
||
{
|
||
public short level;
|
||
public short race;
|
||
public short strength;
|
||
public short vitality;
|
||
public short agility;
|
||
public short energy;
|
||
public int durability;
|
||
public int max_durability;
|
||
};
|
||
struct _weapon_essence
|
||
{
|
||
public enum WEAPON_TYPE
|
||
{
|
||
WEAPON_TYPE_MELEE = 0,
|
||
WEAPON_TYPE_RANGE = 1,
|
||
WEAPON_TYPE_MELEE_ASN = 2, //�̿�ʹ�õĽ���������������Ӱ���﹥�⣬�����������ͬ
|
||
};
|
||
|
||
public short weapon_type; //������� ��Ӧģ����Ľ���Զ�̱�־
|
||
public short weapon_delay; //�����Ĺ����ӳ�ʱ�䣬��50msΪ��λ
|
||
public int weapon_class; //�������� ��Ӧģ����Ĵ��� ���絶�� ������
|
||
public int weapon_level; //�������� ijЩ������Ҫ��������
|
||
public int require_projectile; //��Ҫ��ҩ������
|
||
public int damage_low; //����������С��ֵ
|
||
public int damage_high; //������������ֵ
|
||
public int magic_damage_low; //ħ������
|
||
public int magic_damage_high; //ħ������
|
||
public int attack_speed;
|
||
public float attack_range;
|
||
public float attack_short_range;
|
||
};
|
||
public static class itemdataman
|
||
{
|
||
#region const
|
||
public const uint ELEMENTDATAMAN_MAX_NUM_ADDON_PARAM = 3;
|
||
public struct _addon //������Ŀ
|
||
{
|
||
public int addon_type;
|
||
public int[] addon_arg; // 0 ~ 3 ��Ŀ�� ((type & 0x6000)>>13)
|
||
public _addon(int addon_type) {
|
||
this.addon_type = addon_type;
|
||
addon_arg = new int[ELEMENTDATAMAN_MAX_NUM_ADDON_PARAM];
|
||
}
|
||
};
|
||
#region Equip Mask
|
||
public const uint ELEMENTDATAMAN_MAX_NUM_HOLES = 5;
|
||
public const uint ELEMENTDATAMAN_MAX_NUM_ADDONS = 32;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_WEAPON = 0x0001;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_HEAD = 0x0002;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_NECK = 0x0004;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_SHOULDER = 0x0008;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_BODY = 0x0010;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_WAIST = 0x0020;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_LEG = 0x0040;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_FOOT = 0x0080;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_WRIST = 0x0100;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_FINGER1 = 0x0200;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_FINGER2 = 0x0400;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_PROJECTILE = 0x0800;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_FLYSWORD = 0x1000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_DAMAGERUNE = 0x20000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_BIBLE = 0x40000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_SPEAKER = 0x80000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_AUTO_HP = 0x100000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_AUTO_MP = 0x200000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_ELF = 0x800000; //lgc
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_STALLCARD = 0x1000000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_FORCE_TICKET = 0x4000000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_DYNSKILL_ALL = 0x18000000; public const uint ELEMENTDATAMAN_EQUIP_MASK_HAS_ADDON = 0x40000000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_EXTEND64 = 0x80000000;
|
||
public const uint ELEMENTDATAMAN_EQUIP_MASK_HIGH = 0xC0000000;
|
||
#endregion
|
||
#endregion
|
||
public static Dictionary<uint, LOCATION> sale_item_id_index_map;
|
||
public static elementdataman _edm;
|
||
public static int load_data(string pathname, bool disable_bind2)
|
||
{
|
||
_edm = ElementDataManProvider.GetElementDataMan();
|
||
generate_item_for_sell(disable_bind2);
|
||
return 0;
|
||
// if(await _edm.load_data(pathname) == 0)
|
||
// {
|
||
// generate_item_for_sell(disable_bind2);
|
||
// return 0;
|
||
// }
|
||
// else
|
||
// return -1;
|
||
}
|
||
|
||
public static int generate_item_for_sell(bool disable_bind2)
|
||
{
|
||
//#define CASE_CLEAR_PROC_TYPE(ESSENCE) case DT_##ESSENCE: \
|
||
// {\
|
||
// DATA_TYPE dt2;\
|
||
// ESSENCE* ess = (ESSENCE*)get_data_ptr(id, ID_SPACE_ESSENCE, dt2); \
|
||
// if (dt2 == datatype && ess && disable_bind2) ess->proc_type &= ~(0x0040);\
|
||
// }
|
||
|
||
byte[] item;
|
||
uint size;
|
||
int ret;
|
||
|
||
DATA_TYPE datatype = DATA_TYPE.DT_INVALID;
|
||
item_tag_t tag = new item_tag_t((char)ITEM_MAKE_TAG.IMT_SHOP, (char)'0');
|
||
//uint id = _edm.get_first_data_id(ID_SPACE.ID_SPACE_ESSENCE,ref datatype);
|
||
|
||
|
||
for (uint id = 0; id < _edm.essence_id_data_type_map.Count; id++)
|
||
{
|
||
_edm.essence_id_data_type_map.TryGetValue(id, out datatype);
|
||
switch (datatype)
|
||
{
|
||
case (DATA_TYPE.DT_WEAPON_ESSENCE):
|
||
generate_item_temp.generate_weapon(id,ID_SPACE.ID_SPACE_ESSENCE,
|
||
out item,out size,SPECIFIC.SPECIFIC_RAND,GEN_ADDON_MODE.ADDON_LIST_SHOP,tag);
|
||
BMLogger.Log("generate_item_for_sell: generate_weapon: " + id);
|
||
break;
|
||
default:
|
||
BMLogger.Log("generate_item_for_sell: default: " + id);
|
||
ret = -1;
|
||
break;
|
||
}
|
||
}
|
||
|
||
// CASE_CLEAR_PROC_TYPE(ARMOR_ESSENCE)
|
||
|
||
// ret = generate_armor(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0), element_data::ADDON_LIST_SHOP, &tag, sizeof(tag));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(PROJECTILE_ESSENCE)
|
||
|
||
// ret = generate_projectile(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
|
||
// case DT_QUIVER_ESSENCE:
|
||
// ret = generate_quiver_for_sell(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(STONE_ESSENCE)
|
||
|
||
// ret = generate_stone(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(DECORATION_ESSENCE)
|
||
|
||
// ret = generate_decoration(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0), element_data::ADDON_LIST_SHOP, &tag, sizeof(tag));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(MEDICINE_ESSENCE)
|
||
|
||
// ret = generate_medicine(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(WINGMANWING_ESSENCE)
|
||
|
||
// ret = generate_wingmanwing(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0), &tag, sizeof(tag));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(MATERIAL_ESSENCE)
|
||
|
||
// ret = generate_material(id, ID_SPACE_ESSENCE, (char**)&item, size, (MATERIAL_ESSENCE*)0, DT_MATERIAL_ESSENCE);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(DYE_TICKET_ESSENCE)
|
||
|
||
// ret = generate_material(id, ID_SPACE_ESSENCE, (char**)&item, size, (DYE_TICKET_ESSENCE*)0, DT_DYE_TICKET_ESSENCE);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(FIREWORKS_ESSENCE)
|
||
|
||
// ret = generate_fireworks(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(WAR_TANKCALLIN_ESSENCE)
|
||
|
||
// ret = generate_tankcallin(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(SKILLMATTER_ESSENCE)
|
||
|
||
// ret = generate_skillmatter(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(DAMAGERUNE_ESSENCE)
|
||
|
||
// ret = generate_damagerune(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(ARMORRUNE_ESSENCE)
|
||
|
||
// ret = generate_armorrune(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(SKILLTOME_ESSENCE)
|
||
|
||
// ret = generate_skilltome(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(FLYSWORD_ESSENCE)
|
||
|
||
// ret = generate_flysword(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0), &tag, sizeof(tag));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(TOWNSCROLL_ESSENCE)
|
||
|
||
// ret = generate_townscroll(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(UNIONSCROLL_ESSENCE)
|
||
|
||
// ret = generate_unionscroll(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(REVIVESCROLL_ESSENCE)
|
||
|
||
// ret = generate_revivescroll(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(ELEMENT_ESSENCE)
|
||
|
||
// ret = generate_element(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(TASKMATTER_ESSENCE)
|
||
|
||
// ret = generate_taskmatter(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(TOSSMATTER_ESSENCE)
|
||
|
||
// ret = generate_tossmatter(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(TASKDICE_ESSENCE)
|
||
|
||
// ret = generate_taskdice(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(TASKNORMALMATTER_ESSENCE)
|
||
|
||
// ret = generate_tasknormalmatter(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(FASHION_ESSENCE)
|
||
|
||
// ret = generate_fashion_item(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0), &tag, sizeof(tag));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(FACEPILL_ESSENCE)
|
||
|
||
// ret = generate_facepill(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(FACETICKET_ESSENCE)
|
||
|
||
// ret = generate_faceticket(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(GM_GENERATOR_ESSENCE)
|
||
|
||
// ret = generate_gm_generator(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(PET_EGG_ESSENCE)
|
||
|
||
// ret = generate_pet_egg(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(PET_FOOD_ESSENCE)
|
||
|
||
// ret = generate_pet_food(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(REFINE_TICKET_ESSENCE)
|
||
|
||
// ret = generate_refine_ticket(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(BIBLE_ESSENCE)
|
||
|
||
// ret = generate_bible(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(SPEAKER_ESSENCE)
|
||
|
||
// ret = generate_speaker(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(AUTOHP_ESSENCE)
|
||
|
||
// ret = generate_hp_amulet(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(AUTOMP_ESSENCE)
|
||
|
||
// ret = generate_mp_amulet(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(DOUBLE_EXP_ESSENCE)
|
||
|
||
// ret = generate_double_exp(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(TRANSMITSCROLL_ESSENCE)
|
||
|
||
// ret = generate_transmitscroll(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(GOBLIN_ESSENCE)
|
||
|
||
// ret = generate_elf(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(GOBLIN_EQUIP_ESSENCE)
|
||
|
||
// ret = generate_elf_equip(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(GOBLIN_EXPPILL_ESSENCE)
|
||
|
||
// ret = generate_elf_exppill(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(SELL_CERTIFICATE_ESSENCE)
|
||
|
||
// ret = generate_stallcard(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(TARGET_ITEM_ESSENCE)
|
||
|
||
// ret = generate_skilltrigger2(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(LOOK_INFO_ESSENCE)
|
||
|
||
// ret = generate_queryotherproperty(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(INC_SKILL_ABILITY_ESSENCE)
|
||
|
||
// ret = generate_incskillability(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(WEDDING_BOOKCARD_ESSENCE)
|
||
|
||
// ret = generate_wedding_bookcard(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(WEDDING_INVITECARD_ESSENCE)
|
||
|
||
// ret = generate_wedding_invitecard(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(SHARPENER_ESSENCE)
|
||
|
||
// ret = generate_sharpener(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(FACTION_MATERIAL_ESSENCE)
|
||
|
||
// ret = generate_factionmaterial(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(CONGREGATE_ESSENCE)
|
||
|
||
// ret = generate_congregate(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(FORCE_TOKEN_ESSENCE)
|
||
|
||
// ret = generate_force_ticket(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(DYNSKILLEQUIP_ESSENCE)
|
||
|
||
// ret = generate_dynskillequip(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(MONEY_CONVERTIBLE_ESSENCE)
|
||
|
||
// ret = generate_moneyconvertibleitem(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(MONSTER_SPIRIT_ESSENCE)
|
||
|
||
// ret = generate_soul(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(POKER_ESSENCE)
|
||
|
||
// ret = generate_generalcard(id, ID_SPACE_ESSENCE, (char**)&item, size, element_data::SPECIFIC(0));
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(POKER_DICE_ESSENCE)
|
||
|
||
// ret = generate_generalcard_dice(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(SHOP_TOKEN_ESSENCE)
|
||
|
||
// ret = generate_shoptoken(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// CASE_CLEAR_PROC_TYPE(UNIVERSAL_TOKEN_ESSENCE)
|
||
|
||
// ret = generate_universal_token(id, ID_SPACE_ESSENCE, (char**)&item, size);
|
||
// break;
|
||
|
||
// case DT_MONSTER_ESSENCE:
|
||
// case DT_NPC_ESSENCE:
|
||
// default:
|
||
// continue;
|
||
// }
|
||
|
||
// if (ret == 0 && size != 0)
|
||
// {
|
||
// sale_item_ptr_array.push_back(item);
|
||
// sale_item_size_array.push_back(size);
|
||
// LOCATION loc;
|
||
// loc.type = datatype;
|
||
// loc.pos = sale_item_ptr_array.size() - 1;
|
||
// sale_item_id_index_map[id] = loc;
|
||
// }
|
||
// }
|
||
return 0;
|
||
}
|
||
|
||
|
||
public static object get_item_for_sell(uint id)
|
||
{
|
||
uint pos;
|
||
if (sale_item_id_index_map.TryGetValue(id, out var itr))
|
||
{
|
||
return itr;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public static uint generate_equipment_addon_buffer_2
|
||
(DATA_TYPE essencetype,
|
||
List<int> candidate_addon,
|
||
byte[] addon_buffer, int start_offset,
|
||
ref uint addon_num)
|
||
{
|
||
//���ɶ��addon�����ܻ��в�������ʧ��
|
||
if(addon_num == 0) return 0;
|
||
byte[] addon_sld = addon_buffer;
|
||
int i,j;
|
||
int anum = 0;
|
||
int offset = start_offset;
|
||
for(i=0; i<candidate_addon.Count; i++)
|
||
{
|
||
uint id = (uint)candidate_addon[i];
|
||
if(id <= 0) continue;
|
||
|
||
//��ʼ���� addon
|
||
addon_data addondata = new addon_data((int)id);
|
||
int rparanum;
|
||
if((rparanum = generate_addon(essencetype,id, ref addondata)) < 0) continue;
|
||
|
||
//*(int*)addon_sld = (addondata.id &(~(0x3<<13))) | (rparanum<<13);
|
||
//addon_sld += sizeof(int);
|
||
int value = (addondata.id & (~(0x3 << 13))) | (rparanum << 13);
|
||
byte[] intBytes = BitConverter.GetBytes(value);
|
||
Array.Copy(intBytes, 0, addon_buffer, offset, 4);
|
||
offset += 4;
|
||
|
||
anum ++;
|
||
for(j=0; j<rparanum; j++)
|
||
{
|
||
//*(int*)addon_sld = addondata.arg[j];
|
||
//addon_sld += sizeof(int);
|
||
value = addondata.arg[j];
|
||
intBytes = BitConverter.GetBytes(value);
|
||
Array.Copy(intBytes, 0, addon_buffer, offset, 4);
|
||
offset += 4;
|
||
}
|
||
}
|
||
addon_num = (uint)anum;
|
||
return (uint)(addon_sld.Length - addon_buffer.Length);
|
||
}
|
||
|
||
|
||
public static int generate_addon(DATA_TYPE datatype,uint addon_id, ref addon_data data)
|
||
{
|
||
DATA_TYPE dt = DATA_TYPE.DT_INVALID;
|
||
int paramnum = 0;
|
||
object temp = _edm.get_data_ptr(addon_id, ID_SPACE.ID_SPACE_ADDON, ref dt);
|
||
if(temp == null)
|
||
{
|
||
return -1;
|
||
}
|
||
EQUIPMENT_ADDON addon = (EQUIPMENT_ADDON) temp;
|
||
if(dt != DATA_TYPE.DT_EQUIPMENT_ADDON) // error
|
||
{
|
||
return -1;
|
||
}
|
||
else
|
||
{
|
||
data.id = (int)addon_id;
|
||
paramnum = addon.num_params;
|
||
data.arg[0] = addon.param1;
|
||
data.arg[1] = addon.param2;
|
||
data.arg[2] = addon.param3;
|
||
}
|
||
|
||
return EC_Game.addon_generate_arg(datatype, data, paramnum);
|
||
}
|
||
|
||
public static void generate_template_addon<RAN_CLASS>(
|
||
DATA_TYPE dt,float unique_prob,
|
||
List<int> unique, List<int> produce, List<int> drop, byte[] addon_buf,
|
||
ref uint addon_num,ref uint addon_size, RAN_CLASS cls,GEN_ADDON_MODE normal_addon,List<int> sa_list)
|
||
{
|
||
if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_DROP)
|
||
{
|
||
uint un = 0;
|
||
//ASSERT(addon_size == 0);
|
||
if(element_data.Rand_NORMAL_LOWER(0f,1f,NORMAL.NORMAL_RAND,LOWER.LOWER_TREND) < unique_prob)
|
||
{
|
||
un = 1;
|
||
addon_size = generate_equipment_addon_buffer(dt, unique, 16, addon_buf,0, ref un);
|
||
addon_num -= un;
|
||
}
|
||
addon_size += generate_equipment_addon_buffer(dt, drop, 32, addon_buf, (int)addon_size, ref addon_num);
|
||
addon_num += un;
|
||
}
|
||
else if(normal_addon == GEN_ADDON_MODE.ADDON_LIST_PRODUCE)
|
||
{
|
||
uint un = 0;
|
||
//ASSERT(addon_size == 0);
|
||
if(element_data.Rand_NORMAL_LOWER(0f,1f,NORMAL.NORMAL_RAND,LOWER.LOWER_TREND) < unique_prob)
|
||
{
|
||
un = 1;
|
||
addon_size = generate_equipment_addon_buffer(dt, unique, 16, addon_buf,0, ref un);
|
||
addon_num -= un;
|
||
}
|
||
addon_size += generate_equipment_addon_buffer(dt, produce, 32, addon_buf, (int)addon_size, ref addon_num);
|
||
addon_num += un;
|
||
}
|
||
else if (normal_addon == GEN_ADDON_MODE.ADDON_LIST_SPEC)
|
||
{
|
||
addon_size = generate_spec_addon_buffer(dt,addon_buf, 0, itemdataman.ELEMENTDATAMAN_MAX_NUM_ADDONS, ref addon_num,sa_list);
|
||
}
|
||
else
|
||
{
|
||
addon_size = 0;
|
||
addon_num = 0;
|
||
}
|
||
}
|
||
|
||
public static uint generate_equipment_addon_buffer
|
||
(DATA_TYPE essencetype,
|
||
List<int> candidate_addon,
|
||
int candidate_num,
|
||
byte[] addon_buffer,
|
||
int start_offset,
|
||
ref uint addon_num)
|
||
{
|
||
if(addon_num == 0) return 0;
|
||
int[] addon_list = new int[32];
|
||
int i;
|
||
uint anum;
|
||
//����addon���������
|
||
for(anum = 0,i=0; i<addon_num; i++)
|
||
{
|
||
// float * prob_header =(float*) (candidate_header + sizeof(unsigned int));
|
||
// int addon_index = abase::RandSelect(prob_header, sizeof(unsigned int)+sizeof(float), candidate_num);
|
||
// int id = *(int*)(candidate_header + addon_index*(sizeof(unsigned int)+sizeof(float)));
|
||
uint id = (uint)candidate_addon[i];
|
||
if(id <= 0) continue;
|
||
/*
|
||
//�������ɶ��һ����addon
|
||
for(j =0; j < anum ; j ++)
|
||
{
|
||
if(addon_list[j] == id) break;
|
||
}
|
||
if(j != anum) continue;
|
||
*/
|
||
addon_list[anum++] = (int)id;
|
||
|
||
|
||
}
|
||
addon_num = anum;
|
||
|
||
List<int> addon_list_converted = new List<int>();
|
||
for (int j = 0; j < anum; j++)
|
||
{
|
||
addon_list_converted.Add(addon_list[j]);
|
||
}
|
||
return generate_equipment_addon_buffer_2(essencetype, addon_list_converted, addon_buffer, start_offset, ref addon_num);
|
||
}
|
||
|
||
public static uint generate_spec_addon_buffer
|
||
(DATA_TYPE essencetype,
|
||
byte[] addon_buffer,
|
||
int start_offset,
|
||
uint max_addon_size,
|
||
ref uint addon_num,
|
||
List<int> sa_list)
|
||
{
|
||
addon_num = 0;
|
||
if(sa_list.Count == 0) return 0;
|
||
int i;
|
||
for(i = 0; i < max_addon_size; i ++)
|
||
{
|
||
if(sa_list[i] <= 0) break;
|
||
}
|
||
if(i == 0 ) return 0;
|
||
addon_num = (uint)i;
|
||
return generate_equipment_addon_buffer_2(essencetype,sa_list,addon_buffer,start_offset, ref addon_num);
|
||
}
|
||
public static void get_item_guid( uint id, out int g1, out int g2)
|
||
{
|
||
EC_Game.get_item_guid(id,out g1,out g2);
|
||
}
|
||
public static int addon_update_ess_data(addon_data data, object essence,int ess_size, prerequisition require)
|
||
{
|
||
return EC_Game.addon_update_ess_data(data, essence, ess_size, require);
|
||
}
|
||
public static void update_require_data(prerequisition require)
|
||
{
|
||
EC_Game.update_require_data(require);
|
||
}
|
||
public static void set_to_classid(DATA_TYPE type, byte[] data, int major_type)
|
||
{
|
||
EC_Game.set_to_classid(type, data, major_type);
|
||
}
|
||
}
|
||
|
||
} |