Guest User

Untitled

a guest
Jul 21st, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 351.57 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Threading;
  4. using System.Net.Sockets;
  5. using System.Collections.Generic;
  6. using Conquer_Online_Server.Network.Cryptography;
  7. using Conquer_Online_Server.Network.GamePackets;
  8. using Conquer_Online_Server.Network.Sockets;
  9. using Conquer_Online_Server.Network;
  10. using Conquer_Online_Server.Interfaces;
  11. using Conquer_Online_Server.Game.ConquerStructures;
  12. using System.Drawing;
  13. using Conquer_Online_Server.Game;
  14. using Conquer_Online_Server.Database;
  15. using Albetros.Core;
  16. using System.Diagnostics;
  17. using Microsoft.Win32;
  18. using Conquer_Online_Server.MaTrix;
  19. //using Conquer_Online_Server.iPiraTe.JiangHu;
  20.  
  21.  
  22. namespace Conquer_Online_Server.Client
  23. {
  24.     public class GameState
  25.     {
  26.         public bool InWareHouse()
  27.         {
  28.             foreach (var wh in Warehouses.Values)
  29.             {
  30.                 if (wh.Count > 0)
  31.                     return true;
  32.             }
  33.             return false;
  34.         }
  35.         public void BlessTouch(GameState client)
  36.         {
  37.            
  38.             if (!client.Spells.ContainsKey(12390))
  39.                 return;
  40.  
  41.             if (client.Weapons != null)
  42.                 if (client.Weapons.Item2 != null)
  43.                     if (client.Weapons.Item2.ID / 1000 != 619)
  44.                         return;
  45.  
  46.             var spell2 = SpellTable.GetSpell(client.Spells[12390].ID, client.Spells[12390].Level);
  47.             if (Kernel.Rate((double)spell2.Percent))
  48.             {
  49.  
  50.                 var spell = Database.SpellTable.GetSpell(1095, 4);
  51.                 Entity.AddFlag(Update.Flags.Stigma);
  52.                 Entity.StigmaStamp = Time32.Now;
  53.                 Entity.StigmaIncrease = spell.PowerPercent;
  54.                 Entity.StigmaTime = (byte)spell.Duration;
  55.                 if (Entity.EntityFlag == EntityFlag.Player)
  56.                     Send(Constants.Stigma(spell.PowerPercent, spell.Duration));
  57.  
  58.                 spell = Database.SpellTable.GetSpell(1090, 4);
  59.                 Entity.ShieldTime = 0;
  60.                 Entity.ShieldStamp = Time32.Now;
  61.                 Entity.MagicShieldStamp = Time32.Now;
  62.                 Entity.MagicShieldTime = 0;
  63.  
  64.                 Entity.AddFlag(Update.Flags.MagicShield);
  65.                 Entity.MagicShieldStamp = Time32.Now;
  66.                 Entity.MagicShieldIncrease = 1.1f;//spell.PowerPercent;
  67.                 Entity.MagicShieldTime = (byte)spell.Duration;
  68.                 if (Entity.EntityFlag == EntityFlag.Player)
  69.                     Send(Constants.Shield(spell.PowerPercent, spell.Duration));
  70.  
  71.                 spell = Database.SpellTable.GetSpell(1085, 4);
  72.                 Entity.AccuracyStamp = Time32.Now;
  73.                 Entity.StarOfAccuracyStamp = Time32.Now;
  74.                 Entity.StarOfAccuracyTime = 0;
  75.                 Entity.AccuracyTime = 0;
  76.  
  77.                 Entity.AddFlag(Update.Flags.StarOfAccuracy);
  78.                 Entity.StarOfAccuracyStamp = Time32.Now;
  79.                 Entity.StarOfAccuracyTime = (byte)spell.Duration;
  80.                 if (Entity.EntityFlag == EntityFlag.Player)
  81.                     Send(Constants.Accuracy(spell.Duration));
  82.  
  83.                 client.IncreaseSpellExperience(100, 12390);
  84.             }
  85.         }
  86.  
  87.         public void BreakTouch(GameState client)
  88.         {          
  89.             if (!client.Spells.ContainsKey(12400))
  90.                 return;
  91.  
  92.             if (client.Weapons != null)
  93.                 if (client.Weapons.Item2 != null)
  94.                     if (client.Weapons.Item2.ID / 1000 != 619)
  95.                         return;
  96.  
  97.             var spell = SpellTable.GetSpell(client.Spells[12400].ID, client.Spells[12400].Level);
  98.             if (MyMath.Success((double)30))
  99.             {
  100.                 if (Entity.ContainsFlag3(Update.Flags3.lianhuaran04))
  101.                 {
  102.                     SpellUse suse = new SpellUse(true);
  103.                     suse.Attacker = Entity.UID;
  104.                     suse.SpellID = spell.ID;
  105.                     suse.SpellLevel = spell.Level;
  106.  
  107.                     var array = Game.Attacking.Handle.PlayerinRange(Entity, Entity).ToArray();
  108.                     foreach (var target in array)
  109.                     {                      
  110.                         var attacked = target.Entity;
  111.                         if (attacked.UID == client.Entity.UID)
  112.                             continue;
  113.                         if (Game.Attacking.Handle.CanAttack(client.Entity, attacked, spell, true))
  114.                         {
  115.                             var attack = new Attack(true);
  116.                             attack.Attacker = client.Entity.UID;
  117.                             attack.Attacked = attacked.UID;
  118.                          
  119.                             uint damage = Game.Attacking.Calculate.Magic(client.Entity, attacked, ref attack);
  120.  
  121.                             attack.Damage = damage;
  122.                             suse.Effect1 = attack.Effect1;
  123.                             suse.Effect1 = attack.Effect1;
  124.  
  125.                             Game.Attacking.Handle.ReceiveAttack(client.Entity, attacked, attack, ref damage, spell);
  126.                             suse.AddTarget(attacked, damage, attack);
  127.                         }
  128.                     }
  129.                     client.SendScreen(suse, true);
  130.  
  131.                     Entity.RemoveFlag3(Update.Flags3.lianhuaran01);
  132.                     Entity.RemoveFlag3(Update.Flags3.lianhuaran02);
  133.                     Entity.RemoveFlag3(Update.Flags3.lianhuaran03);
  134.                     Entity.RemoveFlag3(Update.Flags3.lianhuaran04);
  135.                 }
  136.                 else if (Entity.ContainsFlag3(Update.Flags3.lianhuaran03))
  137.                 {
  138.                     Entity.AddFlag3(Update.Flags3.lianhuaran04);
  139.                     Entity.RemoveFlag3(Update.Flags3.lianhuaran03);
  140.                     Entity.lianhuaranPercent = 0.5f;
  141.                 }
  142.                 else if (Entity.ContainsFlag3(Update.Flags3.lianhuaran02))
  143.                 {
  144.                     Entity.AddFlag3(Update.Flags3.lianhuaran03);
  145.                     Entity.RemoveFlag3(Update.Flags3.lianhuaran02);
  146.                     Entity.lianhuaranPercent = 0.4f;
  147.                 }
  148.                 else if (Entity.ContainsFlag3(Update.Flags3.lianhuaran01))
  149.                 {
  150.                     Entity.AddFlag3(Update.Flags3.lianhuaran02);
  151.                     Entity.RemoveFlag3(Update.Flags3.lianhuaran01);
  152.                     Entity.lianhuaranPercent = 0.3f;
  153.                 }
  154.                 else if (!Entity.ContainsFlag3(Update.Flags3.lianhuaran01))
  155.                 {
  156.                     Entity.AddFlag3(Update.Flags3.lianhuaran01);
  157.                     Entity.lianhuaranPercent = 0.1f;
  158.                 }
  159.                 Entity.lianhuaranStamp = Time32.Now;
  160.                 Entity.lianhuaranLeft = 20;
  161.                
  162.                 client.IncreaseSpellExperience(100, 12400);              
  163.             }
  164.         }
  165.         public uint SashSlots
  166.         {
  167.             get { return this["SashSlots"]; }
  168.             set
  169.             {
  170.                 this["SashSlots"] = value;
  171.                 if (Entity.EntityFlag == EntityFlag.Player)
  172.                 {
  173.                     Entity.Update(Update.Sash, value, false);
  174.                     Entity.Update(Update.AvailableSlots, 200, false);
  175.                 }
  176.             }
  177.         }
  178.        
  179.         public SafeDictionary<Conquer_Online_Server.Network.GamePackets.Update.AuraType, MaTrix.Auras> Auras = new SafeDictionary<Update.AuraType, MaTrix.Auras>(8);
  180.         public GameState[] MonksInTeam()
  181.         {
  182.             return Team.Teammates.Where(x => x.Entity.Aura_isActive).ToArray();
  183.         }
  184.         public void CheckTeamAura()
  185.         {
  186.             if (Team != null)
  187.             {
  188.                 var monks = MonksInTeam();
  189.                 if (monks != null)
  190.                 {
  191.                     foreach (var monk in monks)
  192.                     {
  193.                         Update.AuraType aura = Update.AuraType.TyrantAura;
  194.                         switch (monk.Entity.Aura_actType)
  195.                         {
  196.                             case Update.Flags2.EarthAura: aura = Update.AuraType.EarthAura; break;
  197.                             case Update.Flags2.FireAura: aura = Update.AuraType.FireAura; break;
  198.                             case Update.Flags2.WaterAura: aura = Update.AuraType.WaterAura; break;
  199.                             case Update.Flags2.WoodAura: aura = Update.AuraType.WoodAura; break;
  200.                             case Update.Flags2.MetalAura: aura = Update.AuraType.MetalAura; break;
  201.                             case Update.Flags2.FendAura: aura = Update.AuraType.FendAura; break;
  202.                             case Update.Flags2.TyrantAura: aura = Update.AuraType.TyrantAura; break;
  203.                         }
  204.                         if (!Auras.ContainsKey(aura))
  205.                         {
  206.                             if (this.Entity.UID != monk.Entity.UID && Kernel.GetDistance(this.Entity.X, this.Entity.Y, monk.Entity.X, monk.Entity.Y) <= Constants.pScreenDistance)
  207.                             {
  208.                                 MaTrix.Auras Aura = new MaTrix.Auras();
  209.                                 Aura.TeamAuraOwner = monk;
  210.                                 Aura.TeamAuraStatusFlag = monk.Entity.Aura_actType;
  211.                                 Aura.TeamAuraPower = monk.Entity.Aura_actPower;
  212.                                 Aura.TeamAuraLevel = monk.Entity.Aura_actLevel;
  213.                                 Aura.aura = aura;
  214.                                 if (!Auras.ContainsKey(Aura.aura))
  215.                                 {
  216.                                     Auras.Add(Aura.aura, Aura);
  217.                                     this.Entity.AddFlag2(Aura.TeamAuraStatusFlag);
  218.                                     new Update(true).Aura(this.Entity, Update.AuraDataTypes.Add, aura, Aura.TeamAuraLevel, Aura.TeamAuraPower);
  219.                                     this.doAuraBonuses(Aura.TeamAuraStatusFlag, Aura.TeamAuraPower, 1);                                }
  220.                                
  221.                             }
  222.                         }
  223.                     }
  224.                 }
  225.             }
  226.             foreach (var Aura in Auras.Values.ToArray())
  227.             {
  228.                 var pthis = Aura.TeamAuraOwner;
  229.                 if (pthis == null)
  230.                 {
  231.                     new Update(true).Aura(this.Entity, Update.AuraDataTypes.Remove, Aura.aura, Aura.TeamAuraLevel, Aura.TeamAuraPower);
  232.                     //this.removeAuraBonuses(this.TeamAuraStatusFlag, this.TeamAuraPower, 1);
  233.                     this.removeAuraBonuses(Aura.TeamAuraStatusFlag, Aura.TeamAuraPower, 1);
  234.                     this.Entity.RemoveFlag2(Aura.TeamAuraStatusFlag);
  235.                     Auras.Remove(Aura.aura);
  236.                 }
  237.                 else
  238.                 {
  239.                     if (!pthis.Entity.Aura_isActive || !pthis.Socket.Alive || pthis.Entity.Dead || pthis.Entity.MapID != this.Entity.MapID || pthis.Entity.Aura_actType != Aura.TeamAuraStatusFlag)
  240.                     {
  241.                         new Update(true).Aura(this.Entity, Update.AuraDataTypes.Remove, Aura.aura, Aura.TeamAuraLevel, Aura.TeamAuraPower);
  242.                         //this.removeAuraBonuses(this.TeamAuraStatusFlag, this.TeamAuraPower, 1);
  243.                         this.removeAuraBonuses(Aura.TeamAuraStatusFlag, Aura.TeamAuraPower, 1);
  244.                         this.Entity.RemoveFlag2(Aura.TeamAuraStatusFlag);
  245.                         Auras.Remove(Aura.aura);
  246.                     }
  247.                     else
  248.                     {
  249.                         if (this.Team == null || (pthis.Team == null || (pthis.Team != null && !pthis.Team.IsTeammate(this.Entity.UID))) || this.Entity.Dead || Kernel.GetDistance(this.Entity.X, this.Entity.Y, pthis.Entity.X, pthis.Entity.Y) > Constants.pScreenDistance)
  250.                         {
  251.                             new Update(true).Aura(this.Entity, Update.AuraDataTypes.Remove, Aura.aura, Aura.TeamAuraLevel, Aura.TeamAuraPower);
  252.                             this.removeAuraBonuses(Aura.TeamAuraStatusFlag, Aura.TeamAuraPower, 1);
  253.                             this.Entity.RemoveFlag2(Aura.TeamAuraStatusFlag);
  254.                             Auras.Remove(Aura.aura);
  255.                         }
  256.                     }
  257.                 }
  258.             }
  259.  
  260.        
  261.         }
  262.         public MaTrix.ProgressBar ProgressBar;
  263.         public bool TransferedPlayer;
  264.         public void ChangeName(GameState client)
  265.         {
  266.             client.OnDisconnect = p =>
  267.             {
  268.                 #region ChangeName progress
  269.                 string name200 = p.Entity.Name;
  270.                 string newname = p.NewName;
  271.                 uint uid = p.Entity.UID;
  272.                 if (newname != "")
  273.                 {
  274.                     Conquer_Online_Server.Console.WriteLine("Change Name In Progress");
  275.                     if (newname != "")
  276.                     {
  277.                         Database.MySqlCommand cmdupdate = null;
  278.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  279.                         cmdupdate.Update("apprentice").Set("MentorName", newname).Where("MentorID", uid).Execute();
  280.  
  281.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  282.                         cmdupdate.Update("apprentice").Set("ApprenticeName", newname).Where("ApprenticeID", uid).Execute();
  283.  
  284.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  285.                         cmdupdate.Update("arena").Set("EntityName", newname).Where("EntityID", uid).Execute();
  286.  
  287.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  288.                         cmdupdate.Update("claimitems").Set("OwnerName", newname).Where("OwnerUID", uid).Execute();
  289.  
  290.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  291.                         cmdupdate.Update("claimitems").Set("GainerName", newname).Where("GainerUID", uid).Execute();
  292.  
  293.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  294.                         cmdupdate.Update("detaineditems").Set("OwnerName", newname).Where("OwnerUID", uid).Execute();
  295.  
  296.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  297.                         cmdupdate.Update("detaineditems").Set("GainerName", newname).Where("GainerUID", uid).Execute();
  298.  
  299.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  300.                         cmdupdate.Update("enemy").Set("EnemyName", newname).Where("EnemyID", uid).Execute();
  301.  
  302.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  303.                         cmdupdate.Update("friends").Set("FriendName", newname).Where("FriendID", uid).Execute();
  304.  
  305.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  306.                         cmdupdate.Update("guilds").Set("LeaderName", newname).Where("LeaderName", name200).Execute();
  307.  
  308.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  309.                         cmdupdate.Update("clans").Set("LeaderName", newname).Where("LeaderName", name200).Execute();
  310.  
  311.                         if (p.Entity.MyJiang != null)
  312.                         {
  313.                             p.Entity.MyJiang.OwnName = newname;
  314.                             Game.JiangHu.JiangHuClients[p.Entity.UID] = p.Entity.MyJiang;
  315.                         }
  316.                         if (p.Entity.MyFlowers != null)
  317.                             p.Entity.MyFlowers.Name = newname;
  318.  
  319.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  320.                         cmdupdate.Update("nobility").Set("EntityName", newname).Where("EntityUID", uid).Execute();
  321.  
  322.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  323.                         cmdupdate.Update("partners").Set("PartnerName", newname).Where("PartnerID", uid).Execute();
  324.  
  325.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  326.                         cmdupdate.Update("chi").Set("name", newname).Where("uid", uid).Execute();
  327.  
  328.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  329.                         cmdupdate.Update("teamarena").Set("EntityName", newname).Where("EntityID", uid).Execute();
  330.  
  331.                         cmdupdate = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE);
  332.                         cmdupdate.Update("entities").Set("name", newname).Set("namechange", "").Where("UID", uid).Execute();
  333.                         Console.WriteLine(" -[" + name200 + "] : -[" + newname + "]");
  334.  
  335.  
  336.                         if (Game.ConquerStructures.Nobility.Board.ContainsKey(p.Entity.UID))
  337.                         {
  338.                             Game.ConquerStructures.Nobility.Board[p.Entity.UID].Name = p.NewName;
  339.                         }
  340.                         if (Arena.ArenaStatistics.ContainsKey(p.Entity.UID))
  341.                         {
  342.                             Arena.ArenaStatistics[p.Entity.UID].Name = p.NewName;
  343.                         }
  344.                         if (p.Entity.GetClan != null)
  345.                         {
  346.                             if (p.Entity.GetClan.LeaderName == name200)
  347.                             {
  348.                                 Kernel.Clans[p.Entity.ClanId].LeaderName = p.NewName;
  349.                             }
  350.  
  351.                             Kernel.Clans[p.Entity.ClanId].Members[p.Entity.UID].Name = p.NewName;
  352.                         }
  353.                         if (p.Guild != null)
  354.                         {
  355.                             if (p.Guild.LeaderName == name200)
  356.                             {
  357.                                 Kernel.Guilds[p.Guild.ID].LeaderName = p.NewName;
  358.                             }
  359.  
  360.                             Kernel.Guilds[p.Guild.ID].Members[p.Entity.UID].Name = p.NewName;
  361.                         }
  362.  
  363.                     }
  364.                 }
  365.                 #endregion ChangeName progressa
  366.             };
  367.             client.Disconnect();
  368.         }
  369.         public string Country { get; set; }
  370.  
  371.         public DateTime timerattack = new DateTime();
  372.         public GameState LobbyPlayWith;        
  373.         public bool LobbySignup
  374.         {
  375.             get { return this["LobbySignup"]; }
  376.             set
  377.             {
  378.                 this["LobbySignup"] = value;
  379.             }
  380.         }
  381.         public ushort SuperPotion
  382.         {
  383.             get { return this["SuperPotion"]; }
  384.             set
  385.             {
  386.                 this["SuperPotion"] = value;
  387.                 if (Entity.FullyLoaded)
  388.                     if (Entity.EntityFlag == EntityFlag.Player)
  389.                     {
  390.                         if (this != null)
  391.                         {
  392.                             Entity.Update(Network.GamePackets.Update.DoubleExpTimer, Entity.DoubleExperienceTime, 500, false);
  393.                         }
  394.                     }
  395.             }
  396.         }
  397.         public MaTrix.Lobby.QualifierGroup LobbyGroup;
  398.         public void GetLanguages(string language)
  399.         {
  400.             switch (language)
  401.             {
  402.                 case "En":
  403.                     Language = Languages.English;
  404.                     break;
  405.                 case "Ar":
  406.                     Language = Languages.Arabic;
  407.                     break;
  408.             }          
  409.  
  410.         }
  411.         public Languages Language = Languages.English;
  412.         public MaTrix.Hall_of_Fame.FameInfo Fame;
  413.         public MaTrix.Pet Pet;
  414.         public MaTrix.Quests Quests;
  415.         public MaTrix.AI AI;
  416.         public SafeDictionary<uint, MaTrix.Inbox.PrizeInfo> Prizes = new SafeDictionary<uint, MaTrix.Inbox.PrizeInfo>(1000);
  417.         public SafeDictionary<MaTrix.Reward.Event, MaTrix.Reward.RewardInfo> Rewards = new SafeDictionary<MaTrix.Reward.Event, MaTrix.Reward.RewardInfo>(1000);
  418.         public SafeDictionary<uint, MaTrix.Way2Heroes.StageInfo> Way2Heroes = new SafeDictionary<uint, MaTrix.Way2Heroes.StageInfo>();
  419.         public string NewName = "";        
  420.         public int PingCount { get; set; }
  421.         public byte Claimeds
  422.         {
  423.             get { return this["Claimeds"]; }
  424.             set
  425.             {
  426.                 this["Claimeds"] = value;
  427.             }
  428.         }
  429.        
  430.         public bool JiangActive = false;  
  431.         public bool StudyToday
  432.         {
  433.             get { return this["StudyToday"]; }
  434.             set
  435.             {
  436.                 this["StudyToday"] = value;
  437.             }
  438.         }
  439.         public uint UsedCourses
  440.         {
  441.             get { return this["UsedCourses"]; }
  442.             set
  443.             {
  444.                 this["UsedCourses"] = value;
  445.             }
  446.         }
  447.         public DateTime ResetUsedCourses
  448.         {
  449.             get { return this["ResetUsedCourses"]; }
  450.             set
  451.             {
  452.                 this["ResetUsedCourses"] = value;
  453.             }
  454.         }
  455.        
  456.         public bool JoinedDBMap
  457.         {
  458.             get { return this["JoinedDBMap"]; }
  459.             set
  460.             {
  461.                 this["JoinedDBMap"] = value;
  462.             }
  463.         }
  464.         public DateTime inDBmap
  465.         {
  466.             get { return this["inDBmap"]; }
  467.             set
  468.             {
  469.                 this["inDBmap"] = value;
  470.             }
  471.         }
  472.         public uint Appearance
  473.         {
  474.             get { return this["Appearance"]; }
  475.             set
  476.             {
  477.                 this["Appearance"] = value;
  478.             }
  479.         }
  480.         public bool _voted;
  481.         public bool Voted
  482.         {
  483.             get
  484.             {
  485.                 return _voted;
  486.             }
  487.             set
  488.             {
  489.                 _voted = value;              
  490.                 new Database.MySqlCommand(Conquer_Online_Server.Database.MySqlCommandType.UPDATE)
  491.                     .Update("entities").Set("VotePoint", value).Where("UID", Entity.UID).Execute();
  492.        
  493.             }
  494.         }
  495.         public DateTime VoteStamp
  496.         {
  497.             get { return this["VoteStamp"]; }
  498.             set
  499.             {
  500.                 this["VoteStamp"] = value;
  501.             }
  502.         }
  503.         public uint namechanges
  504.         {
  505.             get { return this["namechanges"]; }
  506.             set
  507.             {
  508.                 this["namechanges"] = value;
  509.             }
  510.         }
  511.         public DateTime matrixtime
  512.         {
  513.             get { return this["matrixtime"]; }
  514.             set
  515.             {
  516.                 this["matrixtime"] = value;
  517.             }
  518.         }
  519.    
  520.         public ulong Donationx
  521.         {
  522.             get { return this["Donationx"]; }
  523.             set
  524.             {
  525.                 this["Donationx"] = value;
  526.             }
  527.         }
  528.        
  529.         public string Command = "";
  530.         public bool OnDonation
  531.         {
  532.             get { return this["ondonation"]; }
  533.             set
  534.             {
  535.                 this["ondonation"] = value;
  536.             }
  537.         }
  538.         public bool endarena = false;
  539.         public bool endteam = false;
  540.         public IDisposable[] TimerSubscriptions;
  541.         public object TimerSyncRoot, ItemSyncRoot;
  542.         public Time32 LastVIPTeleport, LastVIPTeamTeleport;
  543.         public bool AlternateEquipment;
  544.         private ClientWrapper _socket;
  545.         public Database.AccountTable Account;
  546.         public GameCryptography Cryptography;
  547.         public DHKeyExchange.ServerKeyExchange DHKeyExchange;
  548.         public bool Exchange = true;
  549.         public ConcurrentPacketQueue Queue;
  550.         public PacketFilter PacketFilter;
  551.         public Time32 CantAttack = Time32.Now;
  552.         public bool Filtering = false;
  553.         public Network.GamePackets.Interaction Interaction;
  554.         public int quarantineKill = 0;
  555.         public int quarantineDeath = 0;
  556.         public int TopDlClaim = 0;
  557.         public int TopGlClaim = 0;
  558.         public uint uniquepoints = 0;
  559.         public Action<GameState> OnDisconnect;
  560.         public int apprtnum = 0;
  561.         public Game.Enums.Color staticArmorColor;
  562.         public bool JustCreated = false;
  563.         public Timer Timer;
  564.         public Conquer_Online_Server.Game.Features.SpiritBeadQuest SpiritBeadQ;
  565.         #region Network
  566.  
  567.         public GameState(ClientWrapper socket)
  568.         {
  569.             Fake = socket == null;
  570.             if (Fake) socket = new ClientWrapper() { Alive = true };
  571.             Queue = new ConcurrentPacketQueue();
  572.             PacketFilter = new PacketFilter() { { 10010, 10 }, { 10005, 7 }, { 2064, 4 }, { 2032, 3 }, { 1027, 2 } };
  573.             Attackable = false;
  574.             Action = 0;
  575.             _socket = socket;
  576.  
  577.             Cryptography = new GameCryptography(Program.Encoding.GetBytes(Constants.GameCryptographyKey));
  578.             if (Program.TestingMode)
  579.                 Cryptography = new GameCryptography(Program.Encoding.GetBytes(Constants.GameCryptographyKey));
  580.             DHKeyExchange = new Network.GamePackets.DHKeyExchange.ServerKeyExchange();
  581.             SpiritBeadQ = new Game.Features.SpiritBeadQuest(this);
  582.             ChiPowers = new List<ChiPowerStructure>();
  583.             Retretead_ChiPowers = new ChiPowerStructure[4];
  584.             //JiangPowers = new List<JiangPowerStructure>();
  585.         }
  586.         public bool Ninja()
  587.         {
  588.             if (Entity.EntityFlag == Game.EntityFlag.Player)
  589.             {
  590.                 if (Entity.Class >= 50 && Entity.Class <= 55)
  591.                     return true;
  592.                 else
  593.                     return false;
  594.             }
  595.             return false;
  596.         }
  597.         public void ReadyToPlay()
  598.         {
  599.             try
  600.             {
  601.                 Weapons = new Tuple<ConquerItem, ConquerItem>(null, null);
  602.                 ItemSyncRoot = new object();
  603.                 Screen = new Game.Screen(this);
  604.               //  if (!Program.ServerTransfer)
  605.                 {
  606.                     Pet = new MaTrix.Pet(this);
  607.                     AI = new MaTrix.AI(this);
  608.                 }
  609.                 Inventory = new Game.ConquerStructures.Inventory(this);
  610.                 Equipment = new Game.ConquerStructures.Equipment(this);
  611.                 WarehouseOpen = false;
  612.                 WarehouseOpenTries = 0;
  613.                 TempPassword = "";
  614.                 ArsenalDonations = new uint[10];
  615.                 if (Account != null)
  616.                 {
  617.                     Warehouses = new SafeDictionary<Game.ConquerStructures.Warehouse.WarehouseID, Game.ConquerStructures.Warehouse>(20);
  618.                     Warehouses.Add((Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)this.Account.EntityID, new Game.ConquerStructures.Warehouse(this, (Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)this.Account.EntityID, 200));
  619.                     Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity, new Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity));
  620.                     Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity, new Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity));
  621.                     Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity, new Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity));
  622.                     Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity, new Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity));
  623.                     Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity, new Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity));
  624.                     Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity, new Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity));
  625.                     Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market, new Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market));
  626.                     if (Account != null)
  627.                     {
  628.                         if (!Warehouses.ContainsKey((Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID)Account.EntityID))
  629.                             Warehouses.Add((Game.ConquerStructures.Warehouse.WarehouseID)Account.EntityID, new Game.ConquerStructures.Warehouse(this, (Game.ConquerStructures.Warehouse.WarehouseID)Account.EntityID));
  630.                     }
  631.                 }
  632.                 Trade = new Game.ConquerStructures.Trade();
  633.                 ArenaStatistic = new ArenaStatistic(true);
  634.                 Prayers = new List<GameState>();
  635.                 map = null;
  636.                 SpiritBeadQ = new Game.Features.SpiritBeadQuest(this);
  637.                 Quests = new MaTrix.Quests(this);
  638.                 //JiangHuStatus = new JiangHuStatus();
  639.             }
  640.             catch (Exception e)
  641.             {
  642.                 Program.SaveException(e);
  643.             }
  644.         }
  645.         public void Send(byte[] buffer)
  646.         {
  647.             if (Fake) return;
  648.             if (!_socket.Alive) return;
  649.             ushort length = BitConverter.ToUInt16(buffer, 0);
  650.             if (length >= 1024 && buffer.Length > length)
  651.             {
  652.                 //Console.WriteLine(Environment.StackTrace);
  653.                 return;
  654.             }
  655.             byte[] _buffer = new byte[buffer.Length];
  656.             if (length == 0)
  657.                 Writer.WriteUInt16((ushort)(buffer.Length - 8), 0, buffer);
  658.             Buffer.BlockCopy(buffer, 0, _buffer, 0, buffer.Length);
  659.             Network.Writer.WriteString(Constants.ServerKey, _buffer.Length - 8, _buffer);
  660.             try
  661.             {
  662.                 lock (_socket)
  663.                 {
  664.                     if (!_socket.Alive) return;
  665.                     lock (Cryptography)
  666.                     {
  667.                         Cryptography.Encrypt(_buffer, _buffer.Length);
  668.                         _socket.Send(_buffer);
  669.                     }
  670.                 }
  671.             }
  672.             catch (Exception)
  673.             {
  674.                 _socket.Alive = false;
  675.                 Disconnect();
  676.             }
  677.         }
  678.         private void EndSend(IAsyncResult res)
  679.         {
  680.             try
  681.             {
  682.                 _socket.Socket.EndSend(res);
  683.             }
  684.             catch
  685.             {
  686.                 _socket.Alive = false;
  687.                 Disconnect();
  688.             }
  689.         }
  690.         public void Send(Interfaces.IPacket buffer)
  691.         {
  692.             Send(buffer.ToArray());
  693.         }
  694.         public void SendScreenSpawn(Interfaces.IMapObject obj, bool self)
  695.         {
  696.             try
  697.             {
  698.                 foreach (Interfaces.IMapObject _obj in Screen.Objects)
  699.                 {
  700.                     if (_obj == null)
  701.                         continue;
  702.                     if (_obj.UID != Entity.UID)
  703.                     {
  704.                         if (_obj.MapObjType == Game.MapObjectType.Player)
  705.                         {
  706.                             GameState client = _obj.Owner as GameState;
  707.                             obj.SendSpawn(client, false);
  708.                         }
  709.                     }
  710.                 }
  711.                 if (self)
  712.                     obj.SendSpawn(this);
  713.             }
  714.             catch (Exception e)
  715.             {
  716.                 Program.SaveException(e);
  717.             }
  718.         }
  719.         public void RemoveScreenSpawn(Interfaces.IMapObject obj, bool self)
  720.         {
  721.             try
  722.             {
  723.                 if (Screen == null) return;
  724.                 if (Screen.Objects == null) return;
  725.                 foreach (Interfaces.IMapObject _obj in Screen.Objects)
  726.                 {
  727.                     if (_obj == null) continue;
  728.                     if (obj == null) continue;
  729.                     if (_obj.UID != Entity.UID)
  730.                     {
  731.                         if (_obj.MapObjType == Game.MapObjectType.Player)
  732.                         {
  733.                             GameState client = _obj.Owner as GameState;
  734.                             client.Screen.Remove(obj);
  735.                         }
  736.                     }
  737.                 }
  738.                 if (self)
  739.                     Screen.Remove(obj);
  740.             }
  741.             catch (Exception e)
  742.             {
  743.                 Program.SaveException(e);
  744.             }
  745.         }
  746.         public void SendScreen(byte[] buffer, bool self = true)
  747.         {
  748.             try
  749.             {
  750.                 foreach (Interfaces.IMapObject obj in Screen.Objects)
  751.                 {
  752.                     if (obj == null) continue;
  753.                     if (obj.UID != Entity.UID)
  754.                     {
  755.                         if (obj.MapObjType == Game.MapObjectType.Player)
  756.                         {
  757.                             GameState client = obj.Owner as GameState;
  758.                             if (WatchingGroup != null && client.WatchingGroup == null)
  759.                                 continue;
  760.                             client.Send(buffer);
  761.                         }
  762.                     }
  763.                 }
  764.                 if (self)
  765.                     Send(buffer);
  766.             }
  767.             catch (Exception e)
  768.             {
  769.                 Program.SaveException(e);
  770.             }
  771.         }
  772.         public void SendScreen(Interfaces.IPacket buffer, bool self = true)
  773.         {
  774.             foreach (Interfaces.IMapObject obj in Screen.Objects)
  775.             {
  776.                 if (obj == null) continue;
  777.                 if (obj.MapObjType == Game.MapObjectType.Player)
  778.                 {
  779.                     GameState client = obj.Owner as GameState;
  780.                     if (client.Entity.UID != Entity.UID)                      
  781.                         client.Send(buffer);
  782.                 }
  783.             }
  784.             if (self)
  785.                 Send(buffer);
  786.         }
  787.         public void Disconnect(bool save = true)
  788.         {
  789.             if (Fake) return;
  790.             if (Screen != null) Screen.DisposeTimers();
  791.             PacketHandler.RemoveTPA(this);
  792.             Program.World.Unregister(this);
  793.             if (OnDisconnect != null) OnDisconnect(this);
  794.             if (_socket.Connector != null)
  795.             {
  796.                 if (Entity != null)
  797.                 {
  798.                     if (Entity.MyPokerTable != null)
  799.                     {
  800.                         if (Entity.MyPokerTable.Players.ContainsKey(Entity.UID) && Entity.MyPokerTable.Pot > 1)
  801.                         {
  802.                             byte[] P = new byte[10];
  803.                             P[6] = 4; P[9] = 200;
  804.                             Entity.MyPokerTable.NewPlayerMove(P, Entity.UID);
  805.                         }
  806.                         else
  807.                             Entity.MyPokerTable.RemovePlayer(Entity.UID);
  808.                     }
  809.                 }
  810.                 _socket.Disconnect();
  811.                 ShutDown();
  812.             }
  813.         }
  814.  
  815.         private void ShutDown()
  816.         {
  817.  
  818.             if (Socket.Connector == null) return;
  819.             Socket.Connector = null;
  820.             if (this.Entity != null)
  821.             {
  822.                 try
  823.                 {
  824.                     if (this.Entity.JustCreated) return;
  825.                     Time32 now = Time32.Now;
  826.                     Kernel.DisconnectPool.Add(this.Entity.UID, this);
  827.                     RemoveScreenSpawn(this.Entity, false);
  828.  
  829.                     using (var conn = Database.DataHolder.MySqlConnection)
  830.                     {
  831.                         conn.Open();
  832.                         Database.EntityTable.UpdateOnlineStatus(this, false, conn);
  833.                         Database.EntityTable.SaveEntity(this, conn);  
  834.                         if (!TransferedPlayer)
  835.                             Database.EntityVariableTable.Save(this, conn);
  836.                         Database.SkillTable.SaveProficiencies(this, conn);
  837.                         Database.SkillTable.SaveSpells(this, conn);
  838.                         if (!TransferedPlayer)
  839.                         {
  840.                             Database.ArenaTable.SaveArenaStatistics(this.ArenaStatistic, conn);
  841.                             Database.TeamArenaTable.SaveArenaStatistics(this.TeamArenaStatistic, conn);
  842.                             Database.ChampionTable.SaveStatistics(this.ChampionStats, conn);
  843.                         }
  844.                     }                  
  845.                     Kernel.GamePool.Remove(this.Entity.UID);
  846.  
  847.                     Fame.Save(this);
  848.  
  849.                     if (Booth != null)
  850.                         Booth.Remove();
  851.  
  852.                     if (Entity.MyClones.Count > 0)
  853.                     {
  854.                         foreach (var item in Entity.MyClones.Values)
  855.                         {                            
  856.                             Data data = new Data(true);
  857.                             data.UID = item.UID;
  858.                             data.ID = Network.GamePackets.Data.RemoveEntity;
  859.                             item.MonsterInfo.SendScreen(data);
  860.                         }
  861.                         Entity.MyClones.Clear();
  862.                     }
  863.                     if (Quests != null)
  864.                         Quests.Save();
  865.  
  866.                     if (Pet != null)
  867.                         Pet.ClearAll();
  868.                     if (QualifierGroup != null)
  869.                         QualifierGroup.End(this);
  870.                     if (TeamQualifierGroup != null)
  871.                         TeamQualifierGroup.CheckEnd(this, true);
  872.                     if (Entity.CLanArenaBattleFight != null)
  873.                         Entity.CLanArenaBattleFight.CheakToEnd(this, true);
  874.                     if (Entity.GuildArenaBattleFight != null)
  875.                         Entity.GuildArenaBattleFight.CheakToEnd(this, true);
  876.                     if (ChampionGroup != null)
  877.                         ChampionGroup.End(this);
  878.                     if (Challenge != null)
  879.                         Challenge.End(this);
  880.  
  881.                    
  882.  
  883.                     Game.Arena.Clear(this);
  884.                     Game.TeamArena.Clear(this);
  885.                     Game.Champion.Clear(this);
  886.  
  887.                     RemoveScreenSpawn(this.Entity, false);
  888.                    
  889.                     #region Friend/TradePartner/Apprentice
  890.                     Message msg = new Message("Your friend, " + Entity.Name + ", has logged off.", System.Drawing.Color.Red, Message.TopLeft);
  891.                     if (Friends == null)
  892.                         Friends = new SafeDictionary<uint, Conquer_Online_Server.Game.ConquerStructures.Society.Friend>(100);
  893.                     foreach (Game.ConquerStructures.Society.Friend friend in Friends.Values)
  894.                     {
  895.                         if (friend.IsOnline)
  896.                         {
  897.                             var packet = new Conquer_Online_Server.Network.GamePackets.KnownPersons(true)
  898.                             {
  899.                                 UID = Entity.UID,
  900.                                 Type = Network.GamePackets.KnownPersons.RemovePerson,
  901.                                 Name = Entity.Name,
  902.                                 Online = false
  903.                             };
  904.                             friend.Client.Send(packet);
  905.                             packet.Type = Network.GamePackets.KnownPersons.AddFriend;
  906.                             if (friend != null)
  907.                             {
  908.                                 if (friend.Client != null)
  909.                                 {
  910.                                     friend.Client.Send(packet);
  911.                                     friend.Client.Send(msg);
  912.                                 }
  913.                             }
  914.                         }
  915.                     }
  916.                     Message msg2 = new Message("Your partner, " + Entity.Name + ", has logged off.", System.Drawing.Color.Red, Message.TopLeft);
  917.  
  918.                     if (Partners != null)
  919.                     {
  920.                         foreach (Game.ConquerStructures.Society.TradePartner partner in Partners.Values)
  921.                         {
  922.                             if (partner.IsOnline)
  923.                             {
  924.                                 var packet = new TradePartner(true)
  925.                                 {
  926.                                     UID = Entity.UID,
  927.                                     Type = TradePartner.BreakPartnership,
  928.                                     Name = Entity.Name,
  929.                                     HoursLeft = (int)(new TimeSpan(partner.ProbationStartedOn.AddDays(3).Ticks).TotalHours - new TimeSpan(DateTime.Now.Ticks).TotalHours),
  930.                                     Online = false
  931.                                 };
  932.                                 partner.Client.Send(packet);
  933.                                 packet.Type = TradePartner.AddPartner;
  934.                                 if (partner != null)
  935.                                 {
  936.                                     if (partner.Client != null)
  937.                                     {
  938.                                         partner.Client.Send(packet);
  939.                                         partner.Client.Send(msg2);
  940.                                     }
  941.                                 }
  942.                             }
  943.                         }
  944.                     }
  945.                     MentorInformation Information = new MentorInformation(true);
  946.                     Information.Mentor_Type = 1;
  947.                     Information.Mentor_ID = Entity.UID;
  948.                     Information.Mentor_Level = Entity.Level;
  949.                     Information.Mentor_Class = Entity.Class;
  950.                     Information.Mentor_PkPoints = Entity.PKPoints;
  951.                     Information.Mentor_Mesh = Entity.Mesh;
  952.                     Information.Mentor_Online = false;
  953.                     Information.String_Count = 3;
  954.                     Information.Mentor_Name = Entity.Name;
  955.                     Information.Mentor_Spouse_Name = Entity.Spouse;
  956.                     if (Apprentices == null) Apprentices = new SafeDictionary<uint, Game.ConquerStructures.Society.Apprentice>();
  957.                     foreach (var appr in Apprentices.Values)
  958.                     {
  959.                         if (appr.IsOnline)
  960.                         {
  961.                             Information.Apprentice_ID = appr.ID;
  962.                             Information.Enrole_Date = appr.EnroleDate;
  963.                             Information.Apprentice_Name = appr.Name;
  964.                             appr.Client.Send(Information);
  965.                             appr.Client.ReviewMentor();
  966.                         }
  967.                     }
  968.                     if (Mentor != null)
  969.                     {
  970.                         if (Mentor.IsOnline)
  971.                         {
  972.                             ApprenticeInformation AppInfo = new ApprenticeInformation();
  973.                             AppInfo.Apprentice_ID = Entity.UID;
  974.                             AppInfo.Apprentice_Level = Entity.Level;
  975.                             AppInfo.Apprentice_Name = Entity.Name;
  976.                             AppInfo.Apprentice_Online = false;
  977.                             AppInfo.Apprentice_Spouse_Name = Entity.Spouse;
  978.                             AppInfo.Enrole_date = Mentor.EnroleDate;
  979.                             AppInfo.Mentor_ID = Mentor.Client.Entity.UID;
  980.                             AppInfo.Mentor_Mesh = Mentor.Client.Entity.Mesh;
  981.                             AppInfo.Mentor_Name = Mentor.Client.Entity.Name;
  982.                             AppInfo.Type = 2;
  983.                             Mentor.Client.Send(AppInfo);
  984.                         }
  985.                     }
  986.  
  987.                     #endregion
  988.                     #region Team
  989.                    /* if (Team != null)
  990.                     {
  991.                         if (Team.TeamLeader)
  992.                         {
  993.                             Network.GamePackets.Team team = new Network.GamePackets.Team();
  994.                             team.UID = Account.EntityID;
  995.                             team.Type = Network.GamePackets.Team.Dismiss;
  996.                             foreach (Client.GameState Teammate in Team.Teammates)
  997.                             {
  998.                                 if (Teammate != null)
  999.                                 {
  1000.                                     if (Teammate.Entity.UID != Account.EntityID)
  1001.                                     {
  1002.                                         Teammate.Send(team);
  1003.                                         Teammate.Team = null;
  1004.                                     }
  1005.                                 }
  1006.                             }
  1007.                         }
  1008.                         else
  1009.                         {
  1010.                             Network.GamePackets.Team team = new Network.GamePackets.Team();
  1011.                             team.UID = Account.EntityID;
  1012.                             team.Type = Network.GamePackets.Team.ExitTeam;
  1013.                             foreach (Client.GameState Teammate in Team.Teammates)
  1014.                             {
  1015.                                 if (Teammate != null)
  1016.                                 {
  1017.                                     if (Teammate.Entity.UID != Account.EntityID)
  1018.                                     {
  1019.                                         Teammate.Send(team);
  1020.                                         Teammate.Team.Remove(this);
  1021.                                     }
  1022.                                 }
  1023.                             }
  1024.                         }
  1025.                     }*/
  1026.                     #endregion
  1027.                     if (Team != null)
  1028.                     {
  1029.                         Team.Remove(this, true);
  1030.                     }
  1031.                 }
  1032.                 catch (Exception e)
  1033.                 {
  1034.                     Program.SaveException(e);
  1035.                 }
  1036.                 finally
  1037.                 {
  1038.                     Kernel.DisconnectPool.Remove(this.Entity.UID);
  1039.                     Console.WriteLine(this.Entity.Name + " has logged off! Ip:[" + this.Account.IP + "]", ConsoleColor.Green);
  1040.                     new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("configuration").Set("LastPlayer", Entity.Name).Set("login", "has logged off").Execute();
  1041.  
  1042.                 }
  1043.             }
  1044.         }
  1045.  
  1046.         public ClientWrapper Socket { get { return _socket; } }
  1047.         public string IP
  1048.         {
  1049.             get
  1050.             {
  1051.                 return _socket.IP;
  1052.             }
  1053.         }
  1054.         #endregion
  1055.  
  1056.         #region Game
  1057.  
  1058.         public Database.ChiTable.ChiData ChiData;
  1059.         public List<ChiPowerStructure> ChiPowers;
  1060.         public ChiPowerStructure[] Retretead_ChiPowers;
  1061.         public uint ChiPoints = 0;
  1062.  
  1063.         //public List<JiangPowerStructure> JiangPowers;
  1064.         //public JiangHuStatus JiangHuStatus;
  1065.         //public JiangHu JiangHu;
  1066.         public SafeDictionary<uint, DetainedItem> ClaimableItem = new SafeDictionary<uint, DetainedItem>(1000),
  1067.                                                   DeatinedItem = new SafeDictionary<uint, DetainedItem>(1000);
  1068.  
  1069.         public bool DoSetOffline = true;
  1070.  
  1071.         public ushort OnlineTrainingPoints = 0;
  1072.         public Time32 LastTrainingPointsUp, LastTreasurePoints = Time32.Now.AddMinutes(1);
  1073.  
  1074.         public List<string> GuildNamesSpawned = new List<string>();
  1075.  
  1076.         public byte KylinUpgradeCount = 0;
  1077.  
  1078.         public ulong OblivionExperience = 0;
  1079.         public byte OblivionKills = 0;
  1080.  
  1081.         public int PremShopType = 0;
  1082.         public DateTime VIPDate;
  1083.         public DateTime LastVote;
  1084.         public uint VIPDays;
  1085.         public uint DonationPoints;
  1086.         //  public uint VotePoints;
  1087.         #region Colo
  1088.         public static uint ScreenColor = 0;
  1089.         #region Night Color
  1090.  
  1091.         public void Night()
  1092.         {
  1093.             ScreenColor = 5855577;
  1094.  
  1095.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1096.             Packet.UID = this.Entity.UID;
  1097.             Packet.ID = 104;
  1098.             Packet.dwParam = ScreenColor;
  1099.             foreach (GameState pclient in Kernel.GamePool.Values)
  1100.             {
  1101.                 pclient.Send(Packet);
  1102.             }
  1103.         }
  1104.         public void Night1()
  1105.         {
  1106.             ScreenColor = 3358767;
  1107.  
  1108.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1109.             Packet.UID = this.Entity.UID;
  1110.             Packet.ID = 104;
  1111.             Packet.dwParam = ScreenColor;
  1112.             foreach (GameState pclient in Kernel.GamePool.Values)
  1113.             {
  1114.                 pclient.Send(Packet);
  1115.             }
  1116.         }
  1117.         public void Night2()
  1118.         {
  1119.             ScreenColor = 97358;
  1120.  
  1121.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1122.             Packet.UID = this.Entity.UID;
  1123.             Packet.ID = 104;
  1124.             Packet.dwParam = ScreenColor;
  1125.             foreach (GameState pclient in Kernel.GamePool.Values)
  1126.             {
  1127.                 pclient.Send(Packet);
  1128.             }
  1129.         }
  1130.  
  1131.         #endregion
  1132.         #region Blue Color
  1133.  
  1134.         public void Blue()
  1135.         {
  1136.             ScreenColor = 69852;
  1137.  
  1138.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1139.             Packet.UID = this.Entity.UID;
  1140.             Packet.ID = 104;
  1141.             Packet.dwParam = ScreenColor;
  1142.             foreach (GameState pclient in Kernel.GamePool.Values)
  1143.             {
  1144.                 pclient.Send(Packet);
  1145.             }
  1146.         }
  1147.         public void Blue1()
  1148.         {
  1149.             ScreenColor = 4532453;
  1150.  
  1151.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1152.             Packet.UID = this.Entity.UID;
  1153.             Packet.ID = 104;
  1154.             Packet.dwParam = ScreenColor;
  1155.             foreach (GameState pclient in Kernel.GamePool.Values)
  1156.             {
  1157.                 pclient.Send(Packet);
  1158.             }
  1159.         }
  1160.         public void Blue2()
  1161.         {
  1162.             ScreenColor = 684533;
  1163.  
  1164.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1165.             Packet.UID = this.Entity.UID;
  1166.             Packet.ID = 104;
  1167.             Packet.dwParam = ScreenColor;
  1168.             foreach (GameState pclient in Kernel.GamePool.Values)
  1169.             {
  1170.                 pclient.Send(Packet);
  1171.             }
  1172.         }
  1173.  
  1174.         #endregion
  1175.         #region Green Color
  1176.  
  1177.         public void Green()
  1178.         {
  1179.             ScreenColor = 838915;
  1180.  
  1181.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1182.             Packet.UID = this.Entity.UID;
  1183.             Packet.ID = 104;
  1184.             Packet.dwParam = ScreenColor;
  1185.             foreach (GameState pclient in Kernel.GamePool.Values)
  1186.             {
  1187.                 pclient.Send(Packet);
  1188.             }
  1189.         }
  1190.         public void Green1()
  1191.         {
  1192.             ScreenColor = 824383;
  1193.  
  1194.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1195.             Packet.UID = this.Entity.UID;
  1196.             Packet.ID = 104;
  1197.             Packet.dwParam = ScreenColor;
  1198.             foreach (GameState pclient in Kernel.GamePool.Values)
  1199.             {
  1200.                 pclient.Send(Packet);
  1201.             }
  1202.         }
  1203.         public void Green2()
  1204.         {
  1205.             ScreenColor = 456828;
  1206.  
  1207.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1208.             Packet.UID = this.Entity.UID;
  1209.             Packet.ID = 104;
  1210.             Packet.dwParam = ScreenColor;
  1211.             foreach (GameState pclient in Kernel.GamePool.Values)
  1212.             {
  1213.                 pclient.Send(Packet);
  1214.             }
  1215.         }
  1216.         public void Green3()
  1217.         {
  1218.             ScreenColor = 5547633;
  1219.  
  1220.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1221.             Packet.UID = this.Entity.UID;
  1222.             Packet.ID = 104;
  1223.             Packet.dwParam = ScreenColor;
  1224.             foreach (GameState pclient in Kernel.GamePool.Values)
  1225.             {
  1226.                 pclient.Send(Packet);
  1227.             }
  1228.         }
  1229.         public void Green4()
  1230.         {
  1231.             ScreenColor = 453450;
  1232.  
  1233.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1234.             Packet.UID = this.Entity.UID;
  1235.             Packet.ID = 104;
  1236.             Packet.dwParam = ScreenColor;
  1237.             foreach (GameState pclient in Kernel.GamePool.Values)
  1238.             {
  1239.                 pclient.Send(Packet);
  1240.             }
  1241.         }
  1242.  
  1243.         #endregion
  1244.         #region Day Color
  1245.  
  1246.         public void Day()
  1247.         {
  1248.             ScreenColor = 0;
  1249.  
  1250.             Network.GamePackets.ScreenColor Packet = new Network.GamePackets.ScreenColor(true);
  1251.             Packet.UID = this.Entity.UID;
  1252.             Packet.ID = 104;
  1253.             Packet.dwParam = ScreenColor;
  1254.             foreach (GameState pclient in Kernel.GamePool.Values)
  1255.             {
  1256.                 pclient.Send(Packet);
  1257.             }
  1258.         }
  1259.  
  1260.         #endregion
  1261.         #endregion
  1262.         public Time32 ScreenReloadTime;
  1263.         public int MillisecondsScreenReload;
  1264.         public bool Reloaded = false;
  1265.         public Interfaces.IPacket ReloadWith;
  1266.  
  1267.         public ushort VendingDisguise;
  1268.         //public uint BlessTime;
  1269.         public uint BlessTime
  1270.         {
  1271.             get { return this["BlessTime"]; }
  1272.             set { this["BlessTime"] = value; }
  1273.         }
  1274.         public DateTime BlessStamp
  1275.         {
  1276.             get { return this["BlessStamp"]; }
  1277.             set { this["BlessStamp"] = value; }
  1278.         }
  1279.         public DateTime DoubleExperienceStamp
  1280.         {
  1281.             get { return this["DoubleExperienceStamp"]; }
  1282.             set { this["DoubleExperienceStamp"] = value; }
  1283.         }
  1284.         public int speedHackSuspiction = 0;
  1285.         public Time32 LastPingT;
  1286.         public uint LastPingStamp = 0;
  1287.        // public Game.Entity Companion;
  1288.  
  1289.         public List<GameState> Prayers;
  1290.         public GameState PrayLead;
  1291.  
  1292.         public DateTime ChatBanTime;
  1293.         public uint ChatBanLasts;
  1294.         public bool ChatBanned;
  1295.  
  1296.         public uint BackupArmorLook
  1297.         {
  1298.             get { return this["bkparmorlook"]; }
  1299.             set { this["bkparmorlook"] = value; }
  1300.         }
  1301.         public uint ArmorLook
  1302.         {
  1303.             get { return this["armorlook"]; }
  1304.             set { this["armorlook"] = value; }
  1305.         }
  1306.         public uint WeaponLook
  1307.         {
  1308.             get { return this["weaponlook"]; }
  1309.             set { this["weaponlook"] = value; }
  1310.         }
  1311.         public uint WeaponLook2
  1312.         {
  1313.             get { return this["weaponlook2"]; }
  1314.             set { this["weaponlook2"] = value; }
  1315.         }
  1316.         public uint HeadgearLook
  1317.         {
  1318.             get { return this["headgearlook"]; }
  1319.             set { this["headgearlook"] = value; }
  1320.         }
  1321.  
  1322.         public bool ValidArmorLook(uint id)
  1323.         {
  1324.             if (id == 0) return false;
  1325.            
  1326.             var soulInfo = Database.AddingInformationTable.SoulGearItems[id];
  1327.             if (id >= 800000 && id < 900000)
  1328.             {
  1329.                 if (soulInfo.ItemIdentifier < 100)
  1330.                     if (soulInfo.ItemIdentifier != ConquerItem.Armor)
  1331.                         return false;
  1332.                     else { }
  1333.                 else
  1334.                     if (Network.PacketHandler.ItemPosition((uint)(soulInfo.ItemIdentifier * 1000)) != ConquerItem.Armor)
  1335.                         return false;
  1336.             }
  1337.             else
  1338.                 if (Network.PacketHandler.ItemPosition(id) != ConquerItem.Armor)
  1339.                     return false;
  1340.             return true;
  1341.         }
  1342.         public bool ValidHeadgearLook(uint id)
  1343.         {
  1344.             if (id == 0) return false;
  1345.            
  1346.             var soulInfo = Database.AddingInformationTable.SoulGearItems[id];
  1347.             if (id >= 800000 && id < 900000)
  1348.             {
  1349.                 if (soulInfo.ItemIdentifier < 100)
  1350.                     if (soulInfo.ItemIdentifier != ConquerItem.Head)
  1351.                         return false;
  1352.                     else { }
  1353.                 else
  1354.                     if (Network.PacketHandler.ItemPosition((uint)(soulInfo.ItemIdentifier * 1000)) != ConquerItem.Head)
  1355.                         return false;
  1356.             }
  1357.             else
  1358.                 if (Network.PacketHandler.ItemPosition(id) != ConquerItem.Head)
  1359.                     return false;
  1360.             return true;
  1361.         }
  1362.         public bool ValidWeaponLook(uint id)
  1363.         {
  1364.             if (id == 0) return false;
  1365.                 if (Network.PacketHandler.ItemPosition(id) != ConquerItem.RightWeapon)
  1366.                     return false;
  1367.             return true;
  1368.         }
  1369.         public bool ValidWeaponLook2(uint id)
  1370.         {
  1371.             if (id == 0) return false;
  1372.             if (Network.PacketHandler.ItemPosition(id) != ConquerItem.RightWeapon)
  1373.             {
  1374.                 if (Network.PacketHandler.ItemPosition(id) != ConquerItem.LeftWeapon)
  1375.                     return false;
  1376.             }
  1377.             else
  1378.             {
  1379.                 if (Network.PacketHandler.IsTwoHand(id))
  1380.                     return false;
  1381.             }            
  1382.             return true;
  1383.         }
  1384.  
  1385.         public ConquerItemBaseInformation CheckLook(string name, ushort pos, out int minDist)
  1386.         {
  1387.             minDist = int.MaxValue;
  1388.             Database.ConquerItemBaseInformation CIBI = null;
  1389.             Game.Enums.ItemQuality Quality = Game.Enums.ItemQuality.Fixed;
  1390.             var itemx = Equipment.TryGetItem((byte)pos);
  1391.             if (itemx != null)
  1392.                 Quality = (Enums.ItemQuality)(itemx.ID % 10);          
  1393.            
  1394.             foreach (var item in Database.ConquerItemInformation.BaseInformations.Values)
  1395.             {
  1396.                 if (pos == ConquerItem.Armor)
  1397.                 {
  1398.                     if (ValidArmorLook(item.ID))
  1399.                     {
  1400.                         int dist = name.LevenshteinDistance(item.LowerName);
  1401.                         if (minDist > dist && Quality == (Game.Enums.ItemQuality)(item.ID % 10))
  1402.                         {
  1403.                             CIBI = item;
  1404.                             minDist = dist;
  1405.                         }
  1406.                     }
  1407.                 }
  1408.                 else if (pos == ConquerItem.Head)
  1409.                 {
  1410.                     if (ValidHeadgearLook(item.ID))
  1411.                     {
  1412.                         int dist = name.LevenshteinDistance(item.LowerName);
  1413.                         if (minDist > dist && Quality == (Game.Enums.ItemQuality)(item.ID % 10))
  1414.                         {
  1415.                             CIBI = item;
  1416.                             minDist = dist;
  1417.                         }
  1418.                     }
  1419.                 }
  1420.                 else if (pos == ConquerItem.LeftWeapon)
  1421.                 {
  1422.                     if (ValidWeaponLook2(item.ID))
  1423.                     {
  1424.                         int dist = name.LevenshteinDistance(item.LowerName);
  1425.                         if (minDist > dist && !PacketHandler.IsTwoHand(item.ID) && Quality == (Game.Enums.ItemQuality)(item.ID % 10))
  1426.                         {
  1427.                             CIBI = item;
  1428.                             minDist = dist;
  1429.                         }
  1430.                     }
  1431.                 }
  1432.                 else if (pos == ConquerItem.RightWeapon)
  1433.                 {
  1434.                     if (ValidWeaponLook(item.ID))
  1435.                     {
  1436.                         //if (PacketHandler.IsTwoHand(itemx.ID))
  1437.                         //{
  1438.                         //    int dist = name.LevenshteinDistance(item.LowerName);
  1439.                         //    if (minDist > dist && PacketHandler.IsTwoHand(item.ID) && Quality == (Game.Enums.ItemQuality)(item.ID % 10))
  1440.                         //    {
  1441.                         //        CIBI = item;
  1442.                         //        minDist = dist;
  1443.                         //    }
  1444.                         //}
  1445.                         //else
  1446.                         {
  1447.                             int dist = name.LevenshteinDistance(item.LowerName);
  1448.                             if (minDist > dist && !PacketHandler.IsTwoHand(item.ID) && Quality == (Game.Enums.ItemQuality)(item.ID % 10))
  1449.                             {
  1450.                                 CIBI = item;
  1451.                                 minDist = dist;
  1452.                             }
  1453.                         }
  1454.  
  1455.                     }
  1456.                 }
  1457.             }
  1458.             return CIBI;
  1459.         }
  1460.  
  1461.         public void SetNewArmorLook(uint id, bool change = true)
  1462.         {
  1463.             if (change)
  1464.                 ArmorLook = id;
  1465.             if (!ValidArmorLook(id)) return;
  1466.             int min = 0;
  1467.             id = CheckLook(Database.ConquerItemInformation.BaseInformations[id].LowerName, ConquerItem.Armor, out min).ID;
  1468.  
  1469.             var item = Equipment.TryGetItem(ConquerItem.Armor);
  1470.             var iu = new Network.GamePackets.ItemUsage(true);
  1471.             iu.UID = uint.MaxValue - 1;
  1472.             iu.dwParam = 13;
  1473.             iu.ID = Network.GamePackets.ItemUsage.UnequipItem;
  1474.             Send(iu);
  1475.             iu = new Network.GamePackets.ItemUsage(true);
  1476.             iu.UID = uint.MaxValue - 1;
  1477.             iu.ID = Network.GamePackets.ItemUsage.RemoveInventory;
  1478.             Send(iu);
  1479.  
  1480.             ConquerItem fakeItem = new Network.GamePackets.ConquerItem(true);
  1481.             fakeItem.ID = id;
  1482.             if (item != null)
  1483.             {
  1484.                 fakeItem.Bless = item.Bless;
  1485.                 fakeItem.Bound = item.Bound;
  1486.                 fakeItem.Color = item.Color;
  1487.                 fakeItem.Effect = item.Effect;
  1488.                 fakeItem.Enchant = item.Enchant;
  1489.                 fakeItem.Plus = item.Plus;
  1490.                 fakeItem.SocketOne = item.SocketOne;
  1491.                 fakeItem.SocketTwo = item.SocketTwo;
  1492.             }
  1493.  
  1494.             fakeItem.Durability = 1;
  1495.             fakeItem.MaximDurability = 1;
  1496.             fakeItem.Color = Game.Enums.Color.Black;
  1497.             fakeItem.UID = uint.MaxValue - 1;
  1498.             fakeItem.Position = 13;
  1499.             Send(fakeItem);
  1500.             fakeItem.Mode = Enums.ItemMode.Update;
  1501.             Send(fakeItem);
  1502.             ClientEquip eqs = new ClientEquip();
  1503.             eqs.DoEquips(this);
  1504.             Send(eqs);
  1505.             Equipment.UpdateEntityPacket();
  1506.         }
  1507.         public void SetNewHeadgearLook(uint id, bool change = true)
  1508.         {
  1509.             if (change)
  1510.                 HeadgearLook = id;
  1511.             if (!ValidHeadgearLook(id)) return;
  1512.             int min = 0;
  1513.             id = CheckLook(Database.ConquerItemInformation.BaseInformations[id].LowerName, ConquerItem.Head, out min).ID;
  1514.  
  1515.             var item = Equipment.TryGetItem(ConquerItem.Head);
  1516.             var iu = new Network.GamePackets.ItemUsage(true);
  1517.             iu.UID = uint.MaxValue - 2;
  1518.             iu.dwParam = 14;
  1519.             iu.ID = Network.GamePackets.ItemUsage.UnequipItem;
  1520.             Send(iu);
  1521.             iu = new Network.GamePackets.ItemUsage(true);
  1522.             iu.UID = uint.MaxValue - 2;
  1523.             iu.ID = Network.GamePackets.ItemUsage.RemoveInventory;
  1524.             Send(iu);
  1525.  
  1526.             ConquerItem fakeItem = new Network.GamePackets.ConquerItem(true);
  1527.             fakeItem.ID = id;
  1528.             if (item != null)
  1529.             {
  1530.                 fakeItem.Bless = item.Bless;
  1531.                 fakeItem.Bound = item.Bound;
  1532.                 fakeItem.Color = item.Color;
  1533.                 fakeItem.Effect = item.Effect;
  1534.                 fakeItem.Enchant = item.Enchant;
  1535.                 fakeItem.Plus = item.Plus;
  1536.                 fakeItem.SocketOne = item.SocketOne;
  1537.                 fakeItem.SocketTwo = item.SocketTwo;
  1538.             }
  1539.  
  1540.             fakeItem.Durability = 1;
  1541.             fakeItem.MaximDurability = 1;
  1542.             fakeItem.Color = Game.Enums.Color.Black;
  1543.             fakeItem.UID = uint.MaxValue - 2;
  1544.             fakeItem.Position = 14;
  1545.             Send(fakeItem);
  1546.             fakeItem.Mode = Enums.ItemMode.Update;
  1547.             Send(fakeItem);
  1548.             ClientEquip eqs = new ClientEquip();
  1549.             eqs.DoEquips(this);
  1550.             Send(eqs);
  1551.             Equipment.UpdateEntityPacket();
  1552.         }
  1553.         public void SetNewWeaponLook(uint id, bool change = true)
  1554.         {
  1555.             if (change)
  1556.                 WeaponLook = id;
  1557.             if (!ValidWeaponLook(id)) return;
  1558.             int min = 0;
  1559.            
  1560.             var item = Equipment.TryGetItem(ConquerItem.RightWeapon);
  1561.             var iu = new Network.GamePackets.ItemUsage(true);
  1562.             iu.UID = uint.MaxValue - 3;
  1563.             iu.dwParam = ConquerItem.RightWeaponAccessory;
  1564.             iu.ID = Network.GamePackets.ItemUsage.UnequipItem;
  1565.             Send(iu);
  1566.             iu = new Network.GamePackets.ItemUsage(true);
  1567.             iu.UID = uint.MaxValue - 3;
  1568.             iu.ID = Network.GamePackets.ItemUsage.RemoveInventory;
  1569.             Send(iu);
  1570.  
  1571.             id = CheckLook(Database.ConquerItemInformation.BaseInformations[id].LowerName, ConquerItem.RightWeapon, out min).ID;
  1572.          
  1573.             ConquerItem fakeItem = new Network.GamePackets.ConquerItem(true);
  1574.             fakeItem.ID = id;
  1575.             if (item != null)
  1576.             {
  1577.                 fakeItem.Bless = item.Bless;
  1578.                 fakeItem.Bound = item.Bound;
  1579.                 fakeItem.Color = item.Color;
  1580.                 fakeItem.Effect = item.Effect;
  1581.                 fakeItem.Enchant = item.Enchant;
  1582.                 fakeItem.Plus = item.Plus;
  1583.                 fakeItem.SocketOne = item.SocketOne;
  1584.                 fakeItem.SocketTwo = item.SocketTwo;
  1585.                 fakeItem.Lock = 1;
  1586.             }
  1587.             fakeItem.Durability = 1;
  1588.             fakeItem.MaximDurability = 1;        
  1589.             fakeItem.UID = uint.MaxValue - 3;
  1590.             fakeItem.Position = ConquerItem.RightWeaponAccessory;
  1591.             Send(fakeItem);
  1592.             fakeItem.Mode = Enums.ItemMode.Update;
  1593.             Send(fakeItem);
  1594.             ClientEquip eqs = new ClientEquip();            
  1595.             eqs.DoEquips(this);
  1596.             Send(eqs);
  1597.             Equipment.UpdateEntityPacket();
  1598.            
  1599.         }
  1600.         public void SetNewWeaponLook2(uint id, bool change = true)
  1601.         {
  1602.             if (change)
  1603.                 WeaponLook2 = id;
  1604.             if (!ValidWeaponLook2(id)) return;
  1605.             int min = 0;
  1606.  
  1607.             var item = Equipment.TryGetItem(ConquerItem.LeftWeapon);
  1608.             var iu = new Network.GamePackets.ItemUsage(true);
  1609.             iu.UID = uint.MaxValue - 4;
  1610.             iu.dwParam = ConquerItem.LeftWeaponAccessory;
  1611.             iu.ID = Network.GamePackets.ItemUsage.UnequipItem;
  1612.             Send(iu);
  1613.             iu = new Network.GamePackets.ItemUsage(true);
  1614.             iu.UID = uint.MaxValue - 4;
  1615.             iu.ID = Network.GamePackets.ItemUsage.RemoveInventory;
  1616.             Send(iu);
  1617.  
  1618.             id = CheckLook(Database.ConquerItemInformation.BaseInformations[id].LowerName, ConquerItem.LeftWeapon, out min).ID;
  1619.  
  1620.             ConquerItem fakeItem = new Network.GamePackets.ConquerItem(true);
  1621.             fakeItem.ID = id;
  1622.             if (item != null)
  1623.             {
  1624.                 fakeItem.Bless = item.Bless;
  1625.                 fakeItem.Bound = item.Bound;
  1626.                 fakeItem.Color = item.Color;
  1627.                 fakeItem.Effect = item.Effect;
  1628.                 fakeItem.Enchant = item.Enchant;
  1629.                 fakeItem.Plus = item.Plus;
  1630.                 fakeItem.SocketOne = item.SocketOne;
  1631.                 fakeItem.SocketTwo = item.SocketTwo;
  1632.                 fakeItem.Lock = 1;
  1633.             }
  1634.  
  1635.             fakeItem.Durability = 1;
  1636.             fakeItem.MaximDurability = 1;
  1637.             fakeItem.UID = uint.MaxValue - 4;
  1638.             fakeItem.Position = ConquerItem.LeftWeaponAccessory;
  1639.             Send(fakeItem);
  1640.             fakeItem.Mode = Enums.ItemMode.Update;
  1641.             Send(fakeItem);
  1642.             ClientEquip eqs = new ClientEquip();            
  1643.             eqs.DoEquips(this);
  1644.             Send(eqs);
  1645.             Equipment.UpdateEntityPacket();
  1646.  
  1647.         }
  1648.  
  1649.         public byte JewelarLauKind, JewelarLauGems;
  1650.         public uint VirtuePoints;
  1651.         public DateTime LastLotteryEntry;
  1652.         public byte LotteryEntries;
  1653.         public bool InLottery;
  1654.         public DateTime OfflineTGEnterTime;
  1655.         public bool Mining = false;
  1656.         public Time32 MiningStamp;
  1657.         public ushort Vigor
  1658.         {
  1659.             get
  1660.             {
  1661.                 if (Equipment != null)
  1662.                     if (!Equipment.Free(12))
  1663.                         return Equipment.TryGetItem((byte)12).Vigor;
  1664.                 return 65535;
  1665.             }
  1666.             set
  1667.             {
  1668.                 if (!Equipment.Free(12))
  1669.                     Equipment.TryGetItem((byte)12).Vigor = value;
  1670.             }
  1671.         }
  1672.         public ushort MaxVigor
  1673.         {
  1674.             get { return (ushort)(30 + Entity.ExtraVigor); }
  1675.         }
  1676.  
  1677.         public bool HeadgearClaim, NecklaceClaim, ArmorClaim, WeaponClaim, RingClaim, BootsClaim, TowerClaim, FanClaim;
  1678.         public string PromoteItemNameNeed
  1679.         {
  1680.             get
  1681.             {
  1682.                 if (Entity.Class % 10 == 0)
  1683.                     return " nothing but";
  1684.                 if (Entity.Class % 10 == 1)
  1685.                     //   if (Entity.Class / 10 == 4)
  1686.                     //      return " five Euxenite Ores and";
  1687.                     //    else
  1688.                     return " nothing but";
  1689.                 if (Entity.Class % 10 == 2)
  1690.                     return " one Emerald and";
  1691.                 if (Entity.Class % 10 == 3)
  1692.                     return " one Meteor and";
  1693.                 if (Entity.Class % 10 == 4)
  1694.                     return " one MoonBox and";
  1695.                 return " nothing but";
  1696.             }
  1697.         }
  1698.         public byte PromoteItemCountNeed
  1699.         {
  1700.             get
  1701.             {
  1702.                 if (Entity.Class % 10 == 0)
  1703.                     return 0;
  1704.                 if (Entity.Class % 10 == 1)
  1705.                     //  if (Entity.Class / 10 == 4)
  1706.                     //       return 5;
  1707.                     //   else
  1708.                     return 0;
  1709.                 if (Entity.Class % 10 == 2)
  1710.                     return 1;
  1711.                 if (Entity.Class % 10 == 3)
  1712.                     return 1;
  1713.                 if (Entity.Class % 10 == 4)
  1714.                     return 1;
  1715.                 return 0;
  1716.             }
  1717.         }
  1718.         public uint PromoteItemNeed
  1719.         {
  1720.             get
  1721.             {
  1722.                 if (Entity.Class % 10 == 0)
  1723.                     return 0;
  1724.                 if (Entity.Class % 10 == 1)
  1725.                     //   if (Entity.Class / 10 == 4)
  1726.                     //       return 1072031;
  1727.                     //   else
  1728.                     return 0;
  1729.                 if (Entity.Class % 10 == 2)
  1730.                     return 1080001;
  1731.                 if (Entity.Class % 10 == 3)
  1732.                     return 1088001;
  1733.                 if (Entity.Class % 10 == 4)
  1734.                     return 721020;
  1735.                 return 0;
  1736.             }
  1737.         }
  1738.         public uint PromoteItemGain
  1739.         {
  1740.             get
  1741.             {
  1742.                 if (Entity.Class % 10 == 0)
  1743.                     return 0;
  1744.                 if (Entity.Class % 10 == 1)
  1745.                     //   if (Entity.Class / 10 == 4)
  1746.                     //       return 500067;
  1747.                     //    else
  1748.                     return 0;
  1749.                 if (Entity.Class % 10 == 2)
  1750.                     return 0;
  1751.                 if (Entity.Class % 10 == 3)
  1752.                     return 700031;
  1753.                 if (Entity.Class % 10 == 4)
  1754.                     return 1088000;
  1755.                 return 0;
  1756.             }
  1757.         }
  1758.         public uint PromoteLevelNeed
  1759.         {
  1760.             get
  1761.             {
  1762.                 if (Entity.Class % 10 == 0)
  1763.                     return 15;
  1764.                 if (Entity.Class % 10 == 1)
  1765.                     return 40;
  1766.                 if (Entity.Class % 10 == 2)
  1767.                     return 70;
  1768.                 if (Entity.Class % 10 == 3)
  1769.                     return 100;
  1770.                 if (Entity.Class % 10 == 4)
  1771.                     return 110;
  1772.                 return 0;
  1773.             }
  1774.         }
  1775.         public byte SelectedItem, UpdateType;
  1776.         public ushort UplevelProficiency;
  1777.         public UInt32 GuildJoinTarget = 0;
  1778.         public uint OnHoldGuildJoin = 0;
  1779.         public uint elitepoints = 0;
  1780.         public bool Effect = false;
  1781.         public bool Effect1 = false;
  1782.         public bool Effect10 = false;
  1783.         public bool Effect8 = false;
  1784.         public bool Effect9 = false;
  1785.         public bool Effect11 = false;
  1786.         public bool Effect4 = false;
  1787.         public bool Effect3 = false;
  1788.         public uint eliterank = 0;
  1789.         public bool SentRequest = false;
  1790.         public Game.ConquerStructures.Society.Guild Guild;
  1791.         public Game.ConquerStructures.Society.Guild.Member AsMember;
  1792.         public uint Arsenal_Donation = 0;
  1793.         public Game.ConquerStructures.Booth Booth;
  1794.  
  1795.  
  1796.         public bool RaceExcitement, RaceDecelerated, RaceGuard, RaceDizzy, RaceFrightened;
  1797.         public Time32 RaceExcitementStamp, GuardStamp, DizzyStamp, FrightenStamp, ExtraVigorStamp, DecelerateStamp;
  1798.         public uint RaceExcitementAmount, RaceExtraVigor;
  1799.         public GameCharacterUpdates SpeedChange;
  1800.         public void ApplyRacePotion(Enums.RaceItemType type, uint target)
  1801.         {
  1802.             switch (type)
  1803.             {
  1804.                 case Enums.RaceItemType.FrozenTrap:
  1805.                     {
  1806.                         if (target != uint.MaxValue)
  1807.                         {
  1808.                             if (Map.Floor[Entity.X, Entity.Y, MapObjectType.StaticEntity])
  1809.                             {
  1810.                                 StaticEntity item = new StaticEntity((uint)(Entity.X * 1000 + Entity.Y), Entity.X, Entity.Y, (ushort)Map.ID);
  1811.                                 item.DoFrozenTrap(Entity.UID);
  1812.                                 Map.AddStaticEntity(item);
  1813.                                 Kernel.SendSpawn(item);
  1814.                             }
  1815.                         }
  1816.                         else
  1817.                         {
  1818.                             Entity.FrozenStamp = Time32.Now;
  1819.                             Entity.FrozenTime = 5;
  1820.                             GameCharacterUpdates update = new GameCharacterUpdates(true);
  1821.                             update.UID = Entity.UID;
  1822.                             update.Add(GameCharacterUpdates.Freeze, 0, 4);
  1823.                             SendScreen(update, true);
  1824.                             Entity.AddFlag(Update.Flags.Freeze);
  1825.                         }
  1826.                         break;
  1827.                     }
  1828.                 case Enums.RaceItemType.RestorePotion:
  1829.                     {
  1830.                         Vigor += 2000;
  1831.                         if (Vigor > MaxVigor)
  1832.                             Vigor = MaxVigor;
  1833.                         Send(new Vigor(true) { Amount = Vigor });
  1834.                         break;
  1835.                     }
  1836.                 case Enums.RaceItemType.ExcitementPotion:
  1837.                     {
  1838.                         if (RaceExcitement && RaceExcitementAmount > 50)
  1839.                             return;
  1840.  
  1841.                         if (RaceDecelerated)
  1842.                         {
  1843.                             RaceDecelerated = false;
  1844.  
  1845.                             var upd = new GameCharacterUpdates(true);
  1846.                             upd.UID = Entity.UID;
  1847.                             upd.Remove(GameCharacterUpdates.Decelerated);
  1848.                             SendScreen(upd, true);
  1849.                         }
  1850.                         RaceExcitementStamp = Time32.Now;
  1851.                         RaceExcitement = true;
  1852.                         {
  1853.                             var upd = new GameCharacterUpdates(true);
  1854.                             upd.UID = Entity.UID;
  1855.                             upd.Add(GameCharacterUpdates.Accelerated, 50, 15, 25);
  1856.                             SendScreen(upd, true);
  1857.                             SpeedChange = upd;
  1858.                         }
  1859.                         RaceExcitementAmount = 50;
  1860.                         Entity.AddFlag(Update.Flags.OrangeSparkles);
  1861.                         break;
  1862.                     }
  1863.                 case Enums.RaceItemType.SuperExcitementPotion:
  1864.                     {
  1865.                         if (RaceDecelerated)
  1866.                         {
  1867.                             RaceDecelerated = false;
  1868.  
  1869.                             var upd = new GameCharacterUpdates(true);
  1870.                             upd.UID = Entity.UID;
  1871.                             upd.Remove(GameCharacterUpdates.Decelerated);
  1872.                             SendScreen(upd, true);
  1873.                         }
  1874.                         RaceExcitementAmount = 200;
  1875.                         RaceExcitementStamp = Time32.Now;
  1876.                         RaceExcitement = true;
  1877.                         this.Entity.AddFlag(Update.Flags.SpeedIncreased);
  1878.                         {
  1879.                             var upd = new GameCharacterUpdates(true);
  1880.                             upd.UID = Entity.UID;
  1881.                             upd.Add(GameCharacterUpdates.Accelerated, 200, 15, 100);
  1882.                             SendScreen(upd, true);
  1883.                             SpeedChange = upd;
  1884.                         }
  1885.                         Entity.AddFlag(Update.Flags.OrangeSparkles);
  1886.                         break;
  1887.                     }
  1888.                 case Enums.RaceItemType.GuardPotion:
  1889.                     {
  1890.                         RaceGuard = true;
  1891.                         GuardStamp = Time32.Now;
  1892.                         Entity.AddFlag(Update.Flags.DivineShield);
  1893.                         DizzyStamp = DizzyStamp.AddSeconds(-100);
  1894.                         FrightenStamp = FrightenStamp.AddSeconds(-100);
  1895.                         var upd = new GameCharacterUpdates(true);
  1896.                         upd.UID = Entity.UID;
  1897.                         upd.Add(GameCharacterUpdates.DivineShield, 0, 10);
  1898.                         SendScreen(upd, true);
  1899.                         break;
  1900.                     }
  1901.                 case Enums.RaceItemType.DizzyHammer:
  1902.                     {
  1903.                         Entity Target;
  1904.                         if (Screen.TryGetValue(target, out Target))
  1905.                         {
  1906.                             var Owner = Target.Owner;
  1907.                             if (Owner != null)
  1908.                             {
  1909.                                 if (!Owner.RaceGuard && !Owner.RaceFrightened)
  1910.                                 {
  1911.                                     Owner.DizzyStamp = Time32.Now;
  1912.                                     Owner.RaceDizzy = true;
  1913.                                     Owner.Entity.AddFlag(Update.Flags.Dizzy);
  1914.                                     {
  1915.                                         var upd = new GameCharacterUpdates(true);
  1916.                                         upd.UID = Entity.UID;
  1917.                                         upd.Add(GameCharacterUpdates.Dizzy, 0, 5);
  1918.                                         Owner.SendScreen(upd, true);
  1919.                                     }
  1920.                                 }
  1921.                             }
  1922.                         }
  1923.                         break;
  1924.                     }
  1925.                 case Enums.RaceItemType.ScreamBomb:
  1926.                     {
  1927.                         SendScreen(new SpellUse(true)
  1928.                         {
  1929.                             Attacker = Entity.UID,
  1930.                             SpellID = 9989,
  1931.                             SpellLevel = 0,
  1932.                             X = Entity.X,
  1933.                             Y = Entity.Y
  1934.                         }.AddTarget(Entity, 0, null), true);
  1935.                         foreach (var obj in Screen.SelectWhere<Entity>(MapObjectType.Player,
  1936.                             (o) => Kernel.GetDistance(o.X, o.Y, Entity.X, Entity.Y) <= 10))
  1937.                         {
  1938.                             var Owner = obj.Owner;
  1939.                             if (!Owner.RaceGuard && !Owner.RaceDizzy)
  1940.                             {
  1941.                                 Owner.RaceFrightened = true;
  1942.                                 Owner.FrightenStamp = Time32.Now;
  1943.                                 Owner.Entity.AddFlag(Update.Flags.Frightened);
  1944.                                 {
  1945.                                     var upd = new GameCharacterUpdates(true);
  1946.                                     upd.UID = Owner.Entity.UID;
  1947.                                     upd.Add(GameCharacterUpdates.Flustered, 0, 20);
  1948.                                     Owner.SendScreen(upd, true);
  1949.                                 }
  1950.                             }
  1951.                         }
  1952.                         break;
  1953.                     }
  1954.                 case Enums.RaceItemType.SpiritPotion:
  1955.                     {
  1956.                         ExtraVigorStamp = Time32.Now;
  1957.                         RaceExtraVigor = 2000;
  1958.                         break;
  1959.                     }
  1960.                 case Enums.RaceItemType.ChaosBomb:
  1961.                     {
  1962.                         SendScreen(new SpellUse(true)
  1963.                         {
  1964.                             Attacker = Entity.UID,
  1965.                             SpellID = 9989,
  1966.                             SpellLevel = 0,
  1967.                             X = Entity.X,
  1968.                             Y = Entity.Y
  1969.                         }.AddTarget(Entity, 0, null), true);
  1970.                         foreach (var obj in this.Screen.SelectWhere<Entity>(MapObjectType.Player,
  1971.                                (o) => Kernel.GetDistance(o.X, o.Y, Entity.X, Entity.Y) <= 10))
  1972.                         {
  1973.                             var Owner = obj.Owner;
  1974.                             if (!Owner.RaceGuard)
  1975.                             {
  1976.                                 Owner.FrightenStamp = Time32.Now;
  1977.                                 Owner.DizzyStamp = Owner.DizzyStamp.AddSeconds(-1000);
  1978.  
  1979.                                 Owner.Entity.AddFlag(Update.Flags.Confused);
  1980.                                 {
  1981.                                     var upd = new GameCharacterUpdates(true);
  1982.                                     upd.UID = Owner.Entity.UID;
  1983.                                     upd.Add(GameCharacterUpdates.Flustered, 0, 15);
  1984.                                     Owner.SendScreen(upd, true);
  1985.                                 }
  1986.                             }
  1987.                         }
  1988.                         break;
  1989.                     }
  1990.                 case Enums.RaceItemType.SluggishPotion:
  1991.                     {
  1992.                         SendScreen(new SpellUse(true)
  1993.                         {
  1994.                             Attacker = Entity.UID,
  1995.                             SpellID = 9989,
  1996.                             SpellLevel = 0,
  1997.                             X = Entity.X,
  1998.                             Y = Entity.Y
  1999.                         }.AddTarget(Entity, 0, null), true);
  2000.                         foreach (var obj in this.Screen.SelectWhere<Entity>(MapObjectType.Player,
  2001.                               o => Kernel.GetDistance(o.X, o.Y, Entity.X, Entity.Y) <= 10))
  2002.                         {
  2003.                             var Owner = obj.Owner;
  2004.                             if (!Owner.RaceGuard)
  2005.                             {
  2006.                                 Owner.RaceDecelerated = true;
  2007.                                 Owner.DecelerateStamp = Time32.Now;
  2008.                                 if (Owner.RaceExcitement)
  2009.                                 {
  2010.                                     Owner.RaceExcitement = false;
  2011.  
  2012.                                     var upd = new GameCharacterUpdates(true);
  2013.                                     upd.UID = Owner.Entity.UID;
  2014.                                     upd.Remove(GameCharacterUpdates.Accelerated);
  2015.                                     Owner.SendScreen(upd, true);
  2016.                                 }
  2017.                                 Owner.Entity.AddFlag(Update.Flags.PurpleSparkles);
  2018.                                 {
  2019.                                     var upd = new GameCharacterUpdates(true);
  2020.                                     upd.UID = Owner.Entity.UID;
  2021.                                     unchecked { upd.Add(GameCharacterUpdates.Decelerated, 50, 10, (uint)(0 - 25)); }
  2022.                                     Owner.SendScreen(upd, true);
  2023.                                     Owner.SpeedChange = upd;
  2024.                                 }
  2025.                             }
  2026.                         }
  2027.                         break;
  2028.                     }
  2029.                 case Enums.RaceItemType.TransformItem:
  2030.                     {
  2031.                         for (int i = 0; i < 5; i++)
  2032.                         {
  2033.                             if (Potions[i] != null)
  2034.                             {
  2035.                                 if (Potions[i].Type != Enums.RaceItemType.TransformItem)
  2036.                                 {
  2037.                                     Send(new RacePotion(true)
  2038.                                     {
  2039.                                         Amount = 0,
  2040.                                         Location = i + 1,
  2041.                                         PotionType = Potions[i].Type
  2042.                                     });
  2043.                                     Potions[i] = null;
  2044.                                 }
  2045.                             }
  2046.                         }
  2047.                         //for (int i = 0; i < 5; i++)
  2048.                         {
  2049.                             int i = 0;
  2050.                             if (Potions[i] == null)
  2051.                             {
  2052.                                 int val = (int)Enums.RaceItemType.TransformItem;
  2053.                                 while (val == (int)Enums.RaceItemType.TransformItem)
  2054.                                     val = Kernel.Random.Next((int)Enums.RaceItemType.ChaosBomb, (int)Enums.RaceItemType.SuperExcitementPotion);
  2055.                                 Potions[i] = new UsableRacePotion();
  2056.                                 Potions[i].Count = 1;
  2057.                                 Potions[i].Type = (Enums.RaceItemType)val;
  2058.                                 Send(new RacePotion(true)
  2059.                                 {
  2060.                                     Amount = 1,
  2061.                                     Location = i + 1,
  2062.                                     PotionType = Potions[i].Type
  2063.                                 });
  2064.                             }
  2065.                         }
  2066.                         break;
  2067.                     }
  2068.             }
  2069.         }
  2070.  
  2071.  
  2072.         public void ReviewMentor()
  2073.         {
  2074.             #region NotMentor
  2075.             uint nowBP = 0;
  2076.             if (Mentor != null)
  2077.             {
  2078.                 if (Mentor.IsOnline)
  2079.                 {
  2080.                     nowBP = Entity.BattlePowerFrom(Mentor.Client.Entity);
  2081.                 }
  2082.             }
  2083.             if (nowBP > 200) nowBP = 0;
  2084.             if (nowBP < 0) nowBP = 0;
  2085.             if (Entity.MentorBattlePower != nowBP)
  2086.             {
  2087.                 Entity.MentorBattlePower = nowBP;
  2088.                 if (Mentor != null)
  2089.                 {
  2090.                     if (Mentor.IsOnline)
  2091.                     {
  2092.                         MentorInformation Information = new MentorInformation(true);
  2093.                         Information.Mentor_Type = 1;
  2094.                         Information.Mentor_ID = Mentor.Client.Entity.UID;
  2095.                         Information.Apprentice_ID = Entity.UID;
  2096.                         Information.Enrole_Date = Mentor.EnroleDate;
  2097.                         Information.Mentor_Level = Mentor.Client.Entity.Level;
  2098.                         Information.Mentor_Class = Mentor.Client.Entity.Class;
  2099.                         Information.Mentor_PkPoints = Mentor.Client.Entity.PKPoints;
  2100.                         Information.Mentor_Mesh = Mentor.Client.Entity.Mesh;
  2101.                         Information.Mentor_Online = true;
  2102.                         Information.Shared_Battle_Power = nowBP;
  2103.                         Information.String_Count = 3;
  2104.                         Information.Mentor_Name = Mentor.Client.Entity.Name;
  2105.                         Information.Apprentice_Name = Entity.Name;
  2106.                         Information.Mentor_Spouse_Name = Mentor.Client.Entity.Spouse;
  2107.                         Send(Information);
  2108.                     }
  2109.                 }
  2110.             }
  2111.             #endregion
  2112.             #region Mentor
  2113.             if (Apprentices == null) Apprentices = new SafeDictionary<uint, Game.ConquerStructures.Society.Apprentice>();
  2114.             foreach (var appr in Apprentices.Values)
  2115.             {
  2116.                 if (appr.IsOnline)
  2117.                 {
  2118.                     uint nowBPs = 0;
  2119.                     nowBPs = appr.Client.Entity.BattlePowerFrom(Entity);
  2120.                     if (appr.Client.Entity.MentorBattlePower != nowBPs)
  2121.                     {
  2122.                         appr.Client.Entity.MentorBattlePower = nowBPs;
  2123.                         MentorInformation Information = new MentorInformation(true);
  2124.                         Information.Mentor_Type = 1;
  2125.                         Information.Mentor_ID = Entity.UID;
  2126.                         Information.Apprentice_ID = appr.Client.Entity.UID;
  2127.                         Information.Enrole_Date = appr.EnroleDate;
  2128.                         Information.Mentor_Level = Entity.Level;
  2129.                         Information.Mentor_Class = Entity.Class;
  2130.                         Information.Mentor_PkPoints = Entity.PKPoints;
  2131.                         Information.Mentor_Mesh = Entity.Mesh;
  2132.                         Information.Mentor_Online = true;
  2133.                         Information.Shared_Battle_Power = nowBPs;
  2134.                         Information.String_Count = 3;
  2135.                         Information.Mentor_Name = Entity.Name;
  2136.                         Information.Apprentice_Name = appr.Client.Entity.Name;
  2137.                         Information.Mentor_Spouse_Name = Entity.Spouse;
  2138.                         appr.Client.Send(Information);
  2139.                     }
  2140.                 }
  2141.             }
  2142.             #endregion
  2143.         }
  2144.         public void AddQuarantineKill()
  2145.         {
  2146.             quarantineKill++;
  2147.             UpdateQuarantineScore();
  2148.         }
  2149.         public void AddGl()
  2150.         {
  2151.             TopGlClaim++;
  2152.             return;
  2153.         }
  2154.         public void AddDl()
  2155.         {
  2156.             TopDlClaim++;
  2157.             return;
  2158.         }
  2159.         public void AddQuarantineDeath()
  2160.         {
  2161.             quarantineDeath++;
  2162.             UpdateQuarantineScore();
  2163.         }
  2164.         public void UpdateQuarantineScore()
  2165.         {
  2166.             string[] scores = new string[3];
  2167.             scores[0] = "Black team: " + Conquer_Online_Server.Game.Quarantine.BlackScore.ToString() + " wins";
  2168.             scores[1] = "White team: " + Conquer_Online_Server.Game.Quarantine.WhiteScore.ToString() + " wins";
  2169.             scores[2] = "Your score: " + quarantineKill + " kills, " + quarantineDeath + " death";
  2170.             for (int i = 0; i < scores.Length; i++)
  2171.             {
  2172.                 Message msg = new Message(scores[i], System.Drawing.Color.Red, i == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
  2173.                 Send(msg);
  2174.             }
  2175.         }
  2176.         public void KillTerrorist()
  2177.         {
  2178.             foreach (Client.GameState Terrorist in Program.Values)
  2179.             {
  2180.                 if (Terrorist.Entity.KillTheTerrorist_IsTerrorist == true && Terrorist.Entity.MapID == 1801)
  2181.                     Conquer_Online_Server.Kernel.SendWorldMessage(new Conquer_Online_Server.Network.GamePackets.Message("Terrorist: " + Terrorist.Entity.Name + " ", System.Drawing.Color.Black, Conquer_Online_Server.Network.GamePackets.Message.FirstRightCorner), Program.Values);
  2182.             }
  2183.         }
  2184.         public void AddBless(uint value)
  2185.         {
  2186.             Entity.HeavenBlessing += value;
  2187.             Entity.Update(Network.GamePackets._String.Effect, "bless", true);
  2188.             if (Mentor != null)
  2189.             {
  2190.                 if (Mentor.IsOnline)
  2191.                 {
  2192.                     Mentor.Client.PrizeHeavenBlessing += (ushort)(value / 10 / 60 / 60);
  2193.                     AsApprentice = Mentor.Client.Apprentices[Entity.UID];
  2194.                 }
  2195.                 if (AsApprentice != null)
  2196.                 {
  2197.                     AsApprentice.Actual_HeavenBlessing += (ushort)(value / 10 / 60 / 60);
  2198.                     AsApprentice.Total_HeavenBlessing += (ushort)(value / 10 / 60 / 60);
  2199.                     if (Time32.Now > LastMentorSave.AddSeconds(5))
  2200.                     {
  2201.                         Database.KnownPersons.SaveApprenticeInfo(AsApprentice);
  2202.                         LastMentorSave = Time32.Now;
  2203.                     }
  2204.                 }
  2205.             }
  2206.         }
  2207.         public ulong PrizeExperience;
  2208.         public ushort PrizeHeavenBlessing;
  2209.         public ushort PrizePlusStone;
  2210.  
  2211.         public uint MentorApprenticeRequest;
  2212.         public uint TradePartnerRequest;
  2213.  
  2214.         public object[] OnMessageBoxEventParams;
  2215.         public Action<GameState> MessageOK;
  2216.         public Action<GameState> MessageCancel;
  2217.  
  2218.         public bool JustLoggedOn = true;
  2219.         public Time32 ReviveStamp = Time32.Now;
  2220.         public bool Attackable;
  2221.  
  2222.         public Game.ConquerStructures.NobilityInformation NobilityInformation;
  2223.         public Game.Entity Entity;
  2224.         public Game.Screen Screen;
  2225.         public Time32 LastPing = Time32.Now;
  2226.         public static ushort NpcTestType = 0;
  2227.         public byte TinterItemSelect = 0;
  2228.         public DateTime LastDragonBallUse, LastResetTime;
  2229.         public byte Action = 0;
  2230.         public bool CheerSent = false;
  2231.         public Game.Arena.QualifierList.QualifierGroup WatchingGroup;
  2232.         public Game.Arena.QualifierList.QualifierGroup QualifierGroup;
  2233.         public Game.Champion.QualifierList.QualifierGroup ChampionGroup;
  2234.         public Network.GamePackets.ArenaStatistic ArenaStatistic;
  2235.  
  2236.         public Game.TeamArena.QualifierList.QualifierGroup TeamWatchingGroup;
  2237.         public Game.TeamArena.QualifierList.QualifierGroup TeamQualifierGroup;
  2238.         public Network.GamePackets.TeamArenaStatistic TeamArenaStatistic;
  2239.         public uint ArenaPoints
  2240.         {
  2241.             get
  2242.             {
  2243.                 return ArenaStatistic.ArenaPoints;
  2244.             }
  2245.             set
  2246.             {
  2247.                 ArenaStatistic.ArenaPoints =
  2248.                     TeamArenaStatistic.ArenaPoints =
  2249.                     value;
  2250.             }
  2251.         }
  2252.         private byte xpCount;
  2253.         public byte XPCount
  2254.         {
  2255.             get { return xpCount; }
  2256.             set
  2257.             {
  2258.                 xpCount = value;
  2259.                 if (xpCount >= 100) xpCount = 100;
  2260.  
  2261.                 Update update = new Update(true);
  2262.                 update.UID = Entity.UID;
  2263.                 update.Append(Update.XPCircle, xpCount);
  2264.                 update.Send(this);
  2265.             }
  2266.         }
  2267.         public Time32 XPCountStamp = Time32.Now;
  2268.         public Time32 XPListStamp = Time32.Now;
  2269.  
  2270.         #region poker
  2271.         public Network.GamePackets.poker2090 poker2090;
  2272.         public Network.GamePackets.poker2091 poker2091;
  2273.         public Network.GamePackets.poker2092 poker2092;
  2274.         public Network.GamePackets.poker2093 poker2093;
  2275.         public Network.GamePackets.poker2094 poker2094;
  2276.         public Network.GamePackets.poker2095 poker2095;
  2277.         #endregion
  2278.         public Conquer_Online_Server.Game.ConquerStructures.Trade Trade;
  2279.         public byte ExpBalls = 0;
  2280.         public uint MoneySave = 0, ActiveNpc = 0;
  2281.         public string WarehousePW1, TempPassword;
  2282.         public uint WarehousePW;
  2283.         public bool WarehouseOpen;
  2284.         public Time32 CoolStamp;
  2285.         public sbyte WarehouseOpenTries;
  2286.         public ushort InputLength;
  2287.         public Conquer_Online_Server.Game.ConquerStructures.Society.Mentor Mentor;
  2288.         public Conquer_Online_Server.Game.ConquerStructures.Society.Apprentice AsApprentice;
  2289.         public SafeDictionary<ushort, Interfaces.ISkill> RemoveSpells = new SafeDictionary<ushort, Interfaces.ISkill>();
  2290.         public SafeDictionary<ushort, Interfaces.IProf> Proficiencies;
  2291.         public SafeDictionary<ushort, Interfaces.ISkill> Spells;
  2292.         public SafeDictionary<uint, Conquer_Online_Server.Game.ConquerStructures.Society.Friend> Friends;
  2293.         public SafeDictionary<uint, Conquer_Online_Server.Game.ConquerStructures.Society.Enemy> Enemy;
  2294.         public SafeDictionary<uint, Conquer_Online_Server.Game.ConquerStructures.Society.TradePartner> Partners;
  2295.         public SafeDictionary<uint, Conquer_Online_Server.Game.ConquerStructures.Society.Apprentice> Apprentices;
  2296.         public Game.ConquerStructures.Inventory Inventory;
  2297.         public Game.ConquerStructures.Equipment Equipment;
  2298.         public SafeDictionary<Game.ConquerStructures.Warehouse.WarehouseID, Game.ConquerStructures.Warehouse> Warehouses;
  2299.         public Game.ConquerStructures.Team Team;
  2300.         public Time32 lastClientJumpTime = Time32.Now;
  2301.         public Time32 lastJumpTime = Time32.Now;
  2302.         public int LastJumpTime = 0;
  2303.         public short lastJumpDistance = 0;
  2304.         public bool DoubleExpToday = false;
  2305.  
  2306.         private Game.Map map;
  2307.         public Game.Map Map
  2308.         {
  2309.             get
  2310.             {
  2311.                 if (map == null)
  2312.                 {
  2313.                     if (Entity == null) return null;
  2314.                     Kernel.Maps.TryGetValue(Entity.MapID, out map);
  2315.                     //   if (Entity.MapID >= 11000 && map == null)
  2316.                     //      Entity.MapID = 1005;
  2317.                     if (map == null)
  2318.                         return (map = new Game.Map(Entity.MapID, Database.MapsTable.MapInformations[Entity.MapID].BaseID, Database.DMaps.MapPaths[Database.MapsTable.MapInformations[Entity.MapID].BaseID]));
  2319.                 }
  2320.                 else
  2321.                 {
  2322.                     if (map.ID != Entity.MapID)
  2323.                     {
  2324.                         Kernel.Maps.TryGetValue(Entity.MapID, out map);
  2325.                         //     if (Entity.MapID >= 11000 && map == null)
  2326.                         //         Entity.MapID = 1005;
  2327.                         if (map == null)
  2328.                             return (map = new Game.Map(Entity.MapID, Database.MapsTable.MapInformations[Entity.MapID].BaseID, Database.DMaps.MapPaths[Database.MapsTable.MapInformations[Entity.MapID].BaseID]));
  2329.                     }
  2330.                 }
  2331.                 return map;
  2332.             }
  2333.         }
  2334.  
  2335.         public uint ExpBall
  2336.         {
  2337.             get
  2338.             {
  2339.                 ulong exp = Database.DataHolder.LevelExperience(Entity.Level);
  2340.                 return (uint)(exp * 13000 / (ulong)((Entity.Level * Entity.Level * Entity.Level / 12) + 1));
  2341.             }
  2342.         }
  2343.  
  2344.         public bool AddProficiency(Interfaces.IProf proficiency)
  2345.         {
  2346.             if (Proficiencies.ContainsKey(proficiency.ID))
  2347.             {
  2348.                 Proficiencies[proficiency.ID].Level = proficiency.Level;
  2349.                 Proficiencies[proficiency.ID].Experience = proficiency.Experience;
  2350.                 proficiency.Send(this);
  2351.                 //Database.SkillTable.SaveProficiencies(this, proficiency.ID);//Samak
  2352.                 return false;
  2353.             }
  2354.             else
  2355.             {
  2356.                 Proficiencies.Add(proficiency.ID, proficiency);
  2357.                 proficiency.NeededExperience = Database.DataHolder.ProficiencyLevelExperience(proficiency.Level);
  2358.                 proficiency.Send(this);
  2359.                 Database.SkillTable.SaveProficiencies(this);//Samak
  2360.                 return true;
  2361.             }
  2362.         }
  2363.  
  2364.         public bool AddSpell(Interfaces.ISkill spell)
  2365.         {
  2366.             if (Spells.ContainsKey(spell.ID))
  2367.             {
  2368.                 if (Spells[spell.ID].Level < spell.Level)
  2369.                 {
  2370.                     Spells[spell.ID].Level = spell.Level;
  2371.                     Spells[spell.ID].Experience = spell.Experience;
  2372.                     if (spell.ID != 3060)
  2373.                     {
  2374.                         spell.Send(this);
  2375.                         //Database.SkillTable.SaveSpells(this, spell.ID);
  2376.                     }
  2377.                 }
  2378.                 return false;
  2379.             }
  2380.             else
  2381.             {
  2382.                 if (spell.ID == 1045 || spell.ID == 1046)
  2383.                 {                    
  2384.                     //if (Proficiencies.ContainsKey(Database.SpellTable.SpellInformations[spell.ID][spell.Level].WeaponSubtype))
  2385.                     //{
  2386.                     //    if (Proficiencies[Database.SpellTable.SpellInformations[spell.ID][spell.Level].WeaponSubtype].Level < 5)
  2387.                     //        return false;
  2388.                     //}
  2389.                     //else
  2390.                     //    return false;
  2391.                 }
  2392.                 Spells.Add(spell.ID, spell);
  2393.                 if (spell.ID != 3060)
  2394.                 {
  2395.                     spell.Send(this);
  2396.                     //      Database.SkillTable.SaveSpells(this, spell.ID);//Samak
  2397.                 }
  2398.                 Database.SkillTable.SaveSpells(this);//Samak
  2399.  
  2400.                 return true;
  2401.             }
  2402.         }      
  2403.         public bool RemoveSpell(Interfaces.ISkill spell)
  2404.         {
  2405.             if (Spells.ContainsKey(spell.ID))
  2406.             {
  2407.                 Spells.Remove(spell.ID);
  2408.                 Network.GamePackets.Data data = new Data(true);
  2409.                 data.UID = Entity.UID;
  2410.                 data.dwParam = spell.ID;
  2411.                 data.ID = 109;
  2412.                 Send(data);
  2413.                 Database.SkillTable.DeleteSpell(this, spell.ID);
  2414.                 return true;
  2415.             }
  2416.             return false;
  2417.         }
  2418.         public bool WentToComplete = false;
  2419.         public byte SelectedGem = 0;
  2420.         public Time32 LastMentorSave = Time32.Now;
  2421.         public void IncreaseExperience(ulong experience, bool addMultiple)
  2422.         {
  2423.             if (Entity.Dead) return;
  2424.             byte level = Entity.Level;
  2425.             ulong _experience = Entity.Experience;
  2426.             ulong prExperienece = experience;          
  2427.             if (addMultiple)
  2428.             {
  2429.                 if (Entity.VIPLevel > 0)
  2430.                     experience *= Entity.VIPLevel;              
  2431.                 experience *= Constants.ExtraExperienceRate;                
  2432.                 if (Entity.HeavenBlessing > 0)
  2433.                     experience += (uint)(experience * 20 / 100);
  2434.                 if (Entity.Reborn >= 2)
  2435.                     experience /= 3;
  2436.                 if (Entity.DoubleExperienceTime > 0 && this.SuperPotion > 0)
  2437.                     experience *= (uint)(this.SuperPotion);
  2438.                
  2439.                 if (Guild != null)
  2440.                 {
  2441.                     if (Guild.Level > 0)
  2442.                     {
  2443.                         experience += (ushort)(experience * Guild.Level / 100);
  2444.                     }
  2445.                 }
  2446.                 prExperienece = experience + (ulong)(experience * ((float)Entity.BattlePower / 100));
  2447.                 _experience += prExperienece;
  2448.  
  2449.                 _experience += (uint)(_experience * (uint)Entity.Gems[3] / 100);
  2450.                
  2451.             }
  2452.             else
  2453.                 _experience += experience;
  2454.  
  2455.             if (Entity.Level < 140 && Entity.Auto == true)
  2456.             {
  2457.                 Entity.autohuntxp += (_experience / 16);
  2458.                 return;
  2459.             }
  2460.             else if (Entity.Level == 140 && Entity.Auto == true)
  2461.             {
  2462.                 Entity.autohuntxp = 0;
  2463.                 return;
  2464.             }
  2465.             if (Entity.Level < 140)
  2466.             {
  2467.                 while (_experience >= Database.DataHolder.LevelExperience(level) && level < 140)
  2468.                 {
  2469.                     _experience -= Database.DataHolder.LevelExperience(level);
  2470.                     level++;
  2471.                     if (Entity.Reborn == 1)
  2472.                     {
  2473.                         if (level >= 130 && Entity.FirstRebornLevel > 130 && level < Entity.FirstRebornLevel)
  2474.                             level = Entity.FirstRebornLevel;
  2475.                     }
  2476.                     else if (Entity.Reborn == 2)
  2477.                     {
  2478.                         if (level >= 130 && Entity.SecondRebornLevel > 130 && level < Entity.SecondRebornLevel)
  2479.                             level = Entity.SecondRebornLevel;
  2480.                     }
  2481.                     if (Entity.Class >= 10 && Entity.Class <= 15)
  2482.                         if (!Spells.ContainsKey(1110))
  2483.                             AddSpell(new Network.GamePackets.Spell(true) { ID = 1110 });
  2484.                     if (Entity.Class >= 20 && Entity.Class <= 25)
  2485.                         if (!Spells.ContainsKey(1020))
  2486.                             AddSpell(new Network.GamePackets.Spell(true) { ID = 1020 });
  2487.                     if (Entity.Class >= 40 && Entity.Class <= 45)
  2488.                         if (!Spells.ContainsKey(8002))
  2489.                             AddSpell(new Network.GamePackets.Spell(true) { ID = 8002 });
  2490.                     if (Entity.Class >= 50 && Entity.Class <= 55)
  2491.                         if (!Spells.ContainsKey(6011))
  2492.                             AddSpell(new Network.GamePackets.Spell(true) { ID = 6011 });
  2493.                     if (Entity.Class >= 60 && Entity.Class <= 65)
  2494.                         if (!Spells.ContainsKey(10490))
  2495.                             AddSpell(new Network.GamePackets.Spell(true) { ID = 10490 });
  2496.                     if (Mentor != null)
  2497.                     {
  2498.                         if (Mentor.IsOnline)
  2499.                         {
  2500.                             uint exExp = (uint)(level * 2);
  2501.                             Mentor.Client.PrizeExperience += exExp;
  2502.                             AsApprentice = Mentor.Client.Apprentices[Entity.UID];
  2503.                             if (AsApprentice != null)
  2504.                             {
  2505.                                 AsApprentice.Actual_Experience += exExp;
  2506.                                 AsApprentice.Total_Experience += exExp;
  2507.                             }
  2508.                             if (Mentor.Client.PrizeExperience > 50 * 606)
  2509.                                 Mentor.Client.PrizeExperience = 50 * 606;
  2510.                         }
  2511.                     }
  2512.                     if (level == 70)
  2513.                     {
  2514.                         if (ArenaStatistic == null || ArenaStatistic.EntityID == 0)
  2515.                         {
  2516.                             ArenaStatistic = new Conquer_Online_Server.Network.GamePackets.ArenaStatistic(true);
  2517.                             ArenaStatistic.EntityID = Entity.UID;
  2518.                             ArenaStatistic.Name = Entity.Name;
  2519.                             ArenaStatistic.Level = Entity.Level;
  2520.                             ArenaStatistic.Class = Entity.Class;
  2521.                             ArenaStatistic.Model = Entity.Mesh;
  2522.                             ArenaPoints = Database.ArenaTable.ArenaPointFill(Entity.Level);
  2523.                             ArenaStatistic.LastArenaPointFill = DateTime.Now;
  2524.                             Database.ArenaTable.InsertArenaStatistic(this);
  2525.                             ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.NotSignedUp;
  2526.                             Game.Arena.ArenaStatistics.Add(Entity.UID, ArenaStatistic);
  2527.                         }
  2528.                     }
  2529.                     if (Entity.Reborn == 0)
  2530.                     {
  2531.                         if (level <= 120)
  2532.                         {
  2533.                             Database.DataHolder.GetStats(Entity.Class, level, this);
  2534.                             CalculateStatBonus();
  2535.                             CalculateHPBonus();
  2536.                             GemAlgorithm();
  2537.                         }
  2538.                         else
  2539.                             Entity.Atributes += 3;
  2540.                     }
  2541.                     else
  2542.                     {
  2543.                         Entity.Atributes += 3;
  2544.                     }
  2545.                 }
  2546.                 if (Entity.Level != level)
  2547.                 {
  2548.                     if (Team != null)
  2549.                     {
  2550.                         if (Team.LowestLevelsUID == Entity.UID)
  2551.                         {
  2552.                             Team.LowestLevel = 0;
  2553.                             Team.LowestLevelsUID = 0;
  2554.                             Team.SearchForLowest();
  2555.                         }
  2556.                     }
  2557.                     Entity.Level = level;
  2558.                     Entity.Hitpoints = Entity.MaxHitpoints;
  2559.                     Entity.Mana = Entity.MaxMana;
  2560.                     if (Entity.Level > 130)
  2561.                         Database.EntityTable.UpdateLevel(Entity.Owner);
  2562.                     if (Entity.Reborn == 2)
  2563.                         Network.PacketHandler.ReincarnationHash(Entity.Owner);
  2564.                 }
  2565.                 if (Entity.Experience != _experience)
  2566.                     Entity.Experience = _experience;
  2567.             }
  2568.         }
  2569.  
  2570.         public void IncreaseSpellExperience(uint experience, ushort id)
  2571.         {
  2572.             if (Spells.ContainsKey(id))
  2573.             {
  2574.                 switch (id)
  2575.                 {
  2576.                     case 1290:
  2577.                     case 5030:
  2578.                     case 7030:
  2579.                         experience = 100; break;
  2580.                 }
  2581.                 experience *= Constants.ExtraSpellRate;
  2582.                 experience += (uint)(experience * Entity.Gems[6] / 100);
  2583.                 if (Map.BaseID == 1039)
  2584.                     experience /= 40;
  2585.                 Interfaces.ISkill spell = Spells[id];
  2586.                 if (spell == null)
  2587.                     return;
  2588.                 if (Entity.VIPLevel > 0)
  2589.                 {
  2590.                     experience *= 5;
  2591.                 }
  2592.                 Database.SpellInformation spellInfo = Database.SpellTable.SpellInformations[spell.ID][spell.Level];
  2593.                 if (spellInfo != null)
  2594.                 {
  2595.                     if (spellInfo.NeedExperience != 0 && Entity.Level >= spellInfo.NeedLevel)
  2596.                     {
  2597.                         spell.Experience += experience;
  2598.                         bool leveled = false;
  2599.                         if (spell.Experience >= spellInfo.NeedExperience)
  2600.                         {
  2601.                             spell.Experience = 0;
  2602.                             spell.Level++;
  2603.                             leveled = true;
  2604.                             Send(Constants.SpellLeveled);
  2605.                         }
  2606.                         if (leveled)
  2607.                         {
  2608.                             spell.Send(this);
  2609.                             Database.SkillTable.SaveSpells(this);//Samak
  2610.                         }
  2611.                         else
  2612.                         {
  2613.                             Network.GamePackets.SkillExperience update = new SkillExperience(true);
  2614.                             update.AppendSpell(spell.ID, spell.Experience);
  2615.                             update.Send(this);
  2616.                             //Database.SkillTable.SaveSpells(this, spell.ID);//Samak Mohsen told men that no excperince any more after fixDatabase.EntityTable.UpdateSkillExp(this, spell.ID, experience);
  2617.                             Database.EntityTable.UpdateSkillExp(this, spell.ID, experience);
  2618.                         }
  2619.                     }
  2620.                 }
  2621.             }
  2622.         }
  2623.  
  2624.         public void IncreaseProficiencyExperience(uint experience, ushort id)
  2625.         {
  2626.             if (Proficiencies.ContainsKey(id))
  2627.             {
  2628.                 Interfaces.IProf proficiency = Proficiencies[id];
  2629.                 experience *= Constants.ExtraProficiencyRate;
  2630.                 experience += (uint)(experience * Entity.Gems[5] / 100);
  2631.                 if (Map.BaseID == 1039)
  2632.                     experience /= 40;
  2633.                 if (Entity.VIPLevel > 0)
  2634.                 {
  2635.                     experience *= 5;
  2636.                 }
  2637.                 proficiency.Experience += experience;
  2638.                 if (proficiency.Level < 20)
  2639.                 {
  2640.                     bool leveled = false;
  2641.                     while (proficiency.Experience >= Database.DataHolder.ProficiencyLevelExperience(proficiency.Level))
  2642.                     {
  2643.                         proficiency.Experience -= Database.DataHolder.ProficiencyLevelExperience(proficiency.Level);
  2644.                         proficiency.Level++;
  2645.                         if (proficiency.Level == 20)
  2646.                         {
  2647.                             proficiency.Experience = 0;
  2648.                             proficiency.Send(this);
  2649.                             Send(Constants.ProficiencyLeveled);
  2650.                             return;
  2651.                         }
  2652.                         proficiency.NeededExperience = Database.DataHolder.ProficiencyLevelExperience(proficiency.Level);
  2653.                         leveled = true;
  2654.                         Send(Constants.ProficiencyLeveled);
  2655.                     }
  2656.                     if (leveled)
  2657.                     {
  2658.                         proficiency.Send(this);
  2659.                         //   Database.SkillTable.SaveProficiencies(this, proficiency.ID);//Samak
  2660.                     }
  2661.                     else
  2662.                     {
  2663.                         Network.GamePackets.SkillExperience update = new SkillExperience(true);
  2664.                         update.AppendProficiency(proficiency.ID, proficiency.Experience, Database.DataHolder.ProficiencyLevelExperience(proficiency.Level));
  2665.                         update.Send(this);
  2666.                     }
  2667.                     //Database.SkillTable.SaveProficiencies(this, proficiency.ID);//Samak XXXX
  2668.                 }
  2669.  
  2670.             }
  2671.             else
  2672.             {
  2673.                 AddProficiency(new Network.GamePackets.Proficiency(true) { ID = id });
  2674.             }
  2675.         }
  2676.  
  2677.         public byte ExtraAtributePoints(byte level, byte mClass)
  2678.         {
  2679.             if (mClass == 135)
  2680.             {
  2681.                 if (level <= 110)
  2682.                     return 0;
  2683.                 switch (level)
  2684.                 {
  2685.                     case 112: return 1;
  2686.                     case 114: return 3;
  2687.                     case 116: return 6;
  2688.                     case 118: return 10;
  2689.                     case 120: return 15;
  2690.                     case 121: return 15;
  2691.                     case 122: return 21;
  2692.                     case 123: return 21;
  2693.                     case 124: return 28;
  2694.                     case 125: return 28;
  2695.                     case 126: return 36;
  2696.                     case 127: return 36;
  2697.                     case 128: return 45;
  2698.                     case 129: return 45;
  2699.                     default:
  2700.                         return 55;
  2701.                 }
  2702.             }
  2703.             else
  2704.             {
  2705.                 if (level <= 120)
  2706.                     return 0;
  2707.                 switch (level)
  2708.                 {
  2709.                     case 121: return 1;
  2710.                     case 122: return 3;
  2711.                     case 123: return 6;
  2712.                     case 124: return 10;
  2713.                     case 125: return 15;
  2714.                     case 126: return 21;
  2715.                     case 127: return 28;
  2716.                     case 128: return 36;
  2717.                     case 129: return 45;
  2718.                     default:
  2719.                         return 55;
  2720.                 }
  2721.             }
  2722.         }
  2723.         public static ISkill LearnableSpell(ushort spellid)
  2724.         {
  2725.             ISkill spell = new Spell(true);
  2726.             spell.ID = spellid;
  2727.             return spell;
  2728.         }
  2729.         public bool Reborn(byte toClass)
  2730.         {
  2731.             #region Items
  2732.  
  2733.             if (Inventory.Count > 37) return false;
  2734.             switch (toClass)
  2735.             {
  2736.                 case 11:
  2737.                 case 21:
  2738.                 case 51:
  2739.                 case 61:
  2740.                 case 71:
  2741.                     {
  2742.                         Inventory.Add(410077, Game.Enums.ItemEffect.Poison);
  2743.                         break;
  2744.                     }
  2745.                 case 41:
  2746.                     {
  2747.                         Inventory.Add(500057, Game.Enums.ItemEffect.Shield);
  2748.                         break;
  2749.                     }
  2750.                 case 132:
  2751.                 case 142:
  2752.                     {
  2753.                         if (toClass == 132)
  2754.                             Inventory.Add(421077, Game.Enums.ItemEffect.MP);
  2755.                         else
  2756.                             Inventory.Add(421077, Game.Enums.ItemEffect.HP);
  2757.                         break;
  2758.                     }
  2759.             }
  2760.  
  2761.             #region Low level items
  2762.  
  2763.             for (byte i = 1; i < 9; i++)
  2764.             {
  2765.                 if (i != 7)
  2766.                 {
  2767.                     ConquerItem item = Equipment.TryGetItem(i);
  2768.                     if (item != null && item.ID != 0)
  2769.                     {
  2770.                         try
  2771.                         {
  2772.                             //UnloadItemStats(item, false);
  2773.                             Database.ConquerItemInformation cii =
  2774.                                 new Conquer_Online_Server.Database.ConquerItemInformation(item.ID, item.Plus);
  2775.                             item.ID =
  2776.                                 cii.LowestID(
  2777.                                     Network.PacketHandler.ItemMinLevel(Network.PacketHandler.ItemPosition(item.ID)));
  2778.                             item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
  2779.                             item.Send(this);
  2780.                             LoadItemStats();
  2781.                             Database.ConquerItemTable.UpdateItemID(item, this);
  2782.                         }
  2783.                         catch
  2784.                         {
  2785.                             Console.WriteLine("Reborn item problem: " + item.ID);
  2786.                         }
  2787.                     }
  2788.                 }
  2789.             }
  2790.             ConquerItem hand = Equipment.TryGetItem(5);
  2791.             if (hand != null)
  2792.             {
  2793.                 Equipment.Remove(5);
  2794.                 CalculateStatBonus();
  2795.                 CalculateHPBonus();
  2796.             }
  2797.             hand = Equipment.TryGetItem(25);
  2798.             if (hand != null)
  2799.             {
  2800.                 Equipment.Remove(25);
  2801.                 CalculateStatBonus();
  2802.                 CalculateHPBonus();
  2803.             }
  2804.             LoadItemStats();
  2805.             SendScreen(Entity.SpawnPacket, false);
  2806.  
  2807.             #endregion
  2808.  
  2809.             #endregion
  2810.  
  2811.             if (Entity.Reborn == 0)
  2812.             {
  2813.                 Entity.FirstRebornClass = Entity.Class;
  2814.                 Entity.FirstRebornLevel = Entity.Level;
  2815.                 Entity.Atributes =
  2816.                     (ushort)(ExtraAtributePoints(Entity.FirstRebornClass, Entity.FirstRebornLevel) + 52);
  2817.             }
  2818.             else
  2819.             {
  2820.                 Entity.SecondRebornClass = Entity.Class;
  2821.                 Entity.SecondRebornLevel = Entity.Level;
  2822.                 Entity.Atributes =
  2823.                     (ushort)(ExtraAtributePoints(Entity.FirstRebornClass, Entity.FirstRebornLevel) +
  2824.                               ExtraAtributePoints(Entity.SecondRebornClass, Entity.SecondRebornLevel) + 62);
  2825.             }
  2826.             byte PreviousClass = Entity.Class;
  2827.             Entity.Reborn++;
  2828.             Entity.Class = toClass;
  2829.             Entity.Level = 15;
  2830.             Entity.Experience = 0;
  2831.  
  2832.             #region Spells
  2833.  
  2834.             Interfaces.ISkill[] spells = Spells.Values.ToArray();
  2835.             foreach (Interfaces.ISkill spell in spells)
  2836.             {
  2837.                 spell.PreviousLevel = spell.Level;
  2838.                 spell.Level = 0;
  2839.                 spell.Experience = 0;
  2840.                 #region KungFuKing
  2841.                 if (PreviousClass == 85)
  2842.                 {
  2843.                     if (Entity.Class != 81)
  2844.                     {
  2845.                         switch (spell.ID)
  2846.                         {
  2847.                             case 12120:
  2848.                             case 12130:
  2849.                             case 12140:
  2850.                             case 12160:
  2851.                             case 12170:
  2852.                             case 12200:
  2853.                             case 12240:
  2854.                             case 12350:
  2855.                             case 12270:
  2856.                             case 12280:
  2857.                             case 12290:
  2858.                             case 12300:
  2859.                             case 12320:
  2860.                             case 12330:
  2861.                             case 12340:
  2862.                                 RemoveSpell(spell);
  2863.                                 break;
  2864.                         }
  2865.                     }
  2866.                 }
  2867.                 #endregion
  2868.                 #region Pirate
  2869.  
  2870.                 if (PreviousClass == 75)
  2871.                 {
  2872.                     if (Entity.Class != 71)
  2873.                     {
  2874.                         switch (spell.ID)
  2875.                         {
  2876.                             case 11110:
  2877.                             case 11040:
  2878.                             case 11050:
  2879.                             case 11060:
  2880.                             case 11100:
  2881.                             case 11120:
  2882.                             case 11130:
  2883.                             case 11030:
  2884.                                 RemoveSpell(spell);
  2885.                                 break;
  2886.                         }
  2887.                     }
  2888.                 }
  2889.  
  2890.                 #endregion
  2891.                 #region Monk
  2892.  
  2893.                 if (PreviousClass == 65)
  2894.                 {
  2895.                     if (Entity.Class != 61)
  2896.                     {
  2897.                         switch (spell.ID)
  2898.                         {
  2899.                             case 10490:
  2900.                             case 10415:
  2901.                             case 10381:
  2902.                             case 10395:
  2903.                             case 10410:
  2904.                             case 10420:
  2905.                             case 10421:
  2906.                             case 10422:
  2907.                             case 10423:
  2908.                             case 10424:
  2909.                             case 10425:
  2910.                                 RemoveSpell(spell);
  2911.                                 break;
  2912.                         }
  2913.                     }
  2914.                 }
  2915.  
  2916.                 #endregion
  2917.                 #region Warrior
  2918.  
  2919.                 if (PreviousClass == 25)
  2920.                 {
  2921.                     if (Entity.Class != 21)
  2922.                     {
  2923.                         switch (spell.ID)
  2924.                         {
  2925.                             case 1025:
  2926.                                 if (Entity.Class != 21 && Entity.Class != 132)
  2927.                                     RemoveSpell(spell);
  2928.                                 break;
  2929.                         }
  2930.                     }
  2931.                 }
  2932.  
  2933.                 #endregion
  2934.                 #region Ninja
  2935.  
  2936.                 if (toClass != 51)
  2937.                 {
  2938.                     switch (spell.ID)
  2939.                     {
  2940.                         case 6010:
  2941.                         case 6000:
  2942.                         case 6011:
  2943.                         case 12070:
  2944.                         case 12080:
  2945.                         case 12110:
  2946.                         case 12090:
  2947.                         case 11170:
  2948.                         case 11180:
  2949.                         case 6004:
  2950.                             RemoveSpell(spell);
  2951.                             break;
  2952.                     }
  2953.                 }
  2954.  
  2955.                 #endregion
  2956.                 #region Trojan
  2957.  
  2958.                 if (toClass != 11)
  2959.                 {
  2960.                     switch (spell.ID)
  2961.                     {
  2962.                         case 1115:
  2963.                         case 11960:
  2964.                         case 11990:
  2965.                         case 11980:
  2966.                             RemoveSpell(spell);
  2967.                             break;
  2968.                     }
  2969.                 }
  2970.  
  2971.                 #endregion
  2972.                 #region Archer
  2973.  
  2974.                 if (toClass != 41)
  2975.                 {
  2976.                     switch (spell.ID)
  2977.                     {
  2978.                         case 8001:
  2979.                         case 8000:
  2980.                         case 8003:
  2981.                         case 9000:
  2982.                         case 8002:
  2983.                         case 8030:
  2984.                         case 11610:
  2985.                         case 11660:
  2986.                         case 11590:
  2987.                         case 11650:
  2988.                         case 11670:
  2989.                         case 11600:
  2990.                         case 11620:
  2991.                             RemoveSpell(spell);
  2992.                             break;
  2993.                     }
  2994.                 }
  2995.  
  2996.                 #endregion
  2997.                 #region WaterTaoist
  2998.  
  2999.                 if (PreviousClass == 135)
  3000.                 {
  3001.                     if (toClass != 132)
  3002.                     {
  3003.                         switch (spell.ID)
  3004.                         {
  3005.                             case 1000:
  3006.                             case 1001:
  3007.                             case 1010:
  3008.                             case 1125:
  3009.                             case 1100:
  3010.                             case 12390:
  3011.                             case 12370:
  3012.                             case 8030:
  3013.                                 RemoveSpell(spell);
  3014.                                 break;
  3015.                             case 1050:
  3016.                             case 1175:
  3017.                             case 1170:
  3018.                                 if (toClass != 142)
  3019.                                     RemoveSpell(spell);
  3020.                                 break;
  3021.                         }
  3022.                     }
  3023.                 }
  3024.  
  3025.                 #endregion
  3026.                 #region FireTaoist
  3027.  
  3028.                 if (PreviousClass == 145)
  3029.                 {
  3030.                     if (toClass != 142)
  3031.                     {
  3032.                         switch (spell.ID)
  3033.                         {
  3034.                             case 1000:
  3035.                             case 1001:
  3036.                             case 1150:
  3037.                             case 1180:
  3038.                             case 1120:
  3039.                             case 1002:
  3040.                             case 1160:
  3041.                             case 1165:
  3042.                             case 12400:
  3043.                             case 12380:
  3044.                                 RemoveSpell(spell);
  3045.                                 break;
  3046.                         }
  3047.                     }
  3048.                 }
  3049.  
  3050.                 #endregion
  3051.  
  3052.                 if (Spells.ContainsKey(spell.ID))
  3053.                     if (spell.ID != (ushort)Game.Enums.SkillIDs.Reflect)
  3054.                         spell.Send(this);
  3055.             }
  3056.  
  3057.             #endregion
  3058.  
  3059.             #region Proficiencies
  3060.  
  3061.             foreach (Interfaces.IProf proficiency in Proficiencies.Values)
  3062.             {
  3063.                 proficiency.PreviousLevel = proficiency.Level;
  3064.                 proficiency.Level = 0;
  3065.                 proficiency.Experience = 0;
  3066.                 proficiency.Send(this);
  3067.             }
  3068.  
  3069.             #endregion
  3070.  
  3071.             #region Adding earned skills
  3072.  
  3073.             if (Entity.Reborn == 2)
  3074.                 AddSpell(new Spell(true) { ID = 9876 });
  3075.             if (toClass == 51 && PreviousClass == 55 && Entity.Reborn == 1)
  3076.                 AddSpell(new Spell(true) { ID = 6002 });
  3077.             if (toClass == 81 && PreviousClass == 85 && Entity.Reborn == 1)
  3078.                 AddSpell(new Spell(true) { ID = 12280 });
  3079.             if (Entity.FirstRebornClass == 85 && Entity.SecondRebornClass == 85 && Entity.Class == 81 &&
  3080.                 Entity.Reborn == 2)
  3081.                 AddSpell(new Spell(true) { ID = 12300 });
  3082.             if (Entity.FirstRebornClass == 15 && Entity.SecondRebornClass == 15 && Entity.Class == 11 &&
  3083.                 Entity.Reborn == 2)
  3084.                 AddSpell(new Spell(true) { ID = 10315 });
  3085.             if (Entity.FirstRebornClass == 25 && Entity.SecondRebornClass == 25 && Entity.Class == 21 &&
  3086.                 Entity.Reborn == 2)
  3087.                 AddSpell(new Spell(true) { ID = 10311 });
  3088.             if (Entity.FirstRebornClass == 45 && Entity.SecondRebornClass == 45 && Entity.Class == 41 &&
  3089.                 Entity.Reborn == 2)
  3090.                 AddSpell(new Spell(true) { ID = 10313 });
  3091.             if (Entity.FirstRebornClass == 55 && Entity.SecondRebornClass == 55 && Entity.Class == 51 &&
  3092.                 Entity.Reborn == 2)
  3093.                 AddSpell(new Spell(true) { ID = 6003 });
  3094.             if (Entity.FirstRebornClass == 65 && Entity.SecondRebornClass == 65 && Entity.Class == 61 &&
  3095.                 Entity.Reborn == 2)
  3096.                 AddSpell(new Spell(true) { ID = 10405 });
  3097.             if (Entity.FirstRebornClass == 135 && Entity.SecondRebornClass == 135 && Entity.Class == 132 &&
  3098.                 Entity.Reborn == 2)
  3099.                 AddSpell(new Spell(true) { ID = 30000 });
  3100.             if (Entity.FirstRebornClass == 145 && Entity.SecondRebornClass == 145 && Entity.Class == 142 &&
  3101.                 Entity.Reborn == 2)
  3102.                 AddSpell(new Spell(true) { ID = 10310 });
  3103.             if (Entity.Reborn == 1)
  3104.             {
  3105.                 if (Entity.FirstRebornClass == 75 && Entity.Class == 71)
  3106.                 {
  3107.                     AddSpell(new Spell(true) { ID = 3050 });
  3108.                 }
  3109.                 if (Entity.FirstRebornClass == 15 && Entity.Class == 11)
  3110.                 {
  3111.                     AddSpell(new Spell(true) { ID = 3050 });
  3112.                 }
  3113.                 else if (Entity.FirstRebornClass == 25 && Entity.Class == 21)
  3114.                 {
  3115.                     AddSpell(new Spell(true) { ID = 3060 });
  3116.                 }
  3117.                 else if (Entity.FirstRebornClass == 145 && Entity.Class == 142)
  3118.                 {
  3119.                     AddSpell(new Spell(true) { ID = 3080 });
  3120.                 }
  3121.                 else if (Entity.FirstRebornClass == 135 && Entity.Class == 132)
  3122.                 {
  3123.                     AddSpell(new Spell(true) { ID = 3090 });
  3124.                 }
  3125.             }
  3126.             if (Entity.Reborn == 2)
  3127.             {
  3128.                 if (Entity.SecondRebornClass == 75 && Entity.Class == 71)
  3129.                 {
  3130.                     AddSpell(new Spell(true) { ID = 3050 });
  3131.                 }
  3132.                 if (Entity.SecondRebornClass == 15 && Entity.Class == 11)
  3133.                 {
  3134.                     AddSpell(new Spell(true) { ID = 3050 });
  3135.                 }
  3136.                 else if (Entity.SecondRebornClass == 25)
  3137.                 {
  3138.                     AddSpell(new Spell(true) { ID = 3060 });
  3139.                 }
  3140.                 else if (Entity.SecondRebornClass == 145 && Entity.Class == 142)
  3141.                 {
  3142.                     AddSpell(new Spell(true) { ID = 3080 });
  3143.                 }
  3144.                 else if (Entity.SecondRebornClass == 135 && Entity.Class == 132)
  3145.                 {
  3146.                     AddSpell(new Spell(true) { ID = 3090 });
  3147.                 }
  3148.             }
  3149.  
  3150.             #endregion
  3151.  
  3152.             #region Remove extra skills
  3153.  
  3154.             //if (Entity.Reborn == 2)
  3155.             //{
  3156.             //    #region Pison Star Del
  3157.             //    if (Entity.SecondRebornClass == 55 && Entity.Class == 41)
  3158.             //    {
  3159.             //        RemoveSpell(new Spell(false) { ID = 6002 });
  3160.             //    }
  3161.             //    if (Entity.SecondRebornClass == 55 && Entity.Class == 81)
  3162.             //    {
  3163.             //        RemoveSpell(new Spell(false) { ID = 6002 });
  3164.             //    }
  3165.             //    if (Entity.SecondRebornClass == 55 && Entity.Class == 11)
  3166.             //    {
  3167.             //        RemoveSpell(new Spell(false) { ID = 6002 });
  3168.             //    }
  3169.             //    if (Entity.SecondRebornClass == 55 && Entity.Class == 71)
  3170.             //    {
  3171.             //        RemoveSpell(new Spell(false) { ID = 6002 });
  3172.             //    }
  3173.             //    if (Entity.SecondRebornClass == 55 && Entity.Class == 61)
  3174.             //    {
  3175.             //        RemoveSpell(new Spell(false) { ID = 6002 });
  3176.             //    }
  3177.             //    if (Entity.SecondRebornClass == 55 && Entity.Class == 21)
  3178.             //    {
  3179.             //        RemoveSpell(new Spell(false) { ID = 6002 });
  3180.             //    }
  3181.             //    else if (Entity.SecondRebornClass == 55 && Entity.Class == 142)
  3182.             //    {
  3183.             //        RemoveSpell(new Spell(false) { ID = 6002 });
  3184.             //    }
  3185.             //    else if (Entity.SecondRebornClass == 55 && Entity.Class == 132)
  3186.             //    {
  3187.             //        RemoveSpell(new Spell(false) { ID = 6002 });
  3188.             //    }
  3189.  
  3190.             //    #endregion
  3191.             //}
  3192.  
  3193.             #endregion
  3194.  
  3195.             Database.DataHolder.GetStats(Entity.Class, Entity.Level, this);
  3196.             CalculateStatBonus();
  3197.             CalculateHPBonus();
  3198.             GemAlgorithm();
  3199.             using (var conn = Database.DataHolder.MySqlConnection)
  3200.             {
  3201.                 conn.Open();
  3202.                 Database.EntityTable.SaveEntity(this, conn);
  3203.                 //Samak Database.SkillTable.SaveSpells(this, conn);
  3204.                 //Samak Database.SkillTable.SaveProficiencies(this, conn);
  3205.                 Database.SkillTable.SaveSpells(this);
  3206.                 Database.SkillTable.SaveProficiencies(this);
  3207.             }
  3208.  
  3209.             Kernel.SendWorldMessage(
  3210.                 new Message("" + Entity.Name + " has got " + Entity.Reborn + " reborns. Congratulations!",
  3211.                     System.Drawing.Color.White, Message.Center), Program.Values);
  3212.             return true;
  3213.         }
  3214.         #region Items
  3215.         //private int StatHP;
  3216.         //public uint[] ArsenalDonations;
  3217.         //public uint GetArsenalDonation()
  3218.         //{
  3219.         //    uint val = 0;
  3220.         //    foreach (var Uint in ArsenalDonations)
  3221.         //        val += Uint;
  3222.         //    using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
  3223.         //        cmd.Update("entities").Set("GuildArsenalDonation", (uint)val).Where("UID", this.Entity.UID)
  3224.         //            .Execute();
  3225.         //    return val;
  3226.         //}
  3227.         //public void CalculateHPBonus()
  3228.         //{
  3229.         //    //  if ((int)Account.State >= 3) return;
  3230.         //    switch (Entity.Class)
  3231.         //    {
  3232.         //        case 11: Entity.MaxHitpoints = (uint)(StatHP * 1.05F); break;
  3233.         //        case 12: Entity.MaxHitpoints = (uint)(StatHP * 1.08F); break;
  3234.         //        case 13: Entity.MaxHitpoints = (uint)(StatHP * 1.10F); break;
  3235.         //        case 14: Entity.MaxHitpoints = (uint)(StatHP * 1.12F); break;
  3236.         //        case 15: Entity.MaxHitpoints = (uint)(StatHP * 1.15F); break;
  3237.         //        default: Entity.MaxHitpoints = (uint)StatHP; break;
  3238.         //    }
  3239.         //    Entity.MaxHitpoints += Entity.ItemHP;
  3240.         //    var plus = Entity.SubClasses.Classes.SingleOrDefault(x => x.Value.ID == 9);
  3241.         //    if (plus.Value != null && Entity.SubClass == 9)
  3242.         //        Entity.MaxHitpoints += (uint)(plus.Value.Level * 100);
  3243.         //    Entity.Hitpoints = Math.Min(Entity.Hitpoints, Entity.MaxHitpoints);
  3244.         //}
  3245.         //public void CalculateStatBonus()
  3246.         //{
  3247.         //    byte ManaBoost = 5;
  3248.         //    const byte HitpointBoost = 24;
  3249.         //    sbyte Class = (sbyte)(Entity.Class / 10);
  3250.         //    if (Class == 13 || Class == 14)
  3251.         //        ManaBoost += (byte)(5 * (Entity.Class - (Class * 10)));
  3252.         //    StatHP = (ushort)((Entity.Strength * 3) +
  3253.         //                             (Entity.Agility * 3) +
  3254.         //                             (Entity.Spirit * 3) +
  3255.         //                             (Entity.Vitality * HitpointBoost));
  3256.         //    Entity.MaxMana = (ushort)((Entity.Spirit * ManaBoost) + Entity.ItemMP);
  3257.         //    Entity.Mana = Math.Min(Entity.Mana, Entity.MaxMana);
  3258.         //}
  3259.         //public void SendStatMessage()
  3260.         //{
  3261.         //    this.ReviewMentor();
  3262.         //    Network.GamePackets.Message Msg = new Conquer_Online_Server.Network.GamePackets.Message(" Your status has been changed", System.Drawing.Color.DarkGoldenrod
  3263.         //        , Network.GamePackets.Message.TopLeft);
  3264.         //    Msg.__Message = string.Format(Msg.__Message,
  3265.         //        new object[] { Entity.MinAttack, Entity.MaxAttack, Entity.MagicAttack, Entity.Defence, (Entity.MagicDefence + Entity.MagicDefence), Entity.Dodge, Entity.PhysicalDamageDecrease, Entity.MagicDamageDecrease, Entity.PhysicalDamageIncrease, Entity.MagicDamageIncrease, Entity.Hitpoints, Entity.MaxHitpoints, Entity.Mana, Entity.MaxMana, Entity.BattlePower });
  3266.         //    this.Send(Msg);
  3267.         //}
  3268.  
  3269.         //private bool AreStatsLoadable(ConquerItem item)
  3270.         //{
  3271.         //    if (!AlternateEquipment)
  3272.         //        if (item.Position > 20)
  3273.         //            return false;
  3274.         //    if (AlternateEquipment)
  3275.         //        if (item.Position < 20)
  3276.         //            if (!Equipment.Free((byte)(20 + item.Position)))
  3277.         //                return false;
  3278.  
  3279.         //    int Position = item.Position;
  3280.         //    if (item.Position > 20) Position -= 20;
  3281.  
  3282.         //    if (Position == ConquerItem.LeftWeapon || Position == ConquerItem.RightWeapon)
  3283.         //        return false;
  3284.  
  3285.         //    return true;
  3286.         //}
  3287.  
  3288.         //private Tuple<ConquerItem, ConquerItem> ComputeWeapons()
  3289.         //{
  3290.         //    if (!AlternateEquipment)
  3291.         //    {
  3292.         //        return new Tuple<ConquerItem, ConquerItem>(
  3293.         //            Equipment.TryGetItem(ConquerItem.RightWeapon),
  3294.         //            Equipment.TryGetItem(ConquerItem.LeftWeapon));
  3295.         //    }
  3296.         //    else
  3297.         //    {
  3298.         //        if (Equipment.Free(ConquerItem.AlternateRightWeapon))
  3299.         //        {
  3300.         //            return new Tuple<ConquerItem, ConquerItem>(
  3301.         //                Equipment.TryGetItem(ConquerItem.RightWeapon),
  3302.         //                Equipment.TryGetItem(ConquerItem.LeftWeapon));
  3303.         //        }
  3304.         //        else
  3305.         //        {
  3306.         //            if (Equipment.Free(ConquerItem.RightWeapon))
  3307.         //            {
  3308.         //                return new Tuple<ConquerItem, ConquerItem>(
  3309.         //                    Equipment.TryGetItem(ConquerItem.AlternateRightWeapon),
  3310.         //                    Equipment.TryGetItem(ConquerItem.AlternateLeftWeapon));
  3311.         //            }
  3312.         //            else
  3313.         //            {
  3314.         //                if (!Equipment.Free(ConquerItem.AlternateLeftWeapon))
  3315.         //                {
  3316.         //                    return new Tuple<ConquerItem, ConquerItem>(
  3317.         //                        Equipment.TryGetItem(ConquerItem.AlternateRightWeapon),
  3318.         //                        Equipment.TryGetItem(ConquerItem.AlternateLeftWeapon));
  3319.         //                }
  3320.         //                else
  3321.         //                {
  3322.         //                    if (Equipment.Free(ConquerItem.LeftWeapon))
  3323.         //                    {
  3324.         //                        return new Tuple<ConquerItem, ConquerItem>(
  3325.         //                            Equipment.TryGetItem(ConquerItem.AlternateRightWeapon),
  3326.         //                            null);
  3327.         //                    }
  3328.         //                    else
  3329.         //                    {
  3330.         //                        ConquerItem aRight = Equipment.TryGetItem(ConquerItem.AlternateRightWeapon),
  3331.         //                                     nLeft = Equipment.TryGetItem(ConquerItem.LeftWeapon);
  3332.         //                        if (PacketHandler.IsTwoHand(aRight.ID))
  3333.         //                        {
  3334.         //                            if (PacketHandler.IsArrow(nLeft.ID))
  3335.         //                            {
  3336.         //                                if (PacketHandler.IsBow(aRight.ID))
  3337.         //                                {
  3338.         //                                    return new Tuple<ConquerItem,
  3339.         //                                        ConquerItem>(aRight, nLeft);
  3340.         //                                }
  3341.         //                                else
  3342.         //                                {
  3343.         //                                    return new Tuple<ConquerItem,
  3344.         //                                        ConquerItem>(aRight, null);
  3345.         //                                }
  3346.         //                            }
  3347.         //                            else
  3348.         //                            {
  3349.         //                                if (PacketHandler.IsShield(nLeft.ID))
  3350.         //                                {
  3351.         //                                    if (!Spells.ContainsKey(10311))//Perseverance
  3352.         //                                    {
  3353.         //                                        Send(new Message("You need to know Perseverance (Pure Warrior skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.Red, Message.Talk));
  3354.         //                                        return new Tuple<ConquerItem,
  3355.         //                                            ConquerItem>(aRight, null);
  3356.         //                                    }
  3357.         //                                    else
  3358.         //                                    {
  3359.         //                                        return new Tuple<ConquerItem,
  3360.         //                                            ConquerItem>(aRight, nLeft);
  3361.         //                                    }
  3362.         //                                }
  3363.         //                                else
  3364.         //                                {
  3365.         //                                    return new Tuple<ConquerItem,
  3366.         //                                        ConquerItem>(aRight, null);
  3367.         //                                }
  3368.         //                            }
  3369.         //                        }
  3370.         //                        else
  3371.         //                        {
  3372.         //                            if (!PacketHandler.IsTwoHand(nLeft.ID))
  3373.         //                            {
  3374.         //                                return new Tuple<ConquerItem,
  3375.         //                                    ConquerItem>(aRight, nLeft);
  3376.         //                            }
  3377.         //                            else
  3378.         //                            {
  3379.         //                                return new Tuple<ConquerItem,
  3380.         //                                    ConquerItem>(aRight, null);
  3381.         //                            }
  3382.         //                        }
  3383.         //                    }
  3384.         //                }
  3385.         //            }
  3386.         //        }
  3387.         //    }
  3388.         //}
  3389.  
  3390.         //public int[][] ChampionAllowedStats = new int[][]
  3391.         //{
  3392.         //    new int[] {1, 0, 0, 0, 0, 0, 0, 30, 0, 0 },
  3393.         //    new int[] {2, 0, 0, 0, 0, 0, 0, 40, 1, 1 },
  3394.         //    new int[] {3, 1, 0, 0, 0, 0, 50, 50, 2, 3 },
  3395.         //    new int[] {4, 3, 1, 1, 0, 0, 100, 60, 5, 4 },
  3396.         //    new int[] {5, 5, 1, 1, 1, 0, 150, 70, 7, 5 },
  3397.         //    new int[] {6, 5, 1, 1, 1, 0, 200, 80, 9, 7 },
  3398.         //    new int[] {12, 7, 2, 2, 1, 1, 255, 100, 12, 9 }
  3399.         //};
  3400.         //public bool DoChampStats { get { return ChampionGroup != null; } }
  3401.         //private int _accuracy;
  3402.         //public int Accuracy
  3403.         //{
  3404.         //    get { return _accuracy; }
  3405.         //}
  3406.         //public void LoadItemStats()
  3407.         //{
  3408.         //    uint bStats = Entity.Hitpoints;
  3409.         //    for (int i = 0; i < 30; i++)
  3410.         //        if (Equipment.Objects[i] != null)
  3411.         //            Equipment.Objects[i].IsWorn = false;
  3412.  
  3413.         //    #region Set Every Variable to Zero
  3414.         //    Entity.Defence = 0;
  3415.         //    Entity.MagicDefence = 0;
  3416.         //    Entity.MagicDefencePercent = 0;
  3417.         //    Entity.BaseMagicAttack = 0;
  3418.         //    Entity.BaseMagicDefence =
  3419.         //    Entity.BaseMaxAttack =
  3420.         //    Entity.BaseMinAttack =
  3421.         //    Entity.PhysicalDamageDecrease =
  3422.         //    Entity.PhysicalDamageIncrease =
  3423.         //    Entity.MagicDamageDecrease =
  3424.         //    Entity.MagicDamageIncrease = 0;
  3425.         //    Entity.ItemHP = 0;
  3426.         //    Entity.ItemHP =
  3427.         //    Entity.ItemMP =
  3428.         //    Entity.AttackRange = (byte)0;
  3429.         //    Entity.Dodge = 0;
  3430.         //    Entity.MinAttack = 0;
  3431.         //    Entity.MaxAttack = 0;
  3432.         //    Entity.Defence = 0;
  3433.         //    Entity.SuperItemBless = 0;
  3434.         //    Entity.MagicDefence = 0;
  3435.         //    Entity.Dodge = 0;
  3436.         //    Entity.BaseMagicAttack = 0;
  3437.         //    Entity.WoodResistance = 0;
  3438.         //    Entity.FireResistance = 0;
  3439.         //    Entity.WaterResistance = 0;
  3440.         //    Entity.EarthResistance = 0;
  3441.         //    Entity.Breaktrough = 0;
  3442.         //    Entity.WearsGoldPrize = false;
  3443.         //    Entity.CriticalStrike = 0;
  3444.         //    Entity.Immunity = 0;
  3445.         //    Entity.Penetration = 0;
  3446.         //    Entity.Counteraction = 0;
  3447.         //    Entity.Block = 0;
  3448.         //    _accuracy = 0;
  3449.         //    Entity.Detoxication = 0;
  3450.         //    Entity.Intensification = 0;
  3451.         //    Entity.Penetration = 0;
  3452.         //    Entity.SkillCStrike = 0;
  3453.         //    Entity.MaxAttack = 0;
  3454.         //    Entity.MinAttack = 0;
  3455.         //    Entity.PhysicalDamageDecrease = 0;
  3456.         //    Entity.MagicDamageDecrease = 0;
  3457.         //    Entity.MagicDamageIncrease = 0;
  3458.         //    Entity.PhysicalDamageIncrease = 0;
  3459.         //    Entity.MagicDefencePercent = 0;
  3460.         //    Entity.ItemHP = 0;
  3461.         //    Entity.ItemMP = 0;
  3462.         //    Entity.ItemBless = 0;
  3463.         //    Entity.AttackRange = 1;
  3464.         //    Entity.BaseMinAttack = 0;
  3465.         //    Entity.BaseMaxAttack = 0;
  3466.         //    Entity.BaseMagicDefence = 0;
  3467.         //    Entity.BaseDefence = 0;
  3468.         //    Entity.MagicDamageIncrease = 0;
  3469.         //    Entity.Gems = new double[10];
  3470.         //    #endregion
  3471.  
  3472.         //    foreach (ConquerItem i in Equipment.Objects)
  3473.         //    {
  3474.         //        if (i == null) continue;
  3475.         //        if (i.Durability == 0) continue;
  3476.         //        if (!AreStatsLoadable(i)) continue;
  3477.         //        loadItemStats(i);
  3478.         //    }
  3479.  
  3480.         //    Weapons = ComputeWeapons();
  3481.         //    if (Weapons == null) Weapons = new Tuple<ConquerItem, ConquerItem>(null, null);
  3482.         //    if (Weapons.Item1 != null)
  3483.         //    {
  3484.         //        loadItemStats(Weapons.Item1);
  3485.         //        if (Weapons.Item2 != null)
  3486.         //        {
  3487.         //            if (!Weapons.Item1.IsTwoHander())
  3488.         //                loadItemStats(Weapons.Item2);
  3489.         //            else
  3490.         //                if (PacketHandler.IsArrow(Weapons.Item2.ID) || (Entity.Class >= 20 && Entity.Class <= 25))
  3491.         //                    loadItemStats(Weapons.Item2);
  3492.         //        }
  3493.         //    }
  3494.  
  3495.         //    #region Subclasses
  3496.         //    foreach (var c in Entity.SubClasses.Classes)
  3497.         //    {
  3498.         //        int lvl = c.Value.Level;
  3499.         //        if (DoChampStats) lvl = Math.Min(lvl, ChampionAllowedStats[ChampionStats.Grade][9]);
  3500.         //        switch ((Conquer_Online_Server.Game.ClassID)c.Value.ID)
  3501.         //        {
  3502.         //            case Game.ClassID.MartialArtist:
  3503.         //                {
  3504.         //                    Entity.CriticalStrike += (ushort)(Entity.CriticalStrike - (Entity.CriticalStrike * (lvl / 15)));
  3505.         //                    break;
  3506.         //                }
  3507.         //            case Game.ClassID.Warlock:
  3508.         //                {
  3509.         //                    Entity.SkillCStrike += (ushort)(Entity.SkillCStrike - (Entity.SkillCStrike * (lvl / 15)));
  3510.         //                    break;
  3511.         //                }
  3512.         //            case Game.ClassID.ChiMaster:
  3513.         //                {
  3514.         //                    Entity.Immunity += (ushort)(Entity.Immunity - (Entity.Immunity * (lvl / 15)));
  3515.         //                    break;
  3516.         //                }
  3517.         //            case Game.ClassID.Sage:
  3518.         //                {
  3519.         //                    Entity.Penetration += (ushort)(Entity.Penetration - (Entity.Penetration * (lvl / 15)));
  3520.         //                    break;
  3521.         //                }
  3522.         //            case Game.ClassID.Apothecary:
  3523.         //                {
  3524.         //                    //double per = lvl * 8 / 10;
  3525.         //                    Entity.Detoxication += (ushort)(Entity.Detoxication - (Entity.Detoxication * (lvl / 15)));//per));
  3526.         //                    break;
  3527.         //                }
  3528.         //            case Game.ClassID.Performer:
  3529.         //                {
  3530.         //                    int per = lvl * 100;
  3531.         //                    Entity.BaseMaxAttack += (uint)per / 2;
  3532.         //                    Entity.BaseMinAttack += (uint)per / 2;
  3533.         //                    Entity.BaseMagicAttack += (uint)per;
  3534.         //                    break;
  3535.         //                }
  3536.         //        }
  3537.         //    }
  3538.         //    #endregion
  3539.         //    #region Chi
  3540.         //    uint percentage = 100;
  3541.         //    if (DoChampStats)
  3542.         //        percentage = (uint)ChampionAllowedStats[ChampionStats.Grade][7];
  3543.         //    foreach (var chiPower in ChiPowers)
  3544.         //    {
  3545.         //        foreach (var attribute in chiPower.Attributes)
  3546.         //        {
  3547.         //            switch (attribute.Type)
  3548.         //            {
  3549.         //                case Game.Enums.ChiAttribute.CriticalStrike:
  3550.         //                    Entity.CriticalStrike += (int)((ushort)(attribute.Value * 10) * percentage / 100);
  3551.         //                    break;
  3552.         //                case Game.Enums.ChiAttribute.Counteraction:
  3553.         //                    Entity.Counteraction += (ushort)(attribute.Value * percentage / 100);
  3554.         //                    break;
  3555.         //                case Game.Enums.ChiAttribute.AddAttack:
  3556.         //                    Entity.BaseMinAttack += attribute.Value * percentage / 100;
  3557.         //                    Entity.BaseMaxAttack += attribute.Value * percentage / 100;
  3558.         //                    break;
  3559.         //                case Game.Enums.ChiAttribute.AddMagicAttack:
  3560.         //                    Entity.BaseMagicAttack += attribute.Value * percentage / 100;
  3561.         //                    break;
  3562.         //                case Game.Enums.ChiAttribute.AddMagicDefense:
  3563.         //                    Entity.BaseMagicDefence += attribute.Value * percentage / 100;
  3564.         //                    break;
  3565.         //                case Game.Enums.ChiAttribute.Breakthrough:
  3566.         //                    Entity.Breaktrough += (ushort)(attribute.Value * percentage / 100);
  3567.         //                    break;
  3568.         //                case Game.Enums.ChiAttribute.HPAdd:
  3569.         //                    Entity.ItemHP += attribute.Value * percentage / 100;
  3570.         //                    break;
  3571.         //                case Game.Enums.ChiAttribute.Immunity:
  3572.         //                    Entity.Immunity += (int)((ushort)(attribute.Value * 10) * percentage / 100);
  3573.         //                    break;
  3574.         //                case Game.Enums.ChiAttribute.MagicDamageDecrease:
  3575.         //                    Entity.MagicDamageDecrease += (ushort)(attribute.Value * percentage / 100);
  3576.         //                    break;
  3577.         //                case Game.Enums.ChiAttribute.MagicDamageIncrease:
  3578.         //                    Entity.MagicDamageIncrease += (ushort)(attribute.Value * percentage / 100);
  3579.         //                    break;
  3580.         //                case Game.Enums.ChiAttribute.PhysicalDamageDecrease:
  3581.         //                    Entity.PhysicalDamageDecrease += (ushort)(attribute.Value * percentage / 100);
  3582.         //                    break;
  3583.         //                case Game.Enums.ChiAttribute.PhysicalDamageIncrease:
  3584.         //                    Entity.PhysicalDamageIncrease += (ushort)(attribute.Value * percentage / 100);
  3585.         //                    break;
  3586.         //                case Game.Enums.ChiAttribute.SkillCriticalStrike:
  3587.         //                    Entity.SkillCStrike += (int)((ushort)(attribute.Value * 10) * percentage / 100);
  3588.         //                    break;
  3589.         //            }
  3590.         //        }
  3591.         //    }
  3592.         //    #region Dragon Ranking
  3593.         //    if (ChiData.DragonRank <= 50 && ChiPowers.Count > 0)
  3594.         //    {
  3595.         //        if (ChiData.DragonRank <= 3)
  3596.         //        {
  3597.         //            Entity.ItemHP += 5000;
  3598.         //            Entity.BaseMagicDefence += 300;
  3599.         //            Entity.PhysicalDamageDecrease += 1000;
  3600.         //            Entity.MagicDamageDecrease += 300;
  3601.         //        }
  3602.         //        else if (ChiData.DragonRank <= 15)
  3603.         //        {
  3604.         //            Entity.ItemHP += (uint)(3000 - (ChiData.DragonRank - 4) * 90);
  3605.         //            Entity.BaseMagicDefence += (uint)(250 - (ChiData.DragonRank - 4) * 9);
  3606.         //            Entity.PhysicalDamageDecrease += (ushort)(600 - (ChiData.DragonRank - 4) * 18);
  3607.         //            Entity.MagicDamageDecrease += (ushort)(200 - (ChiData.DragonRank - 4) * 4);
  3608.         //        }
  3609.         //        else if (ChiData.DragonRank <= 50)
  3610.         //        {
  3611.         //            Entity.ItemHP += 1500;
  3612.         //            Entity.BaseMagicDefence += 100;
  3613.         //            Entity.PhysicalDamageDecrease += 300;
  3614.         //            Entity.MagicDamageDecrease += 100;
  3615.         //        }
  3616.         //    }
  3617.         //    #endregion
  3618.         //    #region Phoenix Ranking
  3619.         //    if (ChiData.PhoenixRank <= 50 && ChiPowers.Count > 1)
  3620.         //    {
  3621.         //        if (ChiData.PhoenixRank <= 3)
  3622.         //        {
  3623.         //            Entity.BaseMinAttack += 3000;
  3624.         //            Entity.BaseMaxAttack += 3000;
  3625.         //            Entity.BaseMagicAttack += 3000;
  3626.         //            Entity.PhysicalDamageIncrease += 1000;
  3627.         //            Entity.MagicDamageIncrease += 300;
  3628.         //        }
  3629.         //        else if (ChiData.PhoenixRank <= 15)
  3630.         //        {
  3631.         //            Entity.BaseMinAttack += (uint)(2000 - (ChiData.PhoenixRank - 4) * 45);
  3632.         //            Entity.BaseMaxAttack += (uint)(2000 - (ChiData.PhoenixRank - 4) * 45);
  3633.         //            Entity.BaseMagicAttack += (uint)(2000 - (ChiData.PhoenixRank - 4) * 45);
  3634.         //            Entity.PhysicalDamageIncrease += (ushort)(600 - (ChiData.PhoenixRank - 4) * 18);
  3635.         //            Entity.MagicDamageIncrease += (ushort)(200 - (ChiData.PhoenixRank - 4) * 4);
  3636.         //        }
  3637.         //        else if (ChiData.PhoenixRank <= 50)
  3638.         //        {
  3639.         //            Entity.BaseMinAttack += 1000;
  3640.         //            Entity.BaseMaxAttack += 1000;
  3641.         //            Entity.BaseMagicAttack += 1000;
  3642.         //            Entity.PhysicalDamageIncrease += 300;
  3643.         //            Entity.MagicDamageIncrease += 100;
  3644.         //        }
  3645.         //    }
  3646.         //    #endregion
  3647.         //    #region Tiger Ranking
  3648.         //    if (ChiData.TigerRank <= 50 && ChiPowers.Count > 2)
  3649.         //    {
  3650.         //        if (ChiData.TigerRank <= 3)
  3651.         //        {
  3652.         //            Entity.CriticalStrike += 1500;
  3653.         //            Entity.SkillCStrike += 1500;
  3654.         //            Entity.Immunity += 800;
  3655.         //        }
  3656.         //        else if (ChiData.TigerRank <= 15)
  3657.         //        {
  3658.         //            Entity.CriticalStrike += (ushort)(1100 - (ChiData.TigerRank - 4) * 10);
  3659.         //            Entity.SkillCStrike += (ushort)(1100 - (ChiData.TigerRank - 4) * 10);
  3660.         //            Entity.Immunity += 500;
  3661.         //        }
  3662.         //        else if (ChiData.TigerRank <= 50)
  3663.         //        {
  3664.         //            Entity.CriticalStrike += 500;
  3665.         //            Entity.SkillCStrike += 500;
  3666.         //            Entity.Immunity += 200;
  3667.         //        }
  3668.         //    }
  3669.         //    #endregion
  3670.         //    #region Turtle Ranking
  3671.         //    if (ChiData.TurtleRank <= 50 && ChiPowers.Count > 3)
  3672.         //    {
  3673.         //        if (ChiData.TurtleRank <= 3)
  3674.         //        {
  3675.         //            Entity.Breaktrough += 150;
  3676.         //            Entity.Counteraction += 150;
  3677.         //            Entity.Immunity += 800;
  3678.         //        }
  3679.         //        else if (ChiData.TurtleRank <= 15)
  3680.         //        {
  3681.         //            Entity.Breaktrough += (ushort)(110 - (ChiData.TurtleRank - 4) * 1);
  3682.         //            Entity.Counteraction += (ushort)(110 - (ChiData.TurtleRank - 4) * 1);
  3683.         //            Entity.Immunity += 500;
  3684.         //        }
  3685.         //        else if (ChiData.TurtleRank <= 50)
  3686.         //        {
  3687.         //            Entity.Breaktrough += 50;
  3688.         //            Entity.Counteraction += 50;
  3689.         //            Entity.Immunity += 200;
  3690.         //        }
  3691.         //    }
  3692.         //    #endregion
  3693.         //    #endregion
  3694.  
  3695.         //    if (Entity.MyJiang != null)
  3696.         //    {
  3697.         //        Entity.MyJiang.CreateStatusAtributes(Entity);
  3698.         //    }
  3699.            
  3700.         //    if (Entity.Aura_isActive)
  3701.         //        doAuraBonuses(Entity.Aura_actType, Entity.Aura_actPower, 1);
  3702.         //    else
  3703.         //        removeAuraBonuses(Entity.Aura_actType, Entity.Aura_actPower, 1);
  3704.         //    if (TeamAura)
  3705.         //        doAuraBonuses(TeamAuraStatusFlag, TeamAuraPower, 1);
  3706.         //    else
  3707.         //        removeAuraBonuses(TeamAuraStatusFlag, TeamAuraPower, 1);
  3708.         //    if (Entity.Class >= 60 && Entity.Class <= 65)
  3709.         //        Entity.AttackRange += 2;
  3710.  
  3711.         //    /*if (Entity.CriticalStrike > 9000)
  3712.         //        Entity.CriticalStrike = 9000;*/
  3713.  
  3714.         //    Entity.Hitpoints = bStats;
  3715.         //    CalculateStatBonus();
  3716.         //    CalculateHPBonus();
  3717.         //    ReviewMentor();
  3718.         //    GemAlgorithm();
  3719.         //    Entity.TrojanBP = (uint)Entity.BattlePower;
  3720.         //}
  3721.  
  3722.         //public void doAuraBonuses(ulong type, uint power, int i)
  3723.         //{
  3724.         //    switch (type)
  3725.         //    {
  3726.         //        case Update.Flags2.EarthAura:
  3727.         //            {
  3728.         //                Entity.EarthResistance += (int)power * i;
  3729.         //                break;
  3730.         //            }
  3731.         //        case Update.Flags2.FireAura:
  3732.         //            {
  3733.         //                Entity.FireResistance += (int)power * i;
  3734.         //                break;
  3735.         //            }
  3736.         //        case Update.Flags2.MetalAura:
  3737.         //            {
  3738.         //                Entity.MetalResistance += (int)power * i;
  3739.         //                break;
  3740.         //            }
  3741.         //        case Update.Flags2.WoodAura:
  3742.         //            {
  3743.         //                Entity.WoodResistance += (int)power * i;
  3744.         //                break;
  3745.         //            }
  3746.         //        case Update.Flags2.WaterAura:
  3747.         //            {
  3748.         //                Entity.WaterResistance += (int)power * i;
  3749.         //                break;
  3750.         //            }
  3751.         //        case Update.Flags2.TyrantAura:
  3752.         //            {
  3753.         //                Entity.CriticalStrike += (int)power * i * 100;
  3754.         //                Entity.SkillCStrike += (int)power * i * 100;
  3755.         //                if (Entity.CriticalStrike > 120000) Entity.CriticalStrike = 120000;
  3756.         //                if (Entity.SkillCStrike > 120000) Entity.SkillCStrike = 120000;
  3757.         //                if (Entity.CriticalStrike < 0) Entity.CriticalStrike = 0;
  3758.         //                if (Entity.SkillCStrike < 0) Entity.SkillCStrike = 0;
  3759.         //                break;
  3760.         //            }
  3761.         //        case Update.Flags2.FendAura:
  3762.         //            {
  3763.         //                Entity.Immunity += (int)power * i * 100;
  3764.         //                break;
  3765.         //            }
  3766.         //    }
  3767.         //}
  3768.  
  3769.         //public void removeAuraBonuses(ulong type, uint power, int i)
  3770.         //{
  3771.         //    switch (type)
  3772.         //    {
  3773.         //        case Update.Flags2.EarthAura:
  3774.         //            {
  3775.         //                Entity.EarthResistance -= (int)power * i;
  3776.         //                break;
  3777.         //            }
  3778.         //        case Update.Flags2.FireAura:
  3779.         //            {
  3780.         //                Entity.FireResistance -= (int)power * i;
  3781.         //                break;
  3782.         //            }
  3783.         //        case Update.Flags2.MetalAura:
  3784.         //            {
  3785.         //                Entity.MetalResistance -= (int)power * i;
  3786.         //                break;
  3787.         //            }
  3788.         //        case Update.Flags2.WoodAura:
  3789.         //            {
  3790.         //                Entity.WoodResistance -= (int)power * i;
  3791.         //                break;
  3792.         //            }
  3793.         //        case Update.Flags2.WaterAura:
  3794.         //            {
  3795.         //                Entity.WaterResistance -= (int)power * i;
  3796.         //                break;
  3797.         //            }
  3798.         //        case Update.Flags2.TyrantAura:
  3799.         //            {
  3800.         //                Entity.CriticalStrike -= (int)power * i * 100;
  3801.         //                Entity.SkillCStrike -= (int)power * i * 100;
  3802.         //                if (Entity.CriticalStrike > 120000) Entity.CriticalStrike = 120000;
  3803.         //                if (Entity.SkillCStrike > 120000) Entity.SkillCStrike = 120000;
  3804.         //                if (Entity.CriticalStrike < 0) Entity.CriticalStrike = 0;
  3805.         //                if (Entity.SkillCStrike < 0) Entity.SkillCStrike = 0;
  3806.         //                break;
  3807.         //            }
  3808.         //        case Update.Flags2.FendAura:
  3809.         //            {
  3810.         //                Entity.Immunity -= (int)power * i * 100;
  3811.         //                break;
  3812.         //            }
  3813.         //    }
  3814.         //}
  3815.  
  3816.         //private void loadItemStats(ConquerItem item)
  3817.         //{
  3818.         //    if (item.ID == ConquerItem.GoldPrize) Entity.WearsGoldPrize = true;
  3819.         //    int position = item.Position;
  3820.         //    bool isOver = false;
  3821.         //    if (isOver = (position > 20))
  3822.         //        position -= 20;
  3823.         //    item.IsWorn = true;
  3824.         //    if (!isOver)
  3825.         //    {
  3826.         //        if (position == ConquerItem.Garment || position == ConquerItem.Tower || position == ConquerItem.Fan || position == ConquerItem.RightWeaponAccessory || position == ConquerItem.LeftWeaponAccessory)
  3827.         //            Entity.SuperItemBless += item.Bless;
  3828.         //        if (position == ConquerItem.SteedArmor || position == ConquerItem.LeftWeaponAccessory || position == ConquerItem.RightWeaponAccessory) return;
  3829.         //    }
  3830.         //    int plus = item.Plus;
  3831.         //    if (DoChampStats)
  3832.         //        plus = Math.Min(item.Plus, ChampionAllowedStats[ChampionStats.Grade][0]);
  3833.         //    Database.ConquerItemInformation dbi = new Database.ConquerItemInformation(item.ID, item.Plus);
  3834.         //    if (dbi != null)
  3835.         //    {
  3836.         //        #region Give Stats.
  3837.  
  3838.         //        if (DoChampStats && ChampionAllowedStats[ChampionStats.Grade][5] == 1 || !DoChampStats)
  3839.         //        {
  3840.         //            if (item.Purification.PurificationItemID != 0)
  3841.         //            {
  3842.         //                Database.ConquerItemInformation soulDB = new Database.ConquerItemInformation(item.Purification.PurificationItemID, 0);
  3843.         //                /*if (position == ConquerItem.LeftWeapon)
  3844.         //                {
  3845.         //                    Entity.BaseMinAttack += (uint)(soulDB.BaseInformation.MinAttack / 2);
  3846.         //                    Entity.BaseMaxAttack += (uint)(soulDB.BaseInformation.MaxAttack / 2);
  3847.         //                }
  3848.         //                else
  3849.         //                {
  3850.         //                    Entity.BaseMinAttack += soulDB.BaseInformation.MinAttack;
  3851.         //                    Entity.BaseMaxAttack += soulDB.BaseInformation.MaxAttack;
  3852.         //                }*/
  3853.         //                Entity.BaseMinAttack += soulDB.BaseInformation.MinAttack;
  3854.         //                Entity.BaseMaxAttack += soulDB.BaseInformation.MaxAttack;
  3855.         //                Entity.ItemHP += soulDB.BaseInformation.ItemHP;
  3856.         //                Entity.BaseDefence += soulDB.BaseInformation.PhysicalDefence;
  3857.         //                Entity.MagicDefence += soulDB.BaseInformation.MagicDefence;
  3858.         //                Entity.Dodge += soulDB.BaseInformation.Dodge;
  3859.         //                Entity.Owner._accuracy += soulDB.BaseInformation.Accuracy;
  3860.         //                Entity.BaseMagicAttack += soulDB.BaseInformation.MagicAttack;
  3861.         //                Entity.WoodResistance += soulDB.BaseInformation.WoodResist;
  3862.         //                Entity.FireResistance += soulDB.BaseInformation.FireResist;
  3863.         //                Entity.WaterResistance += soulDB.BaseInformation.WaterResist;
  3864.         //                Entity.EarthResistance += soulDB.BaseInformation.EarthResist;
  3865.         //                Entity.Breaktrough += soulDB.BaseInformation.BreakThrough;
  3866.         //                Entity.CriticalStrike += soulDB.BaseInformation.CriticalStrike;
  3867.         //                Entity.Immunity += soulDB.BaseInformation.Immunity;
  3868.         //                Entity.Penetration += soulDB.BaseInformation.Penetration;
  3869.         //                Entity.Counteraction += soulDB.BaseInformation.CounterAction;
  3870.         //                Entity.Block += soulDB.BaseInformation.Block;
  3871.         //            }
  3872.         //        }
  3873.         //        if (DoChampStats && ChampionAllowedStats[ChampionStats.Grade][4] == 1 || !DoChampStats)
  3874.         //        {
  3875.         //            Refinery.RefineryItem refine = null;
  3876.         //            if (item.ExtraEffect.Available)
  3877.         //            {
  3878.         //                if (Kernel.DatabaseRefinery.TryGetValue(item.ExtraEffect.EffectID, out refine))
  3879.         //                {
  3880.         //                    if (refine != null)
  3881.         //                    {
  3882.         //                        switch (refine.Type)
  3883.         //                        {
  3884.         //                            case Refinery.RefineryItem.RefineryType.Block:
  3885.         //                                Entity.Block += (UInt16)(refine.Percent * 100);
  3886.         //                                break;
  3887.         //                            case Refinery.RefineryItem.RefineryType.BreakThrough:
  3888.         //                                Entity.Breaktrough += (UInt16)((refine.Percent * 10));
  3889.         //                                break;
  3890.         //                            case Refinery.RefineryItem.RefineryType.Counteraction:
  3891.         //                                Entity.Counteraction += (UInt16)(refine.Percent * 10);
  3892.         //                                break;
  3893.         //                            case Refinery.RefineryItem.RefineryType.Critical:
  3894.         //                                Entity.CriticalStrike += (UInt16)((refine.Percent * 100));
  3895.         //                                break;
  3896.         //                            case Refinery.RefineryItem.RefineryType.Detoxication:
  3897.         //                                Entity.Detoxication += (UInt16)(refine.Percent);
  3898.         //                                break;
  3899.         //                            case Refinery.RefineryItem.RefineryType.Immunity:
  3900.         //                                Entity.Immunity += (UInt16)(refine.Percent * 100);
  3901.         //                                break;
  3902.         //                            case Refinery.RefineryItem.RefineryType.Intensification:
  3903.         //                                Entity.Intensification += (UInt16)(refine.Percent);
  3904.         //                                break;
  3905.         //                            case Refinery.RefineryItem.RefineryType.Penetration:
  3906.         //                                Entity.Penetration += (UInt16)(refine.Percent * 100);
  3907.         //                                break;
  3908.         //                            case Refinery.RefineryItem.RefineryType.SCritical:
  3909.         //                                Entity.SkillCStrike += (UInt16)(refine.Percent * 100);
  3910.         //                                break;
  3911.         //                        }
  3912.         //                    }
  3913.         //                }
  3914.         //            }
  3915.         //        }
  3916.         //        if (position == ConquerItem.Tower)
  3917.         //        {
  3918.         //            Entity.PhysicalDamageDecrease += dbi.BaseInformation.PhysicalDefence;
  3919.         //            Entity.MagicDamageDecrease += dbi.BaseInformation.MagicDefence;
  3920.         //        }
  3921.         //        else
  3922.         //        {
  3923.         //            Entity.BaseDefence += dbi.BaseInformation.PhysicalDefence;
  3924.         //            Entity.MagicDefencePercent += dbi.BaseInformation.MagicDefence;
  3925.         //            Entity.Dodge += (byte)dbi.BaseInformation.Dodge;
  3926.         //            if (position != ConquerItem.Fan)
  3927.         //                Entity.BaseMagicAttack += dbi.BaseInformation.MagicAttack;
  3928.         //        }
  3929.         //        Entity.ItemHP += dbi.BaseInformation.ItemHP;
  3930.         //        Entity.ItemMP += dbi.BaseInformation.ItemMP;
  3931.         //        if (item.Position != ConquerItem.Steed)
  3932.         //        {
  3933.         //            if (DoChampStats)
  3934.         //                Entity.ItemBless += (ushort)Math.Min(item.Bless, ChampionAllowedStats[ChampionStats.Grade][1]);
  3935.         //            else
  3936.         //                Entity.ItemBless += item.Bless;
  3937.         //        }
  3938.         //        if (position == ConquerItem.RightWeapon)
  3939.         //        {
  3940.         //            Entity.AttackRange += dbi.BaseInformation.AttackRange;
  3941.         //            if (Network.PacketHandler.IsTwoHand(dbi.BaseInformation.ID))
  3942.         //                Entity.AttackRange += 4;
  3943.         //            else
  3944.         //                Entity.AttackRange += 3;
  3945.         //        }
  3946.         //        /*if (position == ConquerItem.LeftWeapon)
  3947.         //        {
  3948.         //            Entity.BaseMinAttack += (uint)(dbi.BaseInformation.MinAttack / 2);
  3949.         //            Entity.BaseMaxAttack += (uint)(dbi.BaseInformation.MaxAttack / 2);
  3950.         //        }*/
  3951.         //        if (position == ConquerItem.LeftWeapon)
  3952.         //        {
  3953.         //            Entity.BaseMinAttack += (uint)(dbi.BaseInformation.MinAttack * 0.5F);
  3954.         //            Entity.BaseMaxAttack += (uint)(dbi.BaseInformation.MaxAttack * 0.5F);
  3955.         //        }
  3956.         //        else if (position == ConquerItem.Fan)
  3957.         //        {
  3958.         //            Entity.PhysicalDamageIncrease += dbi.BaseInformation.MinAttack;
  3959.         //            Entity.MagicDamageIncrease += dbi.BaseInformation.MagicAttack;
  3960.         //        }
  3961.         //        else
  3962.         //        {
  3963.         //            Entity.BaseMinAttack += dbi.BaseInformation.MinAttack;
  3964.         //            Entity.BaseMaxAttack += dbi.BaseInformation.MaxAttack;
  3965.         //        }
  3966.         //        if (item.Plus != 0)
  3967.         //        {
  3968.         //            if (position == ConquerItem.Tower)
  3969.         //            {
  3970.         //                Entity.PhysicalDamageDecrease += dbi.PlusInformation.PhysicalDefence;
  3971.         //                Entity.MagicDamageDecrease += (ushort)dbi.PlusInformation.MagicDefence;
  3972.         //            }
  3973.         //            else if (position == ConquerItem.Fan)
  3974.         //            {
  3975.         //                Entity.PhysicalDamageIncrease += (ushort)dbi.PlusInformation.MinAttack;
  3976.         //                Entity.MagicDamageIncrease += (ushort)dbi.PlusInformation.MagicAttack;
  3977.         //            }
  3978.         //            else
  3979.         //            {
  3980.         //                if (position == ConquerItem.Steed)
  3981.         //                    Entity.ExtraVigor += dbi.PlusInformation.Agility;
  3982.         //                Entity.BaseMinAttack += dbi.PlusInformation.MinAttack;
  3983.         //                Entity.BaseMaxAttack += dbi.PlusInformation.MaxAttack;
  3984.         //                Entity.BaseMagicAttack += dbi.PlusInformation.MagicAttack;
  3985.         //                Entity.BaseDefence += dbi.PlusInformation.PhysicalDefence;
  3986.         //                Entity.MagicDefence += dbi.PlusInformation.MagicDefence;
  3987.         //                Entity.ItemHP += dbi.PlusInformation.ItemHP;
  3988.         //                if (position == ConquerItem.Boots)
  3989.         //                    Entity.Dodge += (byte)dbi.PlusInformation.Dodge;
  3990.         //            }
  3991.         //        }
  3992.         //        if (position == ConquerItem.Garment)
  3993.         //        {
  3994.         //            if (item.ID == 187425)
  3995.         //            {
  3996.         //                Entity.BaseDefence += 400;
  3997.         //                Entity.BaseMagicDefence += 2;
  3998.         //            }
  3999.         //            else if (item.ID == 187415)
  4000.         //            {
  4001.         //                Entity.BaseDefence += 600;
  4002.         //                Entity.BaseMagicDefence += 3;
  4003.         //            }
  4004.         //            else if (item.ID == 187405)
  4005.         //            {
  4006.         //                Entity.BaseDefence += 800;
  4007.         //                Entity.BaseMagicDefence += 4;
  4008.         //            }
  4009.         //        }
  4010.         //        byte socketone = (byte)item.SocketOne;
  4011.         //        byte sockettwo = (byte)item.SocketTwo;
  4012.         //        ushort madd = 0, dadd = 0, aatk = 0, matk = 0;
  4013.         //        if (DoChampStats && ChampionAllowedStats[ChampionStats.Grade][2] >= 1 || !DoChampStats)
  4014.         //        {
  4015.         //            switch (socketone)
  4016.         //            {
  4017.         //                case 1: Entity.Gems[0] += 5; break;
  4018.         //                case 2: Entity.Gems[0] += 10; break;
  4019.         //                case 3: Entity.Gems[0] += 15; break;
  4020.  
  4021.         //                case 11: Entity.Gems[1] += .05; break;
  4022.         //                case 12: Entity.Gems[1] += .10; break;
  4023.         //                case 13: Entity.Gems[1] += .15; break;
  4024.  
  4025.         //                case 31: Entity.Gems[3] += 10; break;
  4026.         //                case 32: Entity.Gems[3] += 15; break;
  4027.         //                case 33: Entity.Gems[3] += 25; break;
  4028.  
  4029.         //                case 51: Entity.Gems[5] += 30; break;
  4030.         //                case 52: Entity.Gems[5] += 50; break;
  4031.         //                case 53: Entity.Gems[5] += 100; break;
  4032.  
  4033.         //                case 61: Entity.Gems[6] += 15; break;
  4034.         //                case 62: Entity.Gems[6] += 30; break;
  4035.         //                case 63: Entity.Gems[6] += 50; break;
  4036.  
  4037.         //                case 71: Entity.Gems[7] += .2; break;
  4038.         //                case 72: Entity.Gems[7] += .4; break;
  4039.         //                case 73: Entity.Gems[7] += .6; break;
  4040.  
  4041.         //                case 101: aatk = matk += 100; break;
  4042.         //                case 102: aatk = matk += 300; break;
  4043.         //                case 103: aatk = matk += 500; break;
  4044.  
  4045.         //                case 121: madd = dadd += 100; break;
  4046.         //                case 122: madd = dadd += 300; break;
  4047.         //                case 123: madd = dadd += 500; break;
  4048.         //            }
  4049.         //        }
  4050.         //        if (DoChampStats && ChampionAllowedStats[ChampionStats.Grade][2] >= 2 || !DoChampStats)
  4051.         //        {
  4052.         //            switch (sockettwo)
  4053.         //            {
  4054.         //                case 1: Entity.Gems[0] += 5; break;
  4055.         //                case 2: Entity.Gems[0] += 10; break;
  4056.         //                case 3: Entity.Gems[0] += 15; break;
  4057.  
  4058.         //                case 11: Entity.Gems[1] += .05; break;
  4059.         //                case 12: Entity.Gems[1] += .10; break;
  4060.         //                case 13: Entity.Gems[1] += .15; break;
  4061.  
  4062.         //                case 31: Entity.Gems[3] += 10; break;
  4063.         //                case 32: Entity.Gems[3] += 15; break;
  4064.         //                case 33: Entity.Gems[3] += 25; break;
  4065.  
  4066.         //                case 51: Entity.Gems[5] += 30; break;
  4067.         //                case 52: Entity.Gems[5] += 50; break;
  4068.         //                case 53: Entity.Gems[5] += 100; break;
  4069.  
  4070.         //                case 61: Entity.Gems[6] += 15; break;
  4071.         //                case 62: Entity.Gems[6] += 30; break;
  4072.         //                case 63: Entity.Gems[6] += 50; break;
  4073.  
  4074.         //                case 71: Entity.Gems[7] += 2; break;
  4075.         //                case 72: Entity.Gems[7] += 4; break;
  4076.         //                case 73: Entity.Gems[7] += 6; break;
  4077.  
  4078.         //                case 101: aatk = matk += 100; break;
  4079.         //                case 102: aatk = matk += 300; break;
  4080.         //                case 103: aatk = matk += 500; break;
  4081.  
  4082.         //                case 121: madd = dadd += 100; break;
  4083.         //                case 122: madd = dadd += 300; break;
  4084.         //                case 123: madd = dadd += 500; break;
  4085.         //            }
  4086.         //        }
  4087.         //        Entity.PhysicalDamageDecrease += dadd;
  4088.         //        Entity.MagicDamageDecrease += madd;
  4089.         //        Entity.PhysicalDamageIncrease += aatk;
  4090.         //        Entity.MagicDamageIncrease += matk;
  4091.         //        if (item.Position != ConquerItem.Steed)
  4092.         //            if (!DoChampStats)
  4093.         //                Entity.ItemHP += item.Enchant;
  4094.         //            else
  4095.         //                Entity.ItemHP += (uint)Math.Min(item.Enchant, ChampionAllowedStats[ChampionStats.Grade][6]);
  4096.  
  4097.         //        #endregion
  4098.         //    }
  4099.         //}
  4100.         //public void GemAlgorithm()
  4101.         //{
  4102.         //    Entity.MaxAttack = Entity.Strength + Entity.BaseMaxAttack;
  4103.         //    Entity.MinAttack = Entity.Strength + Entity.BaseMinAttack;
  4104.         //    Entity.MagicAttack = Entity.BaseMagicAttack;
  4105.         //    if (Entity.Gems[0] != 0)
  4106.         //    {
  4107.         //        Entity.MagicAttack += (uint)Math.Floor(Entity.MagicAttack * (double)(Entity.Gems[0] * 0.01));
  4108.         //    }
  4109.         //    if (Entity.Gems[1] != 0)
  4110.         //    {
  4111.         //        Entity.MaxAttack += (uint)Math.Floor(Entity.MaxAttack * (double)(Entity.Gems[1] * 0.003));
  4112.         //        Entity.MinAttack += (uint)Math.Floor(Entity.MinAttack * (double)(Entity.Gems[1] * 0.003));
  4113.         //    }
  4114.         //}
  4115.         //public void GemAlgorithm()
  4116.         //{
  4117.         //    Entity.MaxAttack = Entity.BaseMaxAttack + Entity.Strength;
  4118.         //    Entity.MinAttack = Entity.BaseMinAttack + Entity.Strength;
  4119.         //    Entity.MagicAttack = Entity.BaseMagicAttack;
  4120.         //}
  4121.  
  4122.         #endregion
  4123.  
  4124.         public int Accuracy
  4125.         {
  4126.             get
  4127.             {
  4128.                 if (Entity.EntityFlag == Game.EntityFlag.Monster)
  4129.                     return 0;
  4130.                 int _accuracy = 0;
  4131.                 foreach (ConquerItem i in Equipment.Objects)
  4132.                 {
  4133.                     if (i == null)
  4134.                     {
  4135.                         continue;
  4136.                     }
  4137.                     if (i.Position == Network.GamePackets.ConquerItem.LeftWeapon ||
  4138.                         i.Position == Network.GamePackets.ConquerItem.RightWeapon)
  4139.                     {
  4140.                         Database.ConquerItemInformation dbi = new Database.ConquerItemInformation(i.ID, i.Plus);
  4141.                         if (dbi != null)
  4142.                         {
  4143.                             _accuracy += dbi.PlusInformation.Agility;
  4144.                         }
  4145.                     }
  4146.                 }
  4147.                 return _accuracy;
  4148.             }
  4149.         }
  4150.         public ushort AgilityItem
  4151.         {
  4152.             get
  4153.             {
  4154.                 if (Entity.EntityFlag == Game.EntityFlag.Monster)
  4155.                     return 0;
  4156.                 ushort _AgilityItem = 0;
  4157.                 foreach (ConquerItem i in Equipment.Objects)
  4158.                 {
  4159.                     if (i == null)
  4160.                     {
  4161.                         continue;
  4162.                     }
  4163.                     Database.ConquerItemInformation dbi = new Database.ConquerItemInformation(i.ID, i.Plus);
  4164.                     if (dbi != null)
  4165.                     {
  4166.                         _AgilityItem += dbi.BaseInformation.Frequency;
  4167.                     }
  4168.                 }
  4169.                 return _AgilityItem;
  4170.             }
  4171.         }
  4172.         public ushort MagicDefence
  4173.         {
  4174.             get
  4175.             {
  4176.                 if (Entity.EntityFlag == Game.EntityFlag.Monster)
  4177.                     return 0;
  4178.                 ushort _MagicDefence = 0;
  4179.                 foreach (ConquerItem i in Equipment.Objects)
  4180.                 {
  4181.                     if (i == null)
  4182.                     {
  4183.                         continue;
  4184.                     }
  4185.                     if (i.Position == Network.GamePackets.ConquerItem.Armor ||
  4186.                         i.Position == Network.GamePackets.ConquerItem.Necklace ||
  4187.                         i.Position == Network.GamePackets.ConquerItem.Head)
  4188.                     {
  4189.                         Database.ConquerItemInformation dbi = new Database.ConquerItemInformation(i.ID, i.Plus);
  4190.                         if (dbi != null)
  4191.                         {
  4192.                             _MagicDefence += dbi.BaseInformation.MagicDefence;
  4193.                         }
  4194.                     }
  4195.                 }
  4196.                 return _MagicDefence;
  4197.             }
  4198.         }
  4199.         #region Items
  4200.         private int StatHP;
  4201.         public uint[] ArsenalDonations;
  4202.         public uint GetArsenalDonation()
  4203.         {
  4204.             uint val = 0;
  4205.             foreach (var Uint in ArsenalDonations)
  4206.                 val += Uint;
  4207.  
  4208.             using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE))
  4209.                 cmd.Update("entities").Set("GuildArsenalDonation", (uint)val).Where("UID", this.Entity.UID)
  4210.                     .Execute();
  4211.             if (AsMember != null)
  4212.                 AsMember.ArsenalDonation = val;
  4213.             return val;
  4214.         }
  4215.         public void CalculateHPBonus()
  4216.         {
  4217.             //  if ((int)Account.State >= 3) return;
  4218.             switch (Entity.Class)
  4219.             {
  4220.                 case 11: Entity.MaxHitpoints = (uint)(StatHP * 1.05F); break;
  4221.                 case 12: Entity.MaxHitpoints = (uint)(StatHP * 1.08F); break;
  4222.                 case 13: Entity.MaxHitpoints = (uint)(StatHP * 1.10F); break;
  4223.                 case 14: Entity.MaxHitpoints = (uint)(StatHP * 1.12F); break;
  4224.                 case 15: Entity.MaxHitpoints = (uint)(StatHP * 1.15F); break;
  4225.                 default: Entity.MaxHitpoints = (uint)StatHP; break;
  4226.             }
  4227.             Entity.MaxHitpoints += Entity.ItemHP;
  4228.             Entity.MaxHitpoints += Entity.Intensification;          
  4229.             Entity.Hitpoints = Math.Min(Entity.Hitpoints, Entity.MaxHitpoints);
  4230.         }
  4231.         public void CalculateStatBonus()
  4232.         {
  4233.             byte ManaBoost = 5;
  4234.             const byte HitpointBoost = 24;
  4235.             sbyte Class = (sbyte)(Entity.Class / 10);
  4236.             if (Class == 13 || Class == 14)
  4237.                 ManaBoost += (byte)(5 * (Entity.Class - (Class * 10)));
  4238.             StatHP = (ushort)((Entity.Strength * 3) +
  4239.                                      (Entity.Agility * 3) +
  4240.                                      (Entity.Spirit * 3) +
  4241.                                      (Entity.Vitality * HitpointBoost));
  4242.             Entity.MaxMana = (ushort)((Entity.Spirit * ManaBoost) + Entity.ItemMP);
  4243.             Entity.Mana = Math.Min(Entity.Mana, Entity.MaxMana);
  4244.         }
  4245.         public void SendStatMessage()
  4246.         {
  4247.             this.ReviewMentor();
  4248.             Network.GamePackets.Message Msg = new Conquer_Online_Server.Network.GamePackets.Message(" Your status has been changed", System.Drawing.Color.DarkGoldenrod
  4249.                 , Network.GamePackets.Message.TopLeft);
  4250.             Msg.__Message = string.Format(Msg.__Message,
  4251.                 new object[] { Entity.MinAttack, Entity.MaxAttack, Entity.MagicAttack, Entity.Defence, (Entity.MagicDefence + Entity.MagicDefence), Entity.Dodge, Entity.PhysicalDamageDecrease, Entity.MagicDamageDecrease, Entity.PhysicalDamageIncrease, Entity.MagicDamageIncrease, Entity.Hitpoints, Entity.MaxHitpoints, Entity.Mana, Entity.MaxMana, Entity.BattlePower });
  4252.             this.Send(Msg);
  4253.         }
  4254.  
  4255.         private bool AreStatsLoadable(ConquerItem item)
  4256.         {
  4257.             if (!AlternateEquipment)
  4258.                 if (item.Position > 20)
  4259.                     return false;
  4260.             if (AlternateEquipment)
  4261.                 if (item.Position < 20)
  4262.                     if (!Equipment.Free((byte)(20 + item.Position)))
  4263.                         return false;
  4264.  
  4265.             int Position = item.Position;
  4266.             if (item.Position > 20) Position -= 20;
  4267.  
  4268.             if (Position == ConquerItem.LeftWeapon || Position == ConquerItem.RightWeapon)
  4269.                 return false;
  4270.  
  4271.             return true;
  4272.         }
  4273.  
  4274.         private Tuple<ConquerItem, ConquerItem> ComputeWeapons()
  4275.         {
  4276.             if (!AlternateEquipment)
  4277.             {
  4278.                 return new Tuple<ConquerItem, ConquerItem>(
  4279.                     Equipment.TryGetItem(ConquerItem.RightWeapon),
  4280.                     Equipment.TryGetItem(ConquerItem.LeftWeapon));
  4281.             }
  4282.             else
  4283.             {
  4284.                 if (Equipment.Free(ConquerItem.AlternateRightWeapon))
  4285.                 {
  4286.                     return new Tuple<ConquerItem, ConquerItem>(
  4287.                         Equipment.TryGetItem(ConquerItem.RightWeapon),
  4288.                         Equipment.TryGetItem(ConquerItem.LeftWeapon));
  4289.                 }
  4290.                 else
  4291.                 {
  4292.                     if (Equipment.Free(ConquerItem.RightWeapon))
  4293.                     {
  4294.                         return new Tuple<ConquerItem, ConquerItem>(
  4295.                             Equipment.TryGetItem(ConquerItem.AlternateRightWeapon),
  4296.                             Equipment.TryGetItem(ConquerItem.AlternateLeftWeapon));
  4297.                     }
  4298.                     else
  4299.                     {
  4300.                         if (!Equipment.Free(ConquerItem.AlternateLeftWeapon))
  4301.                         {
  4302.                             return new Tuple<ConquerItem, ConquerItem>(
  4303.                                 Equipment.TryGetItem(ConquerItem.AlternateRightWeapon),
  4304.                                 Equipment.TryGetItem(ConquerItem.AlternateLeftWeapon));
  4305.                         }
  4306.                         else
  4307.                         {
  4308.                             if (Equipment.Free(ConquerItem.LeftWeapon))
  4309.                             {
  4310.                                 return new Tuple<ConquerItem, ConquerItem>(
  4311.                                     Equipment.TryGetItem(ConquerItem.AlternateRightWeapon),
  4312.                                     null);
  4313.                             }
  4314.                             else
  4315.                             {
  4316.                                 ConquerItem aRight = Equipment.TryGetItem(ConquerItem.AlternateRightWeapon),
  4317.                                              nLeft = Equipment.TryGetItem(ConquerItem.LeftWeapon);
  4318.                                 if (PacketHandler.IsTwoHand(aRight.ID))
  4319.                                 {
  4320.                                     if (PacketHandler.IsArrow(nLeft.ID))
  4321.                                     {
  4322.                                         if (PacketHandler.IsBow(aRight.ID))
  4323.                                         {
  4324.                                             return new Tuple<ConquerItem,
  4325.                                                 ConquerItem>(aRight, nLeft);
  4326.                                         }
  4327.                                         else
  4328.                                         {
  4329.                                             return new Tuple<ConquerItem,
  4330.                                                 ConquerItem>(aRight, null);
  4331.                                         }
  4332.                                     }
  4333.                                     else
  4334.                                     {
  4335.                                         if (PacketHandler.IsShield(nLeft.ID))
  4336.                                         {
  4337.                                             if (!Spells.ContainsKey(10311))//Perseverance
  4338.                                             {
  4339.                                                 Send(new Message("You need to know Perseverance (Pure Warrior skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.Red, Message.Talk));
  4340.                                                 return new Tuple<ConquerItem,
  4341.                                                     ConquerItem>(aRight, null);
  4342.                                             }
  4343.                                             else
  4344.                                             {
  4345.                                                 return new Tuple<ConquerItem,
  4346.                                                     ConquerItem>(aRight, nLeft);
  4347.                                             }
  4348.                                         }
  4349.                                         else
  4350.                                         {
  4351.                                             return new Tuple<ConquerItem,
  4352.                                                 ConquerItem>(aRight, null);
  4353.                                         }
  4354.                                     }
  4355.                                 }
  4356.                                 else
  4357.                                 {
  4358.                                     if (!PacketHandler.IsTwoHand(nLeft.ID))
  4359.                                     {
  4360.                                         return new Tuple<ConquerItem,
  4361.                                             ConquerItem>(aRight, nLeft);
  4362.                                     }
  4363.                                     else
  4364.                                     {
  4365.                                         return new Tuple<ConquerItem,
  4366.                                             ConquerItem>(aRight, null);
  4367.                                     }
  4368.                                 }
  4369.                             }
  4370.                         }
  4371.                     }
  4372.                 }
  4373.             }
  4374.         }
  4375.  
  4376.         public int[][] ChampionAllowedStats = new int[][]
  4377.         {
  4378.             new int[] {1, 0, 0, 0, 0, 0, 0, 30, 0, 0 },
  4379.             new int[] {2, 0, 0, 0, 0, 0, 0, 40, 1, 1 },
  4380.             new int[] {3, 1, 0, 0, 0, 0, 50, 50, 2, 3 },
  4381.             new int[] {4, 3, 1, 1, 0, 0, 100, 60, 5, 4 },
  4382.             new int[] {5, 5, 1, 1, 1, 0, 150, 70, 7, 5 },
  4383.             new int[] {6, 5, 1, 1, 1, 0, 200, 80, 9, 7 },
  4384.             new int[] {12, 7, 2, 2, 1, 1, 255, 100, 12, 9 }
  4385.         };
  4386.         public bool DoChampStats { get { return ChampionGroup != null; } }
  4387.         //private int _accuracy;
  4388.         //public int Accuracy
  4389.         //{
  4390.         //    get { return _accuracy; }
  4391.         //}
  4392.         public void LoadItemStats()
  4393.         {
  4394.             uint bStats = Entity.Hitpoints;
  4395.             for (int i = 0; i < 29; i++)
  4396.                 if (Equipment.Objects[i] != null)
  4397.                     Equipment.Objects[i].IsWorn = false;
  4398.             //if (Team != null)
  4399.             //    Team.GetClanShareBp(this);
  4400.             //CalculateStatBonus();
  4401.             #region Set Every Variable to Zero        
  4402.             Entity.Defence = 0;
  4403.             Entity.MagicDefence = 0;
  4404.             Entity.MagicDefencePercent = 0;
  4405.             Entity.BaseMagicAttack = 0;
  4406.             Entity.BaseMagicDefence =
  4407.             Entity.BaseMaxAttack =
  4408.             Entity.BaseMinAttack =
  4409.             Entity.PhysicalDamageDecrease =
  4410.             Entity.PhysicalDamageIncrease =
  4411.             Entity.MagicDamageDecrease =
  4412.             Entity.MagicDamageIncrease = 0;
  4413.             Entity.ItemHP = 0;
  4414.             Entity.ItemHP =
  4415.             Entity.ItemMP =
  4416.             Entity.AttackRange = (byte)0;
  4417.             Entity.Dodge = 0;
  4418.             Entity.MinAttack = 0;
  4419.             Entity.MaxAttack = 0;
  4420.             Entity.Defence = 0;
  4421.             Entity.SuperItemBless = 0;
  4422.             Entity.MagicDefence = 0;
  4423.             Entity.Dodge = 0;
  4424.             Entity.BaseMagicAttack = 0;
  4425.             Entity.WoodResistance = 0;
  4426.             Entity.FireResistance = 0;
  4427.             Entity.WaterResistance = 0;
  4428.             Entity.EarthResistance = 0;
  4429.             Entity.MetalResistance = 0;
  4430.             Entity.Breaktrough = 0;
  4431.             Entity.WearsGoldPrize = false;
  4432.             Entity.CriticalStrike = 0;
  4433.             Entity.Immunity = 0;
  4434.             Entity.Penetration = 0;
  4435.             Entity.Counteraction = 0;
  4436.             Entity.Block = 0;
  4437.             // _accuracy = 0;
  4438.             Entity.Detoxication = 0;
  4439.             Entity.Intensification = 0;
  4440.             Entity.Penetration = 0;
  4441.             Entity.SkillCStrike = 0;
  4442.             Entity.MaxAttack = 0;
  4443.             Entity.MinAttack = 0;
  4444.             Entity.PhysicalDamageDecrease = 0;
  4445.             Entity.MagicDamageDecrease = 0;
  4446.             Entity.MagicDamageIncrease = 0;
  4447.             Entity.PhysicalDamageIncrease = 0;
  4448.             Entity.MagicDefencePercent = 0;
  4449.             Entity.ItemHP = 0;
  4450.             Entity.ItemMP = 0;
  4451.             Entity.ItemBless = 1.0;
  4452.             Entity.AttackRange = 1;
  4453.             Entity.BaseMinAttack = 0;
  4454.             Entity.BaseMaxAttack = 0;
  4455.             Entity.BaseMagicDefence = 0;
  4456.             Entity.BaseDefence = 0;
  4457.             Entity.MagicDamageIncrease = 0;
  4458.             Entity.Gems = new int[GemTypes.Last];
  4459.             Entity.Weight = 0;
  4460.             Entity.Accuracy = 0;
  4461.             #endregion
  4462.  
  4463.             foreach (ConquerItem i in Equipment.Objects)
  4464.             {
  4465.                 if (i == null) continue;
  4466.                 if (i.Durability == 0) continue;
  4467.                 if (!AreStatsLoadable(i)) continue;
  4468.                 loadItemStats(i);
  4469.             }
  4470.  
  4471.             Weapons = ComputeWeapons();
  4472.             if (Weapons == null) Weapons = new Tuple<ConquerItem, ConquerItem>(null, null);
  4473.             if (Weapons.Item1 != null)
  4474.             {
  4475.                 loadItemStats(Weapons.Item1);
  4476.                 if (Weapons.Item2 != null)
  4477.                 {
  4478.                     if (!Weapons.Item1.IsTwoHander())
  4479.                         loadItemStats(Weapons.Item2);
  4480.                     else
  4481.                         if (PacketHandler.IsArrow(Weapons.Item2.ID) || (Entity.Class >= 20 && Entity.Class <= 25))
  4482.                             loadItemStats(Weapons.Item2);
  4483.                 }
  4484.             }
  4485.  
  4486.             if (Entity.SubClasses != null)
  4487.                 Entity.SubClasses.UpgradeStatus(this, false);
  4488.             #region Chi
  4489.             uint percentage = 100;
  4490.             if (DoChampStats)
  4491.                 percentage = (uint)ChampionAllowedStats[ChampionStats.Grade][7];
  4492.             foreach (var chiPower in ChiPowers)
  4493.             {
  4494.                 foreach (var attribute in chiPower.Attributes)
  4495.                 {
  4496.                     switch (attribute.Type)
  4497.                     {
  4498.                         case Game.Enums.ChiAttribute.CriticalStrike:
  4499.                             Entity.CriticalStrike += (int)((ushort)(attribute.Value * 10) * percentage / 100);
  4500.                             break;
  4501.                         case Game.Enums.ChiAttribute.Counteraction:
  4502.                             Entity.Counteraction += (ushort)(attribute.Value * percentage / 100);
  4503.                             break;
  4504.                         case Game.Enums.ChiAttribute.AddAttack:
  4505.                             Entity.BaseMinAttack += attribute.Value * percentage / 100;
  4506.                             Entity.BaseMaxAttack += attribute.Value * percentage / 100;
  4507.                             break;
  4508.                         case Game.Enums.ChiAttribute.AddMagicAttack:
  4509.                             Entity.BaseMagicAttack += attribute.Value * percentage / 100;
  4510.                             break;
  4511.                         case Game.Enums.ChiAttribute.AddMagicDefense:
  4512.                             Entity.BaseMagicDefence += attribute.Value * percentage / 100;
  4513.                             break;
  4514.                         case Game.Enums.ChiAttribute.Breakthrough:
  4515.                             Entity.Breaktrough += (ushort)(attribute.Value * percentage / 100);
  4516.                             break;
  4517.                         case Game.Enums.ChiAttribute.HPAdd:
  4518.                             Entity.ItemHP += attribute.Value * percentage / 100;
  4519.                             break;
  4520.                         case Game.Enums.ChiAttribute.Immunity:
  4521.                             Entity.Immunity += (int)((ushort)(attribute.Value * 10) * percentage / 100);
  4522.                             break;
  4523.                         case Game.Enums.ChiAttribute.MagicDamageDecrease:
  4524.                             Entity.MagicDamageDecrease += (ushort)(attribute.Value * percentage / 100);
  4525.                             break;
  4526.                         case Game.Enums.ChiAttribute.MagicDamageIncrease:
  4527.                             Entity.MagicDamageIncrease += (ushort)(attribute.Value * percentage / 100);
  4528.                             break;
  4529.                         case Game.Enums.ChiAttribute.PhysicalDamageDecrease:
  4530.                             Entity.PhysicalDamageDecrease += (ushort)(attribute.Value * percentage / 100);
  4531.                             break;
  4532.                         case Game.Enums.ChiAttribute.PhysicalDamageIncrease:
  4533.                             Entity.PhysicalDamageIncrease += (ushort)(attribute.Value * percentage / 100);
  4534.                             break;
  4535.                         case Game.Enums.ChiAttribute.SkillCriticalStrike:
  4536.                             Entity.SkillCStrike += (int)((ushort)(attribute.Value * 10) * percentage / 100);
  4537.                             break;
  4538.                     }
  4539.                 }
  4540.             }
  4541.             #region Dragon Ranking
  4542.             if (ChiData.DragonRank <= 50 && ChiPowers.Count > 0)
  4543.             {
  4544.                 if (ChiData.DragonRank <= 3 || ChiData.DragonPoints == 400)
  4545.                 {
  4546.                     Entity.ItemHP += 5000;
  4547.                     Entity.BaseMagicDefence += 300;
  4548.                     Entity.PhysicalDamageDecrease += 1000;
  4549.                     Entity.MagicDamageDecrease += 300;
  4550.                 }
  4551.                 else if (ChiData.DragonRank <= 15)
  4552.                 {
  4553.                     var hp = (uint)Math.Round((3000 - (ChiData.DragonRank - 4) * 62.5));
  4554.                     Entity.ItemHP += hp;
  4555.                     Entity.BaseMagicDefence += (uint)(250 - (ChiData.DragonRank - 4) * 9);
  4556.                     Entity.PhysicalDamageDecrease += (ushort)(600 - (ChiData.DragonRank - 4) * 18);
  4557.                     Entity.MagicDamageDecrease += (ushort)(200 - (ChiData.DragonRank - 4) * 4);
  4558.                 }
  4559.                 else if (ChiData.DragonRank <= 50)
  4560.                 {
  4561.                     Entity.ItemHP += 1500;
  4562.                     Entity.BaseMagicDefence += 100;
  4563.                     Entity.PhysicalDamageDecrease += 300;
  4564.                     Entity.MagicDamageDecrease += 100;
  4565.                 }
  4566.             }
  4567.             #endregion
  4568.             #region Phoenix Ranking
  4569.             if (ChiData.PhoenixRank <= 50 && ChiPowers.Count > 1)
  4570.             {
  4571.                 if (ChiData.PhoenixRank <= 3 || ChiData.PhoenixPoints == 400)
  4572.                 {
  4573.                     Entity.BaseMinAttack += 3000;
  4574.                     Entity.BaseMaxAttack += 3000;
  4575.                     Entity.BaseMagicAttack += 3000;
  4576.                     Entity.PhysicalDamageIncrease += 1000;
  4577.                     Entity.MagicDamageIncrease += 300;
  4578.                 }
  4579.                 else if (ChiData.PhoenixRank <= 15)
  4580.                 {
  4581.                     Entity.BaseMinAttack += (uint)(2000 - (ChiData.PhoenixRank - 4) * 45);
  4582.                     Entity.BaseMaxAttack += (uint)(2000 - (ChiData.PhoenixRank - 4) * 45);
  4583.                     Entity.BaseMagicAttack += (uint)(2000 - (ChiData.PhoenixRank - 4) * 45);
  4584.                     Entity.PhysicalDamageIncrease += (ushort)(600 - (ChiData.PhoenixRank - 4) * 18);
  4585.                     Entity.MagicDamageIncrease += (ushort)(200 - (ChiData.PhoenixRank - 4) * 4);
  4586.                 }
  4587.                 else if (ChiData.PhoenixRank <= 50)
  4588.                 {
  4589.                     Entity.BaseMinAttack += 1000;
  4590.                     Entity.BaseMaxAttack += 1000;
  4591.                     Entity.BaseMagicAttack += 1000;
  4592.                     Entity.PhysicalDamageIncrease += 300;
  4593.                     Entity.MagicDamageIncrease += 100;
  4594.                 }
  4595.             }
  4596.             #endregion
  4597.             #region Tiger Ranking
  4598.             if (ChiData.TigerRank <= 50 && ChiPowers.Count > 2)
  4599.             {
  4600.                 if (ChiData.TigerRank <= 3 || ChiData.TigerPoints == 400)
  4601.                 {
  4602.                     Entity.CriticalStrike += 1500;
  4603.                     Entity.SkillCStrike += 1500;
  4604.                     Entity.Immunity += 800;
  4605.                 }
  4606.                 else if (ChiData.TigerRank <= 15)
  4607.                 {
  4608.                     Entity.CriticalStrike += (ushort)(1100 - (ChiData.TigerRank - 4) * 10);
  4609.                     Entity.SkillCStrike += (ushort)(1100 - (ChiData.TigerRank - 4) * 10);
  4610.                     Entity.Immunity += 500;
  4611.                 }
  4612.                 else if (ChiData.TigerRank <= 50)
  4613.                 {
  4614.                     Entity.CriticalStrike += 500;
  4615.                     Entity.SkillCStrike += 500;
  4616.                     Entity.Immunity += 200;
  4617.                 }
  4618.             }
  4619.             #endregion
  4620.             #region Turtle Ranking
  4621.             if (ChiData.TurtleRank <= 50 && ChiPowers.Count > 3)
  4622.             {
  4623.                 if (ChiData.TurtleRank <= 3 || ChiData.TurtlePoints == 400)
  4624.                 {
  4625.                     Entity.Breaktrough += 150;
  4626.                     Entity.Counteraction += 150;
  4627.                     Entity.Immunity += 800;
  4628.                 }
  4629.                 else if (ChiData.TurtleRank <= 15)
  4630.                 {
  4631.                     Entity.Breaktrough += (ushort)(110 - (ChiData.TurtleRank - 4) * 1);
  4632.                     Entity.Counteraction += (ushort)(110 - (ChiData.TurtleRank - 4) * 1);
  4633.                     Entity.Immunity += 500;
  4634.                 }
  4635.                 else if (ChiData.TurtleRank <= 50)
  4636.                 {
  4637.                     Entity.Breaktrough += 50;
  4638.                     Entity.Counteraction += 50;
  4639.                     Entity.Immunity += 200;
  4640.                 }
  4641.             }
  4642.             #endregion
  4643.             #endregion
  4644.             if (Entity.MyJiang != null)
  4645.             {
  4646.                 Entity.MyJiang.CreateStatusAtributes(Entity);
  4647.             }
  4648.             if (Entity.Aura_isActive)
  4649.                 doAuraBonuses(Entity.Aura_actType, Entity.Aura_actPower, 1);
  4650.             else
  4651.                 removeAuraBonuses(Entity.Aura_actType, Entity.Aura_actPower, 1);
  4652.             //if (TeamAura)
  4653.             //    doAuraBonuses(TeamAuraStatusFlag, TeamAuraPower, 1);
  4654.             //else
  4655.             //    removeAuraBonuses(TeamAuraStatusFlag, TeamAuraPower, 1);
  4656.             foreach (var Aura in Auras.Values)
  4657.             {
  4658.                 doAuraBonuses(Aura.TeamAuraStatusFlag, Aura.TeamAuraPower, 1);
  4659.             }
  4660.             if (Entity.Class >= 60 && Entity.Class <= 65)
  4661.                 Entity.AttackRange += 2;
  4662.             #region VIP
  4663.             if (Entity.VIPLevel == 7)
  4664.             {
  4665.                 Entity.ItemHP += 1500;
  4666.                 Entity.BaseMinAttack += 1500;
  4667.                 Entity.BaseMaxAttack += 1500;
  4668.                 Entity.Immunity += 300;
  4669.                 Entity.CriticalStrike += 300;
  4670.                 Entity.Breaktrough += 30;
  4671.                 Entity.Counteraction += 30;
  4672.                 Entity.BaseMagicAttack += 2500;
  4673.                 Entity.Defence += 1000;
  4674.             }
  4675.             #endregion
  4676.            
  4677.             /*if (Entity.CriticalStrike > 9000)
  4678.                 Entity.CriticalStrike = 9000;*/
  4679.                      
  4680.             CalculateStatBonus();
  4681.             CalculateHPBonus();
  4682.             ReviewMentor();
  4683.             GemAlgorithm();
  4684.             Entity.TrojanBP = (uint)Entity.BattlePower;
  4685.             Entity.Hitpoints = bStats;
  4686.             if (Team != null)
  4687.                 Team.GetClanShareBp(this);
  4688.             CalculateStatBonus();
  4689.             PacketHandler.WindowStats(this);
  4690.         }
  4691.  
  4692.         public void doAuraBonuses(ulong type, uint power, int i)
  4693.         {
  4694.             switch (type)
  4695.             {
  4696.                 case Update.Flags2.EarthAura:
  4697.                     {
  4698.                         Entity.EarthResistance += (int)power * i;
  4699.                         break;
  4700.                     }
  4701.                 case Update.Flags2.FireAura:
  4702.                     {
  4703.                         Entity.FireResistance += (int)power * i;
  4704.                         break;
  4705.                     }
  4706.                 case Update.Flags2.MetalAura:
  4707.                     {
  4708.                         Entity.MetalResistance += (int)power * i;
  4709.                         break;
  4710.                     }
  4711.                 case Update.Flags2.WoodAura:
  4712.                     {
  4713.                         Entity.WoodResistance += (int)power * i;
  4714.                         break;
  4715.                     }
  4716.                 case Update.Flags2.WaterAura:
  4717.                     {
  4718.                         Entity.WaterResistance += (int)power * i;
  4719.                         break;
  4720.                     }
  4721.                 case Update.Flags2.TyrantAura:
  4722.                     {
  4723.                         Entity.CriticalStrike += (int)power * i * 100;
  4724.                         Entity.SkillCStrike += (int)power * i * 100;
  4725.                         if (Entity.CriticalStrike > 120000) Entity.CriticalStrike = 120000;
  4726.                         if (Entity.SkillCStrike > 120000) Entity.SkillCStrike = 120000;
  4727.                         if (Entity.CriticalStrike < 0) Entity.CriticalStrike = 0;
  4728.                         if (Entity.SkillCStrike < 0) Entity.SkillCStrike = 0;
  4729.                         break;
  4730.                     }
  4731.                 case Update.Flags2.FendAura:
  4732.                     {
  4733.                         Entity.Immunity += (int)power * i * 100;
  4734.                         Entity.Counteraction += (int)power * i * 10;
  4735.                         break;
  4736.                     }
  4737.             }
  4738.         }
  4739.  
  4740.         public void removeAuraBonuses(ulong type, uint power, int i)
  4741.         {
  4742.             switch (type)
  4743.             {
  4744.                 case Update.Flags2.EarthAura:
  4745.                     {
  4746.                         Entity.EarthResistance -= (int)power * i;
  4747.                         break;
  4748.                     }
  4749.                 case Update.Flags2.FireAura:
  4750.                     {
  4751.                         Entity.FireResistance -= (int)power * i;
  4752.                         break;
  4753.                     }
  4754.                 case Update.Flags2.MetalAura:
  4755.                     {
  4756.                         Entity.MetalResistance -= (int)power * i;
  4757.                         break;
  4758.                     }
  4759.                 case Update.Flags2.WoodAura:
  4760.                     {
  4761.                         Entity.WoodResistance -= (int)power * i;
  4762.                         break;
  4763.                     }
  4764.                 case Update.Flags2.WaterAura:
  4765.                     {
  4766.                         Entity.WaterResistance -= (int)power * i;
  4767.                         break;
  4768.                     }
  4769.                 case Update.Flags2.TyrantAura:
  4770.                     {
  4771.                         Entity.CriticalStrike -= (int)power * i * 100;
  4772.                         Entity.SkillCStrike -= (int)power * i * 100;
  4773.                         if (Entity.CriticalStrike > 120000) Entity.CriticalStrike = 120000;
  4774.                         if (Entity.SkillCStrike > 120000) Entity.SkillCStrike = 120000;
  4775.                         if (Entity.CriticalStrike < 0) Entity.CriticalStrike = 0;
  4776.                         if (Entity.SkillCStrike < 0) Entity.SkillCStrike = 0;
  4777.                         break;
  4778.                     }
  4779.                 case Update.Flags2.FendAura:
  4780.                     {
  4781.                         Entity.Immunity -= (int)power * i * 100;
  4782.                         //Entity.Counteraction -= (int)power * i * 10;
  4783.  
  4784.                         break;
  4785.                     }
  4786.             }
  4787.         }
  4788.  
  4789.         private void loadItemStats(ConquerItem item)
  4790.         {
  4791.             if (item.ID == ConquerItem.GoldPrize) Entity.WearsGoldPrize = true;
  4792.             int position = item.Position;
  4793.             bool isOver = false;
  4794.             if (isOver = (position > 20))
  4795.                 position -= 20;
  4796.             item.IsWorn = true;
  4797.             //if (!isOver)
  4798.             //{
  4799.             // //   if (position == ConquerItem.Garment || position == ConquerItem.Tower || position == ConquerItem.Fan || position == ConquerItem.RightWeaponAccessory || position == ConquerItem.LeftWeaponAccessory)
  4800.             //    //    Entity.SuperItemBless += item.Bless;
  4801.             //    if (position == ConquerItem.SteedArmor || position == ConquerItem.LeftWeaponAccessory || position == ConquerItem.RightWeaponAccessory) return;
  4802.             //}
  4803.             int plus = item.Plus;
  4804.             if (DoChampStats)
  4805.                 plus = Math.Min(item.Plus, ChampionAllowedStats[ChampionStats.Grade][0]);
  4806.             Database.ConquerItemInformation dbi = new Database.ConquerItemInformation(item.ID, item.Plus);
  4807.             if (dbi != null)
  4808.             {
  4809.                 #region Give Stats.
  4810.  
  4811.                 #region soul stats
  4812.  
  4813.                 if (DoChampStats && ChampionAllowedStats[ChampionStats.Grade][5] == 1 || !DoChampStats)
  4814.                 {
  4815.                     if (item.Purification.PurificationItemID != 0)
  4816.                     {
  4817.                         Database.ConquerItemInformation soulDB = new Database.ConquerItemInformation(item.Purification.PurificationItemID, 0);
  4818.                         if (position == ConquerItem.LeftWeapon)
  4819.                         {
  4820.                             Entity.BaseMinAttack += (uint)(soulDB.BaseInformation.MinAttack / 2);
  4821.                             Entity.BaseMaxAttack += (uint)(soulDB.BaseInformation.MaxAttack / 2);
  4822.                         }
  4823.                         else
  4824.                         {
  4825.                             Entity.BaseMinAttack += soulDB.BaseInformation.MinAttack;
  4826.                             Entity.BaseMaxAttack += soulDB.BaseInformation.MaxAttack;
  4827.                         }
  4828.                         //  Entity.BaseMinAttack += soulDB.BaseInformation.MinAttack;
  4829.                         //  Entity.BaseMaxAttack += soulDB.BaseInformation.MaxAttack;
  4830.                         Entity.ItemHP += soulDB.BaseInformation.ItemHP;
  4831.                         Entity.BaseDefence += soulDB.BaseInformation.PhysicalDefence;
  4832.                         Entity.MagicDefence += soulDB.BaseInformation.MagicDefence;
  4833.                         Entity.Dodge += soulDB.BaseInformation.Dodge;
  4834.                         Entity.Accuracy += soulDB.BaseInformation.Accuracy;
  4835.                         Entity.BaseMagicAttack += soulDB.BaseInformation.MagicAttack;
  4836.                         Entity.MetalResistance += soulDB.BaseInformation.MetalResist;
  4837.                         Entity.WoodResistance += soulDB.BaseInformation.WoodResist;
  4838.                         Entity.FireResistance += soulDB.BaseInformation.FireResist;
  4839.                         Entity.WaterResistance += soulDB.BaseInformation.WaterResist;
  4840.                         Entity.EarthResistance += soulDB.BaseInformation.EarthResist;
  4841.                         Entity.Breaktrough += soulDB.BaseInformation.BreakThrough;
  4842.                         Entity.CriticalStrike += soulDB.BaseInformation.CriticalStrike;
  4843.                         Entity.Immunity += soulDB.BaseInformation.Immunity;
  4844.                         Entity.Penetration += soulDB.BaseInformation.Penetration;
  4845.                         Entity.Counteraction += soulDB.BaseInformation.CounterAction;
  4846.                         Entity.Block += soulDB.BaseInformation.Block;
  4847.  
  4848.                         Entity.Weight += soulDB.BaseInformation.Weight;
  4849.                     }
  4850.                 }
  4851.                 #endregion
  4852.                 #region Refinery stats
  4853.                 if (DoChampStats && ChampionAllowedStats[ChampionStats.Grade][4] == 1 || !DoChampStats)
  4854.                 {
  4855.                     Refinery.RefineryItem refine = null;
  4856.                     if (item.ExtraEffect.Available)
  4857.                     {
  4858.                         if (Kernel.DatabaseRefinery.TryGetValue(item.ExtraEffect.EffectID, out refine))
  4859.                         {
  4860.                             if (refine != null)
  4861.                             {
  4862.                                 switch (refine.Type)
  4863.                                 {
  4864.                                     case Refinery.RefineryItem.RefineryType.Block:
  4865.                                         Entity.Block += (UInt16)(refine.Percent * 100);
  4866.                                         break;
  4867.                                     case Refinery.RefineryItem.RefineryType.BreakThrough:
  4868.                                         Entity.Breaktrough += (UInt16)((refine.Percent * 10));
  4869.                                         break;
  4870.                                     case Refinery.RefineryItem.RefineryType.Counteraction:
  4871.                                         Entity.Counteraction += (UInt16)(refine.Percent * 10);
  4872.                                         break;
  4873.                                     case Refinery.RefineryItem.RefineryType.Critical:
  4874.                                         Entity.CriticalStrike += (UInt16)((refine.Percent * 100));
  4875.                                         break;
  4876.                                     case Refinery.RefineryItem.RefineryType.Detoxication:
  4877.                                         Entity.Detoxication += (UInt16)(refine.Percent);
  4878.                                         break;
  4879.                                     case Refinery.RefineryItem.RefineryType.Immunity:
  4880.                                         Entity.Immunity += (UInt16)(refine.Percent * 100);
  4881.                                         break;
  4882.                                     case Refinery.RefineryItem.RefineryType.Intensification:
  4883.                                         Entity.Intensification += (UInt16)(refine.Percent);
  4884.                                         break;
  4885.                                     case Refinery.RefineryItem.RefineryType.Penetration:
  4886.                                         Entity.Penetration += (UInt16)(refine.Percent * 100);
  4887.                                         break;
  4888.                                     case Refinery.RefineryItem.RefineryType.SCritical:
  4889.                                         Entity.SkillCStrike += (UInt16)(refine.Percent * 100);
  4890.                                         break;
  4891.                                 }
  4892.                             }
  4893.                         }
  4894.                     }
  4895.                 }
  4896.                 #endregion
  4897.                
  4898.                 if (position == ConquerItem.Tower)
  4899.                 {
  4900.                     Entity.PhysicalDamageDecrease += dbi.BaseInformation.PhysicalDefence;
  4901.                     Entity.MagicDamageDecrease += dbi.BaseInformation.MagicDefence;
  4902.                 }
  4903.                 else if (position == ConquerItem.Fan)
  4904.                 {
  4905.                     Entity.PhysicalDamageIncrease += dbi.BaseInformation.MaxAttack;
  4906.                     Entity.MagicDamageIncrease += dbi.BaseInformation.MagicAttack;
  4907.                 }
  4908.                 else
  4909.                 {
  4910.                     if (position == ConquerItem.LeftWeapon)
  4911.                     {
  4912.                         Entity.BaseMinAttack += (uint)dbi.BaseInformation.MinAttack / 2;
  4913.                         Entity.BaseMaxAttack += (uint)dbi.BaseInformation.MaxAttack / 2;                      
  4914.  
  4915.                     }
  4916.                     else
  4917.                     {
  4918.                         if (position == ConquerItem.RightWeapon)
  4919.                         {
  4920.                             Entity.AttackRange += dbi.BaseInformation.AttackRange;
  4921.                             if (Network.PacketHandler.IsTwoHand(dbi.BaseInformation.ID))
  4922.                                 Entity.AttackRange += 4;
  4923.                             else
  4924.                                 Entity.AttackRange += 3;
  4925.                         }
  4926.                         Entity.BaseMinAttack += dbi.BaseInformation.MinAttack;
  4927.                         Entity.BaseMaxAttack += dbi.BaseInformation.MaxAttack;
  4928.                     }
  4929.  
  4930.                     Entity.BaseDefence += dbi.BaseInformation.PhysicalDefence;
  4931.                     Entity.BaseMagicAttack += dbi.BaseInformation.MagicAttack;
  4932.                 }
  4933.  
  4934.                 if (position == ConquerItem.Steed)
  4935.                     Entity.ExtraVigor += dbi.PlusInformation.Agility;
  4936.                 Entity.ItemHP += dbi.BaseInformation.ItemHP;
  4937.                 Entity.ItemMP += dbi.BaseInformation.ItemMP;
  4938.                 Entity.Dodge += dbi.BaseInformation.Dodge;
  4939.                 Entity.Dexterity += dbi.BaseInformation.Frequency;
  4940.                 Entity.Weight += dbi.BaseInformation.Weight;
  4941.                 if (item.Position != ConquerItem.Steed)
  4942.                 {
  4943.                     if (DoChampStats)
  4944.                         Entity.ItemBless -= (ushort)Math.Min(item.Bless / 100, ChampionAllowedStats[ChampionStats.Grade][1]);
  4945.                     else
  4946.                         Entity.ItemBless -= ((double)item.Bless / 100);
  4947.                 }
  4948.                
  4949.  
  4950.                 var gem = (int)item.SocketOne;
  4951.                 if (gem != 0 && gem != 255)
  4952.                     Entity.Gems[gem / 10] += GemTypes.Effects[gem / 10][gem % 10];
  4953.  
  4954.                 gem = (int)item.SocketTwo;
  4955.                 if (gem != 0 && gem != 255)
  4956.                     Entity.Gems[gem / 10] += GemTypes.Effects[gem / 10][gem % 10];
  4957.  
  4958.                 if (item.Plus > 0)
  4959.                 {
  4960.                     var add = dbi.PlusInformation;
  4961.                     Entity.BaseMinAttack += add.MinAttack;
  4962.                     Entity.BaseMaxAttack += add.MaxAttack;
  4963.                     Entity.BaseMagicAttack += add.MagicAttack;
  4964.                     Entity.BaseDefence += add.PhysicalDefence;
  4965.                     Entity.Dodge += add.Dodge;
  4966.                     Entity.Dexterity += add.Agility;
  4967.                     Entity.MagicDefence += add.MagicDefence;
  4968.                     Entity.ItemHP += add.ItemHP;
  4969.                 }
  4970.                 Entity.ItemHP += item.Enchant;
  4971.                 var per = 1;
  4972.                 var per2 = 1;
  4973.               //  if (item.Position == ConquerItem.Garment || item.Position == ConquerItem.Bottle || item.Position == ConquerItem.SteedArmor)
  4974.               //      per = per2 = 1;                
  4975.                 Entity.CriticalStrike += (int)dbi.BaseInformation.CriticalStrike / per;
  4976.                 Entity.SkillCStrike += (int)dbi.BaseInformation.SkillCriticalStrike / per;
  4977.                 Entity.Immunity += (int)dbi.BaseInformation.Immunity / per;
  4978.                 Entity.Penetration += (int)dbi.BaseInformation.Penetration / per;
  4979.                 Entity.Block += (int)dbi.BaseInformation.Block / per;
  4980.                 Entity.Breaktrough += (int)dbi.BaseInformation.BreakThrough / per2;
  4981.                 Entity.Counteraction += (int)dbi.BaseInformation.CounterAction / per2;
  4982.                 Entity.MetalResistance += dbi.BaseInformation.MetalResist;
  4983.                 Entity.WoodResistance += dbi.BaseInformation.WoodResist;
  4984.                 Entity.WaterResistance += dbi.BaseInformation.WaterResist;
  4985.                 Entity.FireResistance += dbi.BaseInformation.FireResist;
  4986.                 Entity.EarthResistance += dbi.BaseInformation.EarthResist;
  4987.  
  4988.                 #endregion
  4989.             }
  4990.         }        
  4991.         public void GemAlgorithm()
  4992.         {
  4993.  
  4994.             Entity.MaxAttack = Entity.BaseMaxAttack + Entity.Strength;
  4995.             Entity.MinAttack = Entity.BaseMinAttack + Entity.Strength;          
  4996.             Entity.MagicAttack = Entity.BaseMagicAttack;
  4997.  
  4998.         }
  4999.  
  5000.         #endregion
  5001.         #endregion
  5002.  
  5003.         #region Matrix
  5004.                
  5005.         public byte Circle_Level;
  5006.         public string circle_Effect;
  5007.         public Point Circle_Center;
  5008.         public void Summon2()
  5009.         {
  5010.             try
  5011.             {
  5012.                 List<System.Drawing.Point> DestructionAreas = new List<System.Drawing.Point>();              
  5013.                 for (int i = 0; i < 360; i++)
  5014.                 {
  5015.                     ushort x = (ushort)(Circle_Center.X + (Circle_Level * Math.Cos(i)));
  5016.                     ushort y = (ushort)(Circle_Center.Y + (Circle_Level * Math.Sin(i)));
  5017.                     System.Drawing.Point p = new System.Drawing.Point((int)x, (int)y);
  5018.                     if (!DestructionAreas.Contains(p))
  5019.                         DestructionAreas.Add(p);
  5020.                 }
  5021.                 foreach (System.Drawing.Point p in DestructionAreas)
  5022.                 {
  5023.                     _String str = new _String(true);
  5024.                     str.TextsCount = 1;
  5025.                     str.PositionX = (ushort)p.X;
  5026.                     str.PositionY = (ushort)p.Y;
  5027.                     str.Type = _String.MapEffect;
  5028.                     str.Texts.Add(circle_Effect);
  5029.                     SendScreen(str, true);
  5030.  
  5031.                    
  5032.                     var spell = Database.SpellTable.GetSpell(11600, this);
  5033.  
  5034.                     var attack = new Attack(true);
  5035.                     attack.Attacker = Entity.UID;
  5036.                     attack.AttackType = Attack.Melee;
  5037.  
  5038.                     foreach (var obj1 in Screen.Objects)
  5039.                     {
  5040.                         if (Kernel.GetDistance(obj1.X, obj1.Y, (ushort)p.X, (ushort)p.Y) <= 3)
  5041.                         {
  5042.                             if (obj1.MapObjType == MapObjectType.Monster || obj1.MapObjType == MapObjectType.Player)
  5043.                             {
  5044.                                 var attacked = obj1 as Entity;
  5045.                                 if (Conquer_Online_Server.Game.Attacking.Handle.CanAttack(Entity, attacked, spell, false))
  5046.                                 {
  5047.                                     uint damage = Game.Attacking.Calculate.Melee(Entity, attacked, spell, ref attack);
  5048.  
  5049.                                     attack.Damage = damage;
  5050.                                     attack.Attacked = attacked.UID;
  5051.                                     attack.X = attacked.X;
  5052.                                     attack.Y = attacked.Y;
  5053.  
  5054.                                     Conquer_Online_Server.Game.Attacking.Handle.ReceiveAttack(Entity, attacked, attack, ref damage, spell);
  5055.                                 }
  5056.                             }
  5057.                             else if (obj1.MapObjType == MapObjectType.SobNpc)
  5058.                             {
  5059.                                 var attacked = obj1 as SobNpcSpawn;
  5060.                                 if (Conquer_Online_Server.Game.Attacking.Handle.CanAttack(Entity, attacked, spell))
  5061.                                 {
  5062.                                     uint damage = Game.Attacking.Calculate.Melee(Entity, attacked, ref attack);
  5063.                                     attack.Damage = damage;
  5064.                                     attack.Attacked = attacked.UID;
  5065.                                     attack.X = attacked.X;
  5066.                                     attack.Y = attacked.Y;
  5067.  
  5068.                                    Conquer_Online_Server.Game.Attacking.Handle.ReceiveAttack(Entity, attacked, attack, damage, spell);
  5069.                                 }
  5070.                             }
  5071.                         }
  5072.                     }
  5073.                 }                
  5074.                 Circle_Level += 1;
  5075.               //  EntityActions.RemoveAction(ProjectX_V3_Game.Entities.DelayedActionType.Summon);
  5076.               //  EntityActions.AddAction(ProjectX_V3_Game.Entities.DelayedActionType.Summon, Summon2, 1500);                                
  5077.                                
  5078.             }
  5079.             catch { }
  5080.         }        
  5081.         public static GameState CharacterFromName(string name)
  5082.         {
  5083.             foreach (GameState c in Kernel.GamePool.Values)
  5084.                 if (c.Entity.Name == name)
  5085.                     return c;
  5086.             return null;
  5087.         }
  5088.         public static GameState CharacterFromName2(string Name)
  5089.         {
  5090.             foreach (GameState C in Kernel.GamePool.Values)
  5091.                 if (C.Entity.Name == Name)
  5092.                     return C;
  5093.             return null;
  5094.         }
  5095.         #region New acc Reg.
  5096.         public string accountname;
  5097.         public string accountpass1;
  5098.         public string accountpass2;
  5099.         public string accountEmail;
  5100.         #endregion
  5101.         public Database.VipVariables VIPInformation = new Database.VipVariables();      
  5102.        
  5103.         public bool ItemGive = false;      
  5104.         public bool IsFairy = false;
  5105.         public uint FairyType = 0;
  5106.         public uint SType = 0;
  5107.  
  5108.         #endregion
  5109.  
  5110.  
  5111.         public bool Fake;
  5112.         public Tuple<ConquerItem, ConquerItem> Weapons;
  5113.         public Game.Enums.PKMode PrevPK;
  5114.         public int TeamCheerFor;
  5115.         public int ArenaState = 0;
  5116.         public QuizShow.QuizClient Quiz;
  5117.         public uint InteractionEffect;
  5118.         public Game.UsableRacePotion[] Potions;
  5119.         //public bool TeamAura;
  5120.         //public GameState TeamAuraOwner;
  5121.         //public ulong TeamAuraStatusFlag;
  5122.         //public uint TeamAuraPower;
  5123.         //public uint TeamAuraLevel;
  5124.         public VariableVault Variables;
  5125.         public uint NpcCpsInput;
  5126.         public SlotMachine SlotMachine;
  5127.         public int SMSpinCount;
  5128.         public string SMCaptcha;
  5129.         public byte[] SMPacket;
  5130.         public Time32 KillCountCaptchaStamp;
  5131.         public bool WaitingKillCaptcha;
  5132.         public string KillCountCaptcha;
  5133.         public bool JustOpenedDetain;
  5134.         public Network.GamePackets.Trade TradePacket;
  5135.         public bool WaitingTradePassword;
  5136.         public ItemLock ItemUnlockPacket;
  5137.         public bool WaitingItemUnlockPassword;
  5138.         public Database.ConquerItemBaseInformation NewLookArmorInfo;
  5139.         public Database.ConquerItemBaseInformation NewLookHeadgearInfo;
  5140.         public Database.ConquerItemBaseInformation NewLookWeapon;
  5141.         public Database.ConquerItemBaseInformation NewLookWeapon2;  
  5142.  
  5143.         public Time32 LastAttack, LastMove;
  5144.  
  5145.         public bool LoggedIn;
  5146.         public KillTournament SelectionKillTournament;
  5147.         public Challenge Challenge;
  5148.         public int ChallengeScore;
  5149.         public bool ChallangeScoreStamp;
  5150.         public ElitePK.FighterStats ElitePKStats;
  5151.         public ElitePK.Match ElitePKMatch, WatchingElitePKMatch;
  5152.         public bool SignedUpForEPK;
  5153.         public bool FakeLoaded;
  5154.         public Time32 FakeQuit;
  5155.         public ChampionStatistic ChampionStats;
  5156.         public Time32 CTFUpdateStamp;
  5157.         public string QAnswer;
  5158.         public bool ExpectingQAnswer;
  5159.         public Action<GameState> QCorrect;
  5160.         public Action<GameState> QWrong;
  5161.         public bool VerifiedChallenge;
  5162.         public int VerifyChallengeCount;
  5163.         public bool AllowedTreasurePoints;
  5164.         public int AllowedTreasurePointsIndex;
  5165.         public DynamicVariable this[string variable]
  5166.         {
  5167.             get { return Variables[variable]; }
  5168.             set { Variables[variable] = value; }
  5169.         }
  5170.         public bool IsWatching()
  5171.         {
  5172.             return WatchingGroup != null || TeamWatchingGroup != null;
  5173.         }
  5174.         public bool InQualifier()
  5175.         {
  5176.             bool inteam = false;
  5177.             if (Team != null)
  5178.             {
  5179.                 if (Team.EliteFighterStats != null)
  5180.                     inteam = true;
  5181.             }
  5182.             return QualifierGroup != null || TeamQualifierGroup != null || LobbyGroup != null || inteam;
  5183.         }
  5184.         public bool InArenaQualifier()
  5185.         {
  5186.             return QualifierGroup != null;
  5187.         }
  5188.         public bool InTeamQualifier()
  5189.         {
  5190.             bool inteam = false;
  5191.             if (Team != null)
  5192.             {
  5193.                 if (Team.EliteMatch != null)
  5194.                     if (Team.EliteMatch.Map != null)
  5195.                         if (Team.EliteMatch.Map.ID == Entity.MapID)
  5196.                             inteam = true;
  5197.             }
  5198.             return TeamQualifierGroup != null || inteam;
  5199.         }
  5200.         public Time32 ImportTime()
  5201.         {
  5202.             if (QualifierGroup != null)
  5203.                 return QualifierGroup.CreateTime;
  5204.             else if (TeamQualifierGroup != null)
  5205.                 return TeamQualifierGroup.ImportTime;
  5206.             else if (LobbyGroup != null)
  5207.                 return LobbyGroup.ImportTime;
  5208.             if (Team != null)
  5209.             {
  5210.                 if (Team.EliteMatch != null)
  5211.                     return Team.EliteMatch.ImportTime;
  5212.             }
  5213.             return Time32.Now;
  5214.         }
  5215.         public void UpdateQualifier(long damage, bool toxicfog = false)
  5216.         {
  5217.             if (LobbyGroup != null)
  5218.             {
  5219.                 LobbyGroup.UpdateDamage(LobbyGroup.OppositeClient(this), (uint)damage);
  5220.             }
  5221.             else if (ChampionGroup != null)
  5222.             {
  5223.                 ChampionGroup.UpdateDamage(ChampionGroup.OppositeClient(this), (uint)damage);
  5224.             }          
  5225.             else if (QualifierGroup != null)
  5226.                 QualifierGroup.UpdateDamage(QualifierGroup.OppositeClient(this), (uint)damage);
  5227.             else if (TeamQualifierGroup != null)
  5228.                 TeamQualifierGroup.UpdateDamage(TeamQualifierGroup.OppositeClient(this), (uint)damage, true);
  5229.             else if (toxicfog)
  5230.             {  
  5231.                if (ElitePKMatch != null)
  5232.                {
  5233.                    var opponent = ElitePKMatch.targetOf(this);
  5234.                    if (opponent != null)
  5235.                        opponent.ElitePKStats.Points += (uint)damage;
  5236.                    ElitePKMatch.Update();
  5237.                }
  5238.                else if (Team != null)
  5239.                {
  5240.                    if (Team.EliteMatch != null)
  5241.                    {
  5242.                        var opponent = Team.EliteMatch.targetOfWin(this.Team);
  5243.                        if (opponent != null)
  5244.                        {
  5245.                            opponent.Points += (uint)damage;
  5246.                            opponent.Team.SendMesageTeam(opponent.Team.EliteMatch.CreateUpdate().ToArray(), 0);
  5247.                        }
  5248.                        Team.SendMesageTeam(Team.EliteMatch.CreateUpdate().ToArray(), 0);
  5249.                    }
  5250.                }
  5251.             }
  5252.         }
  5253.         public uint CurrentHonor
  5254.         {
  5255.             get
  5256.             {
  5257.                 if (ArenaStatistic == null) return 0;
  5258.                 return ArenaStatistic.CurrentHonor;
  5259.             }
  5260.             set
  5261.             {
  5262.                 if (ArenaStatistic == null) return;
  5263.                 if (TeamArenaStatistic == null) return;
  5264.                 ArenaStatistic.CurrentHonor =
  5265.                     TeamArenaStatistic.CurrentHonor =
  5266.                     value;
  5267.             }
  5268.         }
  5269.         public uint HistoryHonor
  5270.         {
  5271.             get
  5272.             {
  5273.                 return ArenaStatistic.HistoryHonor;
  5274.             }
  5275.             set
  5276.             {
  5277.                 if (ArenaStatistic == null) return;
  5278.                 if (TeamArenaStatistic == null) return;
  5279.                 ArenaStatistic.HistoryHonor =
  5280.                     TeamArenaStatistic.HistoryHonor =
  5281.                     value;
  5282.             }
  5283.         }
  5284.         public uint RacePoints
  5285.         {
  5286.             get { return this["racepoints"]; }
  5287.             set
  5288.             {
  5289.                 this["racepoints"] = value;
  5290.                 Entity.Update(Update.RaceShopPoints, value, false);
  5291.             }
  5292.         }
  5293.         internal void EndQualifier()
  5294.         {
  5295.             if (LobbyGroup != null)
  5296.                 LobbyGroup.End(this);
  5297.  
  5298.             if (ChampionGroup != null)
  5299.                 ChampionGroup.End(this);
  5300.  
  5301.             if (QualifierGroup != null)
  5302.                 QualifierGroup.End(this);
  5303.  
  5304.             if (TeamQualifierGroup != null)
  5305.                 TeamQualifierGroup.CheckEnd(this);
  5306.             if (Entity.CLanArenaBattle != null)
  5307.                 Entity.CLanArenaBattle.CheakToEnd(this);
  5308.             if (Entity.GuildArenaBattle != null)
  5309.                 Entity.GuildArenaBattle.CheakToEnd(this);
  5310.         }
  5311.  
  5312.         internal void Send(string msg, uint type = Message.Talk)
  5313.         {
  5314.             Send(new Message(msg, type));
  5315.         }
  5316.  
  5317.         public string GenerateCaptcha(int len)
  5318.         {
  5319.             string str = "";
  5320.             while (len-- > 0)
  5321.             {
  5322.                 string type = str += (char)Kernel.Random.Next('0', '9');
  5323.                 /*int type = Kernel.Random.Next(0, 3);
  5324.                 if (type == 0) str += (char)Kernel.Random.Next('0', '9');
  5325.                 else if (type == 1) str += (char)Kernel.Random.Next('a', 'z');
  5326.                 else str += (char)Kernel.Random.Next('A', 'Z');*/
  5327.             }
  5328.             return str;
  5329.         }
  5330.  
  5331.         public void MessageBox(string text, Action<GameState> msg_ok = null, Action<GameState> msg_cancel = null, uint time = 0, Game.Languages language = Game.Languages.English)
  5332.         {
  5333.             if (InQualifier() || (Challenge != null && Challenge.Inside))
  5334.                 return;
  5335.             if (language != Language)
  5336.                 return;
  5337.             MessageOK = msg_ok;
  5338.             MessageCancel = msg_cancel;
  5339.             NpcReply msg = new NpcReply(NpcReply.MessageBox, text);
  5340.             Send(msg);
  5341.             if (time != 0)
  5342.                 Time(time);
  5343.         }
  5344.  
  5345.         public void Time(uint time)
  5346.         {
  5347.             Send(new Data(true) { UID = Entity.UID, dwParam = time, ID = Data.CountDown });
  5348.         }
  5349.  
  5350.         public bool Online
  5351.         {
  5352.             get
  5353.             {
  5354.                 return Socket.Connector != null;
  5355.             }
  5356.         }
  5357.  
  5358.         internal void LoadData(bool loadFake = false)
  5359.         {
  5360.         //    Database.KissSystemTable.Kisses(this);
  5361.             Database.PkExpelTable.Load(this);
  5362.             Database.ConquerItemTable.LoadItems(this);
  5363.         //    Database.FlowerSystemTable.Flowers(this);
  5364.            
  5365.             if (!loadFake)
  5366.             {
  5367.                 Database.ClaimItemTable.LoadClaimableItems(this);
  5368.                 Database.DetainedItemTable.LoadDetainedItems(this);
  5369.             }
  5370.             else
  5371.             {
  5372.                 ClaimableItem = new SafeDictionary<uint, DetainedItem>();
  5373.                 DeatinedItem = new SafeDictionary<uint, DetainedItem>();
  5374.             }          
  5375.             Database.SubClassTable.Load(this.Entity);
  5376.             if (!loadFake)
  5377.             {
  5378.                 using (var conn = Database.DataHolder.MySqlConnection)
  5379.                 {
  5380.                     conn.Open();
  5381.                     Database.SkillTable.LoadProficiencies(this, conn);
  5382.                     Database.SkillTable.LoadSpells(this, conn);
  5383.                 }
  5384.                 Database.KnownPersons.LoadPartner(this);
  5385.                 Database.KnownPersons.LoadEnemy(this);
  5386.                 Database.KnownPersons.LoaderFriends(this);
  5387.                 Database.KnownPersons.LoadMentor(this);
  5388.             }
  5389.             else
  5390.             {
  5391.                 Spells = new SafeDictionary<ushort, ISkill>();
  5392.                 Proficiencies = new SafeDictionary<ushort, IProf>();
  5393.                 Partners = new SafeDictionary<uint, Game.ConquerStructures.Society.TradePartner>();
  5394.                 Enemy = new SafeDictionary<uint, Game.ConquerStructures.Society.Enemy>();
  5395.                 Friends = new SafeDictionary<uint, Game.ConquerStructures.Society.Friend>();
  5396.                 Apprentices = new SafeDictionary<uint, Game.ConquerStructures.Society.Apprentice>();
  5397.             }
  5398.             Database.ChiTable.Load(this);
  5399.             MaTrix.Inbox.Load(this);
  5400.             MaTrix.Reward.Load(this);
  5401.             MaTrix.Hall_of_Fame.Load(this);
  5402.             Quests.Load();
  5403.             MaTrix.Way2Heroes.Load(this);
  5404.           //  Database.BigBOSRewardDataBase.LoadReward(this);
  5405.         }
  5406.  
  5407.         public void FakeLoad(uint UID, bool enterserver = true)
  5408.         {
  5409.             if (!Kernel.GamePool.ContainsKey(UID))
  5410.             {
  5411.                 ReadyToPlay();                
  5412.                 this.Account = new Database.AccountTable(null);
  5413.                 this.Account.EntityID = UID;
  5414.                 if (Database.EntityTable.LoadEntity(this))
  5415.                 {
  5416.                     if (this.Entity.FullyLoaded)
  5417.                     {
  5418.                         VariableVault variables;
  5419.                         Database.EntityVariableTable.Load(this.Entity.UID, out variables);
  5420.                         this.Variables = variables;
  5421.                                                
  5422.                         if (this.BackupArmorLook != 0)
  5423.                             this.SetNewArmorLook(this.BackupArmorLook);
  5424.                         else
  5425.                             this.SetNewArmorLook(this.ArmorLook);
  5426.                         this.SetNewHeadgearLook(this.HeadgearLook);
  5427.                         this.BackupArmorLook = 0;
  5428.  
  5429.                         this.LoadData(enterserver);
  5430.  
  5431.                         if (this.Entity.GuildID != 0)
  5432.                             this.Entity.GuildBattlePower = this.Guild.GetSharedBattlepower(this.Entity.GuildRank);
  5433.  
  5434.                         this.ReviewMentor();
  5435.  
  5436.                         Entity.NobilityRank = NobilityInformation.Rank;
  5437.  
  5438.                         if (enterserver)
  5439.                         {
  5440.                             Network.PacketHandler.LoginMessages(this);
  5441.  
  5442.                             Program.World.Register(this);
  5443.                             Kernel.GamePool.Add(Entity.UID, this);
  5444.                         }
  5445.                         FakeLoaded = true;
  5446.                        
  5447.                     }
  5448.                 }
  5449.             }
  5450.         }
  5451.         public void FakeLoad2(uint UID, string Name = "")
  5452.         {
  5453.             if (Name == "")
  5454.                 Name = "MaTrix[" + UID + "]";
  5455.             if (!Kernel.GamePool.ContainsKey(UID))
  5456.             {
  5457.                 this.ReadyToPlay();
  5458.                 this.Account = new Database.AccountTable(null);
  5459.                 this.Account.EntityID = UID;
  5460.                 this.Entity = new Entity(EntityFlag.Player, false);
  5461.                 this.Entity.Owner = this;
  5462.                 this.Entity.Name = Name;
  5463.                 this.Entity.UID = UID;
  5464.                 this.Entity.Vitality = 537;              
  5465.                 this.Entity.Face = 37;
  5466.                 this.Entity.Body = 1003;
  5467.                 this.Entity.HairStyle = 630;
  5468.                 this.Entity.Level = 140;
  5469.                 this.Entity.Class = 15;
  5470.                 this.Entity.Reborn = 2;
  5471.                 this.Entity.MaxHitpoints = 20000;
  5472.                 this.Entity.Hitpoints = this.Entity.MaxHitpoints;
  5473.                 this.Entity.Mana = 800;
  5474.                
  5475.                 this.Variables = new VariableVault();
  5476.                 this.Friends = new SafeDictionary<uint, Game.ConquerStructures.Society.Friend>();
  5477.                 this.Enemy = new SafeDictionary<uint, Game.ConquerStructures.Society.Enemy>();
  5478.                 this.ChiData = new ChiTable.ChiData();
  5479.                 this.ChiPowers = new List<ChiPowerStructure>();
  5480.              
  5481.  
  5482.                 this.NobilityInformation = new Conquer_Online_Server.Game.ConquerStructures.NobilityInformation();
  5483.                 this.NobilityInformation.EntityUID = this.Entity.UID;
  5484.                 this.NobilityInformation.Name = this.Entity.Name;
  5485.                 this.NobilityInformation.Donation = 0;
  5486.                 this.NobilityInformation.Rank = Game.ConquerStructures.NobilityRank.Serf;
  5487.                 this.NobilityInformation.Position = -1;
  5488.                 this.NobilityInformation.Gender = 1;
  5489.                 this.NobilityInformation.Mesh = this.Entity.Mesh;
  5490.                 if (this.Entity.Body % 10 >= 3)
  5491.                     this.NobilityInformation.Gender = 0;
  5492.  
  5493.                 this.TeamArenaStatistic = new Conquer_Online_Server.Network.GamePackets.TeamArenaStatistic(true);
  5494.                 this.TeamArenaStatistic.EntityID = this.Entity.UID;
  5495.                 this.TeamArenaStatistic.Name = this.Entity.Name;
  5496.                 this.TeamArenaStatistic.Level = this.Entity.Level;
  5497.                 this.TeamArenaStatistic.Class = this.Entity.Class;
  5498.                 this.TeamArenaStatistic.Model = this.Entity.Mesh;
  5499.                 this.TeamArenaStatistic.Status = Network.GamePackets.TeamArenaStatistic.NotSignedUp;
  5500.  
  5501.                 this.ArenaStatistic = new Conquer_Online_Server.Network.GamePackets.ArenaStatistic(true);
  5502.                 this.ArenaStatistic.EntityID = this.Entity.UID;
  5503.                 this.ArenaStatistic.Name = this.Entity.Name;
  5504.                 this.ArenaStatistic.Level = this.Entity.Level;
  5505.                 this.ArenaStatistic.Class = this.Entity.Class;
  5506.                 this.ArenaStatistic.Model = this.Entity.Mesh;
  5507.                 this.ArenaPoints = ArenaTable.ArenaPointFill(this.Entity.Level);
  5508.                 this.ArenaStatistic.LastArenaPointFill = DateTime.Now;
  5509.                 this.ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.NotSignedUp;
  5510.  
  5511.                 this.ChampionStats = new Conquer_Online_Server.Network.GamePackets.ChampionStatistic(true);
  5512.                 this.ChampionStats.UID = this.Entity.UID;
  5513.                 this.ChampionStats.Name = this.Entity.Name;
  5514.                 this.ChampionStats.Level = this.Entity.Level;
  5515.                 this.ChampionStats.Class = this.Entity.Class;
  5516.                 this.ChampionStats.Model = this.Entity.Mesh;
  5517.                 this.ChampionStats.Points = 0;
  5518.                 this.ChampionStats.LastReset = DateTime.Now;
  5519.                 this.ChiPowers = new List<ChiPowerStructure>();
  5520.                 this.Retretead_ChiPowers = new ChiPowerStructure[4];
  5521.                 this.ChiData = new ChiTable.ChiData() { Name = this.Entity.Name, UID = this.Entity.UID, Powers = this.ChiPowers };
  5522.                
  5523.                 this.Entity.Stamina = 150;
  5524.  
  5525.                 this.Spells = new SafeDictionary<ushort, Interfaces.ISkill>();
  5526.                 this.Proficiencies = new SafeDictionary<ushort, Interfaces.IProf>();
  5527.  
  5528.                 Network.PacketHandler.LoginMessages(this);
  5529.  
  5530.                 Program.World.Register(this);
  5531.                 Kernel.GamePool.Add(Entity.UID, this);
  5532.             }
  5533.         }
  5534.         public void Question(string question, uint answer)
  5535.         {
  5536.             Npcs dialog = new Npcs(this);
  5537.             ActiveNpc = 9999990;
  5538.             QAnswer = answer.ToString();
  5539.             ExpectingQAnswer = true;
  5540.             dialog.Text(question);
  5541.             dialog.Input("Answer:", 1, (byte)QAnswer.Length);
  5542.             dialog.Option("No thank you.", 255);
  5543.             dialog.Send();
  5544.         }
  5545.  
  5546.         public void FakeLoadx(uint UID)
  5547.         {
  5548.             if (!Kernel.GamePool.ContainsKey(UID))
  5549.             {
  5550.                 ReadyToPlay();
  5551.                 this.Account = new Database.AccountTable(null);
  5552.                 this.Account.EntityID = UID;
  5553.                 //   if (Database.EntityTable.LoadEntity(this))
  5554.                 {
  5555.                     #region Load Entity
  5556.                     Conquer_Online_Server.Database.MySqlCommand command = new Conquer_Online_Server.Database.MySqlCommand(MySqlCommandType.SELECT);
  5557.                     command.Select("bots").Where("BotID", (long)UID);
  5558.                     MySqlReader reader = new MySqlReader(command);
  5559.                     if (!reader.Read())
  5560.                     {
  5561.                         return;
  5562.                     }
  5563.                     this.Entity = new Conquer_Online_Server.Game.Entity(EntityFlag.Player, false);
  5564.                     this.Entity.Name = reader.ReadString("BotName");
  5565.                     this.Entity.Owner = this;
  5566.                     this.Entity.UID = UID;
  5567.                     this.Entity.Body = reader.ReadUInt16("BotBody");
  5568.                     this.Entity.Face = reader.ReadUInt16("BotFace");
  5569.                     this.Entity.HairStyle = reader.ReadUInt16("BotHairStyle");
  5570.                     this.Entity.Level = reader.ReadByte("BotLevel");
  5571.                     this.Entity.Class = reader.ReadByte("BotClass");
  5572.                     this.Entity.Reborn = reader.ReadByte("BotReborns");
  5573.                     this.Entity.Titles = new System.Collections.Concurrent.ConcurrentDictionary<TitlePacket.Titles, DateTime>();
  5574.                     this.Entity.MyTitle = (TitlePacket.Titles)reader.ReadUInt32("BotTitle");
  5575.                     this.Entity.MapID = reader.ReadUInt16("BotMap");
  5576.                     if (this.VendingDisguise == 0)
  5577.                         this.VendingDisguise = 0xdf;
  5578.                     this.Entity.X = reader.ReadUInt16("BotMapx");
  5579.                     this.Entity.Y = reader.ReadUInt16("BotMapy");
  5580.                     uint WeaponR = reader.ReadUInt32("BotWeaponR");
  5581.                     uint WeaponL = reader.ReadUInt32("BotWeaponL");
  5582.                     uint Armor = reader.ReadUInt32("BotArmor");
  5583.                     uint Head = reader.ReadUInt32("BotHead");
  5584.                     uint Garment = reader.ReadUInt32("BotGarment");
  5585.                    
  5586.                     string hawkmessage = reader.ReadString("BotMessage");
  5587.                     Entity.MyAchievement = new Game.Achievement(Entity);
  5588.  
  5589.                     int count = reader.ReadInt32("BItemCount");
  5590.                     string[] itemCost = reader.ReadString("BItemCost").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  5591.                     string[] itemID = reader.ReadString("BItemID").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  5592.                     string[] itemPlus = reader.ReadString("BItemPlus").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  5593.                     string[] itemEnchant = reader.ReadString("BItemEnchant").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  5594.                     string[] itemBless = reader.ReadString("BItemBless").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  5595.                     string[] itemSocketOne = reader.ReadString("BItemSoc1").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  5596.                     string[] itemSocketTwo = reader.ReadString("BItemSoc2").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  5597.  
  5598.                     this.ElitePKStats = new ElitePK.FighterStats(this.Entity.UID, this.Entity.Name, this.Entity.Mesh);
  5599.                     if (!Conquer_Online_Server.Game.ConquerStructures.Nobility.Board.TryGetValue(this.Entity.UID, out this.NobilityInformation))
  5600.                     {
  5601.                         this.NobilityInformation = new NobilityInformation();
  5602.                         this.NobilityInformation.EntityUID = this.Entity.UID;
  5603.                         this.NobilityInformation.Name = this.Entity.Name;
  5604.                         this.NobilityInformation.Donation = 0L;
  5605.                         this.NobilityInformation.Rank = NobilityRank.Serf;
  5606.                         this.NobilityInformation.Position = -1;
  5607.                         this.NobilityInformation.Gender = 1;
  5608.                         this.NobilityInformation.Mesh = this.Entity.Mesh;
  5609.                         if ((this.Entity.Body % 10) >= 3)
  5610.                         {
  5611.                             this.NobilityInformation.Gender = 0;
  5612.                         }
  5613.                     }
  5614.                     else
  5615.                     {
  5616.                         this.Entity.NobilityRank = this.NobilityInformation.Rank;
  5617.                     }
  5618.                     Arena.ArenaStatistics.TryGetValue(this.Entity.UID, out this.ArenaStatistic);
  5619.                     if ((this.ArenaStatistic == null) || (this.ArenaStatistic.EntityID == 0))
  5620.                     {
  5621.                         this.ArenaStatistic = new ArenaStatistic(true);
  5622.                         this.ArenaStatistic.EntityID = this.Entity.UID;
  5623.                         this.ArenaStatistic.Name = this.Entity.Name;
  5624.                         this.ArenaStatistic.Level = this.Entity.Level;
  5625.                         this.ArenaStatistic.Class = this.Entity.Class;
  5626.                         this.ArenaStatistic.Model = this.Entity.Mesh;
  5627.                         this.ArenaStatistic.ArenaPoints = ArenaTable.ArenaPointFill(this.Entity.Level);
  5628.                         this.ArenaStatistic.LastArenaPointFill = DateTime.Now;
  5629.                         ArenaTable.InsertArenaStatistic(this);
  5630.                         this.ArenaStatistic.Status = 0;
  5631.                         Arena.ArenaStatistics.Add(this.Entity.UID, this.ArenaStatistic);
  5632.                     }
  5633.                     else
  5634.                     {
  5635.                         this.ArenaStatistic.Level = this.Entity.Level;
  5636.                         this.ArenaStatistic.Class = this.Entity.Class;
  5637.                         this.ArenaStatistic.Model = this.Entity.Mesh;
  5638.                         if (DateTime.Now.DayOfYear != this.ArenaStatistic.LastArenaPointFill.DayOfYear)
  5639.                         {
  5640.                             this.ArenaStatistic.LastSeasonArenaPoints = this.ArenaStatistic.ArenaPoints;
  5641.                             this.ArenaStatistic.LastSeasonWin = this.ArenaStatistic.TodayWin;
  5642.                             this.ArenaStatistic.LastSeasonLose = this.ArenaStatistic.TodayBattles - this.ArenaStatistic.TodayWin;
  5643.                             this.ArenaStatistic.ArenaPoints = ArenaTable.ArenaPointFill(this.Entity.Level);
  5644.                             this.ArenaStatistic.LastArenaPointFill = DateTime.Now;
  5645.                             this.ArenaStatistic.TodayWin = 0;
  5646.                             this.ArenaStatistic.TodayBattles = 0;
  5647.                             Arena.Sort();
  5648.                             Arena.YesterdaySort();
  5649.                         }
  5650.                     }
  5651.                     TeamArena.ArenaStatistics.TryGetValue(this.Entity.UID, out this.TeamArenaStatistic);
  5652.                     if (this.TeamArenaStatistic == null)
  5653.                     {
  5654.                         this.TeamArenaStatistic = new TeamArenaStatistic(true);
  5655.                         this.TeamArenaStatistic.EntityID = this.Entity.UID;
  5656.                         this.TeamArenaStatistic.Name = this.Entity.Name;
  5657.                         this.TeamArenaStatistic.Level = this.Entity.Level;
  5658.                         this.TeamArenaStatistic.Class = this.Entity.Class;
  5659.                         this.TeamArenaStatistic.Model = this.Entity.Mesh;
  5660.                         TeamArenaTable.InsertArenaStatistic(this);
  5661.                         this.TeamArenaStatistic.Status = 0;
  5662.                         if (TeamArena.ArenaStatistics.ContainsKey(this.Entity.UID))
  5663.                         {
  5664.                             TeamArena.ArenaStatistics.Remove(this.Entity.UID);
  5665.                         }
  5666.                         TeamArena.ArenaStatistics.Add(this.Entity.UID, this.TeamArenaStatistic);
  5667.                     }
  5668.                     else if (this.TeamArenaStatistic.EntityID == 0)
  5669.                     {
  5670.                         this.TeamArenaStatistic = new TeamArenaStatistic(true);
  5671.                         this.TeamArenaStatistic.EntityID = this.Entity.UID;
  5672.                         this.TeamArenaStatistic.Name = this.Entity.Name;
  5673.                         this.TeamArenaStatistic.Level = this.Entity.Level;
  5674.                         this.TeamArenaStatistic.Class = this.Entity.Class;
  5675.                         this.TeamArenaStatistic.Model = this.Entity.Mesh;
  5676.                         TeamArenaTable.InsertArenaStatistic(this);
  5677.                         this.TeamArenaStatistic.Status = 0;
  5678.                         if (TeamArena.ArenaStatistics.ContainsKey(this.Entity.UID))
  5679.                         {
  5680.                             TeamArena.ArenaStatistics.Remove(this.Entity.UID);
  5681.                         }
  5682.                         TeamArena.ArenaStatistics.Add(this.Entity.UID, this.TeamArenaStatistic);
  5683.                     }
  5684.                     else
  5685.                     {
  5686.                         this.TeamArenaStatistic.Level = this.Entity.Level;
  5687.                         this.TeamArenaStatistic.Class = this.Entity.Class;
  5688.                         this.TeamArenaStatistic.Model = this.Entity.Mesh;
  5689.                         this.TeamArenaStatistic.Name = this.Entity.Name;
  5690.                     }
  5691.                     #region Champion
  5692.                     Game.Champion.ChampionStats.TryGetValue(this.Entity.UID, out this.ChampionStats);
  5693.                     if (this.ChampionStats == null)
  5694.                     {
  5695.                         this.ChampionStats = new Conquer_Online_Server.Network.GamePackets.ChampionStatistic(true);
  5696.                         this.ChampionStats.UID = this.Entity.UID;
  5697.                         this.ChampionStats.Name = this.Entity.Name;
  5698.                         this.ChampionStats.Level = this.Entity.Level;
  5699.                         this.ChampionStats.Class = this.Entity.Class;
  5700.                         this.ChampionStats.Model = this.Entity.Mesh;
  5701.                         this.ChampionStats.Points = 0;
  5702.                         this.ChampionStats.LastReset = DateTime.Now;
  5703.                         ChampionTable.InsertStatistic(this);
  5704.                         if (Game.Champion.ChampionStats.ContainsKey(this.Entity.UID))
  5705.                             Game.Champion.ChampionStats.Remove(this.Entity.UID);
  5706.                         Game.Champion.ChampionStats.Add(this.Entity.UID, this.ChampionStats);
  5707.                     }
  5708.                     else if (this.ChampionStats.UID == 0)
  5709.                     {
  5710.                         this.ChampionStats = new Network.GamePackets.ChampionStatistic(true);
  5711.                         this.ChampionStats.UID = this.Entity.UID;
  5712.                         this.ChampionStats.Name = this.Entity.Name;
  5713.                         this.ChampionStats.Level = this.Entity.Level;
  5714.                         this.ChampionStats.Class = this.Entity.Class;
  5715.                         this.ChampionStats.Model = this.Entity.Mesh;
  5716.                         this.ChampionStats.Points = 0;
  5717.                         this.ChampionStats.LastReset = DateTime.Now;
  5718.                         ArenaTable.InsertArenaStatistic(this);
  5719.                         this.ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.NotSignedUp;
  5720.                         if (Game.Champion.ChampionStats.ContainsKey(this.Entity.UID))
  5721.                             Game.Champion.ChampionStats.Remove(this.Entity.UID);
  5722.                         Game.Champion.ChampionStats.Add(this.Entity.UID, this.ChampionStats);
  5723.                     }
  5724.                     else
  5725.                     {
  5726.                         this.ChampionStats.Level = this.Entity.Level;
  5727.                         this.ChampionStats.Class = this.Entity.Class;
  5728.                         this.ChampionStats.Model = this.Entity.Mesh;
  5729.                         this.ChampionStats.Name = this.Entity.Name;
  5730.                         if (this.ChampionStats.LastReset.DayOfYear != DateTime.Now.DayOfYear)
  5731.                             ChampionTable.Reset(this.ChampionStats);
  5732.                     }
  5733.                     Game.Champion.Clear(this);
  5734.                     #endregion
  5735.                     DetainedItemTable.LoadDetainedItems(this);
  5736.                     ClaimItemTable.LoadClaimableItems(this);
  5737.                     this.Entity.LoadTopStatus();
  5738.                     this.Entity.FullyLoaded = true;
  5739.  
  5740.                     #endregion
  5741.                     if (this.Entity.FullyLoaded)
  5742.                     {
  5743.                         VariableVault variables;
  5744.                         Database.EntityVariableTable.Load(this.Entity.UID, out variables);
  5745.                         this.Variables = variables;
  5746.  
  5747.                         if (this.BackupArmorLook != 0)
  5748.                             this.SetNewArmorLook(this.BackupArmorLook);
  5749.                         else
  5750.                             this.SetNewArmorLook(this.ArmorLook);
  5751.                         this.SetNewHeadgearLook(this.HeadgearLook);
  5752.                         this.BackupArmorLook = 0;
  5753.  
  5754.                         this.LoadData(true);
  5755.  
  5756.                         if (this.Entity.GuildID != 0)
  5757.                             this.Entity.GuildBattlePower = this.Guild.GetSharedBattlepower(this.Entity.GuildRank);
  5758.  
  5759.                         this.ReviewMentor();
  5760.  
  5761.  
  5762.  
  5763.                         Network.PacketHandler.LoginMessages(this);
  5764.  
  5765.                         #region Equip
  5766.  
  5767.                         ConquerItem item7 = null;
  5768.                         ClientEquip equip = null;
  5769.                         if (WeaponR > 0)
  5770.                         {
  5771.                             Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[WeaponR];
  5772.                             if (CIBI == null) return;
  5773.                             item7 = new ConquerItem(true);
  5774.                             item7.ID = WeaponR;
  5775.                             item7.UID = Program.NextItemID;
  5776.                             //Program.NextItemID++;
  5777.                             item7.Position = 4;
  5778.                             item7.Durability = CIBI.Durability;
  5779.                             item7.MaximDurability = CIBI.Durability;
  5780.                             this.Equipment.Remove(4);
  5781.                             if (this.Equipment.Objects[3] != null)
  5782.                             {
  5783.                                 this.Equipment.Objects[3] = null;
  5784.                             }
  5785.                             this.Equipment.Add(item7);
  5786.                             item7.Mode = Enums.ItemMode.Update;
  5787.                             item7.Send(this);
  5788.                             equip = new ClientEquip();
  5789.                             equip.DoEquips(this);
  5790.                             this.Send(equip);
  5791.                             this.Equipment.UpdateEntityPacket();
  5792.  
  5793.                         }
  5794.                         if (WeaponL > 0)
  5795.                         {
  5796.                             Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[WeaponL];
  5797.                             if (CIBI == null) return;
  5798.                             item7 = new ConquerItem(true);
  5799.                             item7.ID = WeaponL;
  5800.                             item7.UID = Program.NextItemID;
  5801.                             //Program.NextItemID++;
  5802.                             item7.Position = 5;
  5803.                             item7.Durability = CIBI.Durability;
  5804.                             item7.MaximDurability = CIBI.Durability;
  5805.                             this.Equipment.Remove(5);
  5806.                             if (this.Equipment.Objects[4] != null)
  5807.                             {
  5808.                                 this.Equipment.Objects[4] = null;
  5809.                             }
  5810.                             this.Equipment.Add(item7);
  5811.                             item7.Mode = Enums.ItemMode.Update;
  5812.                             item7.Send(this);
  5813.                             equip = new ClientEquip();
  5814.                             equip.DoEquips(this);
  5815.                             this.Send(equip);
  5816.                             this.Equipment.UpdateEntityPacket();
  5817.                         }
  5818.  
  5819.                         if (Armor > 0)
  5820.                         {
  5821.                             Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[Armor];
  5822.                             if (CIBI == null) return;
  5823.                             item7 = new ConquerItem(true);
  5824.                             item7.ID = Armor;
  5825.                             item7.UID = Program.NextItemID;
  5826.                             //Program.NextItemID++;
  5827.                             item7.Position = 3;
  5828.                             item7.Durability = CIBI.Durability;
  5829.                             item7.MaximDurability = CIBI.Durability;
  5830.                             this.Equipment.Remove(3);
  5831.                             if (this.Equipment.Objects[2] != null)
  5832.                             {
  5833.                                 this.Equipment.Objects[2] = null;
  5834.                             }
  5835.                             this.Equipment.Add(item7);
  5836.                             item7.Mode = Enums.ItemMode.Update;
  5837.                             item7.Send(this);
  5838.                             equip = new ClientEquip();
  5839.                             equip.DoEquips(this);
  5840.                             this.Send(equip);
  5841.                             this.Equipment.UpdateEntityPacket();
  5842.  
  5843.                         }
  5844.  
  5845.                         if (Head > 0)
  5846.                         {
  5847.                             Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[Head];
  5848.                             if (CIBI == null) return;
  5849.                             item7 = new ConquerItem(true);
  5850.                             item7.ID = Head;
  5851.                             item7.UID = Program.NextItemID;
  5852.                             //Program.NextItemID++;
  5853.                             item7.Position = 1;
  5854.                             item7.Durability = CIBI.Durability;
  5855.                             item7.MaximDurability = CIBI.Durability;
  5856.                             this.Equipment.Remove(1);
  5857.                             if (this.Equipment.Objects[0] != null)
  5858.                             {
  5859.                                 this.Equipment.Objects[0] = null;
  5860.                             }
  5861.                             this.Equipment.Add(item7);
  5862.                             item7.Mode = Enums.ItemMode.Update;
  5863.                             item7.Send(this);
  5864.                             equip = new ClientEquip();
  5865.                             equip.DoEquips(this);
  5866.                             this.Send(equip);
  5867.                             this.Equipment.UpdateEntityPacket();
  5868.  
  5869.                         }
  5870.  
  5871.                         if (Garment > 0)
  5872.                         {
  5873.                             Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[Garment];
  5874.                             if (CIBI == null) return;
  5875.                             item7 = new ConquerItem(true);
  5876.                             item7.ID = Garment;
  5877.                             item7.UID = Program.NextItemID;
  5878.                             //Program.NextItemID++;
  5879.                             item7.Position = 9;
  5880.                             item7.Durability = CIBI.Durability;
  5881.                             item7.MaximDurability = CIBI.Durability;
  5882.                             this.Equipment.Remove(9);
  5883.                             if (this.Equipment.Objects[8] != null)
  5884.                             {
  5885.                                 this.Equipment.Objects[8] = null;
  5886.                             }
  5887.                             this.Equipment.Add(item7);
  5888.                             item7.Mode = Enums.ItemMode.Update;
  5889.                             item7.Send(this);
  5890.                             equip = new ClientEquip();
  5891.                             equip.DoEquips(this);
  5892.                             this.Send(equip);
  5893.                             this.Equipment.UpdateEntityPacket();
  5894.                         }
  5895.  
  5896.                         #endregion Equip
  5897.  
  5898.  
  5899.                         Program.World.Register(this);
  5900.                         Kernel.GamePool.Add(Entity.UID, this);
  5901.                         FakeLoaded = true;
  5902.                         LoggedIn = true;
  5903.                         Entity.NobilityRank = NobilityInformation.Rank;                      
  5904.                         {
  5905.                             if (this.FakeLoaded)
  5906.                             {
  5907.                                 #region booth
  5908.  
  5909.                                 if (this.Booth == null)
  5910.                                 {
  5911.                                     this.Send(new MapStatus() { BaseID = this.Map.BaseID, ID = this.Map.ID, Status = Database.MapsTable.MapInformations[1036].Status });
  5912.                                     this.Booth = new Game.ConquerStructures.Booth(this, new Data(true) { UID = this.Entity.UID });
  5913.                                     this.Send(new Data(true) { ID = Data.ChangeAction, UID = this.Entity.UID, dwParam = 0 });
  5914.                                     #region new multi items
  5915.                                     try
  5916.                                     {
  5917.                                         for (uint i = 0; i < count; i++)
  5918.                                         {
  5919.                                             for (int ii = 0; ii < itemID.Length; ii++)
  5920.                                             {                                                
  5921.                                                 Game.ConquerStructures.BoothItem item = new Game.ConquerStructures.BoothItem();
  5922.                                                 if (itemCost[ii] != null)
  5923.                                                     item.Cost = uint.Parse(itemCost[ii]);
  5924.                                                 item.Item = new ConquerItem(true);
  5925.                                                 if (itemID[ii] != null)
  5926.                                                     item.Item.ID = uint.Parse(itemID[ii]);
  5927.                                                 item.Item.UID = Program.NextItemID;
  5928.                                                 //Program.NextItemID++;
  5929.                                                 if (itemPlus[ii] != null)
  5930.                                                     item.Item.Plus = byte.Parse(itemPlus[ii]);
  5931.                                                 if (itemEnchant[ii] != null)
  5932.                                                     item.Item.Enchant = byte.Parse(itemEnchant[ii]);
  5933.                                                 if (itemBless[ii] != null)
  5934.                                                     item.Item.Bless = byte.Parse(itemBless[ii]);
  5935.                                                 if (itemSocketOne[ii] != null)
  5936.                                                     item.Item.SocketOne = (Enums.Gem)byte.Parse(itemSocketOne[ii]);
  5937.                                                 if (itemSocketTwo[ii] != null)
  5938.                                                     item.Item.SocketTwo = (Enums.Gem)byte.Parse(itemSocketTwo[ii]);
  5939.  
  5940.                                                 Database.ConquerItemBaseInformation CIBI = null;
  5941.                                                 CIBI = Database.ConquerItemInformation.BaseInformations[item.Item.ID];
  5942.                                                 if (CIBI == null)
  5943.                                                     return;
  5944.                                                 item.Item.Durability = CIBI.Durability;
  5945.                                                 item.Item.MaximDurability = CIBI.Durability;
  5946.                                                 //  this.Inventory.Add(item.Item, Game.Enums.ItemUse.CreateAndAdd);
  5947.                                                 item.Item.Send(this);
  5948.                                                 {
  5949.                                                     ItemUsage usage = new ItemUsage(true) { ID = ItemUsage.AddItemOnBoothForConquerPoints };
  5950.                                                     item.Cost_Type = Game.ConquerStructures.BoothItem.CostType.ConquerPoints;
  5951.                                                     this.Booth.ItemList.Add(item.Item.UID, item);
  5952.                                                     this.Send(usage);
  5953.                                                     Conquer_Online_Server.Network.GamePackets.BoothItem buffer = new Conquer_Online_Server.Network.GamePackets.BoothItem(true);
  5954.                                                     buffer.Fill(item, this.Booth.Base.UID);
  5955.                                                     this.SendScreen(buffer, false);
  5956.                                                 }                                                
  5957.                                             }
  5958.                                         }
  5959.                                        
  5960.                                     }
  5961.                                     catch
  5962.                                     {
  5963.                                         return;
  5964.                                     }
  5965.                                     #endregion
  5966.                                     this.Booth.HawkMessage = new Message(hawkmessage, "ALL", this.Entity.Name, System.Drawing.Color.White, Message.HawkMessage);
  5967.                                 }
  5968.                                 #endregion
  5969.                             }
  5970.                         }
  5971.  
  5972.                     }
  5973.  
  5974.                 }
  5975.             }
  5976.         }
  5977.         public static Dictionary<uint, GameState> BoothingAI = new Dictionary<uint, GameState>();
  5978.         public bool Effect2;
  5979.         public int PKPoints;
  5980.         public int KillerPoints;
  5981.         public static void LoadBoothingAI()
  5982.         {
  5983.             //    Program.NextItemID = ConquerItem.ItemUID.Now - 500000;
  5984.             Database.MySqlCommand Cmd = new Database.MySqlCommand(MySqlCommandType.SELECT);
  5985.             Cmd.Select("bots");
  5986.             MySqlReader Reader = new MySqlReader(Cmd);
  5987.             while (Reader.Read())
  5988.             {
  5989.                 var ID = Reader.ReadUInt32("BotID");
  5990.                 if (ID < 70000000)
  5991.                     ID = (uint)Kernel.Random.Next(70000000, 999999999);
  5992.                 var fClient = new GameState(null);
  5993.                 fClient.FakeLoadx(ID);
  5994.                 BoothingAI.Add(ID, fClient);
  5995.  
  5996.             }
  5997.             //  Reader.Close();
  5998.             //  Reader.Dispose();
  5999.             Conquer_Online_Server.Console.WriteLine("" + BoothingAI.Count + " BoothingAI Loaded.");
  6000.         }
  6001.         public static void Load_New_Booths()
  6002.         {            
  6003.             Database.MySqlCommand Cmd = new Database.MySqlCommand(MySqlCommandType.SELECT);
  6004.             Cmd.Select("booths");
  6005.             MySqlReader Reader = new MySqlReader(Cmd);
  6006.             while (Reader.Read())
  6007.             {
  6008.                 var ID = Reader.ReadUInt32("BotID");
  6009.                 var Name = Reader.ReadString("BotName");
  6010.                 var Map = Reader.ReadUInt16("BotMap");
  6011.                 var X = Reader.ReadUInt16("BotMapx");
  6012.                 var Y = Reader.ReadUInt16("BotMapy");                
  6013.                 var itemz = Reader.ReadString("BItemID").Split(new string[] { "~","@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  6014.                 var costz = Reader.ReadString("BItemCost").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  6015.                 var plusz = Reader.ReadString("BItemPlus").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  6016.                 var blessz = Reader.ReadString("BItemBless").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  6017.                 var hpz = Reader.ReadString("BItemEnchant").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  6018.                 var soc1z = Reader.ReadString("BItemSoc1").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  6019.                 var soc2z = Reader.ReadString("BItemSoc2").Split(new string[] { "~", "@@", " " }, StringSplitOptions.RemoveEmptyEntries);
  6020.                 Game.ConquerStructures.Booth booth = new Game.ConquerStructures.Booth();
  6021.                 SobNpcSpawn Base = new SobNpcSpawn();
  6022.                 Base.UID = ID;
  6023.                 if (Booth.Booths2.ContainsKey(Base.UID))
  6024.                     Booth.Booths2.Remove(Base.UID);
  6025.                 Booth.Booths2.Add(Base.UID, booth);
  6026.                 Base.Mesh = 100;
  6027.                 Base.Type = Game.Enums.NpcType.Booth;
  6028.                 Base.ShowName = true;
  6029.                 Base.Name = "matrix™[" + Base.UID.ToString() + "]";
  6030.                 Base.MapID = Map;
  6031.                 Base.X = X;
  6032.                 Base.Y = Y;
  6033.                 if (Kernel.Maps[Map].Npcs.ContainsKey(Base.UID))
  6034.                     Kernel.Maps[Map].Npcs.Remove(Base.UID);
  6035.                 Kernel.Maps[Map].Npcs.Add(Base.UID, Base);
  6036.  
  6037.                 for (int i = 0; i < itemz.Length; i++)
  6038.                 {
  6039.                     #region booth
  6040.                     Game.ConquerStructures.BoothItem item = new Game.ConquerStructures.BoothItem();
  6041.                     if (costz.Length > i)
  6042.                         item.Cost = uint.Parse(costz[i]);
  6043.                     item.Item = new ConquerItem(true);                    
  6044.                     item.Item.ID = uint.Parse(itemz[i]);
  6045.                     item.Item.UID = Program.NextItemID;
  6046.                     //Program.NextItemID++;
  6047.                     if (plusz.Length > i)
  6048.                         item.Item.Plus = byte.Parse(plusz[i]);
  6049.                     if (hpz.Length > i)
  6050.                         item.Item.Enchant = byte.Parse(hpz[i]);
  6051.                     if (blessz.Length > i)
  6052.                         item.Item.Bless = byte.Parse(blessz[i]);
  6053.                     if (soc1z.Length > i)
  6054.                         item.Item.SocketOne = (Enums.Gem)byte.Parse(soc1z[i]);
  6055.                     if (soc2z.Length > i)
  6056.                         item.Item.SocketTwo = (Enums.Gem)byte.Parse(soc2z[i]);
  6057.                              
  6058.                     Database.ConquerItemBaseInformation CIBI = null;
  6059.                     CIBI = Database.ConquerItemInformation.BaseInformations[item.Item.ID];
  6060.                     if (CIBI == null)
  6061.                         break;
  6062.                     item.Item.Durability = CIBI.Durability;
  6063.                     item.Item.MaximDurability = CIBI.Durability;
  6064.                     item.Cost_Type = Game.ConquerStructures.BoothItem.CostType.ConquerPoints;
  6065.                     booth.ItemList.Add(item.Item.UID, item);
  6066.                     #endregion
  6067.                 }
  6068.                
  6069.  
  6070.             }
  6071.             Conquer_Online_Server.Console.WriteLine("" + Booth.Booths2.Count + " New Booths Loaded.");
  6072.         }
  6073.  
  6074.         public bool InArenaMatch { get; set; }
  6075.  
  6076.         public void CallDialog(Client.GameState client, NpcRequest option)
  6077.         {
  6078.             if (!World.ScriptEngine.Invoke(client.ActiveNpc, new object[] { client, option }))
  6079.             {
  6080.                 client.Send(new Message("NpcID[" + client.ActiveNpc + "]", System.Drawing.Color.Red, Message.TopLeft));
  6081.             }
  6082.         }
  6083.        
  6084.         public static bool IsVaildForTeamPk(GameState client)
  6085.         {
  6086.             if (client.Team != null)
  6087.             {
  6088.                 if (client.Team.EliteFighterStats != null)
  6089.                     if (client.Team.EliteFighterStats.Flag == Game.Features.Tournaments.TeamElitePk.FighterStats.StatusFlag.Fighting)
  6090.                         return true;
  6091.             }
  6092.             return false;
  6093.         }
  6094.         public bool CheckCommand(string _message)
  6095.         {
  6096.             Client.GameState client = this;          
  6097.             string message = _message.Replace("#60", "").Replace("#61", "").Replace("#62", "").Replace("#63", "").Replace("#64", "").Replace("#65", "").Replace("#66", "").Replace("#67", "").Replace("#68", "");
  6098.             try
  6099.             {
  6100.                 if (message.StartsWith("@"))
  6101.                 {
  6102.                     string message_ = message.Substring(1).ToLower();
  6103.                     string Mess = message.Substring(1);
  6104.                     string[] Data = message_.Split(' ');
  6105.                     Program.AddGMCommand(client.Entity.Name, "   " + client.Account.State.ToString() + "   @" + message_ + "    " + DateTime.Now.ToString());
  6106.                     #region GM && PM
  6107.                     if (Data[0] == "mob" || Data[0] == "effect")
  6108.                         Data = message.Substring(1).Split(' ');
  6109.                     switch (Data[0])
  6110.                     {    
  6111.                         case "xzero":
  6112.                             {
  6113.                                 byte[] tets = new byte[12 + 8];
  6114.                                 Writer.Ushort(12, 0, tets);
  6115.                                 Writer.Ushort(2710, 2, tets);
  6116.                                 Writer.Uint(uint.Parse(Data[1]), 4, tets);
  6117.                                 client.Send(tets);
  6118.                                 break;
  6119.                             }
  6120.                         case "a7aaura":
  6121.                             {
  6122.                                 Network.GamePackets.Update upgrade = new Network.GamePackets.Update(true);
  6123.                                 upgrade.UID = client.Entity.UID;
  6124.                                 upgrade.AppendFull(Update.StatusFlag, client.Entity.StatusFlag, client.Entity.StatusFlag2, client.Entity.StatusFlag3);
  6125.                                 upgrade.Append(uint.Parse(Data[1]), uint.Parse(Data[2]), 3, uint.Parse(Data[3]), 0);
  6126.                                 client.Send(upgrade.ToArray());
  6127.                                 break;
  6128.                             }                        
  6129.                         case "xfloor":
  6130.                             {
  6131.                                 FloorItem floorItem = new FloorItem(true);
  6132.                                 floorItem.ItemID = uint.Parse(Data[1]);
  6133.                                 floorItem.MapID = client.Entity.MapID;
  6134.                                 floorItem.Type = FloorItem.Effect;
  6135.                                 floorItem.X = (ushort)Kernel.Random.Next(client.Entity.X - 5, client.Entity.X + 5);
  6136.                                 floorItem.Y = (ushort)Kernel.Random.Next(client.Entity.Y - 5, client.Entity.Y + 5);
  6137.                                 floorItem.OnFloor = Time32.Now;
  6138.                                 floorItem.Owner = client;
  6139.                                 floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
  6140.                                 while (map.FloorItems.ContainsKey(floorItem.UID))
  6141.                                     floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
  6142.                                
  6143.                                 floorItem.MaxLife = 25;
  6144.                                 floorItem.Life = 25;
  6145.                                 floorItem.mColor = 13;
  6146.                                 floorItem.OwnerUID = client.Entity.UID;
  6147.                                 floorItem.OwnerGuildUID = client.Entity.GuildID;
  6148.                                 floorItem.FlowerType = byte.Parse(Data[2]);
  6149.                                 floorItem.Timer = Kernel.TqTimer(DateTime.Now.AddSeconds(7));
  6150.                                 floorItem.Name = "AuroraLotus";
  6151.                                 map.AddFloorItem(floorItem);
  6152.                                 client.SendScreenSpawn(floorItem, true);
  6153.                                 break;
  6154.                             }
  6155.                         case "floor":
  6156.                             {
  6157.                                 var id = ++client.testxx;
  6158.                                 for (int i = 0; i < 5; i++)
  6159.                                 {
  6160.                                     FloorItem floorItem = new FloorItem(true);
  6161.                                     //  floorItem.ItemID = FloorItem.DaggerStorm;
  6162.                                     floorItem.ItemID = id;
  6163.                                     floorItem.MapID = client.Entity.MapID;
  6164.                                     floorItem.ItemColor = (Enums.Color)i;
  6165.                                     floorItem.Type = FloorItem.Effect;
  6166.                                     floorItem.X = (ushort)Kernel.Random.Next(client.Entity.X - 5, client.Entity.X + 5);
  6167.                                     floorItem.Y = (ushort)Kernel.Random.Next(client.Entity.Y - 5, client.Entity.Y + 5);
  6168.                                     floorItem.OnFloor = Time32.Now;
  6169.                                     floorItem.Owner = client;
  6170.                                     while (map.Npcs.ContainsKey(floorItem.UID))
  6171.                                         floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
  6172.                                     map.AddFloorItem(floorItem);
  6173.                                     client.SendScreenSpawn(floorItem, true);
  6174.                                 }
  6175.                                 client.Send(new Message(client.testxx.ToString(), Message.Tip));
  6176.                                 break;
  6177.                             }
  6178.                         case "floor2":
  6179.                             {
  6180.                                 FloorItem floorItem = new FloorItem(true);
  6181.                                 //  floorItem.ItemID = FloorItem.DaggerStorm;
  6182.                                 floorItem.ItemID = uint.Parse(Data[1]);
  6183.                                 floorItem.MapID = client.Entity.MapID;
  6184.                                 floorItem.ItemColor = Enums.Color.Black;
  6185.                                 floorItem.Type = FloorItem.Effect;
  6186.                                 floorItem.X = client.Entity.X;
  6187.                                 floorItem.Y = client.Entity.Y;
  6188.                                 floorItem.OnFloor = Time32.Now;
  6189.                                 floorItem.Owner = client;
  6190.                                 while (map.Npcs.ContainsKey(floorItem.UID))
  6191.                                     floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
  6192.                                 map.AddFloorItem(floorItem);
  6193.                                 client.SendScreenSpawn(floorItem, true);
  6194.                                 break;
  6195.                             }
  6196.                         case "matrixjiang":
  6197.                             {
  6198.                                 if (client.Entity.MyJiang != null)
  6199.                                 {
  6200.                                     byte stageno = (byte)Math.Min(9, int.Parse(Data[1]));
  6201.                                     byte level = (byte)Math.Min(6, int.Parse(Data[2]));
  6202.                                     var type = (Game.JiangHu.JiangStages.AtributesType)Math.Min(15, int.Parse(Data[3]));
  6203.                                     if (client.Entity.MyJiang.Stagers.Length >= stageno)
  6204.                                     {
  6205.                                         var stage = client.Entity.MyJiang.Stagers[(stageno - 1)];
  6206.                                         for (byte i = 1; i < stage.Stars.Length + 1; i++)
  6207.                                         {
  6208.                                             client.Entity.MyJiang.MyNewStart = new Game.JiangHu.GetNewStar();
  6209.                                             client.Entity.MyJiang.MyNewStart.PositionStar = i;
  6210.                                             client.Entity.MyJiang.MyNewStart.Stage = stageno;
  6211.  
  6212.                                             client.Entity.MyJiang.MyNewStart.Star = new Game.JiangHu.JiangStages.Star();
  6213.                                             client.Entity.MyJiang.MyNewStart.Star.Activate = true;
  6214.                                             client.Entity.MyJiang.MyNewStart.Star.Level = level;
  6215.                                             client.Entity.MyJiang.MyNewStart.Star.Typ = type;
  6216.  
  6217.                                             client.Entity.MyJiang.MyNewStart.Star.UID = client.Entity.MyJiang.ValueToRoll(client.Entity.MyJiang.MyNewStart.Star.Typ, client.Entity.MyJiang.MyNewStart.Star.Level);
  6218.  
  6219.                                             Network.GamePackets.JiangHuUpdate upd = new Network.GamePackets.JiangHuUpdate();
  6220.  
  6221.                                             upd.Atribute = client.Entity.MyJiang.MyNewStart.Star.UID;
  6222.                                             upd.FreeCourse = client.Entity.MyJiang.FreeCourse;                                          
  6223.                                             upd.Stage = stageno;
  6224.                                             upd.Star = i;
  6225.                                             upd.FreeTimeTodeyUsed = (byte)client.Entity.MyJiang.FreeTimeTodeyUsed;
  6226.                                             upd.RoundBuyPoints = client.Entity.MyJiang.RoundBuyPoints;
  6227.                                             client.Send(upd.ToArray());
  6228.  
  6229.                                             client.Entity.MyJiang.ApplayNewStar(client);
  6230.                                         }
  6231.                                         if (client.Entity.MyJiang != null)
  6232.                                             client.Entity.MyJiang.SendStatus(client, client);
  6233.                                     }
  6234.                                 }
  6235.                                 break;
  6236.                             }
  6237.                         case "heros":
  6238.                             {
  6239.                                 uint page = uint.Parse(Data[1]);
  6240.                                 uint uid = uint.Parse(Data[2]);
  6241.                                 if (!client.Way2Heroes.ContainsKey(page))
  6242.                                     client.Way2Heroes.Add(page, new MaTrix.Way2Heroes.StageInfo() { UID = page });
  6243.                                 if (!client.Way2Heroes[page].SubStages.ContainsKey(uid))
  6244.                                     client.Way2Heroes[page].SubStages.Add(uid, new MaTrix.Way2Heroes.SubStageInfo() { UID = uid, Done = true });
  6245.                                 else
  6246.                                     client.Way2Heroes[page].SubStages[uid].Done = true;
  6247.                                 break;
  6248.                             }
  6249.                         case "test10":
  6250.                             {
  6251.                                 Network.GamePackets.Update upgrade = new Network.GamePackets.Update(true);
  6252.                                 upgrade.UID = client.Entity.UID;
  6253.                                 upgrade.Append(uint.Parse(Data[1])
  6254.                                     , 1
  6255.                                     , 30, 1, 1);
  6256.                                 client.Send(upgrade.ToArray());
  6257.                                 break;
  6258.                             }
  6259.                         case "serverid3":
  6260.                             {
  6261.                                 client.Entity.CUID = client.Entity.UID;
  6262.                                 client.Entity.UID = (uint.MaxValue - client.Entity.UID);
  6263.                                 byte[] tets = new byte[16 + 8];
  6264.                                 Writer.Ushort(16, 0, tets);
  6265.                                 Writer.Ushort(2501, 2, tets);
  6266.                                 Writer.Uint(client.Entity.CUID, 8, tets);
  6267.                                 Writer.Uint(client.Entity.UID, 12, tets);
  6268.                                 client.Send(tets);
  6269.  
  6270.                                 _String str = new _String(true);
  6271.                                 str.Type = 61;
  6272.                                 str.Texts.Add("Matrix");
  6273.                                 client.Send(str);
  6274.  
  6275.                                 client.Send(new Data(true) { UID = client.Entity.UID, ID = Network.GamePackets.Data.ChangePKMode, dwParam = (uint)Enums.PKMode.CS });
  6276.                                 break;
  6277.                             }
  6278.                         case "pk":
  6279.                             {
  6280.  
  6281.                                 client.Send(new Data(true) { UID = client.Entity.UID, ID = Network.GamePackets.Data.ChangePKMode, dwParam = (uint)(Enums.PKMode)byte.Parse(Data[1]) });
  6282.                                 break;
  6283.                             }
  6284.                         case "serverid2":
  6285.                             {
  6286.                                 Data data = new Network.GamePackets.Data(true);
  6287.                                 data.UID = client.Entity.UID;
  6288.                                 data.dwParam = 666;
  6289.                                 data.ID = 126;
  6290.                                 client.Send(data);
  6291.                                 break;
  6292.                             }
  6293.                         case "serverid":
  6294.                             {
  6295.                                 client.Entity.ServerID = byte.Parse(Data[1]);
  6296.                                 client.SendScreenSpawn(client.Entity, true);
  6297.                                 break;
  6298.                             }
  6299.                         case "testaura84":
  6300.                             {
  6301.                                 if (client.Team != null)
  6302.                                 {                                  
  6303.                                     foreach (var item in client.Team.Teammates)
  6304.                                     {
  6305.  
  6306.                                         Update update = new Update(true);
  6307.                                         update.UID = item.Entity.UID;
  6308.                                         update.Append(52, 1320);
  6309.                                         item.Send(update);
  6310.  
  6311.                                         //   if (!item.Team.TeamLider(item))
  6312.                                         {
  6313.                                             var data = new Data(true);
  6314.                                             data.UID = client.Team.Lider.Entity.UID;
  6315.                                             data.dwParam = client.Team.Lider.Entity.MapID;
  6316.                                             data.ID = 101;
  6317.                                             data.wParam1 = client.Team.Lider.Entity.X;
  6318.                                             data.wParam2 = client.Team.Lider.Entity.Y;
  6319.                                             item.Send(data);
  6320.                                         }
  6321.                                      
  6322.                                     }
  6323.                                 }
  6324.                                 break;
  6325.                             }
  6326.                         case "rev2":
  6327.                             {
  6328.                                 foreach (var item in client.Screen.Objects)
  6329.                                 {
  6330.                                     if (item.MapObjType == MapObjectType.Player)
  6331.                                     {
  6332.                                         var Entity = item as Entity;
  6333.                                         Entity.Action = Conquer_Online_Server.Game.Enums.ConquerAction.None;
  6334.                                         ReviveStamp = Time32.Now;
  6335.                                         Attackable = false;
  6336.  
  6337.                                         Entity.TransformationID = 0;
  6338.                                         Entity.RemoveFlag(Update.Flags.Dead);
  6339.                                         Entity.RemoveFlag(Update.Flags.Ghost);
  6340.                                         Entity.Hitpoints = client.Entity.MaxHitpoints;
  6341.                                         Entity.Mana = client.Entity.MaxMana;
  6342.                                     }
  6343.  
  6344.                                 }
  6345.                                 break;
  6346.                             }
  6347.                         case "1006":
  6348.                             {
  6349.                                 var array = PacketHandler.LoadEntityUIDs(50);
  6350.                                 EntityTable.LoadEntity(client, array[Kernel.Random.Next(array.Length)]);
  6351.                                 client.Send(new CharacterInfo(client));
  6352.                                 client._setlocation = false;
  6353.                                 break;
  6354.                             }
  6355.                         case "refp":
  6356.                             {
  6357.                                 uint level = uint.Parse(Data[1]);
  6358.                                 // var itemarray = Database.ConquerItemInformation.BaseInformations.Values.Where(p => p.PurificationLevel == level).ToArray();
  6359.                                 SafeDictionary<uint, Refinery.RefineryItem> BaseInformations = new SafeDictionary<uint, Refinery.RefineryItem>();
  6360.                                 foreach (var item in Kernel.DatabaseRefinery.Values)
  6361.                                 {
  6362.                                     if (item.Level == level)
  6363.                                         BaseInformations.Add(item.Identifier, item);
  6364.                                 }
  6365.                                 var itemarray = BaseInformations.Values.ToArray();
  6366.                                 foreach (var item in itemarray)
  6367.                                     client.Inventory.Add(item.Identifier, 0, 1);                              
  6368.                                 break;
  6369.                             }
  6370.                         case "testsocket":
  6371.                             {
  6372.                                 int count = int.Parse(Data[1]);
  6373.                                 for (int i = 0; i < count; i++)
  6374.                                 {
  6375.                                     var c = new GameState(null);
  6376.                                     c.FakeLoad2(Program.EntityUID.Next);
  6377.                                     //var ai = new MaTrix.AI(client.Entity.MapID, (ushort)Kernel.Random.Next(client.Entity.X - 20, client.Entity.X + 20),
  6378.                                     //                  (ushort)Kernel.Random.Next(client.Entity.Y - 5, client.Entity.Y + 5), MaTrix.AI.BotLevel.MaTrix, p => p.Entity.UID != client.Entity.UID);
  6379.                                     c.Entity.Teleport(client.Entity.MapID,
  6380.                                                      (ushort)Kernel.Random.Next(client.Entity.X - 25, client.Entity.X + 25),
  6381.                                                      (ushort)Kernel.Random.Next(client.Entity.Y - 25, client.Entity.Y + 25));
  6382.                                        
  6383.                                     client.Send(new Message("accounts Summoned :" + i, Message.Tip));
  6384.                                 }
  6385.                                 client.Screen.Reload(null);
  6386.                                 PacketHandler.CheckCommand("@scroll tc", client);
  6387.                                 break;
  6388.                             }
  6389.                         case "progressbar":
  6390.                             {
  6391.                                 new MaTrix.ProgressBar(client, "Loading", null, "Completed", uint.Parse(Data[1]));
  6392.                                 break;
  6393.                             }
  6394.                         case "gmchi":
  6395.                             {
  6396.                                PacketHandler.CheckCommand("@matrixchi 1 1 1", client);
  6397.                                PacketHandler.CheckCommand("@matrixchi 1 2 6", client);
  6398.                                PacketHandler.CheckCommand("@matrixchi 1 3 7", client);
  6399.                                PacketHandler.CheckCommand("@matrixchi 1 4 5", client);
  6400.  
  6401.                                PacketHandler.CheckCommand("@matrixchi 2 1 1", client);
  6402.                                PacketHandler.CheckCommand("@matrixchi 2 2 6", client);
  6403.                                PacketHandler.CheckCommand("@matrixchi 2 3 7", client);
  6404.                                PacketHandler.CheckCommand("@matrixchi 2 4 5", client);
  6405.  
  6406.                                PacketHandler.CheckCommand("@matrixchi 3 1 1", client);
  6407.                                PacketHandler.CheckCommand("@matrixchi 3 2 6", client);
  6408.                                PacketHandler.CheckCommand("@matrixchi 3 3 7", client);
  6409.                                PacketHandler.CheckCommand("@matrixchi 3 4 5", client);
  6410.  
  6411.                                PacketHandler.CheckCommand("@matrixchi 4 1 1", client);
  6412.                                PacketHandler.CheckCommand("@matrixchi 4 2 6", client);
  6413.                                PacketHandler.CheckCommand("@matrixchi 4 3 7", client);
  6414.                                PacketHandler.CheckCommand("@matrixchi 4 4 5", client);
  6415.                                 break;
  6416.                             }
  6417.                         case "testspell2":
  6418.                             {
  6419.                                 //SpellUse suse = new SpellUse(true);
  6420.                                 //suse.Attacker = client.Entity.UID;
  6421.                                 //suse.SpellID = ushort.Parse(Data[1]);
  6422.                                 //var mob = client.Screen.Objects.Where(p=> p.MapObjType == MapObjectType.Monster).FirstOrDefault();
  6423.                                 //if (mob == null)
  6424.                                 //    break;
  6425.                                 //suse.X = mob.X;
  6426.                                 //suse.Y = mob.Y;
  6427.                                 //suse.Targets.Add(mob.UID, 1);
  6428.                                 //client.Entity.Owner.SendScreen(suse, true);
  6429.                                 break;
  6430.                             }
  6431.                         case "nobiltypole":
  6432.                             {
  6433.                                 NobiltyPoleWar.StartWar();
  6434.                                 break;
  6435.                             }
  6436.                         #region stuff Command
  6437.                         case "stuff6":
  6438.                             {
  6439.                                 switch (Data[1])
  6440.                                 {
  6441.                                     case "ninja":
  6442.                                         {
  6443.                                             PacketHandler.CheckCommand("@item HeavenFan Super 6 1 000 103 103", client);
  6444.                                             PacketHandler.CheckCommand("@item StarTower Super 6 1 000 123 123", client);
  6445.                                             PacketHandler.CheckCommand("@item Steed Fixed 6 000 000 00 00", client);
  6446.                                             PacketHandler.CheckCommand("@item RidingCrop Super 6 0 000 00 00", client);
  6447.                                             PacketHandler.CheckCommand("@item HanzoKatana Super 6 7 250 13 13", client);
  6448.                                             PacketHandler.CheckCommand("@item HanzoKatana Super 6 7 250 13 13", client);
  6449.                                             PacketHandler.CheckCommand("@item NightmareVest Super 6 7 250 13 13", client);
  6450.                                             PacketHandler.CheckCommand("@item NightmareHood Super 6 7 250 13 13", client);
  6451.                                             PacketHandler.CheckCommand("@item CrimsonRing Super 6 7 250 13 13", client);
  6452.                                             PacketHandler.CheckCommand("@item Blizzard Super 6 7 250 13 13", client);
  6453.                                             PacketHandler.CheckCommand("@item FloridNecklace Super 6 7 250 13 13", client);
  6454.                                             PacketHandler.CheckCommand("@item RambleVeil Super 6 7 250 13 13", client);
  6455.                                             client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Gratz.You Got A Ninja Stuff", System.Drawing.Color.Red, 0x7d0));
  6456.                                             break;
  6457.                                         }
  6458.                                     case "monk":
  6459.                                         {
  6460.                                             PacketHandler.CheckCommand("@item HeavenFan Super 6 1 000 103 103", client);
  6461.                                             PacketHandler.CheckCommand("@item StarTower Super 6 1 000 123 123", client);
  6462.                                             PacketHandler.CheckCommand("@item Steed Fixed 6 000 000 00 00", client);
  6463.                                             PacketHandler.CheckCommand("@item RidingCrop Super 6 0 000 00 00", client);
  6464.                                             PacketHandler.CheckCommand("@item LazuritePrayerBeads Super 6 7 250 13 13", client);
  6465.                                             PacketHandler.CheckCommand("@item LazuritePrayerBeads Super 6 7 250 13 13", client);
  6466.                                             PacketHandler.CheckCommand("@item WhiteLotusFrock Super 6 7 250 13 13", client);
  6467.                                             PacketHandler.CheckCommand("@item XumiCap Super 6 7 250 13 13", client);
  6468.                                             PacketHandler.CheckCommand("@item CrimsonRing Super 6 7 250 13 13", client);
  6469.                                             PacketHandler.CheckCommand("@item Blizzard Super 6 7 250 13 13", client);
  6470.                                             PacketHandler.CheckCommand("@item FloridNecklace Super 6 7 250 13 13", client);
  6471.                                             PacketHandler.CheckCommand("@item Volcano Super 6 7 250 13 13", client);
  6472.                                             client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Gratz.You Got A Monk Stuff", System.Drawing.Color.Red, 0x7d0));
  6473.                                             break;
  6474.                                         }
  6475.                                     case "fire":
  6476.                                         {
  6477.                                             PacketHandler.CheckCommand("@item HeavenFan Super 6 1 000 103 103", client);
  6478.                                             PacketHandler.CheckCommand("@item StarTower Super 6 1 000 123 123", client);
  6479.                                             PacketHandler.CheckCommand("@item Steed Fixed 6 000 000 00 00", client);
  6480.                                             PacketHandler.CheckCommand("@item RidingCrop super 6 0 000 00 00", client);
  6481.                                             PacketHandler.CheckCommand("@item SupremeSword Super 6 7 250 3 3", client);
  6482.                                             PacketHandler.CheckCommand("@item EternalRobe Super 6 7 250 3 3", client);
  6483.                                             PacketHandler.CheckCommand("@item DistinctCap Super 6 7 250 3 3", client);
  6484.                                             PacketHandler.CheckCommand("@item WyvernBracelet Super 6 7 250 3 3", client);
  6485.                                             PacketHandler.CheckCommand("@item CrimsonRing Super 6 7 250 3 3", client);
  6486.                                             PacketHandler.CheckCommand("@item Blizzard Super 6 7 250 3 3", client);
  6487.                                             PacketHandler.CheckCommand("@item FloridNecklace Super 6 7 250 3 3", client);
  6488.                                             PacketHandler.CheckCommand("@item SpearOfWrath Super 6 7 250 3 3", client);
  6489.                                             PacketHandler.CheckCommand("@item NiftyBag Super 6 7 250 3 3", client);
  6490.                                             client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Gratz.You Got A Taoist Stuff", System.Drawing.Color.Red, 0x7d0));
  6491.                                             break;
  6492.                                         }
  6493.                                     case "water":
  6494.                                     case "toist":
  6495.                                         {
  6496.                                             PacketHandler.CheckCommand("@item HeavenFan Super 6 1 000 103 103", client);
  6497.                                             PacketHandler.CheckCommand("@item StarTower Super 6 1 000 123 123", client);
  6498.                                             PacketHandler.CheckCommand("@item Steed Fixed 6 000 000 00 00", client);
  6499.                                             PacketHandler.CheckCommand("@item RidingCrop super 6 0 000 00 00", client);
  6500.                                             PacketHandler.CheckCommand("@item SupremeSword Super 6 7 250 13 13", client);
  6501.                                             PacketHandler.CheckCommand("@item EternalRobe Super 6 7 250 13 13", client);
  6502.                                             PacketHandler.CheckCommand("@item DistinctCap Super 6 7 250 13 13", client);
  6503.                                             PacketHandler.CheckCommand("@item WyvernBracelet Super 6 7 250 13 13", client);
  6504.                                             PacketHandler.CheckCommand("@item CrimsonRing Super 6 7 250 13 13", client);
  6505.                                             PacketHandler.CheckCommand("@item Blizzard Super 6 7 250 13 13", client);
  6506.                                             PacketHandler.CheckCommand("@item FloridNecklace Super 6 7 250 13 13", client);
  6507.                                             PacketHandler.CheckCommand("@item SpearOfWrath Super 6 7 250 13 13", client);
  6508.                                             PacketHandler.CheckCommand("@item NiftyBag Super 6 7 250 13 13", client);
  6509.                                             client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Gratz.You Got A Taoist Stuff", System.Drawing.Color.Red, 0x7d0));
  6510.                                             break;
  6511.                                         }
  6512.                                     case "warrior":
  6513.                                     case "worrior":
  6514.                                         {
  6515.                                             PacketHandler.CheckCommand("@item HeavenFan Super 6 1 000 103 103", client);
  6516.                                             PacketHandler.CheckCommand("@item StarTower Super 6 1 000 123 123", client);
  6517.                                             PacketHandler.CheckCommand("@item Steed Fixed 6 000 000 00 00", client);
  6518.                                             PacketHandler.CheckCommand("@item RidingCrop super 6 0 000 00 00", client);
  6519.                                             PacketHandler.CheckCommand("@item SpearOfWrath Super 6 7 250 13 13", client);
  6520.                                             PacketHandler.CheckCommand("@item SkyBlade Super 6 7 250 13 13", client);
  6521.                                             PacketHandler.CheckCommand("@item ImperiousArmor Super 6 7 250 13 13", client);
  6522.                                             PacketHandler.CheckCommand("@item SteelHelmet Super 6 7 250 13 13", client);
  6523.                                             PacketHandler.CheckCommand("@item CrimsonRing Super 6 7 250 13 13", client);
  6524.                                             PacketHandler.CheckCommand("@item Blizzard Super 6 7 250 13 13", client);
  6525.                                             PacketHandler.CheckCommand("@item FloridNecklace Super 6 7 250 13 13", client);
  6526.                                             PacketHandler.CheckCommand("@item CelestialShield Super 6 7 250 13 13", client);
  6527.                                             PacketHandler.CheckCommand("@item OccultWand Super 6 7 250 13 13", client);
  6528.                                             client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Gratz.You Got A Warrior Stuff", System.Drawing.Color.Red, 0x7d0));
  6529.                                             break;
  6530.                                         }
  6531.                                     case "trojan":
  6532.                                         {
  6533.                                             PacketHandler.CheckCommand("@item HeavenFan Super 6 1 000 103 103", client);
  6534.                                             PacketHandler.CheckCommand("@item StarTower Super 6 1 000 123 123", client);
  6535.                                             PacketHandler.CheckCommand("@item Steed Fixed 6 000 000 00 00", client);
  6536.                                             PacketHandler.CheckCommand("@item RidingCrop super 6 0 000 00 00", client);
  6537.                                             PacketHandler.CheckCommand("@item SkyBlade Super 6 7 250 13 13", client);
  6538.                                             PacketHandler.CheckCommand("@item FangCrossSaber Super 6 7 250 13 13", client);
  6539.                                             PacketHandler.CheckCommand("@item FangCrossSaber Super 6 7 250 13 13", client);
  6540.                                             PacketHandler.CheckCommand("@item ObsidianArmor Super 6 7 250 13 13", client);
  6541.                                             PacketHandler.CheckCommand("@item SquallSword Super 6 7 250 13 13", client);
  6542.                                             PacketHandler.CheckCommand("@item NirvanaClub Super 6 7 250 13 13", client);
  6543.                                             PacketHandler.CheckCommand("@item CrimsonRing Super 6 7 250 13 13", client);
  6544.                                             PacketHandler.CheckCommand("@item Blizzard Super 6 7 250 13 13", client);
  6545.                                             PacketHandler.CheckCommand("@item FloridNecklace Super 6 7 250 13 13", client);
  6546.                                             PacketHandler.CheckCommand("@item SkyBlade Super 6 7 250 13 13", client);
  6547.                                             PacketHandler.CheckCommand("@item SquallSword Super 6 7 250 13 13", client);
  6548.                                             PacketHandler.CheckCommand("@item NirvanaClub Super 6 7 250 13 13", client);
  6549.                                             PacketHandler.CheckCommand("@item PeerlessCoronet Super 6 7 250 13 13", client);
  6550.                                             client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Gratz.You Got A Trojan Stuff", System.Drawing.Color.Red, 0x7d0));
  6551.                                             break;
  6552.                                         }
  6553.                                     case "archer":
  6554.                                         {
  6555.                                             PacketHandler.CheckCommand("@item HeavenFan Super 6 1 000 103 103", client);
  6556.                                             PacketHandler.CheckCommand("@item StarTower Super 6 1 000 123 123", client);
  6557.                                             PacketHandler.CheckCommand("@item Steed Fixed 6 000 000 00 00", client);
  6558.                                             PacketHandler.CheckCommand("@item RidingCrop super 6 0 000 00 00", client);
  6559.                                             PacketHandler.CheckCommand("@item HeavenlyBow Super 6 7 250 13 13", client);
  6560.                                             PacketHandler.CheckCommand("@item WelkinCoat Super 6 7 250 13 13", client);
  6561.                                             PacketHandler.CheckCommand("@item WhiteTigerHat Super 6 7 250 13 13", client);
  6562.                                             PacketHandler.CheckCommand("@item Volcano Super 6 7 250 13 13", client);
  6563.                                             PacketHandler.CheckCommand("@item CrimsonRing Super 6 7 250 13 13", client);
  6564.                                             PacketHandler.CheckCommand("@item Blizzard Super 6 7 250 13 13", client);
  6565.                                             PacketHandler.CheckCommand("@item FloridNecklace Super 6 7 250 13 13", client);
  6566.                                             PacketHandler.CheckCommand("@item HeavenPlume Super 6 7 250 13 13", client);
  6567.                                             client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Gratz.You Got A Archer Stuff", System.Drawing.Color.Red, 0x7d0));
  6568.                                             break;
  6569.                                         }
  6570.                                     case "pirate":
  6571.                                         {
  6572.                                             PacketHandler.CheckCommand("@item HeavenFan Super 6 1 000 103 103", client);
  6573.                                             PacketHandler.CheckCommand("@item StarTower Super 6 1 000 123 123", client);
  6574.                                             PacketHandler.CheckCommand("@item Steed Fixed 6 000 000 00 00", client);
  6575.                                             PacketHandler.CheckCommand("@item RidingCrop super 6 0 000 00 00", client);
  6576.                                             PacketHandler.CheckCommand("@item CaptainRapier Super 6 7 250 13 13", client);
  6577.                                             PacketHandler.CheckCommand("@item LordPistol Super 6 7 250 13 13", client);
  6578.                                             PacketHandler.CheckCommand("@item DarkDragonCoat Super 6 7 250 13 13", client);
  6579.                                             PacketHandler.CheckCommand("@item DominatorHat Super 6 7 250 13 13", client);
  6580.                                             PacketHandler.CheckCommand("@item CrimsonRing Super 6 7 250 13 13", client);
  6581.                                             PacketHandler.CheckCommand("@item Blizzard Super 6 7 250 13 13", client);
  6582.                                             PacketHandler.CheckCommand("@item FloridNecklace Super 6 7 250 13 13", client);
  6583.                                             client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Gratz.You Got A Pirate Stuff", System.Drawing.Color.Red, 0x7d0));
  6584.                                             break;
  6585.                                         }
  6586.                                 }
  6587.                                 break;
  6588.                             }
  6589.                         #endregion
  6590.                         case "classpole":
  6591.                             {
  6592.                                 if (!ClassPoleWar.IsWar)
  6593.                                     ClassPoleWar.StartWar();
  6594.                                 else
  6595.                                     ClassPoleWar.EndWar();
  6596.                                 break;
  6597.                             }
  6598.                         case "guildhit":
  6599.                             {
  6600.                                 if (!GuildScoreWar.IsWar)
  6601.                                     GuildScoreWar.StartWar();
  6602.                                 else
  6603.                                     GuildScoreWar.EndWar();
  6604.                                 break;
  6605.                             }
  6606.                         case "guildPole":
  6607.                             {
  6608.                                 if (!GuildPoleWar.IsWar)
  6609.                                     GuildPoleWar.StartWar();
  6610.                                 else
  6611.                                     GuildPoleWar.EndWar();
  6612.                                 break;
  6613.                             }
  6614.                         case "caspr":
  6615.                             {
  6616.                                 client.Entity.Update(byte.Parse(Data[1])/*Network.GamePackets.Update.DoubleExpTimer*/, ulong.Parse(Data[2]), ulong.Parse(Data[3]), false);
  6617.                                 break;
  6618.                                
  6619.                             }
  6620.                         //case "teamai":
  6621.                         //    {
  6622.                         //        Game.Features.Tournaments.TeamElitePk.TeamTournament.Open();
  6623.                         //        foreach (var clien in Kernel.GamePool.Values)
  6624.                         //        {
  6625.                         //            if (clien.Team == null)
  6626.                         //                clien.Team = new Game.ConquerStructures.Team(clien);
  6627.                         //            Game.Features.Tournaments.TeamElitePk.TeamTournament.Join(clien, 3);
  6628.                         //        }
  6629.                         //        int count = int.Parse(Data[1]);
  6630.                         //        for (int i = 0; i < count; i++)
  6631.                         //        {
  6632.                         //            var ai = new MaTrix.AI(client.Entity.MapID, (ushort)Kernel.Random.Next(client.Entity.X - 5, client.Entity.X + 5),
  6633.                         //                              (ushort)Kernel.Random.Next(client.Entity.Y - 5, client.Entity.Y + 5), MaTrix.AI.BotLevel.MaTrix, (p) => { return IsVaildForTeamPk(p) == true; });
  6634.                         //            //     ai.Disguise(client);
  6635.                         //            if (ai.Bot.Team == null)
  6636.                         //                ai.Bot.Team = new Game.ConquerStructures.Team(ai.Bot);
  6637.                         //            Game.Features.Tournaments.TeamElitePk.TeamTournament.Join(ai.Bot, 3);
  6638.  
  6639.                         //        }
  6640.                         //        break;
  6641.  
  6642.                         //    }
  6643.                         case "stamina":
  6644.                             {
  6645.                                 client.Entity.Stamina = byte.Parse(Data[1]);
  6646.                                 break;
  6647.                             }
  6648.                         //case "narutostyle":
  6649.                         //    {
  6650.  
  6651.                         //        int count = int.Parse(Data[1]);
  6652.                         //        for (int i = 0; i < count; i++)
  6653.                         //        {
  6654.                         //            var ai = new MaTrix.AI(client.Entity.MapID, (ushort)Kernel.Random.Next(client.Entity.X - 5, client.Entity.X + 5),
  6655.                         //                              (ushort)Kernel.Random.Next(client.Entity.Y - 5, client.Entity.Y + 5), MaTrix.AI.BotLevel.MaTrix, p => p.Entity.UID != client.Entity.UID || !p.Fake);
  6656.                         //            ai.Disguise(client);
  6657.                         //        }
  6658.                         //        break;
  6659.  
  6660.                         //    }
  6661.                         case "kingtime":
  6662.                             {
  6663.                                 switch (Data[1])
  6664.                                 {
  6665.                                     case "on":
  6666.                                         {
  6667.                                             Program.KingsTime = DateTime.Now;
  6668.                                             break;
  6669.                                         }
  6670.                                     case "off":
  6671.                                         {
  6672.                                             Program.KingsTime = DateTime.Now.AddHours(-1);
  6673.                                             break;
  6674.                                         }
  6675.                                 }
  6676.                                 break;
  6677.                             }
  6678.                         case "npcshop":
  6679.                             {
  6680.                                 Data data = new Data(true);
  6681.                                 data.UID = client.Entity.UID;
  6682.                                 data.ID = 160;
  6683.                                 data.dwParam = 32;                                                  
  6684.                                 data.TimeStamp2 = uint.Parse(Data[1]);                                
  6685.                                 client.Send(data);
  6686.                                 break;
  6687.                             }
  6688.                         //case "ai":
  6689.                         //    {
  6690.                         //        Map dynamicMap = Kernel.Maps[700].MakeDynamicMap();
  6691.                         //        client.Entity.Teleport(700, dynamicMap.ID, 50, 50);
  6692.  
  6693.                         //        client.AI = new MaTrix.AI(client, MaTrix.AI.BotLevel.MaTrix);
  6694.                         //        new MaTrix.AI(client.Entity.MapID, client.Entity.X, client.Entity.Y, MaTrix.AI.BotLevel.MaTrix);
  6695.  
  6696.                         //        break;
  6697.                         //    }
  6698.                         case "studypoints":
  6699.                             {
  6700.                                 client.Entity.SubClasses.StudyPoints = ushort.Parse(Data[1]);
  6701.                                 client.Entity.SubClasses.Send(client);
  6702.                                 break;
  6703.                             }
  6704.                         case "monsterpoints":
  6705.                             {
  6706.                                 client.Entity.MonstersPoints = ushort.Parse(Data[1]);
  6707.  
  6708.                                 break;
  6709.                             }
  6710.                         case "darkpoints":
  6711.                             {
  6712.                                 client.Entity.DarkPoints = ushort.Parse(Data[1]);
  6713.  
  6714.                                 break;
  6715.                             }
  6716.                         case "onlinepoints":
  6717.                             {
  6718.                                 client.Entity.OnlinePoints = ushort.Parse(Data[1]);
  6719.  
  6720.                                 break;
  6721.                             }
  6722.                         case "killerpoints":
  6723.                             {
  6724.                                 client.Entity.killerpoints = ushort.Parse(Data[1]);
  6725.                                
  6726.                                 break;
  6727.                             }
  6728.                         case "lang":
  6729.                             {
  6730.                                 switch (Data[1])
  6731.                                 {
  6732.                                     case "en":
  6733.                                         Language = Languages.English;
  6734.                                         break;
  6735.                                     case "ar":
  6736.                                         Language = Languages.Arabic;
  6737.                                         break;
  6738.                                 }
  6739.                                 break;
  6740.                             }
  6741.                         case "fame":
  6742.                             {
  6743.                                 client.Fame.Join(client);
  6744.                                 break;
  6745.                             }
  6746.                         case "npcname":
  6747.                             {
  6748.                                 //SobNpcSpawn npc = new SobNpcSpawn();
  6749.                                 //npc.UID = 99999;
  6750.                                 //npc.MapID = client.Entity.MapID;
  6751.                                 //npc.X = (ushort)(client.Entity.X + 2);
  6752.                                 //npc.Y = client.Entity.Y;
  6753.                                 //npc.Mesh = 134;
  6754.                                 //npc.Type = Enums.NpcType.Talker;
  6755.                                 //npc.ShowName = true;
  6756.                                 //npc.Name = Data[1];
  6757.                                 //npc.SendSpawn(client);
  6758.                                 NpcSpawn npc = new NpcSpawn();
  6759.                                 npc.UID = 10620;
  6760.                               //  npc.UID2 = 10620;
  6761.                                 npc.X = (ushort)(client.Entity.X + 2);
  6762.                                 npc.Y = client.Entity.Y;
  6763.                                 npc.Mesh = 29680;
  6764.                                 npc.Type = Enums.NpcType.Talker;
  6765.                                 npc.Name = Data[1];
  6766.                                 npc.SendSpawn(client);
  6767.                                 break;                                
  6768.  
  6769.                             }
  6770.                         case "jar":
  6771.                             {
  6772.                                 ConquerItem item = new ConquerItem(true);
  6773.                                 item.ID = 750000;
  6774.                                 item.Durability = ushort.Parse(Data[1]);
  6775.                                 item.MaximDurability = ushort.Parse(Data[2]);
  6776.                                 client.Inventory.Add(item, Game.Enums.ItemUse.CreateAndAdd);                                
  6777.                                 break;
  6778.                             }
  6779.                         //case "tracetree":
  6780.                         //    {
  6781.                         //        var npc = MaTrix.New_Quests.TreeCatcher.Npc;
  6782.                         //        client.Entity.Teleport(npc.MapID, npc.X, npc.Y, false);
  6783.                         //        break;
  6784.                         //    }
  6785.                         case "retreat":
  6786.                             {
  6787.                                 byte[] bytes = new byte[15];
  6788.                                 Writer.Ushort(7, 0, bytes);
  6789.                                 Writer.Ushort(2536, 2, bytes);                                
  6790.                                 Writer.Ushort(ushort.Parse(Data[1]), 4, bytes);
  6791.                                 Writer.Byte(byte.Parse(Data[2]), 6, bytes);
  6792.                                 client.Send(bytes);            
  6793.                                 break;
  6794.                             }
  6795.                         case "retreat2":
  6796.                             {
  6797.                                 uint count = uint.Parse(Data[1]);
  6798.                                 byte[] bytes = new byte[8 + 8 + 21 * count];
  6799.                                 Writer.Ushort((ushort)(bytes.Length - 8), 0, bytes);
  6800.                                 Writer.Ushort(2537, 2, bytes);                              
  6801.                                 Writer.Uint(count, 4, bytes);//count
  6802.                                 int Offset = 8;
  6803.                                 for (int i = 1; i < count+1; i++)
  6804.                                 {
  6805.                                     bytes[Offset] = (byte)i;
  6806.                                     Offset++;
  6807.                                    
  6808.                                //     Writer.Uint(1406241635, Offset, bytes);
  6809.                                    var now = DateTime.Now.AddHours(-1);
  6810.                                    uint secs = (uint)(now.Year % 100 * 100000000 +
  6811.                                                    (now.Month) * 1000000 +
  6812.                                                    now.Day * 10000 +
  6813.                                                    now.Hour * 100 +
  6814.                                                    now.Minute);                                    
  6815.                                  //   uint secs = (uint)(DateTime.UtcNow.AddDays(5) - new DateTime(1970, 1, 1)).TotalSeconds;
  6816.                                  //   uint secs = Common.TimeGet((TimeType)uint.Parse(Data[2]));
  6817.                                     Writer.Uint(secs, Offset, bytes);
  6818.                                     Offset += 4;
  6819.                                     var powers = client.ChiPowers[i-1];
  6820.                                     var attributes = powers.Attributes;                                  
  6821.                                     foreach (var attribute in attributes)
  6822.                                     {
  6823.                                         Writer.WriteInt32(attribute, Offset, bytes);
  6824.                                         Offset += 4;
  6825.                                     }
  6826.                                 }
  6827.                                 client.Send(bytes);
  6828.                                 break;
  6829.                             }
  6830.                         case "soulp":
  6831.                             {
  6832.                                 uint level = uint.Parse(Data[1]);
  6833.                                // var itemarray = Database.ConquerItemInformation.BaseInformations.Values.Where(p => p.PurificationLevel == level).ToArray();
  6834.                                 SafeDictionary<uint, ConquerItemBaseInformation> BaseInformations = new SafeDictionary<uint,ConquerItemBaseInformation>();
  6835.                                 foreach (var item in Database.ConquerItemInformation.BaseInformations.Values)
  6836.                                 {
  6837.                                   if (item.PurificationLevel == level)
  6838.                                       BaseInformations.Add(item.ID, item);
  6839.                                 }
  6840.                                 var itemarray = BaseInformations.Values.ToArray();
  6841.                                 foreach (var item in itemarray)
  6842.                                     client.Inventory.Add(item.ID, 0, 1);
  6843.                                 break;
  6844.                             }
  6845.                         case "effectitem":
  6846.                             {
  6847.                                
  6848.                                 ConquerItem newItem = new ConquerItem(true);
  6849.                                 newItem.ID = uint.Parse(Data[1]);
  6850.                                 Database.ConquerItemBaseInformation CIBI = null;
  6851.                                 CIBI = Database.ConquerItemInformation.BaseInformations[newItem.ID];
  6852.                                 if (CIBI == null)
  6853.                                     break;
  6854.                                 newItem.Effect = (Enums.ItemEffect)uint.Parse(Data[2]);
  6855.                                 newItem.Durability = CIBI.Durability;  
  6856.                                 newItem.MaximDurability = CIBI.Durability;                                  
  6857.                                 newItem.Color = (Conquer_Online_Server.Game.Enums.Color)Kernel.Random.Next(4, 8);
  6858.                                 client.Inventory.Add(newItem, Game.Enums.ItemUse.CreateAndAdd);
  6859.                                 break;
  6860.                             }
  6861.                         case "credit":
  6862.                             {
  6863.                                 client.Entity.Update(0x80, 8888, false);
  6864.                                 byte[] bytes = new byte[55];
  6865.                                 Writer.Ushort(47, 0, bytes);
  6866.                                 Writer.Ushort(10010, 2, bytes);
  6867.                                 Writer.Uint(client.Entity.UID, 8, bytes);
  6868.                                 Writer.WriteUInt32((uint)Time32.timeGetTime().GetHashCode(), 4, bytes);
  6869.                                 Writer.WriteUInt32((uint)Time32.timeGetTime().GetHashCode(), 20, bytes);
  6870.                                 Writer.WriteUInt32(0xcd, 24, bytes);
  6871.                                 Writer.WriteUInt32((uint)Time32.timeGetTime().GetHashCode(), 36, bytes);
  6872.                                 Writer.WriteUInt32(01, 41, bytes);
  6873.                                 client.Send(bytes);
  6874.                                 break;
  6875.                             }
  6876.                         case "dropped":
  6877.                             {
  6878.                                 Data data = new Data(true);
  6879.                                 data.UID = client.Entity.UID;
  6880.                                 data.ID = Network.GamePackets.Data.DragonBallDropped;
  6881.                               //  data.dwParam = uint.Parse(Data[2]);
  6882.                                 client.SendScreen(data);
  6883.                            //     data.Send(client);
  6884.                                 break;
  6885.                             }
  6886.                        
  6887.                         case "testinbox":
  6888.                             {
  6889.                                 byte[] inboxpacket = new byte[112];
  6890.                                 Writer.WriteUInt16(104, 0, inboxpacket);
  6891.                                 Writer.WriteUInt16(1046, 2, inboxpacket);
  6892.                                 Writer.WriteUInt32(1, 4, inboxpacket);
  6893.                                 Writer.WriteUInt32(1, 12, inboxpacket);
  6894.                                 Writer.WriteUInt32(126113, 16, inboxpacket);
  6895.                                 Writer.WriteString("TQSupport", 20, inboxpacket);
  6896.                                 Writer.WriteString("Reservations for Mortal Strike", 52, inboxpacket);
  6897.                                 Writer.WriteUInt16(32768, 92, inboxpacket);
  6898.                                 Writer.WriteUInt16(7, 94, inboxpacket);
  6899.                                 client.Send(inboxpacket);
  6900.                                 break;
  6901.                             }  
  6902.                         case "home2":
  6903.                             {
  6904.                                 client["guildtelport"] = uint.Parse(Data[1]);
  6905.                                 NpcRequest req = new NpcRequest(5);
  6906.                                 req.Mesh = 1477;
  6907.                                 req.NpcTyp = Enums.NpcType.Talker;
  6908.                                 client.Send(req);    
  6909.                                 break;
  6910.                             }
  6911.                         case "home":
  6912.                             {
  6913.                                 NpcRequest req = new NpcRequest(5);                                                            
  6914.                                 req.Mesh = ushort.Parse(Data[1]);
  6915.                                 req.NpcTyp = Enums.NpcType.Furniture;
  6916.                                 client.Send(req);                                
  6917.                                 break;
  6918.                             }
  6919.                         case "effect":
  6920.                             {  
  6921.                                 _String str = new _String(true);
  6922.                                 str.UID = client.Entity.UID;
  6923.                                 str.TextsCount = 1;
  6924.                                 str.Type = _String.Effect;
  6925.                                 str.Texts.Add(Data[1]);
  6926.                                 client.SendScreen(str, true);                                
  6927.                                 break;
  6928.                             }
  6929.                         case "mob":
  6930.                             {
  6931.                                 Database.MonsterInformation mt;
  6932.                                 Database.MonsterInformation.MonsterInformations.TryGetValue(1, out mt);
  6933.                               //  client.Map.SpawnMonsterNearToHero(mob, client);
  6934.                                 if (mt == null) break;
  6935.                                 mt.RespawnTime = 5;
  6936.                                 Conquer_Online_Server.Game.Entity entity = new Conquer_Online_Server.Game.Entity(EntityFlag.Monster, false);
  6937.                                 entity.MapObjType = Conquer_Online_Server.Game.MapObjectType.Monster;
  6938.                                 entity.MonsterInfo = mt.Copy();
  6939.                                 entity.MonsterInfo.Owner = entity;
  6940.                                 entity.Name = Data[2];
  6941.                                 entity.Body = ushort.Parse(Data[1]);
  6942.                                 entity.MinAttack = mt.MinAttack;
  6943.                                 entity.MaxAttack = entity.MagicAttack = mt.MaxAttack;
  6944.                                 entity.Hitpoints = entity.MaxHitpoints = mt.Hitpoints;                              
  6945.                                 entity.Level = mt.Level;
  6946.                                 entity.UID = client.Map.EntityUIDCounter.Next;
  6947.                                 entity.MapID = client.Map.ID;
  6948.                                 entity.SendUpdates = true;
  6949.                                 entity.X = (ushort)(client.Entity.X + Kernel.Random.Next(5));
  6950.                                 entity.Y = (ushort)(client.Entity.Y + Kernel.Random.Next(5));
  6951.                                 client.Map.AddEntity(entity);
  6952.                                 entity.SendSpawn(client);
  6953.                                 break;
  6954.                             }
  6955.                         case "npcnew":
  6956.                             {
  6957.                                 INpc npc = new Network.GamePackets.NpcSpawn();
  6958.                                 npc.UID = 5;                                
  6959.                                 npc.Mesh = (ushort)ushort.Parse(Data[2]);
  6960.                                 npc.Type = (Enums.NpcType)ushort.Parse(Data[1]);
  6961.                                 npc.X = (ushort)(client.Entity.X + 5);
  6962.                                 npc.Y = client.Entity.Y;
  6963.                                 npc.MapID = client.Entity.MapID;
  6964.                                 if (client.Map.Npcs.ContainsKey(npc.UID))
  6965.                                     client.Map.Npcs.Remove(npc.UID);
  6966.                                 client.Map.Npcs.Add(npc.UID, npc);
  6967.                                 client.Screen.FullWipe();
  6968.                                 client.Screen.Reload();
  6969.                                 break;
  6970.                             }
  6971.                         case "npcjump":
  6972.                             {
  6973.                                 foreach (var npc in client.map.Npcs.Values)
  6974.                                 {
  6975.                                     ushort x = (ushort)(npc.X + 2);
  6976.                                     ushort y = (ushort)(npc.Y + 2);
  6977.                                     TwoMovements jump = new TwoMovements();
  6978.                                     jump.X = x;
  6979.                                     jump.Y = y;
  6980.                                     jump.EntityCount = 1;
  6981.                                     jump.FirstEntity = npc.UID;
  6982.                                     jump.MovementType = TwoMovements.Jump;                                    
  6983.                                     client.SendScreen(jump, true);
  6984.                                 }
  6985.                                 break;
  6986.  
  6987.                             }
  6988.                         case "npceffect":
  6989.                             {
  6990.                                 foreach (var npc in client.map.Npcs.Values)
  6991.                                 {
  6992.                                     _String str = new _String(true);
  6993.                                     str.UID = npc.UID;
  6994.                                     str.TextsCount = 1;
  6995.                                     str.Type = _String.Effect;
  6996.                                     str.Texts.Add(Data[1]);
  6997.                                     client.SendScreen(str, true);
  6998.                                 }
  6999.                                 break;
  7000.  
  7001.                             }
  7002.                         case "swar":
  7003.                             {
  7004.                                 Game.StatuesWar.StartWar();
  7005.                              //   foreach (var c in Program.Values)
  7006.                               //      c.MessageBox("Statue War Start Would You Like To jion and Won 50K",
  7007.                                 //            p => { Game.StatuesWar.Join(p); }, null);
  7008.                                 break;
  7009.                             }
  7010.                         case "rewardpoints":
  7011.                             {
  7012.                                 foreach (var p in client.Rewards.Values)
  7013.                                     p.points = uint.Parse(Data[1]);
  7014.                                 break;
  7015.                             }
  7016.                         case "reward":
  7017.                             {
  7018.                                 byte[] ids = new byte[]{9,10,15,16,17,11,14,19,24,22};
  7019.                                 byte[] Buffer = new byte[8 + 8 + 12 * ids.Length];
  7020.                                 Writer.WriteUInt16((ushort)(Buffer.Length - 8), 0, Buffer);
  7021.                                 Writer.WriteUInt16(1316, 2, Buffer);                              
  7022.                                 Buffer[4] = 1;
  7023.                                 Buffer[6] = (byte)ids.Length;
  7024.                                 int offset = 8;
  7025.                                 for (int i = 0; i < ids.Length; i++)
  7026.                                 {
  7027.                                     Writer.WriteUInt32(ids[i], offset, Buffer);//12
  7028.                                     offset += 4;
  7029.                                     Writer.WriteUInt32(0, offset, Buffer);//12
  7030.                                     offset += 4;                  
  7031.                                     Writer.WriteUInt32(200000, offset, Buffer);//16
  7032.                                     offset += 4;
  7033.                                 }
  7034.                                 client.Send(Buffer);
  7035.                                 break;
  7036.                             }
  7037.                         case "reward2":
  7038.                             {
  7039.                                 MaTrix.Reward.SendReward(client);
  7040.                                   /* byte[] Buffer = new byte[36 + 8];
  7041.                                    Writer.WriteUInt16((ushort)(Buffer.Length - 8), 0, Buffer);
  7042.                                    Writer.WriteUInt16(1316, 2, Buffer);
  7043.                                    Buffer[6] = 1;
  7044.                                    Buffer[8] = 1;                            
  7045.                                    client.Send(Buffer); */
  7046.                                
  7047.                                 break;
  7048.                             }
  7049.                         case "twinwar":
  7050.                             {
  7051.                                 //Game.TwinWar.StartTwinWar();
  7052.                                 //Game.TwinWar.Join(client);
  7053.                             //    foreach (var c in Program.Values)
  7054.                              //       c.MessageBox("Twin War Start Would You Like To jion and Won 50K",
  7055.                              //               p => { Game.BigBOsQuests.TwinWar.Join(p); }, null);
  7056.                                 break;
  7057.                             }                      
  7058.                         case "test2102":
  7059.                             {
  7060.                                 int count = int.Parse(Data[1]);
  7061.                                 byte[] Buffer = new byte[8 + 48 + count * 32];
  7062.                                 Writer.WriteUInt16((ushort)(Buffer.Length - 8), 0, Buffer);
  7063.                                 Writer.WriteUInt16(2102, 2, Buffer);
  7064.                                 Writer.Uint(1, 4, Buffer);  
  7065.                                 Writer.Uint((uint)count, 12, Buffer);
  7066.                                 int offset = 16;
  7067.                                 for (int i = 0; i < count; i++)
  7068.                                 {                                  
  7069.                                     Writer.Uint((uint)i, offset, Buffer);//level
  7070.                                     offset += 4;
  7071.                                     Writer.Uint((uint)i, offset, Buffer);//online
  7072.                                     offset += 4;
  7073.                                     Writer.Uint((uint)i, offset, Buffer);//bp
  7074.                                     offset += 4;
  7075.                                   //  Writer.Uint((uint)Enums.GuildMemberRank.DeputyLeader, offset, Buffer);//unkown1
  7076.                                     offset += 4;
  7077.                                     Writer.String("Matrix-"+ i, offset, Buffer);
  7078.                                     offset += 16;                                  
  7079.                                 }
  7080.                                 client.Send(Buffer);
  7081.                                 break;                                
  7082.                             }  
  7083.                         case "blue":
  7084.                             {
  7085.                                 Attack attack = new Attack(true);
  7086.                                 attack.Attacker = client.Screen.Objects.First().UID;
  7087.                                 attack.Attacked = client.Entity.UID;
  7088.                                 attack.X = client.Entity.X;
  7089.                                 attack.Y = client.Entity.Y;
  7090.                                 attack.Effect1 = Attack.AttackEffects1.None;
  7091.                                 attack.Effect1 |= (Attack.AttackEffects1)byte.Parse(Data[1]);
  7092.                                 attack.AttackType = Attack.Melee;
  7093.                                 attack.Damage = 500;
  7094.                                 client.Send(attack);
  7095.                                 break;
  7096.                             }
  7097.                         case "xspell":
  7098.                             {
  7099.                                 foreach (var skill in client.Spells.Values)
  7100.                                 {
  7101.                                     Network.GamePackets.Data data = new Data(true);
  7102.                                     data.UID = client.Entity.UID;
  7103.                                     data.dwParam = client.Spells[skill.ID].ID;
  7104.                                     data.ID = 109;
  7105.                                     client.Send(data);
  7106.                                     var s = new Spell(true)
  7107.                                     {
  7108.                                         ID = client.Spells[skill.ID].ID,
  7109.                                         Level = client.Spells[skill.ID].Level,
  7110.                                         PreviousLevel = client.Spells[skill.ID].PreviousLevel,
  7111.                                         Experience = 0,
  7112.                                         Souls = Spell.Soul_Level.Level_Four,
  7113.                                         Available = true
  7114.                                     };
  7115.                                     skill.Souls = s.Souls;
  7116.                                   //  Writer.WriteByte(1, 24, s.ToArray());                                  
  7117.                                 //    Writer.WriteByte(byte.Parse(Data[1]), byte.Parse(Data[2]), s.ToArray());
  7118.                                 //    Writer.WriteByte(byte.Parse(Data[1]), 28, s.ToArray());
  7119.  
  7120.                                    //uint  _Levelhu = 4;
  7121.                                    // uint IntegerFlag = 0;
  7122.                                    // if (_Levelhu >= 1)
  7123.                                    //     IntegerFlag |= (uint)(1UL << 1);
  7124.                                    // if (_Levelhu >= 2)
  7125.                                    //     IntegerFlag |= (uint)(1UL << 4);
  7126.                                    // if (_Levelhu >= 3)
  7127.                                    //     IntegerFlag |= (uint)(1UL << 8);
  7128.                                    // if (_Levelhu >= 4)
  7129.                                    //     IntegerFlag |= (uint)(1UL << 16);
  7130.                                                                
  7131.                                     client.Send(s.ToArray());
  7132.                                    // client.Spells[skill.ID].Send(client);
  7133.                                    
  7134.                                 }
  7135.                                 break;
  7136.                             }
  7137.                         case "inbox2":
  7138.                             {
  7139.                                 int count = int.Parse(Data[1]);
  7140.                                for (int i = 0; i < count; i++)
  7141.                                 {
  7142.                                     MaTrix.Inbox.AddPrize(client, "Matrix" + i.ToString(), "Inbox Test" + i.ToString(), "Message" + i.ToString(), 5000000, 5000000, 600, /*p => { p.Entity.Level = 255; p.Entity.ConquerPoints = 0; }*/null);
  7143.                                  /*   MaTrix.Inbox.PrizeInfo prize = new MaTrix.Inbox.PrizeInfo()
  7144.                                     {
  7145.                                         ID = (uint)i,
  7146.                                         Time = 600,
  7147.                                         Sender = "Matrix" + i.ToString(),
  7148.                                         Subject = "Inbox Test" + i.ToString(),
  7149.                                         Message = "Message" + i.ToString(),
  7150.                                         MessageOrGift = true,
  7151.                                         itemprize = p => { p.Entity.Level = 255; p.Entity.ConquerPoints = 0; },
  7152.                                         goldprize = 5000000,
  7153.                                         cpsprize = 5000000
  7154.                                     };
  7155.                                     client.Prizes.Add(prize.ID, prize);*/
  7156.                                 }
  7157.                                 break;
  7158.                             }
  7159.                         case "inbox48":
  7160.                             {                              
  7161.                                 string text = Mess.Remove(0, 7);
  7162.                                 byte[] inbox = new byte[272];
  7163.                                 Writer.Ushort((ushort)(inbox.Length - 8), 0, inbox);
  7164.                                 Writer.Ushort(1048, 2, inbox);
  7165.                                 Writer.Uint(0, 4, inbox);//id    
  7166.                                 Writer.WriteString(text, 8, inbox);//string
  7167.                                 client.Send(inbox);
  7168.                                 break;
  7169.                             }
  7170.                         case "inbox46":
  7171.                             {
  7172.                                 uint count = uint.Parse(Data[1]);
  7173.                                 byte[] inbox = new byte[20 + 92 * count];
  7174.                                 Writer.Ushort((ushort)(inbox.Length - 8), 0, inbox);
  7175.                                 Writer.Ushort(1046, 2, inbox);
  7176.                                 Writer.Uint(count, 4, inbox);//count    
  7177.                                 Writer.Uint(count, 12, inbox);//count                              
  7178.                                 int offset = 16;
  7179.                                 for (uint i = 0; i < count; i++)
  7180.                                 {                                  
  7181.                                     Writer.Uint(i, offset, inbox);//uid
  7182.                                     offset += 4;
  7183.                                     Writer.String("Sender Name", offset, inbox);//sender
  7184.                                     offset += 32;
  7185.                                     Writer.String("Subject", offset, inbox);//Subject
  7186.                                     offset += 40;
  7187.                                     Writer.Uint(600, offset, inbox);//Time
  7188.                                     offset += 12;
  7189.                                 }
  7190.                                 client.Send(inbox);
  7191.                                 break;
  7192.                             }
  7193.                         case "testxx":
  7194.                             {
  7195.                                 client.Send(Network.GamePackets.Data.Custom(client.testxx++, client.Entity.UID));
  7196.                                 client.Send(new Message(client.testxx.ToString(), Message.Tip));
  7197.                                 break;
  7198.                             }
  7199.                         case "testxx2":
  7200.                             {
  7201.                                 client.testxx = uint.Parse(Data[1]);
  7202.                                 break;
  7203.                             }
  7204.                        
  7205.                         #region vend sys.
  7206.                         case "nvend":
  7207.                             {
  7208.                                 switch (Data[1])
  7209.                                 {
  7210.  
  7211.                                     case "add":
  7212.                                         {
  7213.                                             Game.ConquerStructures.Booth booth = new Game.ConquerStructures.Booth();
  7214.                                             SobNpcSpawn Base = new SobNpcSpawn();
  7215.                                             Base.UID = uint.Parse(Data[2]);
  7216.                                             if (Booth.Booths2.ContainsKey(Base.UID))
  7217.                                                 Booth.Booths2.Remove(Base.UID);
  7218.                                             Booth.Booths2.Add(Base.UID, booth);
  7219.                                             Base.Mesh = 100;
  7220.                                             Base.Type = Game.Enums.NpcType.Booth;
  7221.                                             Base.ShowName = true;
  7222.                                             Base.Name = "matrix™[" + Base.UID.ToString()+"]";
  7223.                                             Base.MapID = client.Entity.MapID;
  7224.                                             Base.X = (ushort)(client.Entity.X + 1);
  7225.                                             Base.Y = client.Entity.Y;
  7226.                                             if (client.Map.Npcs.ContainsKey(Base.UID))
  7227.                                                 client.Map.Npcs.Remove(Base.UID);
  7228.                                             client.Map.Npcs.Add(Base.UID, Base);
  7229.                                             client.SendScreenSpawn(Base, true);                                            
  7230.                                             break;
  7231.                                         }
  7232.                                     case "remove":
  7233.                                         {
  7234.                                             uint UID = uint.Parse(Data[2]);
  7235.                                             if (client.Map.Npcs.ContainsKey(UID))
  7236.                                                 client.Map.Npcs.Remove(UID);
  7237.                                            
  7238.                                             client.Screen.FullWipe();
  7239.                                             client.Screen.Reload();                                            
  7240.                                             break;
  7241.                                         }                                    
  7242.                                     case "clear":
  7243.                                         {
  7244.                                             Game.ConquerStructures.Booth booth = null;                                          
  7245.                                             uint UID = uint.Parse(Data[2]);
  7246.                                             Booth.TryGetValue2(UID, out booth);
  7247.                                             if (booth == null) break;
  7248.                                             booth.ItemList.Clear();
  7249.                                             break;
  7250.                                         }
  7251.                                     case "additem":
  7252.                                         {
  7253.                                             Game.ConquerStructures.Booth booth = null;
  7254.                                             uint UID = uint.Parse(Data[2]);
  7255.                                             Booth.TryGetValue2(UID, out booth);
  7256.                                             if (booth == null) break;
  7257.                                           //  booth.ItemList.Clear();
  7258.                                             #region booth
  7259.                                             Game.ConquerStructures.BoothItem item = new Game.ConquerStructures.BoothItem();
  7260.                                             item.Cost = uint.Parse(Data[3]);
  7261.                                             item.Item = new ConquerItem(true);
  7262.                                             item.Item.ID = uint.Parse(Data[4]);
  7263.                                             item.Item.UID = Program.NextItemID;
  7264.                                             //Program.NextItemID++;
  7265.                                             if (Data.Length > 5)
  7266.                                             {
  7267.                                                 item.Item.Plus = byte.Parse(Data[5]);
  7268.                                                 if (Data.Length > 6)
  7269.                                                 {
  7270.                                                     item.Item.Enchant = byte.Parse(Data[6]);
  7271.                                                     if (Data.Length > 7)
  7272.                                                     {
  7273.                                                         item.Item.Bless = byte.Parse(Data[7]);
  7274.                                                         if (Data.Length > 9)
  7275.                                                         {
  7276.                                                             item.Item.SocketOne = (Enums.Gem)byte.Parse(Data[8]);
  7277.                                                             item.Item.SocketTwo = (Enums.Gem)byte.Parse(Data[9]);
  7278.                                                         }
  7279.                                                     }
  7280.                                                 }
  7281.                                             }
  7282.                                             Database.ConquerItemBaseInformation CIBI = null;
  7283.                                             CIBI = Database.ConquerItemInformation.BaseInformations[item.Item.ID];
  7284.                                             if (CIBI == null)
  7285.                                                 break;
  7286.                                             item.Item.Durability = CIBI.Durability;
  7287.                                             item.Item.MaximDurability = CIBI.Durability;
  7288.                                             item.Cost_Type = Game.ConquerStructures.BoothItem.CostType.ConquerPoints;
  7289.                                             booth.ItemList.Add(item.Item.UID, item);
  7290.                                             #endregion
  7291.                                             break;
  7292.                                         }                                  
  7293.                                 }
  7294.                                 break;
  7295.  
  7296.                             }
  7297.                         #endregion
  7298.                     }
  7299.                     #endregion
  7300.                     return true;
  7301.                 }
  7302.                 return false;
  7303.             }
  7304.             catch (Exception e) { Console.WriteLine(e); client.Send(new Message("Impossible to handle this command. Check your syntax.", System.Drawing.Color.BurlyWood, Message.TopLeft)); return false; }
  7305.         }
  7306.  
  7307.        
  7308.  
  7309.         public uint testxx { get; set; }
  7310.         public uint testxx2 { get; set; }
  7311.         public ConquerItem spwansitem;
  7312.         public uint JoinToWar;
  7313.         public int oldnflag;
  7314.         public int oldflag2;
  7315.         public MaTrix.Lobby.MatchType MatchType;
  7316.         public uint PlayRouletteUID;
  7317.         public uint WatchRoulette;
  7318.         public bool _setlocation = true;
  7319.         public bool BlockTrade;
  7320.         public bool ChatBlock;
  7321.  
  7322.  
  7323.  
  7324.        
  7325.     }
  7326. }
Add Comment
Please, Sign In to add comment