public void Load() { _levels = new Dictionary <byte, ExpirienceLevelTemplate>(); using (var connection = SQLite.CreateConnection()) { _log.Info("Loading expirience data..."); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM levels"; command.Prepare(); using (var sqliteDataReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteDataReader)) { while (reader.Read()) { var level = new ExpirienceLevelTemplate(); level.Level = reader.GetByte("id"); level.TotalExp = reader.GetInt32("total_exp"); level.TotalMateExp = reader.GetInt32("total_mate_exp"); level.SkillPoints = reader.GetInt32("skill_points"); _levels.Add(level.Level, level); } } } _log.Info("Expirience data loaded"); } }
public void Load() { Log.Info("Loading character templates..."); using (var connection = SQLite.CreateConnection()) { var temp = new Dictionary <uint, byte>(); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM characters"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var template = new CharacterTemplate(); var id = reader.GetUInt32("id"); template.Race = (Race)reader.GetByte("char_race_id"); template.Gender = (Gender)reader.GetByte("char_gender_id"); template.ModelId = reader.GetUInt32("model_id"); template.FactionId = reader.GetUInt32("faction_id"); template.ZoneId = reader.GetUInt32("starting_zone_id"); template.ReturnDictrictId = reader.GetUInt32("default_return_district_id"); template.ResurrectionDictrictId = reader.GetUInt32("default_resurrection_district_id"); using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT * FROM item_body_parts WHERE model_id=@model_id"; command2.Prepare(); command2.Parameters.AddWithValue("model_id", template.ModelId); using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader())) { while (reader2.Read()) { var itemId = reader2.GetUInt32("item_id", 0); var slot = reader2.GetInt32("slot_type_id") - 23; template.Items[slot] = itemId; } } } var templateId = (byte)(16 * (byte)template.Gender + (byte)template.Race); _templates.Add(templateId, template); temp.Add(id, templateId); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM character_buffs"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var characterId = reader.GetUInt32("character_id"); var buffId = reader.GetUInt32("buff_id"); var template = _templates[temp[characterId]]; template.Buffs.Add(buffId); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM character_supplies"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var ability = reader.GetByte("ability_id"); var item = new AbilitySupplyItem { Id = reader.GetUInt32("item_id"), Amount = reader.GetInt32("amount"), Grade = reader.GetByte("grade_id") }; if (!_abilityItems.ContainsKey(ability)) { _abilityItems.Add(ability, new AbilityItems()); } _abilityItems[ability].Supplies.Add(item); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM character_equip_packs"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var ability = reader.GetByte("ability_id"); var template = new AbilityItems { Ability = ability, Items = new EquipItemsTemplate() }; var clothPack = reader.GetUInt32("newbie_cloth_pack_id", 0); var weaponPack = reader.GetUInt32("newbie_weapon_pack_id", 0); if (clothPack > 0) { using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT * FROM equip_pack_cloths WHERE id=@id"; command2.Prepare(); command2.Parameters.AddWithValue("id", clothPack); using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader())) { while (reader2.Read()) { template.Items.Headgear = reader2.GetUInt32("headgear_id"); template.Items.HeadgearGrade = reader2.GetByte("headgear_grade_id"); template.Items.Necklace = reader2.GetUInt32("necklace_id"); template.Items.NecklaceGrade = reader2.GetByte("necklace_grade_id"); template.Items.Shirt = reader2.GetUInt32("shirt_id"); template.Items.ShirtGrade = reader2.GetByte("shirt_grade_id"); template.Items.Belt = reader2.GetUInt32("belt_id"); template.Items.BeltGrade = reader2.GetByte("belt_grade_id"); template.Items.Pants = reader2.GetUInt32("pants_id"); template.Items.PantsGrade = reader2.GetByte("pants_grade_id"); template.Items.Gloves = reader2.GetUInt32("glove_id"); template.Items.GlovesGrade = reader2.GetByte("glove_grade_id"); template.Items.Shoes = reader2.GetUInt32("shoes_id"); template.Items.ShoesGrade = reader2.GetByte("shoes_grade_id"); template.Items.Bracelet = reader2.GetUInt32("bracelet_id"); template.Items.BraceletGrade = reader2.GetByte("bracelet_grade_id"); template.Items.Back = reader2.GetUInt32("back_id"); template.Items.BackGrade = reader2.GetByte("back_grade_id"); template.Items.Cosplay = reader2.GetUInt32("cosplay_id"); template.Items.CosplayGrade = reader2.GetByte("cosplay_grade_id"); template.Items.Undershirts = reader2.GetUInt32("undershirt_id"); template.Items.UndershirtsGrade = reader2.GetByte("undershirt_grade_id"); template.Items.Underpants = reader2.GetUInt32("underpants_id"); template.Items.UnderpantsGrade = reader2.GetByte("underpants_grade_id"); } } } } if (weaponPack > 0) { using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT * FROM equip_pack_weapons WHERE id=@id"; command2.Prepare(); command2.Parameters.AddWithValue("id", weaponPack); using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader())) { while (reader2.Read()) { template.Items.Mainhand = reader2.GetUInt32("mainhand_id"); template.Items.MainhandGrade = reader2.GetByte("mainhand_grade_id"); template.Items.Offhand = reader2.GetUInt32("offhand_id"); template.Items.OffhandGrade = reader2.GetByte("offhand_grade_id"); template.Items.Ranged = reader2.GetUInt32("ranged_id"); template.Items.RangedGrade = reader2.GetByte("ranged_grade_id"); template.Items.Musical = reader2.GetUInt32("musical_id"); template.Items.MusicalGrade = reader2.GetByte("musical_grade_id"); } } } } _abilityItems.Add(template.Ability, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM bag_expands"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var expand = new Expand(); expand.IsBank = reader.GetBoolean("is_bank", true); expand.Step = reader.GetInt32("step"); expand.Price = reader.GetInt32("price"); expand.ItemId = reader.GetUInt32("item_id", 0); expand.ItemCount = reader.GetInt32("item_count"); expand.CurrencyId = reader.GetInt32("currency_id"); if (!_expands.ContainsKey(expand.Step)) { _expands.Add(expand.Step, new List <Expand> { expand }); } else { _expands[expand.Step].Add(expand); } } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT id, buff_id FROM appellations"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var template = new AppellationTemplate(); template.Id = reader.GetUInt32("id"); template.BuffId = reader.GetUInt32("buff_id", 0); _appellations.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM actability_groups"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var template = new ActabilityTemplate(); template.Id = reader.GetUInt32("id"); template.Name = reader.GetString("name"); template.UnitAttributeId = reader.GetInt32("unit_attr_id"); _actabilities.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM expert_limits ORDER BY up_limit ASC"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { var step = 0; while (reader.Read()) { var template = new ExpertLimit(); template.Id = reader.GetUInt32("id"); template.UpLimit = reader.GetInt32("up_limit"); template.ExpertLimitCount = reader.GetByte("expert_limit"); template.Advantage = reader.GetInt32("advantage"); template.CastAdvantage = reader.GetInt32("cast_adv"); template.UpCurrencyId = reader.GetUInt32("up_currency_id", 0); template.UpPrice = reader.GetInt32("up_price"); template.DownCurrencyId = reader.GetUInt32("down_currency_id", 0); template.DownPrice = reader.GetInt32("down_price"); _expertLimits.Add(step++, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM expand_expert_limits ORDER BY expand_count ASC"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { var step = 0; while (reader.Read()) { var template = new ExpandExpertLimit(); template.Id = reader.GetUInt32("id"); template.ExpandCount = reader.GetByte("expand_count"); template.LifePoint = reader.GetInt32("life_point"); template.ItemId = reader.GetUInt32("item_id", 0); template.ItemCount = reader.GetInt32("item_count"); _expandExpertLimits.Add(step++, template); } } } } var content = FileManager.GetFileContents("./Data/CharTemplates.json"); if (string.IsNullOrWhiteSpace(content)) { throw new IOException( $"File {FileManager.AppPath + "Data/CharTemplates.json"} doesn't exists or is empty."); } if (JsonHelper.TryDeserializeObject(content, out List <CharacterTemplateConfig> charTemplates, out _)) { foreach (var charTemplate in charTemplates) { var point = new Point(charTemplate.Pos.X, charTemplate.Pos.Y, charTemplate.Pos.Z); point.ZoneId = WorldManager .Instance .GetZoneId(charTemplate.Pos.WorldId, charTemplate.Pos.X, charTemplate.Pos.Y); // TODO ... var template = _templates[(byte)(16 + charTemplate.Id)]; template.Position = point; template.NumInventorySlot = charTemplate.NumInventorySlot; template.NumBankSlot = charTemplate.NumBankSlot; template = _templates[(byte)(32 + charTemplate.Id)]; template.Position = point; template.NumInventorySlot = charTemplate.NumInventorySlot; template.NumBankSlot = charTemplate.NumBankSlot; } } else { throw new Exception($"CharacterManager: Parse {FileManager.AppPath + "Data/CharTemplates.json"} file"); } Log.Info("Loaded {0} character templates", _templates.Count); }
public void Load() { _systemFactions = new Dictionary <uint, SystemFaction>(); _relations = new List <FactionRelation>(); using (var connection = SQLite.CreateConnection()) { _log.Info("Loading system factions..."); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM system_factions"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var faction = new SystemFaction { Id = reader.GetUInt32("id"), Name = reader.GetString("name"), OwnerName = reader.GetString("owner_name"), UnitOwnerType = (sbyte)reader.GetInt16("owner_type_id"), OwnerId = reader.GetUInt32("owner_id"), PoliticalSystem = reader.GetByte("political_system_id"), MotherId = reader.GetUInt32("mother_id"), AggroLink = reader.GetBoolean("aggro_link", true), GuardHelp = reader.GetBoolean("guard_help", true), DiplomacyTarget = reader.GetBoolean("is_diplomacy_tgt", true) }; _systemFactions.Add(faction.Id, faction); } } } _log.Info("Loaded {0} system factions", _systemFactions.Count); _log.Info("Loading faction relations..."); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM system_faction_relations"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var relation = new FactionRelation { Id = reader.GetUInt32("faction1_id"), Id2 = reader.GetUInt32("faction2_id"), State = (RelationState)reader.GetByte("state_id") }; _relations.Add(relation); var faction = _systemFactions[relation.Id]; faction.Relations.Add(relation.Id2, relation); faction = _systemFactions[relation.Id2]; faction.Relations.Add(relation.Id, relation); } } } _log.Info("Loaded {0} faction relations", _relations.Count); } }
public void Load() { _templates = new Dictionary <uint, NpcTemplate>(); _goods = new Dictionary <uint, MerchantGoods>(); using (var connection = SQLite.CreateConnection()) { _log.Info("Loading npc templates..."); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * from npcs"; command.Prepare(); using (var sqliteDataReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteDataReader)) { while (reader.Read()) { var template = new NpcTemplate(); template.Id = reader.GetUInt32("id"); template.Name = reader.GetString("name"); template.CharRaceId = reader.GetInt32("char_race_id"); template.NpcGradeId = (NpcGradeType)reader.GetByte("npc_grade_id"); template.NpcKindId = (NpcKindType)reader.GetByte("npc_kind_id"); template.Level = reader.GetByte("level"); template.NpcTemplateId = (NpcTemplateType)reader.GetByte("npc_template_id"); template.ModelId = reader.GetUInt32("model_id"); template.FactionId = reader.GetUInt32("faction_id"); template.SkillTrainer = reader.GetBoolean("skill_trainer", true); template.AiFileId = reader.GetInt32("ai_file_id"); template.Merchant = reader.GetBoolean("merchant", true); template.NpcNicknameId = reader.GetInt32("npc_nickname_id"); template.Auctioneer = reader.GetBoolean("auctioneer", true); template.ShowNameTag = reader.GetBoolean("show_name_tag", true); template.VisibleToCreatorOnly = reader.GetBoolean("visible_to_creator_only", true); template.NoExp = reader.GetBoolean("no_exp", true); template.PetItemId = reader.GetInt32("pet_item_id", 0); template.BaseSkillId = reader.GetInt32("base_skill_id"); template.TrackFriendship = reader.GetBoolean("track_friendship", true); template.Priest = reader.GetBoolean("priest", true); template.NpcTedencyId = reader.GetInt32("npc_tendency_id", 0); template.Blacksmith = reader.GetBoolean("blacksmith", true); template.Teleporter = reader.GetBoolean("teleporter", true); template.Opacity = reader.GetFloat("opacity"); template.AbilityChanger = reader.GetBoolean("ability_changer", true); template.Scale = reader.GetFloat("scale"); template.SightRangeScale = reader.GetFloat("sight_range_scale"); template.SightFovScale = reader.GetFloat("sight_fov_scale"); template.MilestoneId = reader.GetInt32("milestone_id", 0); template.AttackStartRangeScale = reader.GetFloat("attack_start_range_scale"); template.Aggression = reader.GetBoolean("aggression", true); template.ExpMultiplier = reader.GetFloat("exp_multiplier"); template.ExpAdder = reader.GetInt32("exp_adder"); template.Stabler = reader.GetBoolean("stabler", true); template.AcceptAggroLink = reader.GetBoolean("accept_aggro_link", true); template.RecrutingBattlefieldId = reader.GetInt32("recruiting_battle_field_id"); template.ReturnDistance = reader.GetFloat("return_distance"); template.NpcAiParamId = reader.GetInt32("npc_ai_param_id"); template.NonPushableByActor = reader.GetBoolean("non_pushable_by_actor", true); template.Banker = reader.GetBoolean("banker", true); template.AggroLinkSpecialRuleId = reader.GetInt32("aggro_link_special_rule_id"); template.AggroLinkHelpDist = reader.GetFloat("aggro_link_help_dist"); template.AggroLinkSightCheck = reader.GetBoolean("aggro_link_sight_check", true); template.Expedition = reader.GetBoolean("expedition", true); template.HonorPoint = reader.GetInt32("honor_point"); template.Trader = reader.GetBoolean("trader", true); template.AggroLinkSpecialGuard = reader.GetBoolean("aggro_link_special_guard", true); template.AggroLinkSpecialIgnoreNpcAttacker = reader.GetBoolean("aggro_link_special_ignore_npc_attacker", true); template.AbsoluteReturnDistance = reader.GetFloat("absolute_return_distance"); template.Repairman = reader.GetBoolean("repairman", true); template.ActivateAiAlways = reader.GetBoolean("activate_ai_always", true); template.Specialty = reader.GetBoolean("specialty", true); template.UseRangeMod = reader.GetBoolean("use_range_mod", true); template.NpcPostureSetId = reader.GetInt32("npc_posture_set_id"); template.MateEquipSlotPackId = reader.GetInt32("mate_equip_slot_pack_id", 0); template.MateKindId = reader.GetInt32("mate_kind_id", 0); template.EngageCombatGiveQuestId = reader.GetInt32("engage_combat_give_quest_id", 0); template.NoApplyTotalCustom = reader.GetBoolean("no_apply_total_custom", true); template.BaseSkillStrafe = reader.GetBoolean("base_skill_strafe", true); template.BaseSkillDelay = reader.GetFloat("base_skill_delay"); template.NpcInteractionSetId = reader.GetInt32("npc_interaction_set_id", 0); template.UseAbuserList = reader.GetBoolean("use_abuser_list", true); template.ReturnWhenEnterHousingArea = reader.GetBoolean("return_when_enter_housing_area", true); template.LookConverter = reader.GetBoolean("look_converter", true); template.UseDDCMSMountSkill = reader.GetBoolean("use_ddcms_mount_skill", true); template.CrowdEffect = reader.GetBoolean("crowd_effect", true); var bodyPack = reader.GetInt32("equip_bodies_id", 0); var clothPack = reader.GetInt32("equip_cloths_id", 0); var weaponPack = reader.GetInt32("equip_weapons_id", 0); var totalCustomId = reader.GetInt32("total_custom_id", 0); if (clothPack > 0) { using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT * FROM equip_pack_cloths WHERE id=@id"; command2.Prepare(); command2.Parameters.AddWithValue("id", clothPack); using (var sqliteReader2 = command2.ExecuteReader()) using (var reader2 = new SQLiteWrapperReader(sqliteReader2)) { while (reader2.Read()) { template.Items.Headgear = reader2.GetUInt32("headgear_id"); template.Items.HeadgearGrade = reader2.GetByte("headgear_grade_id"); template.Items.Necklace = reader2.GetUInt32("necklace_id"); template.Items.NecklaceGrade = reader2.GetByte("necklace_grade_id"); template.Items.Shirt = reader2.GetUInt32("shirt_id"); template.Items.ShirtGrade = reader2.GetByte("shirt_grade_id"); template.Items.Belt = reader2.GetUInt32("belt_id"); template.Items.BeltGrade = reader2.GetByte("belt_grade_id"); template.Items.Pants = reader2.GetUInt32("pants_id"); template.Items.PantsGrade = reader2.GetByte("pants_grade_id"); template.Items.Gloves = reader2.GetUInt32("glove_id"); template.Items.GlovesGrade = reader2.GetByte("glove_grade_id"); template.Items.Shoes = reader2.GetUInt32("shoes_id"); template.Items.ShoesGrade = reader2.GetByte("shoes_grade_id"); template.Items.Bracelet = reader2.GetUInt32("bracelet_id"); template.Items.BraceletGrade = reader2.GetByte("bracelet_grade_id"); template.Items.Back = reader2.GetUInt32("back_id"); template.Items.BackGrade = reader2.GetByte("back_grade_id"); template.Items.Cosplay = reader2.GetUInt32("cosplay_id"); template.Items.CosplayGrade = reader2.GetByte("cosplay_grade_id"); template.Items.Undershirts = reader2.GetUInt32("undershirt_id"); template.Items.UndershirtsGrade = reader2.GetByte("undershirt_grade_id"); template.Items.Underpants = reader2.GetUInt32("underpants_id"); template.Items.UnderpantsGrade = reader2.GetByte("underpants_grade_id"); } } } } if (weaponPack > 0) { using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT * FROM equip_pack_weapons WHERE id=@id"; command2.Prepare(); command2.Parameters.AddWithValue("id", weaponPack); using (var sqliteReader2 = command2.ExecuteReader()) using (var reader2 = new SQLiteWrapperReader(sqliteReader2)) { while (reader2.Read()) { template.Items.Mainhand = reader2.GetUInt32("mainhand_id"); template.Items.MainhandGrade = reader2.GetByte("mainhand_grade_id"); template.Items.Offhand = reader2.GetUInt32("offhand_id"); template.Items.OffhandGrade = reader2.GetByte("offhand_grade_id"); template.Items.Ranged = reader2.GetUInt32("ranged_id"); template.Items.RangedGrade = reader2.GetByte("ranged_grade_id"); template.Items.Musical = reader2.GetUInt32("musical_id"); template.Items.MusicalGrade = reader2.GetByte("musical_grade_id"); } } } } if (totalCustomId > 0) { using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT * FROM total_character_customs WHERE id=@id"; command2.Prepare(); command2.Parameters.AddWithValue("id", totalCustomId); using (var sqliteReader2 = command2.ExecuteReader()) using (var reader2 = new SQLiteWrapperReader(sqliteReader2)) { while (reader2.Read()) { template.HairId = reader2.GetUInt32("hair_id"); template.ModelParams = new UnitCustomModelParams(UnitCustomModelType.Face); template.ModelParams .SetHairColorId(reader2.GetUInt32("hair_color_id")) .SetSkinColorId(reader2.GetUInt32("skin_color_id")); template.ModelParams.Face.MovableDecalAssetId = reader2.GetUInt32("face_movable_decal_asset_id"); template.ModelParams.Face.MovableDecalScale = reader2.GetFloat("face_movable_decal_scale"); template.ModelParams.Face.MovableDecalRotate = reader2.GetFloat("face_movable_decal_rotate"); template.ModelParams.Face.MovableDecalMoveX = reader2.GetInt16("face_movable_decal_move_x"); template.ModelParams.Face.MovableDecalMoveY = reader2.GetInt16("face_movable_decal_move_y"); template.ModelParams.Face.SetFixedDecalAsset(0, reader2.GetUInt32("face_fixed_decal_asset_0_id"), reader2.GetFloat("face_fixed_decal_asset_0_weight")); template.ModelParams.Face.SetFixedDecalAsset(1, reader2.GetUInt32("face_fixed_decal_asset_1_id"), reader2.GetFloat("face_fixed_decal_asset_1_weight")); template.ModelParams.Face.SetFixedDecalAsset(2, reader2.GetUInt32("face_fixed_decal_asset_2_id"), reader2.GetFloat("face_fixed_decal_asset_2_weight")); template.ModelParams.Face.SetFixedDecalAsset(3, reader2.GetUInt32("face_fixed_decal_asset_3_id"), reader2.GetFloat("face_fixed_decal_asset_3_weight")); template.ModelParams.Face.DiffuseMapId = reader2.GetUInt32("face_diffuse_map_id"); template.ModelParams.Face.NormalMapId = reader2.GetUInt32("face_normal_map_id"); template.ModelParams.Face.EyelashMapId = reader2.GetUInt32("face_eyelash_map_id"); template.ModelParams.Face.LipColor = reader2.GetUInt32("lip_color"); template.ModelParams.Face.LeftPupilColor = reader2.GetUInt32("left_pupil_color"); template.ModelParams.Face.RightPupilColor = reader2.GetUInt32("right_pupil_color"); template.ModelParams.Face.EyebrowColor = reader2.GetUInt32("eyebrow_color"); reader2.GetBytes("modifier", 0, template.ModelParams.Face.Modifier, 0, 128); template.ModelParams.Face.MovableDecalWeight = reader2.GetFloat("face_movable_decal_weight"); template.ModelParams.Face.NormalMapWeight = reader2.GetFloat("face_normal_map_weight"); template.ModelParams.Face.DecoColor = reader2.GetUInt32("deco_color"); } } } } else { template.ModelParams = new UnitCustomModelParams(UnitCustomModelType.Skin); } if (template.NpcPostureSetId > 0) { using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT * FROM npc_postures WHERE npc_posture_set_id=@id"; command2.Prepare(); command2.Parameters.AddWithValue("id", template.NpcPostureSetId); using (var sqliteReader2 = command2.ExecuteReader()) using (var reader2 = new SQLiteWrapperReader(sqliteReader2)) { if (reader2.Read()) { template.AnimActionId = reader2.GetUInt32("anim_action_id"); } } } } using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT * FROM item_body_parts WHERE model_id = @model_id"; command2.Prepare(); command2.Parameters.AddWithValue("model_id", template.ModelId); using (var sqliteReader2 = command2.ExecuteReader()) using (var reader2 = new SQLiteWrapperReader(sqliteReader2)) { while (reader2.Read()) { var itemId = reader2.GetUInt32("item_id", 0); var slot = reader2.GetInt32("slot_type_id") - 23; template.BodyItems[slot] = itemId; } } } if (template.CharRaceId > 0) { using (var command2 = connection.CreateCommand()) { command2.CommandText = "SELECT char_race_id, char_gender_id FROM characters WHERE model_id = @model_id"; command2.Prepare(); command2.Parameters.AddWithValue("model_id", template.ModelId); using (var sqliteReader2 = command2.ExecuteReader()) using (var reader2 = new SQLiteWrapperReader(sqliteReader2)) { if (reader2.Read()) { template.Race = reader2.GetByte("char_race_id"); template.Gender = reader2.GetByte("char_gender_id"); } } } } _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM unit_modifiers WHERE owner_type='Npc'"; command.Prepare(); using (var sqliteDataReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteDataReader)) { while (reader.Read()) { var npcId = reader.GetUInt32("owner_id"); if (!_templates.ContainsKey(npcId)) { continue; } var npc = _templates[npcId]; var template = new BonusTemplate(); template.Attribute = (UnitAttribute)reader.GetByte("unit_attribute_id"); template.ModifierType = (UnitModifierType)reader.GetByte("unit_modifier_type_id"); template.Value = reader.GetInt32("value"); template.LinearLevelBonus = reader.GetInt32("linear_level_bonus"); npc.Bonuses.Add(template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM npc_initial_buffs"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var id = reader.GetUInt32("npc_id"); var buffId = reader.GetUInt32("buff_id"); if (!_templates.ContainsKey(id)) { continue; } var template = _templates[id]; template.Buffs.Add(buffId); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM merchants"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var id = reader.GetUInt32("npc_id"); if (!_templates.ContainsKey(id)) { continue; } var template = _templates[id]; template.MerchantPackId = reader.GetUInt32("merchant_pack_id"); } } } _log.Info("Loaded {0} npc templates", _templates.Count); _log.Info("Loading merchant packs..."); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM merchant_goods"; command.Prepare(); using (var reader = new SQLiteWrapperReader(command.ExecuteReader())) { while (reader.Read()) { var id = reader.GetUInt32("merchant_pack_id"); if (!_goods.ContainsKey(id)) { _goods.Add(id, new MerchantGoods(id)); } var itemId = reader.GetUInt32("item_id"); var grade = reader.GetByte("grade_id"); if (_goods[id].Items.ContainsKey(itemId)) { if (_goods[id].Items[itemId].IndexOf(grade) > -1) { continue; } _goods[id].Items[itemId].Add(grade); } else { _goods[id].Items.Add(itemId, new List <byte> { grade }); } } } } _log.Info("Loaded {0} merchant packs", _goods.Count); } }
public void Load() { // TODO Funcs: min, max, clamp, if_zero, if_positive, if_negative, floor, log, sqrt CalculationEngine = new CalculationEngine(CultureInfo.InvariantCulture, ExecutionMode.Compiled, true, true, false); CalculationEngine.AddFunction("clamp", (a, b, c) => a < b ? b : (a > c ? c : a)); CalculationEngine.AddFunction("if_negative", (a, b, c) => a < 0 ? b : c); CalculationEngine.AddFunction("if_positive", (a, b, c) => a > 0 ? b : c); CalculationEngine.AddFunction("if_zero", (a, b, c) => a == 0 ? b : c); _unitFormulas = new Dictionary <FormulaOwnerType, Dictionary <UnitFormulaKind, UnitFormula> >(); foreach (var owner in Enum.GetValues(typeof(FormulaOwnerType))) { _unitFormulas.Add((FormulaOwnerType)owner, new Dictionary <UnitFormulaKind, UnitFormula>()); } _wearableFormulas = new Dictionary <WearableFormulaType, WearableFormula>(); _unitVariables = new Dictionary <uint, Dictionary <UnitFormulaVariableType, Dictionary <uint, UnitFormulaVariable> > >(); _formulas = new Dictionary <uint, Formula>(); using (var connection = SQLite.CreateConnection()) { _log.Info("Loading formulas..."); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * from unit_formulas"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var formula = new UnitFormula { Id = reader.GetUInt32("id"), TextFormula = reader.GetString("formula"), Kind = (UnitFormulaKind)reader.GetByte("kind_id"), Owner = (FormulaOwnerType)reader.GetByte("owner_type_id") }; if (formula.Prepare()) { _unitFormulas[formula.Owner].Add(formula.Kind, formula); } } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * from unit_formula_variables"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var variable = new UnitFormulaVariable { FormulaId = reader.GetUInt32("unit_formula_id"), Type = (UnitFormulaVariableType)reader.GetByte("variable_kind_id"), Key = reader.GetUInt32("key"), Value = reader.GetFloat("value") }; if (!_unitVariables.ContainsKey(variable.FormulaId)) { _unitVariables.Add(variable.FormulaId, new Dictionary <UnitFormulaVariableType, Dictionary <uint, UnitFormulaVariable> >()); } if (!_unitVariables[variable.FormulaId].ContainsKey(variable.Type)) { _unitVariables[variable.FormulaId].Add(variable.Type, new Dictionary <uint, UnitFormulaVariable>()); } _unitVariables[variable.FormulaId][variable.Type].Add(variable.Key, variable); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * from wearable_formulas"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var formula = new WearableFormula { Id = reader.GetUInt32("id"), Type = (WearableFormulaType)reader.GetByte("kind_id"), TextFormula = reader.GetString("formula") }; if (formula.Prepare()) { _wearableFormulas.Add(formula.Type, formula); } } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * from formulas"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var formula = new Formula { Id = reader.GetUInt32("id"), TextFormula = reader.GetString("formula") }; if (formula.Prepare()) { _formulas.Add(formula.Id, formula); } } } } _log.Info("Formulas loaded"); } }
public void Load() { _grades = new Dictionary <int, GradeTemplate>(); _holdables = new Dictionary <uint, Holdable>(); _wearables = new Dictionary <uint, Wearable>(); _wearableKinds = new Dictionary <uint, WearableKind>(); _wearableSlots = new Dictionary <uint, WearableSlot>(); _modifiers = new Dictionary <uint, AttributeModifiers>(); _templates = new Dictionary <uint, ItemTemplate>(); _enchantingCosts = new Dictionary <uint, EquipSlotEnchantingCost>(); _gradesOrdered = new Dictionary <int, GradeTemplate>(); _enchantingSupports = new Dictionary <uint, ItemGradeEnchantingSupport>(); _config = new ItemConfig(); using (var connection = SQLite.CreateConnection()) { using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_configs"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { if (!reader.Read()) { return; } _config.DurabilityDecrementChance = reader.GetFloat("durability_decrement_chance"); _config.DurabilityRepairCostFactor = reader.GetFloat("durability_repair_cost_factor"); _config.DurabilityConst = reader.GetFloat("durability_const"); _config.HoldableDurabilityConst = reader.GetFloat("holdable_durability_const"); _config.WearableDurabilityConst = reader.GetFloat("wearable_durability_const"); _config.DeathDurabilityLossRatio = reader.GetInt32("death_durability_loss_ratio"); _config.ItemStatConst = reader.GetInt32("item_stat_const"); _config.HoldableStatConst = reader.GetInt32("holdable_stat_const"); _config.WearableStatConst = reader.GetInt32("wearable_stat_const"); _config.StatValueConst = reader.GetInt32("stat_value_const"); } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_grades"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new GradeTemplate(); template.Grade = reader.GetInt32("id"); template.GradeOrder = reader.GetInt32("grade_order"); template.HoldableDps = reader.GetFloat("var_holdable_dps"); template.HoldableArmor = reader.GetFloat("var_holdable_armor"); template.HoldableMagicDps = reader.GetFloat("var_holdable_magic_dps"); template.WearableArmor = reader.GetFloat("var_wearable_armor"); template.WearableMagicResistance = reader.GetFloat("var_wearable_magic_resistance"); template.Durability = reader.GetFloat("durability_value"); template.UpgradeRatio = reader.GetInt32("upgrade_ratio"); template.StatMultiplier = reader.GetInt32("stat_multiplier"); template.RefundMultiplier = reader.GetInt32("refund_multiplier"); template.EnchantSuccessRatio = reader.GetInt32("grade_enchant_success_ratio"); template.EnchantGreatSuccessRatio = reader.GetInt32("grade_enchant_great_success_ratio"); template.EnchantBreakRatio = reader.GetInt32("grade_enchant_break_ratio"); template.EnchantDowngradeRatio = reader.GetInt32("grade_enchant_downgrade_ratio"); template.EnchantCost = reader.GetInt32("grade_enchant_cost"); template.HoldableHealDps = reader.GetFloat("var_holdable_heal_dps"); template.EnchantDowngradeMin = reader.GetInt32("grade_enchant_downgrade_min"); template.EnchantDowngradeMax = reader.GetInt32("grade_enchant_downgrade_max"); template.CurrencyId = reader.GetInt32("currency_id"); _grades.Add(template.Grade, template); _gradesOrdered.Add(template.GradeOrder, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM holdables"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new Holdable { Id = reader.GetUInt32("id"), KindId = reader.GetUInt32("kind_id"), Speed = reader.GetInt32("speed"), ExtraDamagePierceFactor = reader.GetInt32("extra_damage_pierce_factor"), ExtraDamageSlashFactor = reader.GetInt32("extra_damage_slash_factor"), ExtraDamageBluntFactor = reader.GetInt32("extra_damage_blunt_factor"), MaxRange = reader.GetInt32("max_range"), Angle = reader.GetInt32("angle"), EnchantedDps1000 = reader.GetInt32("enchanted_dps1000"), SlotTypeId = reader.GetUInt32("slot_type_id"), DamageScale = reader.GetInt32("damage_scale"), FormulaDps = new Formula(reader.GetString("formula_dps")), FormulaMDps = new Formula(reader.GetString("formula_mdps")), FormulaArmor = new Formula(reader.GetString("formula_armor")), MinRange = reader.GetInt32("min_range"), SheathePriority = reader.GetInt32("sheathe_priority"), DurabilityRatio = reader.GetFloat("durability_ratio"), RenewCategory = reader.GetInt32("renew_category"), ItemProcId = reader.GetInt32("item_proc_id"), StatMultiplier = reader.GetInt32("stat_multiplier") }; _holdables.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM wearables"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new Wearable { TypeId = reader.GetUInt32("armor_type_id"), SlotTypeId = reader.GetUInt32("slot_type_id"), ArmorBp = reader.GetInt32("armor_bp"), MagicResistanceBp = reader.GetInt32("magic_resistance_bp") }; _wearables.Add(template.TypeId * 128 + template.SlotTypeId, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM wearable_kinds"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new WearableKind { TypeId = reader.GetUInt32("armor_type_id"), ArmorRatio = reader.GetInt32("armor_ratio"), MagicResistanceRatio = reader.GetInt32("magic_resistance_ratio"), FullBufId = reader.GetUInt32("full_buff_id"), HalfBufId = reader.GetUInt32("half_buff_id"), ExtraDamagePierce = reader.GetInt32("extra_damage_pierce"), ExtraDamageSlash = reader.GetInt32("extra_damage_slash"), ExtraDamageBlunt = reader.GetInt32("extra_damage_blunt"), DurabilityRatio = reader.GetFloat("durability_ratio") }; _wearableKinds.Add(template.TypeId, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM wearable_slots"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new WearableSlot { SlotTypeId = reader.GetUInt32("slot_type_id"), Coverage = reader.GetInt32("coverage") }; _wearableSlots.Add(template.SlotTypeId, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM equip_item_attr_modifiers"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new AttributeModifiers { Id = reader.GetUInt32("id"), // TODO ... alias StrWeight = reader.GetInt32("str_weight"), DexWeight = reader.GetInt32("dex_weight"), StaWeight = reader.GetInt32("sta_weight"), IntWeight = reader.GetInt32("int_weight"), SpiWeight = reader.GetInt32("spi_weight") }; _modifiers.Add(template.Id, template); } } } _log.Info("Loading items..."); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_armors"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var slotTypeId = reader.GetUInt32("slot_type_id"); var typeId = reader.GetUInt32("type_id"); var template = new ArmorTemplate { Id = reader.GetUInt32("item_id"), WearableTemplate = _wearables[typeId * 128 + slotTypeId], KindTemplate = _wearableKinds[typeId], SlotTemplate = _wearableSlots[slotTypeId], BaseEnchantable = reader.GetBoolean("base_enchantable", true), ModSetId = reader.GetUInt32("mod_set_id", 0), Repairable = reader.GetBoolean("repairable", true), DurabilityMultiplier = reader.GetInt32("durability_multiplier"), BaseEquipment = reader.GetBoolean("base_equipment", true), RechargeBuffId = reader.GetUInt32("recharge_buff_id", 0), ChargeLifetime = reader.GetInt32("charge_lifetime"), ChargeCount = reader.GetInt32("charge_count") }; _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_weapons"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var holdableId = reader.GetUInt32("holdable_id"); var template = new WeaponTemplate { Id = reader.GetUInt32("item_id"), BaseEnchantable = reader.GetBoolean("base_enchantable"), HoldableTemplate = _holdables[holdableId], ModSetId = reader.GetUInt32("mod_set_id", 0), Repairable = reader.GetBoolean("repairable", true), DurabilityMultiplier = reader.GetInt32("durability_multiplier"), BaseEquipment = reader.GetBoolean("base_equipment", true), RechargeBuffId = reader.GetUInt32("recharge_buff_id", 0), ChargeLifetime = reader.GetInt32("charge_lifetime"), ChargeCount = reader.GetInt32("charge_count") }; _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_accessories"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var slotTypeId = reader.GetUInt32("slot_type_id"); var typeId = reader.GetUInt32("type_id"); var template = new AccessoryTemplate { Id = reader.GetUInt32("item_id"), WearableTemplate = _wearables[typeId * 128 + slotTypeId], KindTemplate = _wearableKinds[typeId], SlotTemplate = _wearableSlots[slotTypeId], ModSetId = reader.GetUInt32("mod_set_id", 0), Repairable = reader.GetBoolean("repairable", true), DurabilityMultiplier = reader.GetInt32("durability_multiplier"), RechargeBuffId = reader.GetUInt32("recharge_buff_id", 0), ChargeLifetime = reader.GetInt32("charge_lifetime"), ChargeCount = reader.GetInt32("charge_count") }; _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_summon_mates"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new SummonMateTemplate { Id = reader.GetUInt32("item_id"), NpcId = reader.GetUInt32("npc_id") }; _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_summon_slaves"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new SummonSlaveTemplate { Id = reader.GetUInt32("item_id"), SlaveId = reader.GetUInt32("slave_id") }; _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_body_parts"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { if (reader.IsDBNull("item_id")) { continue; } var template = new BodyPartTemplate { Id = reader.GetUInt32("item_id"), ModelId = reader.GetUInt32("model_id"), NpcOnly = reader.GetBoolean("npc_only", true), BeautyShopOnly = reader.GetBoolean("beautyshop_only", true) }; _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_enchanting_gems"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new RuneTemplate { Id = reader.GetUInt32("item_id"), EquipSlotGroupId = reader.GetUInt32("equip_slot_group_id", 0), EquipLevel = reader.GetByte("equip_level", 0), ItemGradeId = reader.GetByte("item_grade_id", 0) }; _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_backpacks"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new BackpackTemplate { Id = reader.GetUInt32("item_id"), AssetId = reader.GetUInt32("asset_id"), BackpackType = (BackpackType)reader.GetUInt32("backpack_type_id"), DeclareSiegeZoneGroupId = reader.GetUInt32("declare_siege_zone_group_id"), Heavy = reader.GetBoolean("heavy"), Asset2Id = reader.GetUInt32("asset2_id"), NormalSpeciality = reader.GetBoolean("normal_specialty"), UseAsStat = reader.GetBoolean("use_as_stat"), SkinKindId = reader.GetUInt32("skin_kind_id") }; _templates.Add(template.Id, template); } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM items"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var id = reader.GetUInt32("id"); var template = _templates.ContainsKey(id) ? _templates[id] : new ItemTemplate(); template.Id = id; template.Level = reader.GetInt32("level"); template.Price = reader.GetInt32("price"); template.Refund = reader.GetInt32("refund"); template.BindId = reader.GetUInt32("bind_id"); template.PickupLimit = reader.GetInt32("pickup_limit"); template.MaxCount = reader.GetInt32("max_stack_size"); template.Sellable = reader.GetBoolean("sellable", true); template.UseSkillId = reader.GetUInt32("use_skill_id"); template.BuffId = reader.GetUInt32("buff_id"); template.Gradable = reader.GetBoolean("gradable", true); template.LootMulti = reader.GetBoolean("loot_multi", true); template.LootQuestId = reader.GetUInt32("loot_quest_id"); template.HonorPrice = reader.GetInt32("honor_price"); template.ExpAbsLifetime = reader.GetInt32("exp_abs_lifetime"); template.ExpOnlineLifetime = reader.GetInt32("exp_online_lifetime"); template.ExpDate = reader.IsDBNull("exp_online_lifetime") ? reader.GetInt32("exp_date") : 0; template.LevelRequirement = reader.GetInt32("level_requirement"); template.LevelLimit = reader.GetInt32("level_limit"); template.FixedGrade = reader.GetInt32("fixed_grade"); template.LivingPointPrice = reader.GetInt32("living_point_price"); template.CharGender = reader.GetByte("char_gender_id"); if (!_templates.ContainsKey(id)) { _templates.Add(template.Id, template); } } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM equip_slot_enchanting_costs"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new EquipSlotEnchantingCost(); template.Id = reader.GetUInt32("id"); template.SlotTypeId = reader.GetUInt32("slot_type_id"); template.Cost = reader.GetInt32("cost"); if (!_enchantingCosts.ContainsKey(template.SlotTypeId)) { _enchantingCosts.Add(template.SlotTypeId, template); } } } } using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM item_grade_enchanting_supports"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var template = new ItemGradeEnchantingSupport(); template.Id = reader.GetUInt32("id"); template.ItemId = reader.GetUInt32("item_id"); template.RequireGradeMin = reader.GetInt32("require_grade_min"); template.RequireGradeMax = reader.GetInt32("require_grade_max"); template.AddSuccessRatio = reader.GetInt32("add_success_ratio"); template.AddSuccessMul = reader.GetInt32("add_success_mul"); template.AddGreatSuccessRatio = reader.GetInt32("add_great_success_ratio"); template.AddGreatSuccessMul = reader.GetInt32("add_great_success_mul"); template.AddBreakRatio = reader.GetInt32("add_break_ratio"); template.AddBreakMul = reader.GetInt32("add_break_mul"); template.AddDowngradeRatio = reader.GetInt32("add_downgrade_ratio"); template.AddDowngradeMul = reader.GetInt32("add_downgrade_mul"); template.AddGreatSuccessGrade = reader.GetInt32("add_great_success_grade"); if (!_enchantingSupports.ContainsKey(template.ItemId)) { _enchantingSupports.Add(template.ItemId, template); } } } } _log.Info("Loaded {0} items", _templates.Count); } }