public ItemData(int id, string name, int level, PLAYER_RACES[] races, bool _stacks, ITEM_TYPES type, ITEM_SUB_TYPES sub_type, BONUS_TYPE bonus_type0, float bonus_value0, BONUS_TYPE bonus_type1, float bonus_value1, BONUS_TYPE bonus_type2, float bonus_value2, BONUS_TYPE bonus_type3, float bonus_value3, BONUS_TYPE bonus_type4, float bonus_value4, BONUS_TYPE bonus_type5, float bonus_value5) { this.vnum = id; this.name = name; this.level = level; this.races = races; this.stacks = _stacks; this.type = type; this.sub_type = sub_type; this.bonus_type0 = bonus_type0; this.bonus_value0 = bonus_value0; this.bonus_type1 = bonus_type1; this.bonus_value1 = bonus_value1; this.bonus_type2 = bonus_type2; this.bonus_value2 = bonus_value2; this.bonus_type3 = bonus_type3; this.bonus_value3 = bonus_value3; this.bonus_type4 = bonus_type4; this.bonus_value4 = bonus_value4; this.bonus_type5 = bonus_type5; this.bonus_value5 = bonus_value5; }
public static bool ReadItemData() { if (!File.Exists(Config.LocalePath + "item_data")) { return(false); } string raw = File.ReadAllText(Config.LocalePath + "item_data"); if (raw == "") { return(false); } try { int len = getFinalLocaleId(raw); ItemData[] items = new ItemData[len]; string[] lines = raw.Split(Environment.NewLine.ToCharArray()); for (int l = 0; l < lines.Length; l++) { if (lines[l] == "" || lines[l][0] == '#') { continue; } string[] line_contents = lines[l].Split('\t'); Int32.TryParse(line_contents[0].ToString(), out int vnum); string name = line_contents[1]; Int32.TryParse(line_contents[2].ToString(), out int level); List <PLAYER_RACES> races = new List <PLAYER_RACES>(); if (line_contents[3].ToString() == "ALL") { races = Enum.GetValues(typeof(PLAYER_RACES)).Cast <PLAYER_RACES>().Select(v => v.ToString()).ToList().Select(x => Enum.Parse(typeof(PLAYER_RACES), x)).Cast <PLAYER_RACES>().ToList(); } else { string[] races_string = line_contents[3].Split(','); for (int r = 0; r < races_string.Length; r++) { races.Add((PLAYER_RACES)Enum.Parse(typeof(PLAYER_RACES), races_string[r])); } } Int32.TryParse(line_contents[4].ToString(), out int _stacks); bool stacks = false; if (_stacks == 1) { stacks = true; } ITEM_TYPES type = (ITEM_TYPES)Enum.Parse(typeof(ITEM_TYPES), line_contents[5]); ITEM_SUB_TYPES sub_type = (ITEM_SUB_TYPES)Enum.Parse(typeof(ITEM_SUB_TYPES), line_contents[6]); BONUS_TYPE bonus_type0 = (BONUS_TYPE)Enum.Parse(typeof(BONUS_TYPE), line_contents[7]); float.TryParse(line_contents[8].ToString(), out float bonus_value0); BONUS_TYPE bonus_type1 = (BONUS_TYPE)Enum.Parse(typeof(BONUS_TYPE), line_contents[9]); float.TryParse(line_contents[10].ToString(), out float bonus_value1); BONUS_TYPE bonus_type2 = (BONUS_TYPE)Enum.Parse(typeof(BONUS_TYPE), line_contents[11]); float.TryParse(line_contents[12].ToString(), out float bonus_value2); BONUS_TYPE bonus_type3 = (BONUS_TYPE)Enum.Parse(typeof(BONUS_TYPE), line_contents[13]); float.TryParse(line_contents[14].ToString(), out float bonus_value3); BONUS_TYPE bonus_type4 = (BONUS_TYPE)Enum.Parse(typeof(BONUS_TYPE), line_contents[15]); float.TryParse(line_contents[16].ToString(), out float bonus_value4); BONUS_TYPE bonus_type5 = (BONUS_TYPE)Enum.Parse(typeof(BONUS_TYPE), line_contents[17]); float.TryParse(line_contents[18].ToString(), out float bonus_value5); ItemData iData = new ItemData(vnum, name, level, races.ToArray(), stacks, type, sub_type, bonus_type0, bonus_value0, bonus_type1, bonus_value1, bonus_type2, bonus_value2, bonus_type3, bonus_value3, bonus_type4, bonus_value4, bonus_type5, bonus_value5); items[vnum] = iData; } Config.Items = items.ToArray(); } catch (Exception e) { Logger.Syserr(e.Message); return(false); } return(true); }
public ItemData(int id, string name, int level, PLAYER_RACES[] races, bool _stacks, ITEM_TYPES type, ITEM_SUB_TYPES sub_type, BONUS_TYPE bonus_type0, float bonus_value0, BONUS_TYPE bonus_type1, float bonus_value1, BONUS_TYPE bonus_type2, float bonus_value2, BONUS_TYPE bonus_type3, float bonus_value3, BONUS_TYPE bonus_type4, float bonus_value4, BONUS_TYPE bonus_type5, float bonus_value5) { this.vnum = id; this.name = name; this.level = level; this.races = races; this.stacks = _stacks; this.type = type; this.sub_type = sub_type; this.bonus_type0 = bonus_type0; this.bonus_value0 = bonus_value0; this.bonus_type1 = bonus_type1; this.bonus_value1 = bonus_value1; this.bonus_type2 = bonus_type2; this.bonus_value2 = bonus_value2; this.bonus_type3 = bonus_type3; this.bonus_value3 = bonus_value3; this.bonus_type4 = bonus_type4; this.bonus_value4 = bonus_value4; this.bonus_type5 = bonus_type5; this.bonus_value5 = bonus_value5; if (type == ITEM_TYPES.WEAPON) { if (bonus_type0 == BONUS_TYPE.P_ATTACK) { this.pDamage = bonus_value0; } if (bonus_type1 == BONUS_TYPE.P_ATTACK) { this.pDamage = bonus_value1; } if (bonus_type2 == BONUS_TYPE.P_ATTACK) { this.pDamage = bonus_value2; } if (bonus_type3 == BONUS_TYPE.P_ATTACK) { this.pDamage = bonus_value3; } if (bonus_type4 == BONUS_TYPE.P_ATTACK) { this.pDamage = bonus_value4; } if (bonus_type5 == BONUS_TYPE.P_ATTACK) { this.pDamage = bonus_value5; } if (bonus_type0 == BONUS_TYPE.M_ATTACK) { this.mDamage = bonus_value0; } if (bonus_type1 == BONUS_TYPE.M_ATTACK) { this.mDamage = bonus_value1; } if (bonus_type2 == BONUS_TYPE.M_ATTACK) { this.mDamage = bonus_value2; } if (bonus_type3 == BONUS_TYPE.M_ATTACK) { this.mDamage = bonus_value3; } if (bonus_type4 == BONUS_TYPE.M_ATTACK) { this.mDamage = bonus_value4; } if (bonus_type5 == BONUS_TYPE.M_ATTACK) { this.mDamage = bonus_value5; } } }