public static void Load() { MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT); command.Select("lottery"); MySqlReader reader = new MySqlReader(command); while (reader.Read()) { LotteryItem item = new LotteryItem(); item.Rank = reader.ReadInt32("rank"); item.Chance = reader.ReadInt32("chance"); item.Name = reader.ReadString("prize_name"); item.ID = reader.ReadUInt32("prize_item"); item.Color = reader.ReadByte("color"); item.Sockets = reader.ReadByte("hole_num"); item.Plus = reader.ReadByte("addition_lev"); LotteryItems.Add(item); } reader.Close(); Console.WriteLine("Lottery items loaded."); }
public static void LoadFlower() { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("cq_flowers"); MySqlReader r = new MySqlReader(cmd); while (r.Read()) { Game.Struct.Flowers F = new Game.Struct.Flowers(); F.Lilies = r.ReadInt32("lilies"); F.Lilies2day = r.ReadInt32("liliestoday"); F.Orchads = r.ReadInt32("orchads"); F.Orchads2day = r.ReadInt32("orchadstoday"); F.RedRoses = r.ReadInt32("redroses"); F.RedRoses2day = r.ReadInt32("redrosestoday"); F.Tulips = r.ReadInt32("tulips"); F.Tulips2day = r.ReadInt32("tulipstoday"); Conquer_Online_Server.ServerBase.Kernel.AllFlower.Add(r.ReadUInt32("charuid"), F); } r.Close(); }
public static void Load() { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("specialdrops"); MySqlReader rdr = new MySqlReader(cmd); while (rdr.Read()) { SpecialItemDrop sitem = new SpecialItemDrop(); sitem.ItemID = rdr.ReadInt32("itemid"); sitem.Rate = rdr.ReadInt32("rate"); sitem.Discriminant = rdr.ReadInt32("discriminant"); sitem.Map = rdr.ReadInt32("map"); SpecialItemDropList.Add(sitem); } rdr.Close(); MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT); command.Select("monsterinfos"); MySqlReader reader = new MySqlReader(command); while (reader.Read()) { MonsterInformation mf = new MonsterInformation(); mf.ID = reader.ReadUInt32("id"); mf.Name = reader.ReadString("name"); mf.Mesh = reader.ReadUInt16("lookface"); mf.Level = reader.ReadByte("level"); mf.Hitpoints = reader.ReadUInt32("life"); ServerBase.IniFile IniFile = new ServerBase.IniFile(ServerBase.Constants.MonstersPath); if (IniFile.ReadString(mf.Name, "MaxLife") != "") { if (uint.Parse(IniFile.ReadString(mf.Name, "MaxLife")) != 0) { mf.Hitpoints = uint.Parse(IniFile.ReadString(mf.Name, "MaxLife")); byte boss = byte.Parse(IniFile.ReadString(mf.Name, "Boss")); if (boss == 0) mf.Boss = false; else mf.Boss = true; if (mf.Name == "TeratoDragon" || mf.Name == "SnowBanshee") { mf.SuperBoss = true; } } } mf.ViewRange = reader.ReadUInt16("view_range"); mf.AttackRange = reader.ReadUInt16("attack_range"); mf.AttackType = reader.ReadByte("attack_user"); mf.MinAttack = reader.ReadUInt32("attack_min"); mf.MaxAttack = reader.ReadUInt32("attack_max"); mf.SpellID = reader.ReadUInt16("magic_type"); mf.MoveSpeed = reader.ReadInt32("move_speed"); mf.RunSpeed = reader.ReadInt32("run_speed"); mf.OwnItemID = reader.ReadInt32("ownitem"); mf.HPPotionID = reader.ReadInt32("drop_hp"); mf.MPPotionID = reader.ReadInt32("drop_mp"); mf.OwnItemRate = reader.ReadInt32("ownitemrate"); mf.AttackSpeed = reader.ReadInt32("attack_speed"); mf.ExtraExperience = reader.ReadUInt32("extra_exp"); #region TeratoDragon if (mf.Name == "TeratoDragon") { byte times = (byte)ServerBase.Kernel.Random.Next(1, 4); byte ref_times = (byte)ServerBase.Kernel.Random.Next(1, 6); for (byte i = 0; i < times; i++) { uint Uid = 0;// uint type = (byte)ServerBase.Kernel.Random.Next(1, 4); switch (type) { case 1: Uid = 7013; break; case 2: Uid = 7014; break; case 3: Uid = 7017; break; case 4: Uid = 10361; break; } if (Uid != 0) { mf.SpellID = (ushort)Uid; } } } #endregion #region Banshee if (mf.Name == "SnowBanshee") { byte times = (byte)ServerBase.Kernel.Random.Next(1, 3); byte ref_times = (byte)ServerBase.Kernel.Random.Next(1, 6); for (byte i = 0; i < times; i++) { uint Uid = 0;// uint type = (byte)ServerBase.Kernel.Random.Next(1, 3); switch (type) { case 1: Uid = 30010; break; case 2: Uid = 30011; break; case 3: Uid = 30012; break; } if (Uid != 0) { mf.SpellID = (ushort)Uid; } } } #endregion #region ThrillingSpook if (mf.Name == "ThrillingSpook") { byte times = (byte)ServerBase.Kernel.Random.Next(1, 4); byte ref_times = (byte)ServerBase.Kernel.Random.Next(1, 6); for (byte i = 0; i < times; i++) { uint Uid = 0;// uint type = (byte)ServerBase.Kernel.Random.Next(1, 4); switch (type) { case 1: Uid = 10363; break; case 2: Uid = 10362; break; case 3: Uid = 10360; break; case 4: Uid = 10361; break; } if (Uid != 0) { mf.SpellID = (ushort)Uid; } } } #endregion #region SwordMaster if (mf.Name == "SwordMaster") { byte times = (byte)ServerBase.Kernel.Random.Next(1, 4); byte ref_times = (byte)ServerBase.Kernel.Random.Next(1, 6); for (byte i = 0; i < times; i++) { uint Uid = 0;// uint type = (byte)ServerBase.Kernel.Random.Next(1, 4); switch (type) { case 1: Uid = 10504; break; case 2: Uid = 10506; break; case 3: Uid = 10502; break; case 4: Uid = 10505; break; } if (Uid != 0) { mf.SpellID = (ushort)Uid; } } } #endregion // uint MoneyDropAmount = reader.ReadUInt16("level"); if (MoneyDropAmount != 0) { mf.MaxMoneyDropAmount = MoneyDropAmount * 25; if (mf.MaxMoneyDropAmount != 0) mf.MinMoneyDropAmount = 1; } if (mf.MoveSpeed <= 500) mf.MoveSpeed += 500; if (mf.AttackSpeed <= 500) mf.AttackSpeed += 500; MonsterInfos.Add(mf.ID, mf); byte lvl = mf.Level; if (mf.Name == "Slinger" || mf.Name == "GoldGhost" || mf.Name == "AgileRat" || mf.Name == "Bladeling" || mf.Name == "BlueBird" || mf.Name == "BlueFiend" || mf.Name == "MinotaurL120") { mf.LabirinthDrop = true; lvl = 20; } if (!ItemDropCache.ContainsKey(lvl)) { List<uint> itemdroplist = new List<uint>(); foreach (ConquerItemBaseInformation itemInfo in ConquerItemInformation.BaseInformations.Values) { if (itemInfo.ID >= 800000 && itemInfo.ID <= 824014) continue; ushort position = Network.PacketHandler.ItemPosition(itemInfo.ID); if (Network.PacketHandler.IsArrow(itemInfo.ID) || itemInfo.Level == 0 || itemInfo.Level > 121) continue; if (position < 9 && position != 7) { if (itemInfo.Level == 100) if (itemInfo.Name.Contains("Dress")) continue; if (itemInfo.Level > 121) continue; int diff = (int)lvl - (int)itemInfo.Level; if (!(diff > 10 || diff < -10)) { itemdroplist.Add(itemInfo.ID); } } if (position == 10 || position == 11 && lvl >= 70) itemdroplist.Add(itemInfo.ID); } ItemDropCache.Add(lvl, itemdroplist); } if (mf.Boss) { List<uint> itemdroplist = new List<uint>(); foreach (ConquerItemBaseInformation itemInfo in ConquerItemInformation.BaseInformations.Values) { if (itemInfo.ID >= 800000 && itemInfo.ID <= 824014) { if (itemInfo.PurificationLevel <= 3 || (mf.SuperBoss && itemInfo.PurificationLevel > 3)) { int diff = (int)mf.Level - (int)itemInfo.Level; if (!(diff > 20 || diff < -20)) { if (itemInfo.Level <= 110) itemdroplist.Add(itemInfo.ID); } } } } SoulItemCache.Add(lvl, itemdroplist); } } //723755, 723768, 723772 ,723774 reader.Close(); Console.WriteLine("Monster information loaded."); Console.WriteLine("Monster drops generated."); }
static void EngineThread_Execute() { Time32 Start = Time32.Now; RandomSeed = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2)); ServerBase.Kernel.Random = new Random(RandomSeed); StartDate = DateTime.Now; //Console.Title = "Conquer Online Server Emulator. Start time: " + StartDate.ToString("dd MM yyyy hh:mm"); Console.BackgroundColor = ConsoleColor.Green; //Console.ForegroundColor = ConsoleColor.DarkRed; Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Load server configuration!"); string ConfigFileName = "configuration.ini"; ServerBase.IniFile IniFile = new ServerBase.IniFile(ConfigFileName); GameIP = IniFile.ReadString("configuration", "IP"); GamePort = IniFile.ReadUInt16("configuration", "GamePort"); AuthPort = IniFile.ReadUInt16("configuration", "AuthPort"); ServerBase.Constants.ServerName = IniFile.ReadString("configuration", "ServerName"); Database.DataHolder.CreateConnection(IniFile.ReadString("MySql", "Username"), IniFile.ReadString("MySql", "Password"), IniFile.ReadString("MySql", "Database"), IniFile.ReadString("MySql", "Host")); MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("configuration").Where("Server", ServerBase.Constants.ServerName); MySqlReader r = new MySqlReader(cmd); if (r.Read()) { EntityUID = new ServerBase.Counter(r.ReadUInt32("EntityID")); Game.Clans.ClanCount = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("ClanUID")); Game.ConquerStructures.Society.Guild.GuildCounter = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("GuildID")); Network.GamePackets.ConquerItem.ItemUID = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("ItemUID")); ServerBase.Constants.ExtraExperienceRate = r.ReadUInt32("ExperienceRate"); ServerBase.Constants.ExtraSpellRate = r.ReadUInt32("ProficiencyExperienceRate"); ServerBase.Constants.ExtraProficiencyRate = r.ReadUInt32("SpellExperienceRate"); ServerBase.Constants.MoneyDropRate = r.ReadUInt32("MoneyDropRate"); ServerBase.Constants.MoneyDropMultiple = r.ReadUInt32("MoneyDropMultiple"); ServerBase.Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate"); ServerBase.Constants.ConquerPointsDropMultiple = r.ReadUInt32("ConquerPointsDropMultiple"); ServerBase.Constants.ItemDropRate = r.ReadUInt32("ItemDropRate"); ServerBase.Constants.ItemDropQualityRates = r.ReadString("ItemDropQualityString").Split('~'); ServerBase.Constants.WebAccExt = r.ReadString("AccountWebExt"); ServerBase.Constants.WebVoteExt = r.ReadString("VoteWebExt"); ServerBase.Constants.WebDonateExt = r.ReadString("DonateWebExt"); ServerBase.Constants.ServerWebsite = r.ReadString("ServerWebsite"); ServerBase.Constants.ServerGMPass = r.ReadString("ServerGMPass"); PlayerCap = r.ReadInt32("PlayerCap"); Database.DetainedItemTable.Counter = new Conquer_Online_Server.ServerBase.Counter(r.ReadUInt32("DetainItemUID")); } r.Close(); Console.WriteLine("Initializing database."); Database.ConquerItemInformation.Load(); Database.DataHolder.ReadStats(); Database.MonsterInformation.Load(); Database.SpellTable.Load(); Database.ShopFile.Load(); Database.EShopFile.Load(); Database.MapsTable.Load(); Database.NobilityTable.Load(); Database.ArenaTable.Load(); Database.GuildTable.Load(); Database.LotteryTable.Load(); Database.DMaps.Load(); Database.EntityTable.LoadPlayersVots(); Database.LotteryTable2.Load(); Database.EntityTable.NextUit(); // Database.DROP_SOULS.LoadDrops(); Database.Clans.LoadAllClans(); ServerBase.FrameworkTimer.SetPole(100, 50); System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ServerBase.FrameworkTimer.DoNothing)); Values = new Client.GameState[0]; new Game.Map(1038, Database.DMaps.MapPaths[1038]); Game.ConquerStructures.Society.GuildWar.Initiate(); Console.WriteLine("Guild war initializated."); Network.AuthPackets.Forward.Incrementer = new ServerBase.Counter(); Network.Cryptography.AuthCryptography.PrepareAuthCryptography(); ServerBase.Kernel.Elite_PK_Tournament = new Conquer_Online_Server.Game.Tournaments.EliteTournament(); ServerBase.Kernel.Elite_PK_Tournament.LoadTop8(); Console.WriteLine("Initializing sockets."); AuthServer = new AsyncSocket(AuthPort); AuthServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceNewConnection); AuthServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(AuthServer_AnnounceReceive); AuthServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(AuthServer_AnnounceDisconnection); GameServer = new AsyncSocket(GamePort); GameServer.OnClientConnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceNewConnection); GameServer.OnClientReceive += new Action<byte[], Interfaces.ISocketWrapper>(GameServer_AnnounceReceive); GameServer.OnClientDisconnect += new Action<Interfaces.ISocketWrapper>(GameServer_AnnounceDisconnection); Console.WriteLine("Authentication server on port " + AuthPort + "is online."); Console.WriteLine("Game server on port " + GamePort + "is online."); Console.WriteLine(); Console.WriteLine("Server loaded in " + (Time32.Now - Start) + " milliseconds."); StatusFlagChange.Execute += new Action(StatusFlagChange_Execute); StatusFlagChange.Start(); CharacterThread.Execute += new Action(CharacterThread_Execute); CharacterThread.Start(); AttackThread.Execute += new Action(AttackThread_Execute); AttackThread.Start(); CompanionThread.Execute += new Action(CompanionThread_Execute); CompanionThread.Start(); BlessThread.Execute += new Action(BlessThread_Execute); BlessThread.Start(); CharacterThread.Execute += new Action(CharacterThread_Execute); CharacterThread.Start(); ServerStuff.Execute += new Action(ServerStuff_Execute); ServerStuff.Start(); ArenaSystem.Execute += new Action(Game.ConquerStructures.Arena.ArenaSystem_Execute); ArenaSystem.Start(); new MySqlCommand(MySqlCommandType.UPDATE).Update("entities").Set("Online", 0).Execute(); GC.Collect(); System.Threading.Thread.Sleep(000); Console.WriteLine("----------------Source 5620--------------"); while (true) CommandsAI(Console.ReadLine()); }
public static void Load() { MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT); command.Select("spells"); MySqlReader reader = new MySqlReader(command); while (reader.Read()) { SpellInformation spell = new SpellInformation(); spell.ID = reader.ReadUInt16("type"); spell.Sort = reader.ReadByte("sort"); spell.CanKill = reader.ReadBoolean("crime"); spell.OnlyGround = reader.ReadBoolean("ground"); spell.Multi = reader.ReadBoolean("multi"); spell.Target = reader.ReadByte("target"); spell.Level = reader.ReadByte("level"); spell.UseMana = reader.ReadUInt16("use_mp"); spell.UseStamina = reader.ReadByte("use_ep"); spell.UseArrows = reader.ReadByte("use_item_num"); spell.Power = reader.ReadUInt16("power"); spell.PowerPercent = (float)(reader.ReadUInt16("power") % 1000) / 100; if (spell.Power > 13000) spell.Power = 0; spell.Percent = reader.ReadByte("percent"); spell.Duration = reader.ReadInt32("step_secs"); spell.Range = reader.ReadUInt16("range"); spell.Sector = spell.Range * 20; spell.Distance = reader.ReadUInt16("distance"); if (spell.Distance >= 4) spell.Distance--; spell.Status = reader.ReadUInt64("status"); spell.NeedExperience = reader.ReadUInt32("need_exp"); spell.NeedLevel = reader.ReadByte("need_level"); spell.WeaponSubtype = spell.OnlyWithThisWeaponSubtype = reader.ReadUInt16("weapon_subtype"); spell.NextSpellID = reader.ReadUInt16("next_magic"); spell.NeedXP = reader.ReadByte("use_xp"); if (SpellInformations.ContainsKey(spell.ID)) { SpellInformations[spell.ID].Add(spell.Level, spell); } else { SpellInformations.Add(spell.ID, new SafeDictionary<byte, SpellInformation>(10)); SpellInformations[spell.ID].Add(spell.Level, spell); } if (spell.Distance > 17) spell.Distance = 17; if (spell.WeaponSubtype != 0) { switch (spell.ID) { 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 (!WeaponSpells.ContainsKey(spell.WeaponSubtype)) { WeaponSpells.Add(spell.WeaponSubtype, spell.ID); } break; } } } reader.Close(); Console.WriteLine("Spells information loaded."); }