Exemplo n.º 1
0
        public void Load()
        {
            _housingTemplates = new Dictionary <uint, HousingTemplate>();
            _houses           = new Dictionary <uint, House>();

//            var housingAreas = new Dictionary<uint, HousingAreas>();
            var houseTaxes = new Dictionary <uint, HouseTax>();

            using (var connection = SQLite.CreateConnection())
            {
//                using (var command = connection.CreateCommand())
//                {
//                    command.CommandText = "SELECT * FROM housing_areas";
//                    command.Prepare();
//                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
//                    {
//                        while (reader.Read())
//                        {
//                            var template = new HousingAreas();
//                            template.Id = reader.GetUInt32("id");
//                            template.Name = reader.GetString("name");
//                            template.GroupId = reader.GetUInt32("housing_group_id");
//                            housingAreas.Add(template.Id, template);
//                        }
//                    }
//                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM taxations";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new HouseTax();
                            template.Id   = reader.GetUInt32("id");
                            template.Tax  = reader.GetUInt32("tax");
                            template.Show = reader.GetBoolean("show", true);
                            houseTaxes.Add(template.Id, template);
                        }
                    }
                }

                _log.Info("Loading Housing Templates...");

                var contents = FileManager.GetFileContents($"{FileManager.AppPath}Data/housing_bindings.json");
                if (string.IsNullOrWhiteSpace(contents))
                {
                    throw new IOException(
                              $"File {FileManager.AppPath}Data/housing_bindings.json doesn't exists or is empty.");
                }

                List <HousingBindingTemplate> binding;
                if (JsonHelper.TryDeserializeObject(contents, out binding, out _))
                {
                    _log.Info("Housing bindings loaded...");
                }
                else
                {
                    _log.Warn("Housing bindings not loaded...");
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM housings";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new HousingTemplate();
                            template.Id           = reader.GetUInt32("id");
                            template.Name         = reader.GetString("name");
                            template.CategoryId   = reader.GetUInt32("category_id");
                            template.MainModelId  = reader.GetUInt32("main_model_id");
                            template.DoorModelId  = reader.GetUInt32("door_model_id", 0);
                            template.StairModelId = reader.GetUInt32("stair_model_id", 0);
                            template.AutoZ        = reader.GetBoolean("auto_z", true);
                            template.GateExists   = reader.GetBoolean("gate_exists", true);
                            template.Hp           = reader.GetInt32("hp");
                            template.RepairCost   = reader.GetUInt32("repair_cost");
                            template.GardenRadius = reader.GetFloat("garden_radius");
                            template.Family       = reader.GetString("family");
                            var taxationId = reader.GetUInt32("taxation_id");
                            template.Taxation            = houseTaxes.ContainsKey(taxationId) ? houseTaxes[taxationId] : null;
                            template.GuardTowerSettingId = reader.GetUInt32("guard_tower_setting_id", 0);
                            template.CinemaRadius        = reader.GetFloat("cinema_radius");
                            template.AutoZOffsetX        = reader.GetFloat("auto_z_offset_x");
                            template.AutoZOffsetY        = reader.GetFloat("auto_z_offset_y");
                            template.AutoZOffsetZ        = reader.GetFloat("auto_z_offset_z");
                            template.Alley              = reader.GetFloat("alley");
                            template.ExtraHeightAbove   = reader.GetFloat("extra_height_above");
                            template.ExtraHeightBelow   = reader.GetFloat("extra_height_below");
                            template.DecoLimit          = reader.GetUInt32("deco_limit");
                            template.AbsoluteDecoLimit  = reader.GetUInt32("absolute_deco_limit");
                            template.HousingDecoLimitId = reader.GetUInt32("housing_deco_limit_id", 0);
                            template.IsSellable         = reader.GetBoolean("is_sellable", true);
                            _housingTemplates.Add(template.Id, template);

                            var templateBindings = binding.Find(x => x.TemplateId.Contains(template.Id));
                            using (var command2 = connection.CreateCommand())
                            {
                                command2.CommandText =
                                    "SELECT * FROM housing_binding_doodads WHERE owner_id=@owner_id AND owner_type='Housing'";
                                command2.Prepare();
                                command2.Parameters.AddWithValue("owner_id", template.Id);
                                using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader()))
                                {
                                    var doodads = new List <HousingBindingDoodad>();
                                    while (reader2.Read())
                                    {
                                        var bindingDoodad = new HousingBindingDoodad();
                                        bindingDoodad.AttachPointId = reader2.GetUInt32("attach_point_id");
                                        bindingDoodad.DoodadId      = reader2.GetUInt32("doodad_id");

                                        if (templateBindings != null &&
                                            templateBindings.AttachPointId.ContainsKey(bindingDoodad.AttachPointId))
                                        {
                                            bindingDoodad.Position = templateBindings
                                                                     .AttachPointId[bindingDoodad.AttachPointId].Clone();
                                        }

                                        if (bindingDoodad.Position == null)
                                        {
                                            bindingDoodad.Position = new Point(0, 0, 0);
                                        }
                                        bindingDoodad.Position.WorldId = 1;

                                        doodads.Add(bindingDoodad);
                                    }

                                    template.HousingBindingDoodad = doodads.ToArray();
                                }
                            }
                        }
                    }
                }

                _log.Info("Loaded Housing Templates {0}", _housingTemplates.Count);

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM housing_build_steps";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var housingId = reader.GetUInt32("housing_id");
                            if (!_housingTemplates.ContainsKey(housingId))
                            {
                                continue;
                            }

                            var template = new HousingBuildStep();
                            template.Id         = reader.GetUInt32("id");
                            template.HousingId  = housingId;
                            template.Step       = reader.GetInt16("step");
                            template.ModelId    = reader.GetUInt32("model_id");
                            template.SkillId    = reader.GetUInt32("skill_id");
                            template.NumActions = reader.GetInt32("num_actions");

                            _housingTemplates[housingId].BuildSteps.Add(template.Step, template);
                        }
                    }
                }
            }

            _log.Info("Loading Housing...");
            using (var connection = MySQL.CreateConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = "SELECT * FROM housings";
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var templateId = reader.GetUInt32("template_id");
                            var house      = Create(templateId);
                            house.Id        = reader.GetUInt32("id");
                            house.AccountId = reader.GetUInt32("account_id");
                            house.OwnerId   = reader.GetUInt32("owner");
                            house.Position  =
                                new Point(reader.GetFloat("x"), reader.GetFloat("y"), reader.GetFloat("z"));
                            house.Position.RotationZ = reader.GetSByte("rotation_z");
                            house.Position.WorldId   = 1;
                            house.CurrentStep        = reader.GetInt32("current_step");
                            house.Permission         = reader.GetByte("permission");
                            _houses.Add(house.Id, house);
                        }
                    }
                }
            }

            _log.Info("Loaded Housing {0}", _houses.Count);
        }
Exemplo n.º 2
0
        public void Load()
        {
            _slaveTemplates = new Dictionary <uint, SlaveTemplate>();
            _activeSlaves   = new Dictionary <uint, Slave>();

            #region SQLLite

            using (var connection = SQLite.CreateConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM slaves";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new SlaveTemplate
                            {
                                Id                     = reader.GetUInt32("id"),
                                Name                   = reader.GetString("name"),
                                ModelId                = reader.GetUInt32("model_id"),
                                Mountable              = reader.GetBoolean("mountable"),
                                SpawnXOffset           = reader.GetFloat("spawn_x_offset"),
                                SpawnYOffset           = reader.GetFloat("spawn_y_offset"),
                                FactionId              = reader.GetUInt32("faction_id", 0),
                                Level                  = reader.GetUInt32("level"),
                                Cost                   = reader.GetInt32("cost"),
                                SlaveKindId            = reader.GetUInt32("slave_kind_id"),
                                SpawnValidAreaRance    = reader.GetUInt32("spawn_valid_area_range", 0),
                                SlaveInitialItemPackId = reader.GetUInt32("slave_initial_item_pack_id", 0),
                                SlaveCustomizingId     = reader.GetUInt32("slave_customizing_id", 0),
                                Customizable           = reader.GetBoolean("customizable", false)
                            };
                            _slaveTemplates.Add(template.Id, template);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM slave_initial_buffs";
                    command.Prepare();

                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new SlaveInitialBuffs
                            {
                                Id      = reader.GetUInt32("id"), // нет такого поля в 3.5.5.3
                                SlaveId = reader.GetUInt32("slave_id"),
                                BuffId  = reader.GetUInt32("buff_id")
                            };
                            if (_slaveTemplates.ContainsKey(template.SlaveId))
                            {
                                _slaveTemplates[template.SlaveId].InitialBuffs.Add(template);
                            }
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM slave_passive_buffs";
                    command.Prepare();

                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new SlavePassiveBuffs
                            {
                                Id            = reader.GetUInt32("id"), // нет такого поля в 3.5.5.3
                                OwnerId       = reader.GetUInt32("owner_id"),
                                OwnerType     = reader.GetString("owner_type"),
                                PassiveBuffId = reader.GetUInt32("passive_buff_id")
                            };
                            if (_slaveTemplates.ContainsKey(template.OwnerId))
                            {
                                _slaveTemplates[template.OwnerId].PassiveBuffs.Add(template);
                            }
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM slave_doodad_bindings ORDER BY owner_id ASC";
                    command.Prepare();

                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        //var step = 0U;
                        while (reader.Read())
                        {
                            var template = new SlaveDoodadBindings();
                            template.Id = reader.GetUInt32("id"); // нет такого поля в 3.5.5.3
                            //template.Id = step++;
                            template.OwnerId       = reader.GetUInt32("owner_id");
                            template.OwnerType     = reader.GetString("owner_type");
                            template.AttachPointId = reader.GetInt32("attach_point_id");
                            template.DoodadId      = reader.GetUInt32("doodad_id");
                            template.Persist       = reader.GetBoolean("persist");
                            template.Scale         = reader.GetFloat("scale");
                            if (_slaveTemplates.ContainsKey(template.OwnerId))
                            {
                                _slaveTemplates[template.OwnerId].DoodadBindings.Add(template);
                            }
                        }
                    }
                }
            }

            #endregion
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        public void Load()
        {
            _shipyards = new Dictionary <uint, ShipyardsTemplate>();

            _log.Info("Loading Shipyards...");
            using (var connection = SQLite.CreateConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM shipyards";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new ShipyardsTemplate
                            {
                                Id               = reader.GetUInt32("id"),
                                Name             = reader.GetString("name"),
                                MainModelId      = reader.GetUInt32("main_model_id"),
                                ItemId           = reader.GetUInt32("item_id"),
                                SpawnOffsetFront = reader.GetFloat("spawn_offset_front"),
                                SpawnOffsetZ     = reader.GetFloat("spawn_offset_z"),
                                BuildRadius      = reader.GetInt32("build_radius"),
                                TaxDuration      = reader.GetInt32("tax_duration", 0),
                                OriginItemId     = reader.GetUInt32("origin_item_id", 0),
                                TaxationId       = reader.GetInt32("taxation_id")
                            };
                            _shipyards.Add(template.Id, template);
                        }
                    }
                }
                _log.Info("Loaded {0} shipyards", _shipyards.Count);

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM shipyard_steps";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new ShipyardSteps()
                            {
                                Id         = reader.GetUInt32("id"),
                                ShipyardId = reader.GetUInt32("shipyard_id"),
                                Step       = reader.GetInt32("step"),
                                ModelId    = reader.GetUInt32("model_id"),
                                SkillId    = reader.GetUInt32("skill_id"),
                                NumActions = reader.GetInt32("num_actions"),
                                MaxHp      = reader.GetInt32("max_hp")
                            };
                            if (_shipyards.ContainsKey(template.ShipyardId))
                            {
                                _shipyards[template.ShipyardId].ShipyardSteps.Add(template.Step, template);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        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");
            }
        }
Exemplo n.º 6
0
        public void Load()
        {
            _zones           = new Dictionary <uint, Zone>();
            _groups          = new Dictionary <ushort, ZoneGroup>();
            _conflicts       = new Dictionary <ushort, ZoneConflict>();
            _groupBannedTags = new Dictionary <uint, ZoneGroupBannedTag>();
            _climateElem     = new Dictionary <uint, ZoneClimateElem>();
            _log.Info("Loading ZoneManager...");
            using (var connection = SQLite.CreateConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM zones";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new Zone();
                            template.Id            = reader.GetUInt32("id");
                            template.Name          = (string)reader.GetValue("name");
                            template.ZoneKey       = reader.GetUInt32("zone_key");
                            template.GroupId       = reader.GetUInt32("group_id", 0);
                            template.Closed        = reader.GetBoolean("closed", true);
                            template.FactionId     = reader.GetUInt32("faction_id", 0);
                            template.ZoneClimateId = reader.GetUInt32("zone_climate_id", 0);
                            _zones.Add(template.ZoneKey, template);
                        }
                    }
                }

                _log.Info("Loaded {0} zones", _zones.Count);

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM zone_groups";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new ZoneGroup();
                            template.Id                    = reader.GetUInt16("id");
                            template.Name                  = (string)reader.GetValue("name");
                            template.X                     = reader.GetFloat("x");
                            template.Y                     = reader.GetFloat("y");
                            template.Width                 = reader.GetFloat("w");
                            template.Hight                 = reader.GetFloat("h");
                            template.TargetId              = reader.GetUInt32("target_id");
                            template.FactionChatRegionId   = reader.GetUInt32("faction_chat_region_id");
                            template.PirateDesperado       = reader.GetBoolean("pirate_desperado", true);
                            template.FishingSeaLootPackId  = reader.GetUInt32("fishing_sea_loot_pack_id", 0);
                            template.FishingLandLootPackId = reader.GetUInt32("fishing_land_loot_pack_id", 0);
                            // TODO 1.2 // template.BuffId = reader.GetUInt32("buff_id", 0);
                            _groups.Add(template.Id, template);
                        }
                    }
                }

                _log.Info("Loaded {0} groups", _groups.Count);

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM conflict_zones";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var zoneGroupId = reader.GetUInt16("zone_group_id");
                            if (_groups.ContainsKey(zoneGroupId))
                            {
                                var template = new ZoneConflict(_groups[zoneGroupId]);
                                template.ZoneGroupId = zoneGroupId;

                                for (var i = 0; i < 5; i++)
                                {
                                    template.NumKills[i]  = reader.GetInt32($"num_kills_{i}");
                                    template.NoKillMin[i] = reader.GetInt32($"no_kill_min_{i}");
                                }

                                template.ConflictMin = reader.GetInt32("conflict_min");
                                template.WarMin      = reader.GetInt32("war_min");
                                template.PeaceMin    = reader.GetInt32("peace_min");

                                template.PeaceProtectedFactionId = reader.GetUInt32("peace_protected_faction_id", 0);
                                template.NuiaReturnPointId       = reader.GetUInt32("nuia_return_point_id", 0);
                                template.HariharaReturnPointId   = reader.GetUInt32("harihara_return_point_id", 0);
                                template.WarTowerDefId           = reader.GetUInt32("war_tower_def_id", 0);
                                // TODO 1.2 // template.PeaceTowerDefId = reader.GetUInt32("peace_tower_def_id", 0);

                                _groups[zoneGroupId].Conflict = template;
                                _conflicts.Add(zoneGroupId, template);
                            }
                            else
                            {
                                _log.Warn("ZoneGroupId: {1} doesn't exist for conflict", zoneGroupId);
                            }
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM zone_group_banned_tags";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new ZoneGroupBannedTag();
                            template.Id          = reader.GetUInt32("id");
                            template.ZoneGroupId = reader.GetUInt32("zone_group_id");
                            template.TagId       = reader.GetUInt32("tag_id");
                            // TODO 1.2 // template.BannedPeriodsId = reader.GetUInt32("banned_periods_id");
                            _groupBannedTags.Add(template.Id, template);
                        }
                    }
                }

                _log.Info("Loaded {0} group banned tags", _groupBannedTags.Count);
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM zone_climate_elems";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new ZoneClimateElem();
                            template.Id            = reader.GetUInt32("id");
                            template.ZoneClimateId = reader.GetUInt32("zone_climate_id");
                            template.ClimateId     = reader.GetUInt32("climate_id");
                            _climateElem.Add(template.Id, template);
                        }
                    }
                }

                _log.Info("Loaded {0} climate elems", _climateElem.Count);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        public void Load()
        {
            _templates     = new Dictionary <uint, DoodadTemplate>();
            _funcs         = new Dictionary <uint, List <DoodadFunc> >();
            _phaseFuncs    = new Dictionary <uint, List <DoodadFunc> >();
            _funcTemplates = new Dictionary <string, Dictionary <uint, DoodadFuncTemplate> >();
            foreach (var type in Helpers.GetTypesInNamespace("AAEmu.Game.Models.Game.DoodadObj.Funcs"))
            {
                if (type.BaseType == typeof(DoodadFuncTemplate))
                {
                    _funcTemplates.Add(type.Name, new Dictionary <uint, DoodadFuncTemplate>());
                }
            }

            using (var connection = SQLite.CreateConnection())
            {
                _log.Info("Loading doodad templates...");
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * from doodad_almighties";
                    command.Prepare();
                    using (var sqliteDataReader = command.ExecuteReader())
                        using (var reader = new SQLiteWrapperReader(sqliteDataReader))
                        {
                            while (reader.Read())
                            {
                                var template = new DoodadTemplate();
                                template.Id                  = reader.GetUInt32("id");
                                template.OnceOneMan          = reader.GetBoolean("once_one_man", true);
                                template.OnceOneInteraction  = reader.GetBoolean("once_one_interaction", true);
                                template.MgmtSpawn           = reader.GetBoolean("mgmt_spawn", true);
                                template.Percent             = reader.GetInt32("percent", 0);
                                template.MinTime             = reader.GetInt32("min_time", 0);
                                template.MaxTime             = reader.GetInt32("max_time", 0);
                                template.ModelKindId         = reader.GetUInt32("model_kind_id");
                                template.UseCreatorFaction   = reader.GetBoolean("use_creator_faction", true);
                                template.ForceTodTopPriority = reader.GetBoolean("force_tod_top_priority", true);
                                template.MilestoneId         = reader.GetUInt32("milestone_id", 0);
                                template.GroupId             = reader.GetUInt32("group_id");
                                template.UseTargetDecal      = reader.GetBoolean("use_target_decal", true);
                                template.UseTargetSilhouette = reader.GetBoolean("use_target_silhouette", true);
                                template.UseTargetHighlight  = reader.GetBoolean("use_target_highlight", true);
                                template.TargetDecalSize     = reader.GetFloat("target_decal_size", 0);
                                template.SimRadius           = reader.GetInt32("sim_radius", 0);
                                template.CollideShip         = reader.GetBoolean("collide_ship", true);
                                template.CollideVehicle      = reader.GetBoolean("collide_vehicle", true);
                                template.ClimateId           = reader.GetUInt32("climate_id", 0);
                                template.SaveIndun           = reader.GetBoolean("save_indun", true);
                                template.ForceUpAction       = reader.GetBoolean("force_up_action", true);
                                template.Parentable          = reader.GetBoolean("parentable", true);
                                template.Childable           = reader.GetBoolean("childable", true);
                                template.FactionId           = reader.GetUInt32("faction_id");
                                template.GrowthTime          = reader.GetInt32("growth_time", 0);
                                template.DespawnOnCollision  = reader.GetBoolean("despawn_on_collision", true);
                                template.NoCollision         = reader.GetBoolean("no_collision", true);
                                // TODO 1.2 template.RestrictZoneId = reader.IsDBNull("restrict_zone_id") ? 0 : reader.GetUInt32("restrict_zone_id");

                                using (var commandChild = connection.CreateCommand())
                                {
                                    commandChild.CommandText =
                                        "SELECT * FROM doodad_func_groups WHERE doodad_almighty_id = @doodad_almighty_id";
                                    commandChild.Prepare();
                                    commandChild.Parameters.AddWithValue("doodad_almighty_id", template.Id);
                                    using (var sqliteDataReaderChild = commandChild.ExecuteReader())
                                        using (var readerChild = new SQLiteWrapperReader(sqliteDataReaderChild))
                                        {
                                            while (readerChild.Read())
                                            {
                                                var funcGroups = new DoodadFuncGroups();
                                                funcGroups.Id          = readerChild.GetUInt32("id");
                                                funcGroups.GroupKindId = readerChild.GetUInt32("doodad_func_group_kind_id");
                                                template.FuncGroups.Add(funcGroups);
                                            }
                                        }
                                }

                                _templates.Add(template.Id, template);
                            }
                        }
                }

                _log.Info("Loaded {0} doodad templates", _templates.Count);

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM doodad_funcs";
                    command.Prepare();
                    using (var sqliteDataReader = command.ExecuteReader())
                        using (var reader = new SQLiteWrapperReader(sqliteDataReader))
                        {
                            while (reader.Read())
                            {
                                var func = new DoodadFunc();
                                func.GroupId   = reader.GetUInt32("doodad_func_group_id");
                                func.FuncId    = reader.GetUInt32("actual_func_id");
                                func.FuncType  = reader.GetString("actual_func_type");
                                func.NextPhase = reader.GetInt32("next_phase", -1); // TODO next_phase = 0?
                                func.SkillId   = reader.GetUInt32("func_skill_id", 0);
                                func.PermId    = reader.GetUInt32("perm_id");
                                func.Count     = reader.GetInt32("act_count", 0);
                                List <DoodadFunc> list;
                                if (_funcs.ContainsKey(func.GroupId))
                                {
                                    list = _funcs[func.GroupId];
                                }
                                else
                                {
                                    list = new List <DoodadFunc>();
                                    _funcs.Add(func.GroupId, list);
                                }

                                list.Add(func);
                            }
                        }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM doodad_phase_funcs";
                    command.Prepare();
                    using (var sqliteDataReader = command.ExecuteReader())
                        using (var reader = new SQLiteWrapperReader(sqliteDataReader))
                        {
                            while (reader.Read())
                            {
                                var func = new DoodadFunc();
                                func.GroupId  = reader.GetUInt32("doodad_func_group_id");
                                func.FuncId   = reader.GetUInt32("actual_func_id");
                                func.FuncType = reader.GetString("actual_func_type");
                                List <DoodadFunc> list;
                                if (_phaseFuncs.ContainsKey(func.GroupId))
                                {
                                    list = _phaseFuncs[func.GroupId];
                                }
                                else
                                {
                                    list = new List <DoodadFunc>();
                                    _phaseFuncs.Add(func.GroupId, list);
                                }

                                list.Add(func);
                            }
                        }
                }
            }
        }
Exemplo n.º 9
0
        public void Load()
        {
            _housing      = new Dictionary <uint, HousingTemplate>();
            _housingAreas = new Dictionary <uint, HousingAreas>();
            _houseTaxes   = new Dictionary <uint, HouseTaxes>();
            _log.Info("Loading Housing...");

            using (var connection = SQLite.CreateConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM housings";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new HousingTemplate();
                            template.Id                  = reader.GetUInt32("id");
                            template.Name                = reader.GetString("name");
                            template.CategoryId          = reader.GetUInt32("category_id");
                            template.MainModelId         = reader.GetUInt32("main_model_id");
                            template.DoorModelId         = reader.GetUInt32("door_model_id", 0);
                            template.StairModelId        = reader.GetUInt32("stair_model_id", 0);
                            template.AutoZ               = reader.GetBoolean("auto_z", true);
                            template.GateExists          = reader.GetBoolean("gate_exists", true);
                            template.Hp                  = reader.GetInt32("hp");
                            template.RepairCost          = reader.GetUInt32("repair_cost");
                            template.GardenRadius        = reader.GetFloat("garden_radius");
                            template.Family              = reader.GetString("family");
                            template.TaxationId          = reader.GetUInt32("taxation_id");
                            template.GuardTowerSettingId = reader.GetUInt32("guard_tower_setting_id", 0);
                            template.CinemaRadius        = reader.GetFloat("cinema_radius");
                            template.AutoZOffsetX        = reader.GetFloat("auto_z_offset_x");
                            template.AutoZOffsetY        = reader.GetFloat("auto_z_offset_y");
                            template.AutoZOffsetZ        = reader.GetFloat("auto_z_offset_z");
                            template.Alley               = reader.GetFloat("alley");
                            template.ExtraHeightAbove    = reader.GetFloat("extra_height_above");
                            template.ExtraHeightBelow    = reader.GetFloat("extra_height_below");
                            template.DecoLimit           = reader.GetUInt32("deco_limit");
                            template.AbsoluteDecoLimit   = reader.GetUInt32("absolute_deco_limit");
                            template.HousingDecoLimitId  = reader.GetUInt32("housing_deco_limit_id", 0);
                            template.IsSellable          = reader.GetBoolean("is_sellable", true);
                            _housing.Add(template.Id, template);

                            using (var command2 = connection.CreateCommand())
                            {
                                command2.CommandText =
                                    "SELECT * FROM housing_binding_doodads WHERE owner_id=@owner_id AND owner_type='Housing'";
                                command2.Prepare();
                                command2.Parameters.AddWithValue("owner_id", template.Id);
                                using (var reader2 = new SQLiteWrapperReader(command2.ExecuteReader()))
                                {
                                    var doodads = new List <HousingBindingDoodad>();
                                    while (reader2.Read())
                                    {
                                        var bindingDoodad = new HousingBindingDoodad();
                                        bindingDoodad.AttachPointId = reader2.GetUInt32("attach_point_id");
                                        bindingDoodad.DoodadId      = reader2.GetUInt32("doodad_id");

                                        doodads.Add(bindingDoodad);
                                    }

                                    template.HousingBindingDoodad = doodads.ToArray();
                                }
                            }
                        }
                    }
                }
                _log.Info("Loaded Housing", _housing.Count);

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM housing_build_steps";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var housingId = reader.GetUInt32("housing_id");
                            if (!_housing.ContainsKey(housingId))
                            {
                                continue;
                            }

                            var template = new HousingBuildStep();
                            template.Id         = reader.GetUInt32("id");
                            template.HousingId  = housingId;
                            template.Step       = reader.GetInt16("step");
                            template.ModelId    = reader.GetUInt32("model_id");
                            template.SkillId    = reader.GetUInt32("skill_id");
                            template.NumActions = reader.GetInt32("num_actions");

                            _housing[housingId].BuildSteps.Add(template.Step, template);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM housing_areas";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new HousingAreas();
                            template.Id      = reader.GetUInt32("id");
                            template.Name    = reader.GetString("name");
                            template.GroupId = reader.GetUInt32("housing_group_id");
                            _housingAreas.Add(template.Id, template);
                        }
                    }
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM taxations";
                    command.Prepare();
                    using (var reader = new SQLiteWrapperReader(command.ExecuteReader()))
                    {
                        while (reader.Read())
                        {
                            var template = new HouseTaxes();
                            template.Id   = reader.GetUInt32("id");
                            template.Tax  = reader.GetUInt32("tax");
                            template.Desc = reader.GetString("desc");
                            template.Show = reader.GetBoolean("show", true);
                            _houseTaxes.Add(template.Id, template);
                        }
                    }
                }
            }
        }