/// <summary> /// Loads all the revive spots. /// </summary> /// <returns>Returns true if the revive spots were loaded.</returns> public static bool LoadReviveSpots() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\tLoading Revive Spots..."); using (var revive = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(revive, SqlCommandType.SELECT, false)) { cmd.Finish("DB_ReviveSpots"); } while (revive.Read()) { Maps.MapPoint revivepoint = new ProjectX_V3_Game.Maps.MapPoint(revive.ReadUInt16("ReviveTargetMapID"), revive.ReadUInt16("ReviveX"), revive.ReadUInt16("ReviveY")); ushort frommap = revive.ReadUInt16("ReviveMapID"); if (!Core.Kernel.Maps.Contains(frommap)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load revive spots. Failed at map: {0}, perhaps the map is not existing.", revivepoint.MapID); Console.ResetColor(); return false; } Core.Kernel.Maps[frommap].RevivePoint = revivepoint; } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\tLoaded Revive Spots..."); return true; }
public static void LoadBots() { #if SPAWN_BOTS #region AfkBots using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, false)) { cmd.Finish("DB_BotInfo"); } while (sql.Read()) { Entities.AIBot bot = new ProjectX_V3_Game.Entities.AIBot(); bot.LoadBot(Enums.BotType.AFKBot, sql.ReadInt32("BotRefID"), new Maps.MapPoint( sql.ReadUInt16("BotMapID"), sql.ReadUInt16("BotX"), sql.ReadUInt16("BotY")), null); } } #endregion #endif }
public static bool LoadPortals() { using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, false)) { cmd.Finish("DB_Portals"); } while (sql.Read()) { if (!Core.Kernel.Portals.TryAdd( new Core.PortalPoint(sql.ReadUInt16("StartMap"), sql.ReadUInt16("StartX"), sql.ReadUInt16("StartY")), new Core.PortalPoint(sql.ReadUInt16("EndMap"), sql.ReadUInt16("EndX"), sql.ReadUInt16("EndY")))) { return false; } } } return true; }
/// <summary> /// Loads all the spells. /// </summary> /// <returns></returns> public static bool LoadSpells() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\tLoading Spells..."); using (var spellinfo = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(spellinfo, SqlCommandType.SELECT, false)) { cmd.Finish("DB_SpellInfo"); } while (spellinfo.Read()) { Data.Spell spell = new ProjectX_V3_Game.Data.Spell(); spell.ID = spellinfo.ReadUInt16("SpellID"); if (spell.ID == 0) { return false; } spell.SpellID = spellinfo.ReadUInt16("Type"); if (spell.SpellID == 0) { return false; } spell.Sort = spellinfo.ReadByte("Sort"); spell.Crime = spellinfo.ReadBoolean("Crime"); spell.Ground = spellinfo.ReadBoolean("Ground"); spell.Multi = spellinfo.ReadBoolean("Multi"); spell.Target = spellinfo.ReadByte("Target"); spell.Level = spellinfo.ReadByte("SpellLevel"); spell.UseMP = spellinfo.ReadUInt16("UseMP"); spell.Power = spellinfo.ReadUInt16("Power"); if (spell.Power == 0) spell.PowerPercentage = 1; else spell.PowerPercentage = (float)(spell.Power % 1000) / 100; spell.IntoneSpeed = spellinfo.ReadUInt16("IntoneSpeed"); spell.Percentage = spellinfo.ReadByte("SpellPercent"); spell.Duration = spellinfo.ReadByte("StepSecs"); spell.Range = spellinfo.ReadUInt16("Range"); spell.Sector = spell.Range * 20; spell.Distance = spellinfo.ReadUInt16("Distance"); if (spell.Distance >= 4) spell.Distance--; if (spell.Distance > 17) spell.Distance = 17; spell.Status = spellinfo.ReadUInt64("Status"); spell.NeedExp = spellinfo.ReadUInt32("NeedExp"); spell.NeedLevel = spellinfo.ReadByte("NeedLevel"); spell.UseXP = spellinfo.ReadByte("UseXP"); spell.WeaponSubtype = spellinfo.ReadUInt16("WeaponSubtype"); spell.UseEP = spellinfo.ReadByte("UseEP"); spell.NextMagic = spellinfo.ReadUInt16("NextMagic"); spell.UseItem = spellinfo.ReadByte("UseItem"); spell.UseItemNum = spellinfo.ReadByte("UseItemNum"); if (Core.Kernel.SpellInfos.ContainsKey(spell.SpellID)) { Core.Kernel.SpellInfos[spell.SpellID].TryAdd(spell.Level, spell); } else { if (!Core.Kernel.SpellInfos.TryAdd(spell.SpellID)) return false; if (!Core.Kernel.SpellInfos[spell.SpellID].TryAdd(spell.Level, spell)) return false; } switch (spell.SpellID) { case 5010: case 7020: case 1290: case 1260: case 5030: case 5040: case 7000: case 7010: case 7030: case 7040: case 1250: case 5050: case 5020: case 10490: case 1300: if (spell.Distance >= 3) spell.Distance = 3; if (spell.Range > 3) spell.Range = 3; if (!Core.Kernel.WeaponSpells.ContainsKey(spell.WeaponSubtype)) { if (!Core.Kernel.WeaponSpells.TryAdd(spell.WeaponSubtype, spell.SpellID)) { return false; } } break; } } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\tLoaded {0} Spells...", Core.Kernel.SpellInfos.Count); return true; }
/// <summary> /// Loads all the items. /// </summary> /// <returns>Returns true if the items were loaded.</returns> public static bool LoadItemInfos() { Console.ForegroundColor = ConsoleColor.Yellow; string wrt = "\tLoading Items..."; /*using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, false)) { cmd.Finish("DB_ItemInfo"); } //int count = 0; while (sql.Read()) { count++; Console.WriteLine("\tLoaded {0} item additions...", count); Console.Clear(); } } */ //Console.WriteLine("SWAG"); //return true; Console.WriteLine(wrt); System.Threading.Thread.Sleep(2000); int nameduplicates = 0; int loaded = 0; using (var item = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(item, SqlCommandType.SELECT, false)) { cmd.Finish("DB_ItemInfo"); } while (item.Read()) { Data.ItemInfo info = new ProjectX_V3_Game.Data.ItemInfo(); info.ItemID = item.ReadUInt32("ItemID"); info.Name = item.ReadString("Name"); byte prof = item.ReadByte("Profession"); if (prof == 190) info.Profession = Enums.Class.InternTaoist; info.RequiredProf = item.ReadByte("WeaponSkill"); info.RequiredLevel = item.ReadByte("RequiredLevel"); info.Sex = (Enums.Sex)Enum.Parse(typeof(Enums.Sex), item.ReadString("Sex")); info.RequiredStrength = item.ReadUInt16("RequiredStrength"); info.RequiredAgility = item.ReadUInt16("RequiredAgility"); info.RequiredVitality = item.ReadUInt16("RequiredVitality"); info.RequiredSpirit = item.ReadUInt16("RequiredSpirit"); info.Monopoly = item.ReadByte("Monopoly"); info.Weight = item.ReadUInt16("Weight"); info.Price = item.ReadUInt32("Price"); info.ActionID = item.ReadUInt32("ActionID"); info.MaxAttack = item.ReadUInt16("MaxAttack"); info.MinAttack = item.ReadUInt16("MinAttack"); info.Defense = item.ReadUInt16("Defense"); info.Dexterity = item.ReadUInt16("Dexterity"); info.Dodge = item.ReadUInt16("Dodge"); info.HP = item.ReadUInt16("Life"); info.MP = item.ReadUInt16("Mana"); info.AmountLimit = item.ReadUInt16("Amount"); if (info.IsArrow()) { info.MaxDura = (short)info.AmountLimit; info.CurrentDura = info.MaxDura; } info.Ident = item.ReadByte("Ident"); info.StGem1 = item.ReadByte("Gem1"); info.StGem2 = item.ReadByte("Gem2"); info.Magic1 = item.ReadUInt16("Magic1"); info.Magic2 = item.ReadByte("Magic2"); info.Magic3 = item.ReadByte("Magic3"); info.Data = item.ReadInt32("Data"); info.MagicAttack = item.ReadUInt16("MagicAttack"); info.MagicDefense = item.ReadUInt16("MagicDefense"); info.AttackRange = item.ReadUInt16("AttackRange"); info.AttackSpeed = item.ReadUInt16("AttackSpeed"); info.FrayMode = item.ReadByte("FrayMode"); info.RepairMode = item.ReadByte("RepairMode"); info.TypeMask = item.ReadByte("TypeMask"); info.CPPrice = item.ReadUInt32("EMoneyPrice"); info.Unknown1 = item.ReadUInt32("Unknown1"); info.Unknown2 = item.ReadUInt32("Unknown2"); info.CriticalStrike = item.ReadUInt32("CriticalStrike"); info.SkillCriticalStrike = item.ReadUInt32("SkillCriticalStrike"); info.Immunity = item.ReadUInt32("Immunity"); info.Penetration = item.ReadUInt32("Penetration"); info.Block = item.ReadUInt32("Block"); info.BreakThrough = item.ReadUInt32("BreakThrough"); info.CounterAction = item.ReadUInt32("CounterAction"); info.StackLimit = item.ReadUInt32("StackLimit"); info.ResistMetal = item.ReadUInt32("ResistMetal"); info.ResistWood = item.ReadUInt32("ResistWood"); info.ResistWater = item.ReadUInt32("ResistWater"); info.ResistFire = item.ReadUInt32("ResistFire"); info.ResistEarth = item.ReadUInt32("ResistEarth"); info.TypeName = item.ReadString("TypeName"); info.Description = item.ReadString("Description"); info.NameColor = item.ReadUInt32("NameColor"); info.DragonSoulPhase = item.ReadUInt32("DragonSoulPhase"); info.DragonSoulRequirements = item.ReadUInt32("DragonSoulRequirements"); info.Plus = item.ReadByte("StaticPlus"); if (info.IsShield()) info.ItemType = Enums.ItemType.Shield; else if (info.IsArmor()) info.ItemType = Enums.ItemType.Armor; else if (info.IsHeadgear()) info.ItemType = Enums.ItemType.Head; else if (info.IsOneHand()) info.ItemType = Enums.ItemType.OneHand; else if (info.IsTwoHand()) info.ItemType = Enums.ItemType.TwoHand; else if (info.IsArrow()) info.ItemType = Enums.ItemType.Arrow; else if (info.IsBow()) info.ItemType = Enums.ItemType.Bow; else if (info.IsNecklace()) info.ItemType = Enums.ItemType.Necklace; else if (info.IsRing()) info.ItemType = Enums.ItemType.Ring; else if (info.IsBoots()) info.ItemType = Enums.ItemType.Boots; else if (info.IsGarment()) info.ItemType = Enums.ItemType.Garment; else if (info.IsFan()) info.ItemType = Enums.ItemType.Fan; else if (info.IsTower()) info.ItemType = Enums.ItemType.Tower; else if (info.IsSteed()) info.ItemType = Enums.ItemType.Steed; else if (info.IsBottle()) info.ItemType = Enums.ItemType.Bottle; else if (info.IsMountArmor()) info.ItemType = Enums.ItemType.SteedArmor; else info.ItemType = Enums.ItemType.Misc; if (Core.Kernel.ItemInfos.Contains(info.Name)) { nameduplicates++; } if (!Core.Kernel.ItemInfos.TryAddAndDismiss(info.ItemID, info.Name, info)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tFailed to load items. [ADD]" + Core.Kernel.ItemInfos.Count); Console.ResetColor(); return false; } /*if (!Core.Kernel.SortedItemInfos.Contains(info.ItemID)) { if (!Core.Kernel.SortedItemInfos.TryAdd(info.ItemID, info.Name, new System.Collections.Concurrent.ConcurrentDictionary<byte, Data.ItemInfo>())) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tFailed to load items. [SORTED]" + Core.Kernel.ItemInfos.Count); Console.ResetColor(); return false; } } if (!Core.Kernel.SortedItemInfos.selectorCollection2[info.Name].TryAdd(info.Quality, info)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tFailed to load items. [SORTED : NAME]" + Core.Kernel.ItemInfos.Count); Console.ResetColor(); return false; }*/ Console.Clear(); Console.WriteLine("{0}{1}\tLoaded {2} items... Duplicates so far: {3}", wrt, Environment.NewLine, loaded++, nameduplicates); } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\tLoaded {0} Items... Duplicate names: {1}", Core.Kernel.ItemInfos.Count, nameduplicates); return true; }
/// <summary> /// Loads all the npc informations and spawns. /// </summary> /// <returns>Returns true if the the infos/spawns were loaded.</returns> public static bool LoadNPCInfo() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\tLoading NPCs..."); using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, false)) { cmd.Finish("DB_NPCInfo"); } while (sql.Read()) { Entities.NPC npc = new ProjectX_V3_Game.Entities.NPC(); npc.EntityUID = sql.ReadUInt32("NPCID"); ushort mapid = sql.ReadUInt16("MapID"); if (mapid == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load npcs. [MAPID]"); Console.ResetColor(); return false; } Maps.Map map; Core.Kernel.Maps.TrySelect(mapid, out map); npc.Map = map; if (!npc.Map.EnterMap(npc)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load npcs. [MAP]"); Console.ResetColor(); return false; } npc.Mesh = sql.ReadUInt16("Mesh"); npc.Flag = sql.ReadUInt32("Flag"); npc.Name = sql.ReadString("NPCName"); npc.X = sql.ReadUInt16("X"); npc.Y = sql.ReadUInt16("Y"); npc.NPCType = (Enums.NPCType)Enum.Parse(typeof(Enums.NPCType), sql.ReadString("Type")); npc.Avatar = sql.ReadByte("Avatar"); if (!Core.Kernel.NPCs.TryAdd(npc.EntityUID, npc)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load npcs. [ADD]"); Console.ResetColor(); return false; } } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\tLoaded {0} NPCs...", Core.Kernel.NPCs.Count); return true; }
/// <summary> /// Loads all the shopflag informations and spawns. /// </summary> /// <returns>Returns true if the the infos/spawns were loaded.</returns> public static bool LoadShopFlags() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\tLoading ShopFlags..."); int NpcCount = Core.Kernel.NPCs.Count; using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, false)) { cmd.Finish("DB_ShopFlags"); } while (sql.Read()) { Entities.NPC npc = new ProjectX_V3_Game.Entities.NPC(); npc.EntityUID = sql.ReadUInt32("ShopFlagID"); ushort mapid = sql.ReadUInt16("ShopFlagMapID"); if (mapid == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load shopflags. [MAPID]"); Console.ResetColor(); return false; } Maps.Map map; Core.Kernel.Maps.TrySelect(mapid, out map); npc.Map = map; if (!npc.Map.EnterMap(npc)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load shopflags. [MAP]"); Console.ResetColor(); return false; } npc.Mesh = sql.ReadUInt16("ShopFlagMesh"); npc.Flag = sql.ReadUInt32("ShopFlagFlag"); npc.Name = ""; npc.X = sql.ReadUInt16("ShopFlagX"); npc.Y = sql.ReadUInt16("ShopFlagY"); npc.NPCType = Enums.NPCType.ShopFlag; npc.Avatar = 0; if (!Core.Kernel.NPCs.TryAdd(npc.EntityUID, npc)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load shopflags. [ADD]"); Console.ResetColor(); return false; } } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\tLoaded {0} ShopFlags...", (Core.Kernel.NPCs.Count - NpcCount)); return true; }
/// <summary> /// Loads the map info. /// </summary> /// <returns>Returns true if the maps were loaded.</returns> public static bool LoadMaps() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\tLoading Maps..."); using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, false)) { cmd.Finish("DB_MapInfo"); } while (sql.Read()) { Maps.Map map = new ProjectX_V3_Game.Maps.Map( sql.ReadUInt16("MapID"), sql.ReadString("Name")); if (map.MapID == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load maps. [MAPID]"); Console.ResetColor(); return false; } map.MapType = (Enums.MapType)Enum.Parse(typeof(Enums.MapType), sql.ReadString("MapType")); ushort dmap = sql.ReadUInt16("DMapInfo"); if (dmap > 0) map.DMapInfo = dmap; map.InheritanceMap = sql.ReadUInt16("InheritanceMap"); using (var sqlflags = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd2 = new SqlCommandBuilder(sqlflags, SqlCommandType.SELECT, true)) { cmd2.AddWhereValue("MapID", map.MapID); cmd2.Finish("DB_MapFlags"); } while (sqlflags.Read()) { Enums.MapTypeFlags flag = (Enums.MapTypeFlags)Enum.Parse(typeof(Enums.MapTypeFlags), sqlflags.ReadString("Flag")); if (!map.Flags.TryAdd((ulong)flag, flag)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load maps. [FLAGS] Failed at ID: {0}", map.MapID); Console.ResetColor(); return false; } } } if (!Core.Kernel.Maps.TryAdd(map.MapID, map.Name, map)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to load maps. [MAP] Failed at ID: {0}", map.MapID); Console.ResetColor(); return false; } } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\tLoaded {0} Maps...", Core.Kernel.Maps.Count); return true; }
public static bool LoadMonsterSpawns() { Console.ForegroundColor = ConsoleColor.Yellow; string wrt = "\tLoading Monster Spawns..."; Console.WriteLine(wrt); int SpawnCount = 0; int GuardSpawnCount = 0; using (var spawn = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(spawn, SqlCommandType.SELECT, false)) { cmd.Finish("DB_MobSpawns"); } while (spawn.Read()) { ushort mapid = spawn.ReadUInt16("MapID"); Maps.Map map; if (!Core.Kernel.Maps.TrySelect(mapid, out map)) { return false; } ushort CenterX = spawn.ReadUInt16("CenterX"); ushort CenterY = spawn.ReadUInt16("CenterY"); int Range = spawn.ReadUInt16("Range"); // int DropData = spawn.ReadInt32("DropID"); int Monster = spawn.ReadInt32("MonsterID"); int MobCount = spawn.ReadInt32("Count"); if (CenterX > 0 && CenterY > 0 && Range > 0 && Monster > 0 && MobCount > 0) { for (int j = 0; j < MobCount; j++) { Entities.Monster spawnmob = Core.Kernel.Monsters[Monster].Copy(); spawnmob.MobID = Monster; spawnmob.Direction = (byte)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(0, 8); if (!map.EnterMap(spawnmob)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[MAP] Failed to load spawns. Failed at Map: {0} and MobID: {1}", mapid, Monster); Console.ResetColor(); return false; } Maps.MapPoint Location = spawnmob.Map.CreateAvailableLocation<Entities.Monster>(CenterX, CenterY, Range); if (Location != null) { spawnmob.X = Location.X; spawnmob.Y = Location.Y; spawnmob.OriginalRange = Range; spawnmob.OriginalX = CenterX; spawnmob.OriginalY = CenterY; spawnmob.DropData = Core.Kernel.DropData[map.MapID].Copy(); if (((byte)spawnmob.Behaviour) < 3 || spawnmob.Behaviour == Enums.MonsterBehaviour.PhysicalGuard) // physical guards should walk around { #if SPAWN_MOBS Threads.MonsterThread.AddToMonsterThread(spawnmob, false); SpawnCount++; #endif } else { Threads.MonsterThread.AddToMonsterThread(spawnmob, true); GuardSpawnCount++; } } else spawnmob.Map.LeaveMap(spawnmob); // there was no location available Console.Clear(); Console.WriteLine(wrt); Console.WriteLine("\tLoaded {0} Monster Spawns and {1} Guard Spawns...", SpawnCount, GuardSpawnCount); } } } } return true; }
/// <summary> /// Loads all the data of a character. /// </summary> /// <param name="client">The client.</param> /// <param name="newchar">[out] if true then the character is not yet made.</param> /// <returns>Returns true.</returns> public static bool LoadCharacter(Entities.GameClient client, out bool newchar) { newchar = false; try { client.CharDB = new CharacterDatabase(client.DatabaseUID); #region Load Stats ; Loads all the main stats of the character (name, level, coordinates etc.) using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, true)) { cmd.AddWhereValue("PlayerID", client.DatabaseUID); cmd.Finish("DB_Players"); } if (!sql.Read()) return false; if (sql.ReadBoolean("PlayerNew")) { newchar = true; return false; } client.Name = sql.ReadString("PlayerName"); if (string.IsNullOrEmpty(client.Name) || string.IsNullOrWhiteSpace(client.Name)) return false; client.Permission = (Enums.PlayerPermission)Enum.Parse(typeof(Enums.PlayerPermission), sql.ReadString("PlayerPermission")); client.Faction = (Enums.Faction)Enum.Parse(typeof(Enums.Faction), sql.ReadString("PlayerFaction")); client.Avatar = sql.ReadUInt16("PlayerAvatar"); client.Model = sql.ReadUInt16("PlayerModel"); client.HairStyle = sql.ReadUInt16("PlayerHairStyle"); client.Money = sql.ReadUInt32("PlayerMoney"); client.WarehouseMoney = sql.ReadUInt32("PlayerWarehouseMoney"); client.CPs = sql.ReadUInt32("PlayerCPs"); client.BoundCPs = sql.ReadUInt32("PlayerBoundCPs"); client.Strength = sql.ReadUInt16("PlayerStrength"); client.Agility = sql.ReadUInt16("PlayerAgility"); client.Vitality = sql.ReadUInt16("PlayerVitality"); client.Spirit = sql.ReadUInt16("PlayerSpirit"); client.AttributePoints = sql.ReadUInt16("PlayerAttributePoints"); client.MaxHP = sql.ReadInt32("PlayerMaxHP"); client.HP = sql.ReadInt32("PlayerHP"); if (client.HP <= 0) client.HP = 1; client.MaxMP = sql.ReadInt32("PlayerMaxMP"); client.MP = sql.ReadInt32("PlayerMP"); client.PKPoints = sql.ReadInt16("PlayerPKPoints"); client.Level = sql.ReadByte("PlayerLevel"); client.Experience = sql.ReadUInt64("PlayerExperience"); client.Class = (Enums.Class)Enum.Parse(typeof(Enums.Class), sql.ReadString("PlayerClass")); client.PlayerTitle = (Enums.PlayerTitle)Enum.Parse(typeof(Enums.PlayerTitle), sql.ReadString("PlayerTitle")); client.Account = sql.ReadString("PlayerAccount"); client.Reborns = sql.ReadByte("PlayerReborns"); client.SpouseDatabaseUID = sql.ReadInt32("PlayerSpouseID"); client.QuestPoints = sql.ReadUInt32("PlayerQuestPoints"); /*string n = sql.ReadObject("PlayerCurrentQuest").ToString(); if (!string.IsNullOrWhiteSpace(n)) client.CurrentQuest = client.Quests[n];*/ Maps.MapPoint startmap = Maps.MapTools.GetStartMap( sql.ReadUInt16("PlayerMapID"), sql.ReadUInt16("PlayerX"), sql.ReadUInt16("PlayerY"), sql.ReadUInt16("PlayerLastMapID")); client.Map = startmap.Map; client.LastMapID = client.Map.MapID; client.X = startmap.X; client.Y = startmap.Y; client.LastMapX = client.X; client.LastMapY = client.Y; client.LastX = client.X; client.LastY = client.Y; uint entityuid; Maps.IMapObject rObject; if (client.Map.ContainsClientByName(client.Name, out entityuid)) client.Map.MapObjects.TryRemove(entityuid, out rObject); if (!client.Map.EnterMap(client)) return false; } #endregion #region Load Inventory ; Loads the inventory of the character. IniFile itemfile = client.CharDB.ItemFiles[0]; if (itemfile.Exists()) { string[] sections = itemfile.GetSectionNames(255); if (sections.Length > 0) { int[] positions; sections.ConverToInt32(out positions); for (int i = 0; i < 40; i++) { if (positions.Contains(i)) { itemfile.SetSection(i.ToString()); uint itemid = itemfile.ReadUInt32("ItemID", 0); if (itemid == 0) return false; Data.ItemInfo item; Data.ItemInfo original; if (!Core.Kernel.ItemInfos.TrySelect(itemid, out original)) return false; item = original.Copy(); item.Plus = itemfile.ReadByte("Plus", 0); item.Bless = itemfile.ReadByte("Bless", 0); item.Enchant = itemfile.ReadByte("Enchant", 0); item.Gem1 = (Enums.SocketGem)Enum.Parse(typeof(Enums.SocketGem), itemfile.ReadString("Gem1", "NoSocket")); item.Gem2 = (Enums.SocketGem)Enum.Parse(typeof(Enums.SocketGem), itemfile.ReadString("Gem2", "NoSocket")); item.Location = Enums.ItemLocation.Inventory; item.CurrentDura = itemfile.ReadInt16("CurrentDura", 0); item.MaxDura = itemfile.ReadInt16("MaxDura", 0); item.Color = (Enums.ItemColor)Enum.Parse(typeof(Enums.ItemColor), itemfile.ReadString("Color", "Orange")); item.SocketAndRGB = itemfile.ReadUInt32("SocketProgress", 0); // // other data // public uint SocketAndRGB = 0; // public ushort CurrentDura = 100; // public ushort MaxDura = 100; // public ushort RebornEffect = 0; // public bool Free = false; // public uint GreenText = 0; // public uint INS = 0; // public bool Suspicious = false; // public bool Locked = false; // public uint Composition = 0; // public uint LockedTime = 0; // public ushort Amount = 0; // public byte Color = 0; if (!client.Inventory.AddItem(item, (byte)i)) return false; } } } } #endregion #region Load Equipments ; Loads the equipments of the character. IniFile equipfile = client.CharDB.ItemFiles[1]; if (equipfile.Exists()) { for (byte i = 1; i <= 32; i++) { equipfile.SetSection(i.ToString()); uint itemid = equipfile.ReadUInt32("ID", 0); if (itemid > 0) { Data.ItemInfo item; Data.ItemInfo original; if (!Core.Kernel.ItemInfos.TrySelect(itemid, out original)) return false; item = original.Copy(); item.Plus = equipfile.ReadByte("Plus", 0); item.Bless = equipfile.ReadByte("Bless", 0); item.Enchant = equipfile.ReadByte("Enchant", 0); item.Gem1 = (Enums.SocketGem)Enum.Parse(typeof(Enums.SocketGem), equipfile.ReadString("Gem1", "NoSocket")); item.Gem2 = (Enums.SocketGem)Enum.Parse(typeof(Enums.SocketGem), equipfile.ReadString("Gem2", "NoSocket")); item.CurrentDura = equipfile.ReadInt16("CurrentDura", 0); item.MaxDura = equipfile.ReadInt16("MaxDura", 0); item.Color = (Enums.ItemColor)Enum.Parse(typeof(Enums.ItemColor), equipfile.ReadString("Color", "Orange")); item.SocketAndRGB = equipfile.ReadUInt32("SocketProgress", 0); // FIX REMOVE!! client.Equipments.Equip(item, (Enums.ItemLocation)i, false); } } } #endregion #region Load Prof ; Loads the prof-skills of the character. using (var prof = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(prof, SqlCommandType.SELECT, true)) { cmd.AddWhereValue("PlayerID", client.DatabaseUID); cmd.Finish("DB_PlayerProfs"); } while (prof.Read()) { Data.SpellInfo profinfo = new ProjectX_V3_Game.Data.SpellInfo(); profinfo.ID = prof.ReadUInt16("Prof"); profinfo.Level = prof.ReadUInt16("ProfLevel"); profinfo.Experience = prof.ReadUInt32("ProfExperience"); client.SpellData.AddProf(profinfo); } } #endregion #region Load Skills ; Loads the skills of the character. using (var spell = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(spell, SqlCommandType.SELECT, true)) { cmd.AddWhereValue("PlayerID", client.DatabaseUID); cmd.Finish("DB_PlayerSpells"); } while (spell.Read()) { Data.SpellInfo spellinfo = new ProjectX_V3_Game.Data.SpellInfo(); spellinfo.ID = spell.ReadUInt16("SpellSkillID"); spellinfo.Level = spell.ReadUInt16("SpellLevel"); spellinfo.Experience = spell.ReadUInt32("SpellExperience"); client.SpellData.AddSpell(spellinfo); } } #endregion #region Load Banks ; Loads the warehouses of the character. foreach (ushort WhID in whids) { IniFile warehousefile = client.CharDB.WarehouseFiles[WhID]; if (warehousefile.Exists()) { string[] sections = warehousefile.GetSectionNames(255); if (sections.Length > 0) { int[] positions; sections.ConverToInt32(out positions); for (int i = 0; i < 40; i++) { if (positions.Contains(i)) { warehousefile.SetSection(i.ToString()); uint itemid = warehousefile.ReadUInt32("ItemID", 0); if (itemid == 0) return false; Data.ItemInfo item; Data.ItemInfo original; if (!Core.Kernel.ItemInfos.TrySelect(itemid, out original)) return false; item = original.Copy(); item.Plus = warehousefile.ReadByte("Plus", 0); item.Bless = warehousefile.ReadByte("Bless", 0); item.Enchant = warehousefile.ReadByte("Enchant", 0); item.Gem1 = (Enums.SocketGem)Enum.Parse(typeof(Enums.SocketGem), warehousefile.ReadString("Gem1", "NoSocket")); item.Gem2 = (Enums.SocketGem)Enum.Parse(typeof(Enums.SocketGem), warehousefile.ReadString("Gem2", "NoSocket")); item.Location = Enums.ItemLocation.Inventory; item.CurrentDura = warehousefile.ReadInt16("CurrentDura", 0); item.MaxDura = warehousefile.ReadInt16("MaxDura", 0); item.Color = (Enums.ItemColor)Enum.Parse(typeof(Enums.ItemColor), warehousefile.ReadString("Color", "Orange")); item.SocketAndRGB = warehousefile.ReadUInt32("SocketProgress", 0); // // other data // public uint SocketAndRGB = 0; // public ushort CurrentDura = 100; // public ushort MaxDura = 100; // public ushort RebornEffect = 0; // public bool Free = false; // public uint GreenText = 0; // public uint INS = 0; // public bool Suspicious = false; // public bool Locked = false; // public uint Composition = 0; // public uint LockedTime = 0; // public ushort Amount = 0; // public byte Color = 0; if (!client.Warehouses[WhID].AddItem(item, (byte)i)) return false; } } } } } #endregion #region Load Guild ; Loads the guild of the character. // Look Packets.GeneralData.GetSynAttr.cs #endregion #region Load Association ; Loads the character associations. #endregion #region Load Quests ; Loads the quests of the character. /*using (var quest = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(quest, SqlCommandType.SELECT, true)) { cmd.AddWhereValue("PlayerID", client.DatabaseUID); cmd.Finish("DB_Quests"); } while (quest.Read()) { string Name = quest.ReadString("QuestName"); int Progress = quest.ReadInt32("QuestProgress"); if (Progress == -1) client.Quests[Name].Finished = true; else { client.Quests[Name].QuestProgress = (ushort)Progress; client.Quests[Name].LoadInfoString(quest.ReadString("QuestInfo")); } } }*/ #endregion client.BaseEntity.SetBaseStats(); client.BaseEntity.CalculateBaseStats(); UpdateSpouse(client); return true; } catch (Exception e) { Console.WriteLine(e.ToString()); return false; } }