Beispiel #1
0
 public void Teleport(ushort MapID, ushort X, ushort Y)
 {
     if (EntityFlag == EntityFlag.Player)
     {
         if (!Database.MapsTable.MapInformations.ContainsKey(MapID))
             return;
         if (EntityFlag == EntityFlag.Player)
         {
             if (Owner.Companion != null)
             {
                 Owner.Map.RemoveEntity(Owner.Companion);
                 Data data = new Data(true);
                 data.UID = Owner.Companion.UID;
                 data.ID = Network.GamePackets.Data.RemoveEntity;
                 Owner.Companion.MonsterInfo.SendScreen(data);
                 Owner.Companion = null;
             }
         }
         if (MapID == this.MapID)
         {
             Teleport(X, Y);
             return;
         }
         this.X = X;
         this.Y = Y;
         this.PreviousMapID = this.MapID;
         this.MapID = MapID;
         Network.GamePackets.Data Data = new Network.GamePackets.Data(true);
         Data.UID = UID;
         Data.ID = Network.GamePackets.Data.Teleport;
         Data.dwParam = Database.MapsTable.MapInformations[MapID].BaseID;
         Data.wParam1 = X;
         Data.wParam2 = Y;
         Owner.Send(Data);
         Owner.Send(new MapStatus() { BaseID = Owner.Map.BaseID, ID = Owner.Map.ID, Status = Database.MapsTable.MapInformations[Owner.Map.ID].Status });
         if (!Owner.Equipment.Free(12))
             if (Owner.Map.ID == 1036 && Owner.Equipment.TryGetItem((byte)12).Plus < 6)
                 RemoveFlag(Network.GamePackets.Update.Flags.Ride);
     }
 }
Beispiel #2
0
        public void Teleport(ushort MapID, ushort DynamicID, ushort X, ushort Y)
        {
            if (EntityFlag == EntityFlag.Player)
            {
                if (!Database.DMaps.MapPaths.ContainsKey(MapID))
                    return;

                this.PrevX = this.X;
                this.PrevY = this.Y;
                this.X = X;
                this.Y = Y;
                this.PreviousMapID = this.MapID;
                this.MapID = DynamicID;
                Network.GamePackets.Data Data = new Network.GamePackets.Data(true);
                Data.UID = UID;
                Data.ID = Network.GamePackets.Data.Teleport;
                Data.dwParam = MapID;
                Data.wParam1 = X;
                Data.wParam2 = Y;
                Owner.Send(Data);
                Owner.Send(new MapStatus() { BaseID = Owner.Map.BaseID, ID = Owner.Map.ID, Status = Database.MapsTable.MapInformations[Owner.Map.ID].Status });
                if (!Owner.Equipment.Free(12))
                    if (Owner.Map.ID == 1036 && Owner.Equipment.TryGetItem((byte)12).Plus < 6)
                        RemoveFlag(Network.GamePackets.Update.Flags.Ride);
            }
        }
Beispiel #3
0
 public void Shift(ushort X, ushort Y)
 {
     if (EntityFlag == EntityFlag.Player)
     {
         if (!Database.MapsTable.MapInformations.ContainsKey(MapID))
             return;
         this.X = X;
         this.Y = Y;
         Network.GamePackets.Data Data = new Network.GamePackets.Data(true);
         Data.UID = UID;
         Data.ID = Network.GamePackets.Data.FlashStep;
         Data.dwParam = MapID;
         Data.wParam1 = X;
         Data.wParam2 = Y;
         Owner.SendScreen(Data, true);
         Owner.Screen.Reload(null);
     }
 }
Beispiel #4
0
 public void Teleport(ushort X, ushort Y)
 {
     if (EntityFlag == EntityFlag.Player)
     {
         if (!Database.MapsTable.MapInformations.ContainsKey(MapID))
             return;
         this.X = X;
         this.Y = Y;
         Network.GamePackets.Data Data = new Network.GamePackets.Data(true);
         Data.UID = UID;
         Data.ID = Network.GamePackets.Data.Teleport;
         Data.dwParam = Database.MapsTable.MapInformations[MapID].BaseID;
         Data.wParam1 = X;
         Data.wParam2 = Y;
         Owner.Send(Data);
     }
 }
Beispiel #5
0
        static void PlayerGroundMovment(GroundMovement groundMovement, Client.GameState client)
        {
            client.Entity.Action = Conquer_Online_Server.Game.Enums.ConquerAction.None;
            client.Attackable = true;
            client.Mining = false;
            if (client.Entity.ContainsFlag(Update.Flags.CastPray))
            {
                client.Entity.RemoveFlag(Update.Flags.CastPray);
                foreach (var Client in client.Prayers)
                {
                    if (Client.Entity.ContainsFlag(Update.Flags.Praying))
                    {
                        Client.Entity.RemoveFlag(Update.Flags.Praying);
                    }
                }
                client.Prayers.Clear();
            }
            if (client.Entity.ContainsFlag(Update.Flags.Praying))
            {
                client.Entity.RemoveFlag(Update.Flags.Praying);
                if (client.PrayLead != null)
                    client.PrayLead.Prayers.Remove(client);
                client.PrayLead = null;
            }
            if (client.Entity.AttackPacket != null)
            {
                client.Entity.AttackPacket = null;
            }
            if (client.Entity.ContainsFlag(Update.Flags.Ride))
                client.Entity.Vigor -= 1;
            client.Entity.PX = client.Entity.X;
            client.Entity.PY = client.Entity.Y;

            if ((byte)groundMovement.Direction > 7)
                groundMovement.Direction = (Conquer_Online_Server.Game.Enums.ConquerAngle)((byte)groundMovement.Direction % 8);

            client.Entity.Move(groundMovement.Direction);

            if (groundMovement.GroundMovementType == GroundMovement.TwoCoordonates)
                client.Entity.Move(groundMovement.Direction);

            client.SendScreen(groundMovement, true);
            client.Screen.Reload(groundMovement);

            if (client.Entity.InteractionInProgress)
            {
                if (!client.Entity.InteractionSet)
                {
                    if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                    {
                        Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];
                        if (ch.Entity.InteractionInProgress && ch.Entity.InteractionWith == client.Entity.UID)
                        {
                            if (client.Entity.InteractionX == client.Entity.X && client.Entity.Y == client.Entity.InteractionY)
                            {
                                if (client.Entity.X == ch.Entity.X && client.Entity.Y == ch.Entity.Y)
                                {
                                    Network.GamePackets.Attack atac = new Network.GamePackets.Attack(true);
                                    atac.Attacker = ch.Entity.UID;
                                    atac.Attacked = client.Entity.UID;
                                    atac.X = ch.Entity.X;
                                    atac.Y = ch.Entity.Y;
                                    atac.Damage = client.Entity.InteractionType;
                                    atac.AttackType = 47;
                                    ch.Send(atac);

                                    atac.AttackType = 49;
                                    atac.Attacker = client.Entity.UID;
                                    atac.Attacked = ch.Entity.UID;
                                    client.SendScreen(atac, true);

                                    atac.Attacker = ch.Entity.UID;
                                    atac.Attacked = client.Entity.UID;
                                    client.SendScreen(atac, true);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (client.Entity.Body == 1003 || client.Entity.Body == 1004)
                    {
                        if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                        {
                            Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];

                            ch.Entity.Facing = groundMovement.Direction;
                            ch.Entity.Move(groundMovement.Direction);
                            Network.GamePackets.Data general = new Network.GamePackets.Data(true);
                            general.UID = ch.Entity.UID;
                            general.wParam1 = ch.Entity.X;
                            general.wParam2 = ch.Entity.Y;
                            general.ID = 0x9c;
                            ch.Send(general.ToArray());
                            ch.Screen.Reload(null);
                        }
                    }
                }
            }
        }
        static void PlayerGroundMovment(GroundMovement groundMovement, Client.GameState client)
        {
            client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
            client.Attackable = true;
            client.Mining = false;

            if (client.Entity.ContainsFlag3(Network.GamePackets.Update.Flags3.MagicDefender))
            {

                client.Entity.MagicDefenderTime = 0;
                client.Entity.MagicDefenderIncrease = 0;
                client.Entity.RemoveFlag3(Network.GamePackets.Update.Flags3.MagicDefender);
                SyncPacket packet = new SyncPacket
                {
                    Identifier = client.Entity.UID,
                    Count = 2,
                    Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                    StatusFlag1 = (ulong)client.Entity.StatusFlag,
                    StatusFlag2 = (ulong)client.Entity.StatusFlag2,
                    Unknown1 = 0x31,
                    StatusFlagOffset = 0x80,
                    Time = 0,
                    Value = 0,
                    Level = 0
                };
                client.Entity.Owner.Send((byte[])packet);
                foreach (var Client in client.MagicDef)
                {
                    if (Client.Entity.ContainsFlag2(Update.Flags2.kimo4))
                    {
                        Client.Entity.RemoveFlag2(Update.Flags2.kimo4);
                    }
                }
                client.MagicDef.Clear();
            }
            if (client.Entity.ContainsFlag(Update.Flags.CastPray))
            {
                client.Entity.RemoveFlag(Update.Flags.CastPray);
                foreach (var Client in client.Prayers)
                {
                    if (Client.Entity.ContainsFlag(Update.Flags.Praying))
                    {
                        Client.Entity.RemoveFlag(Update.Flags.Praying);
                    }
                }
                client.Prayers.Clear();
            }
            if (client.Entity.ContainsFlag(Update.Flags.Praying))
            {
                client.Entity.RemoveFlag(Update.Flags.Praying);
                if (client.PrayLead != null)
                    client.PrayLead.Prayers.Remove(client);
                client.PrayLead = null;
            }
            if (client.Entity.AttackPacket != null)
            {
                client.Entity.AttackPacket = null;
            }
            if (client.Entity.ContainsFlag(Update.Flags.Ride))
                client.Entity.Vigor -= 1;
            client.Entity.PX = client.Entity.X;
            client.Entity.PY = client.Entity.Y;

            if ((byte)groundMovement.Direction > 7)
                groundMovement.Direction = (PhoenixProject.Game.Enums.ConquerAngle)((byte)groundMovement.Direction % 8);

            client.Entity.Move(groundMovement.Direction);

            if (groundMovement.GroundMovementType == GroundMovement.TwoCoordonates)
                client.Entity.Move(groundMovement.Direction);

            client.SendScreen(groundMovement, true);
            client.Screen.Reload(groundMovement);
            if (client.Entity.MapID == 1002)
            {
                if (client.Entity.X == 436 && client.Entity.Y == 444)//stig
                {
                    if (!client.Entity.ContainsFlag(Update.Flags.Ghost))
                    {
                        if (client.Entity.EntityFlag == PhoenixProject.Game.EntityFlag.Player && client.Entity.MaxHitpoints != client.Entity.Hitpoints)
                        {
                            SpellUse suse = new SpellUse(true);
                            suse.Attacker = client.Entity.UID;
                            suse.SpellID = 1195;
                            suse.SpellLevel = 0;
                            suse.X = 436;
                            suse.Y = 444;
                            uint Hp = (client.Entity.MaxHitpoints - client.Entity.Hitpoints);
                            client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                            suse.Targets.Add(client.Entity.UID, Hp);
                            client.SendScreen(suse, true);
                            client.Send(new Message("Your HP Now : " + client.Entity.Hitpoints + "!", System.Drawing.Color.Red, Message.Talk));
                        }
                    }
                }

            }
            if (client.Entity.MapID == 1005)
            {
                if (client.Entity.X == 42 && client.Entity.Y == 51)//stig
                {
                    if (!client.Entity.ContainsFlag(Update.Flags.Stigma) && !client.Entity.ContainsFlag(Update.Flags.Ghost))
                    {
                        SpellUse suse = new SpellUse(true);
                        suse.Attacker = client.Entity.UID;
                        suse.SpellID = 1095;
                        suse.SpellLevel = 3;
                        suse.X = 42;
                        suse.Y = 51;
                        suse.Targets.Add(client.Entity.UID, 0);
                        client.Entity.AddFlag(Update.Flags.Stigma);
                        client.Entity.StigmaStamp = Time32.Now;
                        client.Entity.StigmaIncrease = 25;
                        client.Entity.StigmaTime = 20;
                        client.SendScreen(suse, true);
                        if (client.Entity.EntityFlag == PhoenixProject.Game.EntityFlag.Player)
                            client.Send(ServerBase.Constants.Stigma(25, 20));
                    }
                }
                else
                {
                    if (client.Entity.X == 42 && client.Entity.Y == 48)//rev
                    {
                        if (client.Entity.ContainsFlag(Update.Flags.Ghost))
                        {
                            SpellUse suse = new SpellUse(true);
                            suse.Attacker = client.Entity.UID;
                            suse.SpellID = 1050;
                            suse.SpellLevel = 0;
                            suse.X = 42;
                            suse.Y = 48;
                            suse.Targets.Add(client.Entity.UID, 0);
                            client.SendScreen(suse, true);
                            client.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
                            client.ReviveStamp = Time32.Now;
                            client.Attackable = false;
                            client.Entity.TransformationID = 0;
                            client.Entity.RemoveFlag(Update.Flags.Dead);
                            client.Entity.RemoveFlag(Update.Flags.Ghost);
                            client.Entity.Hitpoints = client.Entity.MaxHitpoints;
                            client.Entity.Ressurect();

                        }
                    }

                }
            }
            if (client.Entity.InteractionInProgress)
            {
                if (!client.Entity.InteractionSet)
                {
                    if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                    {
                        Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];
                        if (ch.Entity.InteractionInProgress && ch.Entity.InteractionWith == client.Entity.UID)
                        {
                            if (client.Entity.InteractionX == client.Entity.X && client.Entity.Y == client.Entity.InteractionY)
                            {
                                if (client.Entity.X == ch.Entity.X && client.Entity.Y == ch.Entity.Y)
                                {
                                    Network.GamePackets.Attack atac = new Network.GamePackets.Attack(true);
                                    atac.Attacker = ch.Entity.UID;
                                    atac.Attacked = client.Entity.UID;
                                    atac.X = ch.Entity.X;
                                    atac.Y = ch.Entity.Y;
                                    atac.Damage = client.Entity.InteractionType;
                                    atac.AttackType = 47;
                                    ch.Send(atac);

                                    atac.AttackType = 49;
                                    atac.Attacker = client.Entity.UID;
                                    atac.Attacked = ch.Entity.UID;
                                    client.SendScreen(atac, true);

                                    atac.Attacker = ch.Entity.UID;
                                    atac.Attacked = client.Entity.UID;
                                    client.SendScreen(atac, true);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (client.Entity.Body == 1003 || client.Entity.Body == 1004)
                    {
                        if (ServerBase.Kernel.GamePool.ContainsKey(client.Entity.InteractionWith))
                        {
                            Client.GameState ch = ServerBase.Kernel.GamePool[client.Entity.InteractionWith];

                            ch.Entity.Facing = groundMovement.Direction;
                            ch.Entity.Move(groundMovement.Direction);
                            Network.GamePackets.Data general = new Network.GamePackets.Data(true);
                            general.UID = ch.Entity.UID;
                            general.wParam1 = ch.Entity.X;
                            general.wParam2 = ch.Entity.Y;
                            general.ID = 0x9c;
                            ch.Send(general.ToArray());
                            ch.Screen.Reload(null);
                        }
                    }
                }
            }
            client.Entity.MapRegion = Region.Region.FindRegion((uint)client.Map.BaseID, client.Entity.X, client.Entity.Y);
        }
        public void Teleportxx(ushort X, ushort Y)
        {
            if (EntityFlag == EntityFlag.Player)
            {

                if (!Database.MapsTable.MapInformations.ContainsKey(MapID))
                    return;
                if (Owner.Entity.ContainsFlag3(Network.GamePackets.Update.Flags3.MagicDefender))
                {

                    Owner.Entity.MagicDefenderTime = 0;
                    Owner.Entity.MagicDefenderIncrease = 0;
                    Owner.Entity.RemoveFlag3(Network.GamePackets.Update.Flags3.MagicDefender);
                    UpdateEffects(true);
                    SyncPacket packet = new SyncPacket
                    {
                        Identifier = Owner.Entity.UID,
                        Count = 2,
                        Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                        StatusFlag1 = (ulong)Owner.Entity.StatusFlag,
                        StatusFlag2 = (ulong)Owner.Entity.StatusFlag2,
                        Unknown1 = 0x31,
                        StatusFlagOffset = 0x80,
                        Time = 0,
                        Value = 0,
                        Level = 0
                    };
                    Owner.Entity.Owner.Send((byte[])packet);
                    foreach (var Client in Owner.MagicDef)
                    {
                        if (Client.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.kimo4))
                        {
                            Client.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.kimo4);
                        }
                    }
                    Owner.MagicDef.Clear();
                }
                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.CastPray))
                {
                    Owner.Entity.RemoveFlag(Network.GamePackets.Update.Flags.CastPray);

                    foreach (var Client in Owner.Prayers)
                    {
                        if (Client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Praying))
                        {
                            Client.Entity.RemoveFlag(Network.GamePackets.Update.Flags.Praying);
                        }
                    }
                    Owner.Prayers.Clear();
                }
                this.X = X;
                this.Y = Y;
                Network.GamePackets.Data Data = new Network.GamePackets.Data(true);
                Data.UID = UID;
                Data.ID = Network.GamePackets.Data.Jump;
                Data.dwParam = (uint)Database.MapsTable.MapInformations[MapID].BaseID;
                Data.wParam1 = X;
                Data.wParam2 = Y;
                Owner.Send(Data);
            }
        }
Beispiel #8
0
 public void Remove()
 {
     Network.GamePackets.Data data = new Network.GamePackets.Data(true);
     data.UID = Base.UID;
     data.ID = Network.GamePackets.Data.RemoveEntity;
     Owner.SendScreen(data, true);
 }
        public void TeleportHouse(ulong MapID, ushort X, ushort Y)
        {
            if (EntityFlag == EntityFlag.Player)
            {

                if (!ServerBase.Kernel.Maps.ContainsKey(MapID))
                    return;
                if (Owner.Entity.ContainsFlag3(Network.GamePackets.Update.Flags3.MagicDefender))
                {

                    Owner.Entity.MagicDefenderTime = 0;
                    Owner.Entity.MagicDefenderIncrease = 0;
                    Owner.Entity.RemoveFlag3(Network.GamePackets.Update.Flags3.MagicDefender);
                    UpdateEffects(true);
                    SyncPacket packet = new SyncPacket
                    {
                        Identifier = Owner.Entity.UID,
                        Count = 2,
                        Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                        StatusFlag1 = (ulong)Owner.Entity.StatusFlag,
                        StatusFlag2 = (ulong)Owner.Entity.StatusFlag2,
                        Unknown1 = 0x31,
                        StatusFlagOffset = 0x80,
                        Time = 0,
                        Value = 0,
                        Level = 0
                    };
                    Owner.Entity.Owner.Send((byte[])packet);
                    foreach (var Client in Owner.MagicDef)
                    {
                        if (Client.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.kimo4))
                        {
                            Client.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.kimo4);
                        }
                    }
                    Owner.MagicDef.Clear();
                }
                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.CastPray))
                {
                    Owner.Entity.RemoveFlag(Network.GamePackets.Update.Flags.CastPray);

                    foreach (var Client in Owner.Prayers)
                    {
                        if (Client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Praying))
                        {
                            Client.Entity.RemoveFlag(Network.GamePackets.Update.Flags.Praying);
                        }
                    }
                    Owner.Prayers.Clear();
                }
                if (EntityFlag == EntityFlag.Player)
                {
                    if (Owner.Companion != null)
                    {
                        Owner.Map.RemoveEntity(Owner.Companion);
                        Data data = new Data(true);
                        data.UID = Owner.Companion.UID;
                        data.ID = Network.GamePackets.Data.RemoveEntity;
                        Owner.Companion.MonsterInfo.SendScreen(data);
                        Owner.Companion = null;
                    }
                }
                if (MapID == this.MapID)
                {
                    Teleport(X, Y);
                    return;
                }
                this.X = X;
                this.Y = Y;
                PX = 0;
                PY = 0;
                this.PreviousMapID = this.MapID;
                this.MapID = MapID;
                Network.GamePackets.Data Data = new Network.GamePackets.Data(true);
                Data.UID = UID;
                Data.ID = Network.GamePackets.Data.Teleport;
                Data.dwParam = (uint)ServerBase.Kernel.Maps[UID].BaseID;
                Data.wParam1 = X;
                Data.wParam2 = Y;
                Owner.Send(Data);
                Owner.Send(new MapStatus() { BaseID = (ushort)Database.MapsTable.MapInformations[Owner.Map.ID].BaseID, ID = (uint)Owner.Map.ID, Status = Database.DMapsTablesss.HouseInfo[Owner.Map.ID].Status, Weather = Database.MapsTable.MapInformations[Owner.Map.ID].Weather });
                Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                weather.WeatherType = (uint)Program.WeatherType;
                weather.Intensity = 100;
                weather.Appearence = 2;
                weather.Direction = 4;
                Owner.Send(weather);
                Owner.Entity.MapRegion = Region.Region.FindRegion((uint)Owner.Map.BaseID, Owner.Entity.X, Owner.Entity.Y);
            }
        }
        public void Teleport(ulong MapID, ulong DynamicID, ushort X, ushort Y)
        {
            if (EntityFlag == EntityFlag.Player)
            {

                if (!Database.DMaps.MapPaths.ContainsKey(MapID))
                {
                    Console.WriteLine(" ss ");
                    return;
                }
                if (Owner.Entity.ContainsFlag3(Network.GamePackets.Update.Flags3.MagicDefender))
                {

                    Owner.Entity.MagicDefenderTime = 0;
                    Owner.Entity.MagicDefenderIncrease = 0;
                    Owner.Entity.RemoveFlag3(Network.GamePackets.Update.Flags3.MagicDefender);
                    UpdateEffects(true);
                    SyncPacket packet = new SyncPacket
                    {
                        Identifier = Owner.Entity.UID,
                        Count = 2,
                        Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                        StatusFlag1 = (ulong)Owner.Entity.StatusFlag,
                        StatusFlag2 = (ulong)Owner.Entity.StatusFlag2,
                        Unknown1 = 0x31,
                        StatusFlagOffset = 0x80,
                        Time = 0,
                        Value = 0,
                        Level = 0
                    };
                    Owner.Entity.Owner.Send((byte[])packet);
                    foreach (var Client in Owner.MagicDef)
                    {
                        if (Client.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.kimo4))
                        {
                            Client.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.kimo4);
                        }
                    }
                    Owner.MagicDef.Clear();
                }
                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.CastPray))
                {
                    Owner.Entity.RemoveFlag(Network.GamePackets.Update.Flags.CastPray);

                    foreach (var Client in Owner.Prayers)
                    {
                        if (Client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Praying))
                        {
                            Client.Entity.RemoveFlag(Network.GamePackets.Update.Flags.Praying);
                        }
                    }
                    Owner.Prayers.Clear();
                }
                this.PrevX = this.X;
                this.PrevY = this.Y;
                this.X = X;
                this.Y = Y;
                this.PreviousMapID = this.MapID;
                this.MapID = DynamicID;
                Network.GamePackets.Data Data = new Network.GamePackets.Data(true);
                Data.UID = UID;
                Data.ID = Network.GamePackets.Data.Teleport;
                Data.dwParam = (ushort)MapID;
                Data.wParam1 = X;
                Data.wParam2 = Y;
                Owner.Send(Data);
                Owner.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
                Owner.ReviveStamp = Time32.Now;
                Owner.Attackable = false;
                Owner.Send(new MapStatus() { BaseID = (ushort)Database.MapsTable.MapInformations[Owner.Map.ID].BaseID, ID = (uint)Owner.Map.ID, Status = Database.MapsTable.MapInformations[Owner.Map.ID].Status, Weather = Database.MapsTable.MapInformations[Owner.Map.ID].Weather });
                Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                weather.WeatherType = (uint)Program.WeatherType;
                weather.Intensity = 100;
                weather.Appearence = 2;
                weather.Direction = 4;
                Owner.Send(weather);
                Owner.Entity.MapRegion = Region.Region.FindRegion((uint)Owner.Map.BaseID, Owner.Entity.X, Owner.Entity.Y);
            }
        }
        public void Teleport(ulong MapID, ushort X, ushort Y)
        {
            if (EntityFlag == EntityFlag.Player)
            {

                if (Owner.WatchingGroup != null)
                {
                    PhoenixProject.Game.ConquerStructures.Arena.QualifyEngine.DoLeave(Owner);
                }
                if (Owner.QualifierGroup != null)
                {
                    PhoenixProject.Game.ConquerStructures.Arena.QualifyEngine.DoQuit(Owner);
                    //Owner.ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.NotSignedUp;
                }

                if (!Database.MapsTable.MapInformations.ContainsKey(MapID))
                {
                    if (MapID != UID)
                    {

                        return;
                    }
                }
                if (Owner.Entity.ContainsFlag3(Network.GamePackets.Update.Flags3.MagicDefender))
                {

                    Owner.Entity.MagicDefenderTime = 0;
                    Owner.Entity.MagicDefenderIncrease = 0;
                    Owner.Entity.RemoveFlag3(Network.GamePackets.Update.Flags3.MagicDefender);
                    UpdateEffects(true);
                    SyncPacket packet = new SyncPacket
                    {
                        Identifier = Owner.Entity.UID,
                        Count = 2,
                        Type = PhoenixProject.Network.GamePackets.SyncPacket.SyncType.StatusFlag,
                        StatusFlag1 = (ulong)Owner.Entity.StatusFlag,
                        StatusFlag2 = (ulong)Owner.Entity.StatusFlag2,
                        Unknown1 = 0x31,
                        StatusFlagOffset = 0x80,
                        Time = 0,
                        Value = 0,
                        Level = 0
                    };
                    Owner.Entity.Owner.Send((byte[])packet);
                    foreach (var Client in Owner.MagicDef)
                    {
                        if (Client.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.kimo4))
                        {
                            Client.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.kimo4);
                        }
                    }
                    Owner.MagicDef.Clear();
                }
                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.CastPray))
                {
                    Owner.Entity.RemoveFlag(Network.GamePackets.Update.Flags.CastPray);

                    foreach (var Client in Owner.Prayers)
                    {
                        if (Client.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Praying))
                        {
                            Client.Entity.RemoveFlag(Network.GamePackets.Update.Flags.Praying);
                        }
                    }
                    Owner.Prayers.Clear();
                }

                if (EntityFlag == EntityFlag.Player)
                {
                    if (Owner.Companion != null)
                    {
                        Owner.Map.RemoveEntity(Owner.Companion);
                        Data data = new Data(true);
                        data.UID = Owner.Companion.UID;
                        data.ID = Network.GamePackets.Data.RemoveEntity;
                        Owner.Companion.MonsterInfo.SendScreen(data);
                        Owner.Companion = null;
                    }
                }
                if (MapID == this.MapID)
                {
                    Teleport(X, Y);
                    return;
                }
                this.X = X;
                this.Y = Y;
                this.PreviousMapID = this.MapID;
                this.MapID = MapID;
                Network.GamePackets.Data Data = new Network.GamePackets.Data(true);
                Data.UID = UID;
                Data.ID = Network.GamePackets.Data.Teleport;
                Data.dwParam = (uint)Database.MapsTable.MapInformations[MapID].BaseID;
                Data.wParam1 = X;
                Data.wParam2 = Y;
                Owner.Send(Data);
                Owner.Send(new MapStatus() { BaseID = (ushort)Database.MapsTable.MapInformations[Owner.Map.ID].BaseID, ID = (uint)Owner.Map.ID, Status = Database.MapsTable.MapInformations[Owner.Map.ID].Status, Weather = Database.MapsTable.MapInformations[Owner.Map.ID].Weather });
                Network.GamePackets.Weather weather = new Network.GamePackets.Weather(true);
                weather.WeatherType = (uint)Program.WeatherType;
                weather.Intensity = 100;
                weather.Appearence = 2;
                weather.Direction = 4;
                Owner.Send(weather);
                Owner.Entity.Action = PhoenixProject.Game.Enums.ConquerAction.None;
                Owner.ReviveStamp = Time32.Now;
                Owner.Attackable = false;
                Owner.Entity.MapRegion = Region.Region.FindRegion((uint)Owner.Map.BaseID, Owner.Entity.X, Owner.Entity.Y);
            }
        }
        public void _timerCallBack(object jjjhh, System.Timers.ElapsedEventArgs arg)
        {
            try
            {
                if (Owner.Socket ==null ||!Owner.Socket.Connected || Owner.Entity == null)
                {
                    if (Owner != null)
                    {
                        if (Owner.Screen != null)
                        {
                            if (Owner.Screen.MyTimer != null)
                            {

                                Owner.Screen.MyTimer.Close();
                                Owner.Screen.MyTimer.Dispose();
                            }
                        }
                    }
                    return;
                }
                try
                {
                    while (OnAdd.Count != 0)
                        Objects.Add(OnAdd.Dequeue());
                    while (OnRemove.Count != 0)
                        Objects.Remove(OnRemove.Dequeue());
                }
                catch
                {
                    // Console.WriteLine(e.ToString());
                }
                #region Monsters
               // List<IMapObject> toRemove = new List<IMapObject>();
                if (Owner.Map.FreezeMonsters)
                    return;
                try
                {
                    for (int c = 0; c < Objects.Count; c++)
                    {
                        if (c >= Objects.Count)
                            break;
                        //List<IMapObject> list = new List<IMapObject>();
                        IMapObject obj = Objects[c];
                        if (obj != null)
                        {
                            if (obj.MapObjType == MapObjectType.SobNpc)
                            {
                                /*short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                if (distance <= monster.MonsterInfo.AttackRange)
                                {
                                    monster.MonsterInfo.LastMove = Time32.Now;
                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                }*/
                                Network.GamePackets.SobNpcSpawn item = obj as Network.GamePackets.SobNpcSpawn;
                                if (item.MapID == 2060)
                                {

                                    if (item.UID == 10011)
                                    {
                                        if (Game.Team.RedCapture)
                                        {
                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (_obj.MapObjType == MapObjectType.Player)
                                                    {
                                                        (_obj as Entity).Owner.Send(item);
                                                        (_obj as Entity).Owner.Screen.Remove(item);
                                                    }
                                                }
                                            }
                                            Owner.Map.Floor[item.X, item.Y, MapObjectType.SobNpc, null] = true;
                                            Remove(obj);
                                            //toRemove.Add(item);
                                        }
                                    }
                                    if (item.UID == 10021)
                                    {
                                        if (Game.Team.RedCapture)
                                        {

                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (Owner != null)
                                                    {
                                                        if (Owner.CaptureR && Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.CaryingFlag))
                                                        {
                                                            short distance = Kernel.GetDistance(item.X, item.Y, Owner.Entity.X, Owner.Entity.Y);
                                                            if (distance <= 5)
                                                            {
                                                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                                                                Data datas = new Data(true);
                                                                datas.UID = Owner.Entity.UID;
                                                                datas.ID = 116;
                                                                datas.dwParam = (uint)3145;
                                                                Owner.Send(datas);
                                                                Game.Team.RedCapture = false;
                                                                Game.Team.RScore += 1;
                                                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("Congratulations! " + Owner.Entity.Name + " scored for the Red team. RedScore: " + Game.Team.RScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                                                                if (Game.Team.RScore >= 10)
                                                                {
                                                                    Game.Team.ClaimRed();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (item.UID == 10022)
                                    {
                                        if (Game.Team.RedCapture)
                                        {

                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (Owner != null)
                                                    {
                                                        if (Owner.CaptureB && Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.CaryingFlag))
                                                        {
                                                            short distance = Kernel.GetDistance(item.X, item.Y, Owner.Entity.X, Owner.Entity.Y);
                                                            if (distance <= 5)
                                                            {
                                                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                                                                Game.Team.RedCapture = false;
                                                                Game.Team.BScore += 1;
                                                                Data datas = new Data(true);
                                                                datas.UID = Owner.Entity.UID;
                                                                datas.ID = 116;
                                                                datas.dwParam = (uint)3145;
                                                                Owner.Send(datas);
                                                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("Congratulations! " + Owner.Entity.Name + " scored for the Blue team. BlueScore: " + Game.Team.BScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                                                                if (Game.Team.BScore >= 10)
                                                                {
                                                                    Game.Team.ClaimBLUE();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (item.UID == 10023)
                                    {
                                        if (Game.Team.RedCapture)
                                        {

                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (Owner != null)
                                                    {
                                                        if (Owner.CaptureW && Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.CaryingFlag))
                                                        {
                                                            short distance = Kernel.GetDistance(item.X, item.Y, Owner.Entity.X, Owner.Entity.Y);
                                                            if (distance <= 5)
                                                            {
                                                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                                                                Game.Team.RedCapture = false;
                                                                Game.Team.WScore += 1;
                                                                Data datas = new Data(true);
                                                                datas.UID = Owner.Entity.UID;
                                                                datas.ID = 116;
                                                                datas.dwParam = (uint)3145;
                                                                Owner.Send(datas);
                                                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("Congratulations! " + Owner.Entity.Name + " scored for the White team. WhiteScore: " + Game.Team.WScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                                                                if (Game.Team.WScore >= 10)
                                                                {
                                                                    Game.Team.ClaimWhite();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (item.UID == 10024)
                                    {
                                        if (Game.Team.RedCapture)
                                        {

                                            foreach (Interfaces.IMapObject _obj in Objects)
                                            {
                                                if (_obj != null)
                                                {
                                                    if (Owner != null)
                                                    {
                                                        if (Owner.CaptureBL && Owner.Entity.ContainsFlag2(Network.GamePackets.Update.Flags2.CaryingFlag))
                                                        {
                                                            short distance = Kernel.GetDistance(item.X, item.Y, Owner.Entity.X, Owner.Entity.Y);
                                                            if (distance <= 5)
                                                            {
                                                                Owner.Entity.RemoveFlag2(Network.GamePackets.Update.Flags2.CaryingFlag);
                                                                Game.Team.RedCapture = false;
                                                                Game.Team.BLScore += 1;
                                                                Data datas = new Data(true);
                                                                datas.UID = Owner.Entity.UID;
                                                                datas.ID = 116;
                                                                datas.dwParam = (uint)3145;
                                                                Owner.Send(datas);
                                                                PhoenixProject.ServerBase.Kernel.SendWorldMessage(new Message("Congratulations! " + Owner.Entity.Name + " scored for the Black team. BlackScore: " + Game.Team.BLScore + "", System.Drawing.Color.Black, Message.Center), PhoenixProject.ServerBase.Kernel.GamePool.Values);
                                                                if (Game.Team.BLScore >= 10)
                                                                {
                                                                    Game.Team.ClaimBlack();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (obj.MapObjType == MapObjectType.Monster)
                            {
                                if (Owner != null)
                                {
                                    if (Owner.Map != null)
                                    {
                                        if (Owner.Map != null)
                                        {
                                            Entity monster = null;
                                            if (Objects[c] == null) continue;
                                            monster = Objects[c] as Game.Entity;
                                            if (monster == null) continue;
                                            #region Buffers
                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                                            {
                                                if (Time32.Now >= monster.StigmaStamp.AddSeconds(monster.StigmaTime))
                                                {
                                                    monster.StigmaTime = 0;
                                                    monster.StigmaIncrease = 0;
                                                    monster.RemoveFlag(Network.GamePackets.Update.Flags.Stigma);
                                                }
                                            }
                                            if (monster.BlackSpotTime2 > 0)
                                            {
                                                if (Time32.Now >= monster.BlackSpotTime.AddSeconds(monster.BlackSpotTime2))
                                                {
                                                    monster.BlackSpotTime2 = 0;
                                                    monster.BlackSpots = false;
                                                    BlackSpot spot = new BlackSpot
                                                    {
                                                        Remove = 1,
                                                        Identifier = monster.UID
                                                    };
                                                    Owner.Send(spot);
                                                }
                                                else
                                                {
                                                    BlackSpot spot = new BlackSpot
                                                    {
                                                        Remove = 0,
                                                        Identifier = monster.UID
                                                    };
                                                    Owner.Send(spot);
                                                }

                                            }
                                            else
                                            {
                                                BlackSpot spot = new BlackSpot
                                                {
                                                    Remove = 1,
                                                    Identifier = monster.UID
                                                };
                                                Owner.Send(spot);
                                            }

                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.Dodge))
                                            {
                                                if (Time32.Now >= monster.DodgeStamp.AddSeconds(monster.DodgeTime))
                                                {
                                                    monster.DodgeTime = 0;
                                                    monster.DodgeIncrease = 0;
                                                    monster.RemoveFlag(Network.GamePackets.Update.Flags.Dodge);
                                                }
                                            }
                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                            {
                                                if (Time32.Now >= monster.InvisibilityStamp.AddSeconds(monster.InvisibilityTime))
                                                {
                                                    monster.RemoveFlag(Network.GamePackets.Update.Flags.Invisibility);
                                                }
                                            }
                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.StarOfAccuracy))
                                            {
                                                if (monster.StarOfAccuracyTime != 0)
                                                {
                                                    if (Time32.Now >= monster.StarOfAccuracyStamp.AddSeconds(monster.StarOfAccuracyTime))
                                                    {
                                                        monster.RemoveFlag(Network.GamePackets.Update.Flags.StarOfAccuracy);
                                                    }
                                                }
                                                else
                                                {
                                                    if (Time32.Now >= monster.AccuracyStamp.AddSeconds(monster.AccuracyTime))
                                                    {
                                                        monster.RemoveFlag(Network.GamePackets.Update.Flags.StarOfAccuracy);
                                                    }
                                                }
                                            }
                                            if (monster.ContainsFlag(Network.GamePackets.Update.Flags.MagicShield))
                                            {
                                                if (monster.MagicShieldTime != 0)
                                                {
                                                    if (Time32.Now >= monster.MagicShieldStamp.AddSeconds(monster.MagicShieldTime))
                                                    {
                                                        monster.MagicShieldIncrease = 0;
                                                        monster.MagicShieldTime = 0;
                                                        monster.RemoveFlag(Network.GamePackets.Update.Flags.MagicShield);
                                                    }
                                                }
                                                else
                                                {
                                                    if (Time32.Now >= monster.ShieldStamp.AddSeconds(monster.ShieldTime))
                                                    {
                                                        monster.ShieldIncrease = 0;
                                                        monster.ShieldTime = 0;
                                                        monster.RemoveFlag(Network.GamePackets.Update.Flags.MagicShield);
                                                    }
                                                }
                                            }
                                            #endregion
                                            #region Dead monster
                                            if (monster.Dead || monster.Killed)
                                            {
                                                if (!monster.ContainsFlag(Network.GamePackets.Update.Flags.Ghost) || monster.Killed)
                                                {
                                                    monster.Killed = false;
                                                    monster.MonsterInfo.InSight = 0;
                                                    monster.MonsterInfo.InStig = 0;
                                                    monster.MonsterInfo.InRev = 0;
                                                    monster.MonsterInfo.InBlack = 0;
                                                    monster.AddFlag(Network.GamePackets.Update.Flags.Ghost);
                                                    monster.AddFlag(Network.GamePackets.Update.Flags.Dead);
                                                    monster.AddFlag(Network.GamePackets.Update.Flags.FadeAway);
                                                    Network.GamePackets.Attack attack = new Network.GamePackets.Attack(true);
                                                    attack.Attacker = monster.Killer.UID;
                                                    attack.Attacked = monster.UID;
                                                    attack.AttackType = Network.GamePackets.Attack.Kill;
                                                    attack.X = monster.X;
                                                    attack.Y = monster.Y;
                                                    Owner.Map.Floor[monster.X, monster.Y, MapObjectType.Monster, monster] = true;
                                                    attack.KOCount = ++monster.Killer.KOCount;
                                                    if (monster.Killer.EntityFlag == EntityFlag.Player)
                                                    {
                                                        monster.MonsterInfo.ExcludeFromSend = monster.Killer.UID;
                                                        monster.Killer.Owner.Send(attack);
                                                        if (monster.Killer.Owner.Companion != null)
                                                        {
                                                            if (monster.Killer.Owner.Companion.MonsterInfo != null)
                                                            {
                                                                monster.Killer.Owner.Map.RemoveEntity(monster.Killer.Owner.Companion);
                                                                Data data = new Data(true);
                                                                data.UID = monster.Killer.Owner.Companion.UID;
                                                                data.ID = Data.RemoveEntity;
                                                                monster.Killer.Owner.Companion.MonsterInfo.SendScreen(data);
                                                                monster.Killer.Owner.Companion = null;
                                                            }
                                                        }
                                                    }
                                                    monster.MonsterInfo.SendScreen(attack);
                                                    monster.MonsterInfo.ExcludeFromSend = 0;
                                                }
                                                if (Time32.Now > monster.DeathStamp.AddSeconds(4))
                                                {
                                                    Network.GamePackets.Data data = new Network.GamePackets.Data(true);
                                                    data.UID = monster.UID;
                                                    data.ID = Network.GamePackets.Data.RemoveEntity;
                                                    monster.MonsterInfo.SendScreen(data);
                                                }
                                            }
                                            #endregion
                                            #region Alive monster
                                            else
                                            {
                                                if ((obj as Entity).Stunned)
                                                {
                                                    if (Time32.Now > (obj as Entity).StunStamp.AddMilliseconds(1500))
                                                        (obj as Entity).Stunned = false;
                                                    else
                                                        continue;
                                                }
                                                if ((obj as Entity).Companion)
                                                    continue;
                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MinimumSpeed))
                                                {
                                                    #region Guards
                                                    if (monster.Name.Contains("Guard"))
                                                    {
                                                        if (monster.Name == "Guard1" || monster.MonsterInfo.ID >= 9000 && monster.MonsterInfo.ID <= 9003)
                                                        {
                                                            if (monster.MonsterInfo.InSight == 0)
                                                            {
                                                                if (monster.X != monster.MonsterInfo.BoundX || monster.Y != monster.MonsterInfo.BoundY)
                                                                {
                                                                    monster.X = monster.MonsterInfo.BoundX;
                                                                    monster.Y = monster.MonsterInfo.BoundY;
                                                                    Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                    jump.X = monster.MonsterInfo.BoundX;
                                                                    jump.Y = monster.MonsterInfo.BoundY;
                                                                    jump.EntityCount = 1;
                                                                    jump.FirstEntity = monster.UID;
                                                                    jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                    Owner.SendScreen(jump, true);
                                                                }
                                                                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.FlashingName))
                                                                    monster.MonsterInfo.InSight = Owner.Entity.UID;
                                                            }
                                                            else
                                                            {
                                                                if (Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.FlashingName))
                                                                {
                                                                    if (monster.MonsterInfo.InSight == Owner.Entity.UID)
                                                                    {
                                                                        if (!Owner.Entity.Dead)
                                                                        {
                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                            {
                                                                                short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                                    {
                                                                                        Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                                        jump.X = Owner.Entity.X;
                                                                                        jump.Y = Owner.Entity.Y;
                                                                                        monster.X = Owner.Entity.X;
                                                                                        monster.Y = Owner.Entity.Y;
                                                                                        jump.EntityCount = 1;
                                                                                        jump.FirstEntity = monster.UID;
                                                                                        jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                                        Owner.SendScreen(jump, true);
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            monster.MonsterInfo.InSight = 0;
                                                                        }
                                                                    }
                                                                    else
                                                                    {

                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InSight == Owner.Entity.UID)
                                                                    {
                                                                        monster.MonsterInfo.InSight = 0;
                                                                    }
                                                                }
                                                            }

                                                            for (int i = 0; i < Objects.Count; i++)
                                                            {
                                                                if (i >= Objects.Count)
                                                                    break;
                                                                IMapObject obj2 = Objects[i];
                                                                if (obj2 == null)
                                                                    continue;
                                                                if (obj2.MapObjType == MapObjectType.Monster)
                                                                {
                                                                    Entity monster2 = obj2 as Entity;//null;// Owner.Map.Entities[obj2.UID];
                                                                    if (monster2 == null)
                                                                        continue;
                                                                    if (monster2.Dead)
                                                                        continue;
                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                    {
                                                                        if (!monster2.Name.Contains("Guard") && !monster2.Companion)
                                                                        {
                                                                            short distance = Kernel.GetDistance(monster.X, monster.Y, monster2.X, monster2.Y);

                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                monster.MonsterInfo.LastMove = Time32.Now;
                                                                                new Game.Attacking.Handle(null, monster, monster2);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        #region BlackName Guard
                                                        if (monster.Name == "Guard2")
                                                        {
                                                            if (monster.MonsterInfo.InBlack == 0)
                                                            {
                                                                if (monster.X != monster.MonsterInfo.BoundX || monster.Y != monster.MonsterInfo.BoundY)
                                                                {
                                                                    monster.X = monster.MonsterInfo.BoundX;
                                                                    monster.Y = monster.MonsterInfo.BoundY;
                                                                    Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                    jump.X = monster.MonsterInfo.BoundX;
                                                                    jump.Y = monster.MonsterInfo.BoundY;
                                                                    jump.EntityCount = 1;
                                                                    jump.FirstEntity = monster.UID;
                                                                    jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                    Owner.SendScreen(jump, true);
                                                                }
                                                                if (Owner.Entity.PKPoints > 99 || Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.FlashingName))
                                                                    monster.MonsterInfo.InBlack = Owner.Entity.UID;
                                                            }
                                                            else
                                                            {
                                                                if (Owner.Entity.PKPoints > 99 || Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.FlashingName))
                                                                {
                                                                    if (monster.MonsterInfo.InBlack == Owner.Entity.UID)
                                                                    {
                                                                        if (!Owner.Entity.Dead)
                                                                        {
                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                            {
                                                                                short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                                    {
                                                                                        Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                                        jump.X = Owner.Entity.X;
                                                                                        jump.Y = Owner.Entity.Y;
                                                                                        monster.X = Owner.Entity.X;
                                                                                        monster.Y = Owner.Entity.Y;
                                                                                        jump.EntityCount = 1;
                                                                                        jump.FirstEntity = monster.UID;
                                                                                        jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                                        Owner.SendScreen(jump, true);
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            monster.MonsterInfo.InBlack = 0;
                                                                        }

                                                                    }
                                                                    else
                                                                    {

                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InBlack == Owner.Entity.UID)
                                                                    {
                                                                        monster.MonsterInfo.InBlack = 0;
                                                                    }
                                                                }
                                                            }

                                                            for (int i = 0; i < Objects.Count; i++)
                                                            {
                                                                if (i >= Objects.Count)
                                                                    break;
                                                                IMapObject obj2 = Objects[i];
                                                                if (obj2 == null)
                                                                    continue;
                                                                if (obj2.MapObjType == MapObjectType.Monster)
                                                                {
                                                                    Entity monster2 = obj2 as Entity;//null;// Owner.Map.Entities[obj2.UID];
                                                                    if (monster2 == null)
                                                                        continue;
                                                                    if (monster2.Dead)
                                                                        continue;
                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                    {
                                                                        if (!monster2.Name.Contains("Guard") && !monster2.Companion)
                                                                        {
                                                                            short distance = Kernel.GetDistance(monster.X, monster.Y, monster2.X, monster2.Y);

                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                monster.MonsterInfo.LastMove = Time32.Now;
                                                                                new Game.Attacking.Handle(null, monster, monster2);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        #endregion
                                                        #region Rev Guard
                                                        if (monster.Name == "RevGuard")
                                                        {
                                                            if (monster.MonsterInfo.InRev == 0)
                                                            {
                                                                if (monster.X != monster.MonsterInfo.BoundX || monster.Y != monster.MonsterInfo.BoundY)
                                                                {
                                                                    monster.X = monster.MonsterInfo.BoundX;
                                                                    monster.Y = monster.MonsterInfo.BoundY;
                                                                    Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                    jump.X = monster.MonsterInfo.BoundX;
                                                                    jump.Y = monster.MonsterInfo.BoundY;
                                                                    jump.EntityCount = 1;
                                                                    jump.FirstEntity = monster.UID;
                                                                    jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                    Owner.SendScreen(jump, true);
                                                                }
                                                                if (Owner.Entity.Dead)
                                                                    monster.MonsterInfo.InRev = Owner.Entity.UID;
                                                            }
                                                            else
                                                            {
                                                                if (Owner.Entity.Dead)
                                                                {
                                                                    if (monster.MonsterInfo.InRev == Owner.Entity.UID)
                                                                    {
                                                                        if (Owner.Entity.Dead)
                                                                        {
                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                            {
                                                                                short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                                    {
                                                                                        /*Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                                        jump.X = Owner.Entity.X;
                                                                                        jump.Y = Owner.Entity.Y;
                                                                                        monster.X = Owner.Entity.X;
                                                                                        monster.Y = Owner.Entity.Y;
                                                                                        jump.EntityCount = 1;
                                                                                        jump.FirstEntity = monster.UID;
                                                                                        jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                                        Owner.SendScreen(jump, true);*/
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            monster.MonsterInfo.InRev = 0;
                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        monster.MonsterInfo.InRev = 0;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InRev == Owner.Entity.UID)
                                                                    {
                                                                        monster.MonsterInfo.InRev = 0;
                                                                    }
                                                                }
                                                            }

                                                        }
                                                        #endregion
                                                        #region Stig Guard
                                                        if (monster.Name == "StigGuard")
                                                        {
                                                            if (monster.MonsterInfo.InStig == 0)
                                                            {
                                                                if (monster.X != monster.MonsterInfo.BoundX || monster.Y != monster.MonsterInfo.BoundY)
                                                                {
                                                                    monster.X = monster.MonsterInfo.BoundX;
                                                                    monster.Y = monster.MonsterInfo.BoundY;
                                                                    Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                    jump.X = monster.MonsterInfo.BoundX;
                                                                    jump.Y = monster.MonsterInfo.BoundY;
                                                                    jump.EntityCount = 1;
                                                                    jump.FirstEntity = monster.UID;
                                                                    jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                    Owner.SendScreen(jump, true);
                                                                }
                                                                if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                                                                    monster.MonsterInfo.InStig = Owner.Entity.UID;
                                                            }
                                                            else
                                                            {
                                                                if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                                                                {
                                                                    if (monster.MonsterInfo.InStig == Owner.Entity.UID)
                                                                    {
                                                                        if (!Owner.Entity.Dead)
                                                                        {
                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                            {
                                                                                short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);

                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                                    {
                                                                                        /*Network.GamePackets.TwoMovements jump = new PhoenixProject.Network.GamePackets.TwoMovements();
                                                                                        jump.X = Owner.Entity.X;
                                                                                        jump.Y = Owner.Entity.Y;
                                                                                        monster.X = Owner.Entity.X;
                                                                                        monster.Y = Owner.Entity.Y;
                                                                                        jump.EntityCount = 1;
                                                                                        jump.FirstEntity = monster.UID;
                                                                                        jump.MovementType = Network.GamePackets.TwoMovements.Jump;
                                                                                        Owner.SendScreen(jump, true);*/
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            monster.MonsterInfo.InStig = 0;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        monster.MonsterInfo.InStig = 0;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InStig == Owner.Entity.UID)
                                                                    {
                                                                        monster.MonsterInfo.InStig = 0;
                                                                    }
                                                                }
                                                            }
                                                            for (int i = 0; i < Objects.Count; i++)
                                                            {
                                                                if (i >= Objects.Count)
                                                                    break;
                                                                IMapObject obj2 = Objects[i];
                                                                if (obj2 == null)
                                                                    continue;
                                                                if (obj2.MapObjType == MapObjectType.Monster)
                                                                {
                                                                    Entity monster2 = obj2 as Entity;//null;// Owner.Map.Entities[obj2.UID];
                                                                    if (monster2 == null)
                                                                        continue;
                                                                    if (monster2.Dead)
                                                                        continue;
                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                    {
                                                                        if (!monster2.Name.Contains("Guard") && !monster2.Companion)
                                                                        {
                                                                            short distance = Kernel.GetDistance(monster.X, monster.Y, monster2.X, monster2.Y);

                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                monster.MonsterInfo.LastMove = Time32.Now;
                                                                                new Game.Attacking.Handle(null, monster, monster2);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                        }
                                                        #endregion
                                                    #endregion
                                                    }
                                                    else
                                                    {
                                                        #region Monsters

                                                        short distance = Kernel.GetDistance(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                        if (monster.MonsterInfo.InSight != 0 && monster.MonsterInfo.InSight != Owner.Entity.UID)
                                                        {
                                                            if (monster.MonsterInfo.InSight > 1000000)
                                                            {
                                                                var cl = ServerBase.Kernel.GamePool[monster.MonsterInfo.InSight];
                                                                if (cl == null)
                                                                    monster.MonsterInfo.InSight = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, cl.Entity.X, cl.Entity.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance)
                                                                        monster.MonsterInfo.InSight = 0;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                Entity companion = null;
                                                                for (int x = 0; x < Owner.Map.Companions.Count; x++)
                                                                {
                                                                    if (x >= Owner.Map.Companions.Count)
                                                                        break;
                                                                    if (Owner.Map.Companions[x] != null)
                                                                    {
                                                                        if (Owner.Map.Companions[x].UID == monster.MonsterInfo.InSight)
                                                                        {
                                                                            companion = Owner.Map.Companions[x];
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                                if (companion == null)
                                                                    monster.MonsterInfo.InSight = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, companion.X, companion.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance)
                                                                        monster.MonsterInfo.InSight = 0;
                                                                }
                                                            }
                                                        }
                                                        /*if (monster.MonsterInfo.InRev != 0 && monster.MonsterInfo.InRev != Owner.Entity.UID)
                                                        {
                                                            if (monster.MonsterInfo.InRev > 1000000)
                                                            {
                                                                var cl = ServerBase.Kernel.GamePool[monster.MonsterInfo.InRev];
                                                                if (cl == null)
                                                                    monster.MonsterInfo.InRev = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, cl.Entity.X, cl.Entity.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance2 || !cl.Entity.Dead)
                                                                        monster.MonsterInfo.InRev = 0;
                                                                }
                                                            }

                                                        }
                                                        if (monster.MonsterInfo.InStig != 0 && monster.MonsterInfo.InStig != Owner.Entity.UID)
                                                        {
                                                            if (monster.MonsterInfo.InStig > 1000000)
                                                            {
                                                                var cl = ServerBase.Kernel.GamePool[monster.MonsterInfo.InStig];
                                                                if (cl == null)
                                                                    monster.MonsterInfo.InStig = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, cl.Entity.X, cl.Entity.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance2 || cl.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Stigma))
                                                                        monster.MonsterInfo.InStig = 0;
                                                                }
                                                            }

                                                        }
                                                        if (monster.MonsterInfo.InBlack != 0 && monster.MonsterInfo.InBlack != Owner.Entity.UID)
                                                        {
                                                            if (monster.MonsterInfo.InBlack > 1000000)
                                                            {
                                                                var cl = ServerBase.Kernel.GamePool[monster.MonsterInfo.InBlack];
                                                                if (cl == null)
                                                                    monster.MonsterInfo.InBlack = 0;
                                                                else
                                                                {
                                                                    short dst = Kernel.GetDistance(monster.X, monster.Y, cl.Entity.X, cl.Entity.Y);
                                                                    if (dst > ServerBase.Constants.pScreenDistance || cl.Entity.PKPoints < 100)
                                                                        monster.MonsterInfo.InBlack = 0;
                                                                }
                                                            }

                                                        }*/
                                                        if (distance <= ServerBase.Constants.pScreenDistance)
                                                        {
                                                            #region Companions
                                                            if (Owner.Companion != null)
                                                            {
                                                                if (Owner.Companion.Companion && !Owner.Companion.Dead)
                                                                {
                                                                    short distance2 = Kernel.GetDistance(monster.X, monster.Y, Owner.Companion.X, Owner.Companion.Y);
                                                                    if (distance > distance2 || Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility) || Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                    {
                                                                        if (monster.MonsterInfo.InSight == 0)
                                                                        {
                                                                            monster.MonsterInfo.InSight = Owner.Companion.UID;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (monster.MonsterInfo.InSight == Owner.Companion.UID)
                                                                            {
                                                                                if (distance2 > ServerBase.Constants.pScreenDistance)
                                                                                {
                                                                                    monster.MonsterInfo.InSight = 0;
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance2 <= monster.MonsterInfo.AttackRange)
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;
                                                                                            new Game.Attacking.Handle(null, monster, Owner.Companion);
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (distance2 > monster.MonsterInfo.ViewRange / 2)
                                                                                        {
                                                                                            if (distance2 < ServerBase.Constants.pScreenDistance)
                                                                                            {
                                                                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                                {
                                                                                                    monster.MonsterInfo.LastMove = Time32.Now;

                                                                                                    Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Companion.X, Owner.Companion.Y);
                                                                                                    if (!monster.Move(facing))
                                                                                                    {
                                                                                                        facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                        if (monster.Move(facing))
                                                                                                        {
                                                                                                            monster.Facing = facing;
                                                                                                            Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                            move.Direction = facing;
                                                                                                            move.UID = monster.UID;
                                                                                                            move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                            monster.MonsterInfo.SendScreen(move);
                                                                                                        }
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        monster.Facing = facing;
                                                                                                        Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                        move.Direction = facing;
                                                                                                        move.UID = monster.UID;
                                                                                                        move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                        monster.MonsterInfo.SendScreen(move);
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.MonsterInfo.InSight = 0;
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                            {
                                                                                                monster.MonsterInfo.LastMove = Time32.Now;
                                                                                                Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Companion.X, Owner.Companion.Y);
                                                                                                if (!monster.Move(facing))
                                                                                                {
                                                                                                    facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                    if (monster.Move(facing))
                                                                                                    {
                                                                                                        monster.Facing = facing;
                                                                                                        Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                        move.Direction = facing;
                                                                                                        move.UID = monster.UID;
                                                                                                        monster.MonsterInfo.SendScreen(move);
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                            else
                                                                                goto Over;
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                    goto Over;
                                                            }
                                                            else
                                                                goto Over;
                                                            #endregion
                                                        Over:
                                                            #region Player
                                                            if (monster.MonsterInfo.Name.Contains("Guard"))
                                                            {
                                                                if (monster.MonsterInfo.InBlack == 0)
                                                                {
                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                    {
                                                                        if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                                                        {
                                                                            if (monster.MonsterInfo.SpellID != 0 || !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                            {
                                                                                monster.MonsterInfo.InBlack = Owner.Entity.UID;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InBlack == Owner.Entity.UID)
                                                                    {
                                                                        if (monster.MonsterInfo.SpellID == 0 && Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                        {
                                                                            monster.MonsterInfo.InBlack = 0;
                                                                            return;
                                                                        }

                                                                        if (Owner.Entity.Dead)
                                                                        {
                                                                            monster.MonsterInfo.InBlack = 0;
                                                                            return;
                                                                        }
                                                                        if (distance > ServerBase.Constants.pScreenDistance)
                                                                        {
                                                                            monster.MonsterInfo.InBlack = 0;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (distance > monster.MonsterInfo.ViewRange / 2)
                                                                                {
                                                                                    if (distance < ServerBase.Constants.pScreenDistance)
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;

                                                                                            Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                            if (!monster.Move(facing))
                                                                                            {
                                                                                                facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                if (monster.Move(facing))
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        monster.MonsterInfo.InBlack = 0;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                    {
                                                                                        monster.MonsterInfo.LastMove = Time32.Now;
                                                                                        Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                        if (!monster.Move(facing))
                                                                                        {
                                                                                            facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                            if (monster.Move(facing))
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            monster.Facing = facing;
                                                                                            Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                            move.Direction = facing;
                                                                                            move.UID = monster.UID;
                                                                                            monster.MonsterInfo.SendScreen(move);
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (monster.MonsterInfo.InSight == 0)
                                                            {
                                                                if (!Owner.Entity.Dead)
                                                                {
                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                    {
                                                                        if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                                                        {
                                                                            if (monster.MonsterInfo.SpellID != 0 || !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                            {
                                                                                monster.MonsterInfo.InSight = Owner.Entity.UID;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if (!Owner.Entity.Dead)
                                                                {
                                                                    if (monster.MonsterInfo.InSight == Owner.Entity.UID)
                                                                    {
                                                                        if (monster.MonsterInfo.SpellID == 0 && Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                        {
                                                                            monster.MonsterInfo.InSight = 0;
                                                                            return;
                                                                        }

                                                                        if (Owner.Entity.Dead)
                                                                        {
                                                                            monster.MonsterInfo.InSight = 0;
                                                                            return;
                                                                        }
                                                                        if (distance > ServerBase.Constants.pScreenDistance)
                                                                        {
                                                                            monster.MonsterInfo.InSight = 0;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (!Owner.Entity.Dead)
                                                                            {
                                                                                if (distance <= monster.MonsterInfo.AttackRange)
                                                                                {
                                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                    {
                                                                                        monster.MonsterInfo.LastMove = Time32.Now;
                                                                                        new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (distance > monster.MonsterInfo.ViewRange / 2)
                                                                                    {
                                                                                        if (distance < ServerBase.Constants.pScreenDistance)
                                                                                        {
                                                                                            if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                            {
                                                                                                monster.MonsterInfo.LastMove = Time32.Now;

                                                                                                Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                                if (!monster.Move(facing))
                                                                                                {
                                                                                                    facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                    if (monster.Move(facing))
                                                                                                    {
                                                                                                        monster.Facing = facing;
                                                                                                        Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                        move.Direction = facing;
                                                                                                        move.UID = monster.UID;
                                                                                                        move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                        monster.MonsterInfo.SendScreen(move);
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            monster.MonsterInfo.InSight = 0;
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;
                                                                                            Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                            if (!monster.Move(facing))
                                                                                            {
                                                                                                facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                if (monster.Move(facing))
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (Owner.Entity.Dead)
                                                                                {
                                                                                    monster.MonsterInfo.InSight = 0;
                                                                                    // Console.WriteLine("cheack1");
                                                                                    return;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (monster.MonsterInfo.Name.Contains("Guard"))
                                                            {
                                                                if (monster.MonsterInfo.InRev == 0)
                                                                {
                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                    {
                                                                        if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                                                        {
                                                                            if (monster.MonsterInfo.SpellID != 0 || !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                            {
                                                                                monster.MonsterInfo.InRev = Owner.Entity.UID;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InRev == Owner.Entity.UID)
                                                                    {
                                                                        if (monster.MonsterInfo.SpellID == 0 && Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                        {
                                                                            monster.MonsterInfo.InRev = 0;
                                                                            return;
                                                                        }

                                                                        if (!Owner.Entity.Dead)
                                                                        {
                                                                            monster.MonsterInfo.InRev = 0;
                                                                            return;
                                                                        }
                                                                        if (distance > ServerBase.Constants.pScreenDistance)
                                                                        {
                                                                            monster.MonsterInfo.InRev = 0;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (distance > monster.MonsterInfo.ViewRange / 2)
                                                                                {
                                                                                    if (distance < ServerBase.Constants.pScreenDistance)
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;

                                                                                            Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                            if (!monster.Move(facing))
                                                                                            {
                                                                                                facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                if (monster.Move(facing))
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        monster.MonsterInfo.InRev = 0;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                    {
                                                                                        monster.MonsterInfo.LastMove = Time32.Now;
                                                                                        Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                        if (!monster.Move(facing))
                                                                                        {
                                                                                            facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                            if (monster.Move(facing))
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            monster.Facing = facing;
                                                                                            Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                            move.Direction = facing;
                                                                                            move.UID = monster.UID;
                                                                                            monster.MonsterInfo.SendScreen(move);
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (monster.MonsterInfo.Name.Contains("Guard"))
                                                            {
                                                                if (monster.MonsterInfo.InStig == 0)
                                                                {
                                                                    if (distance <= monster.MonsterInfo.ViewRange)
                                                                    {
                                                                        if (!Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Invisibility))
                                                                        {
                                                                            if (monster.MonsterInfo.SpellID != 0 || !Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                            {
                                                                                monster.MonsterInfo.InStig = Owner.Entity.UID;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (monster.MonsterInfo.InStig == Owner.Entity.UID)
                                                                    {
                                                                        if (monster.MonsterInfo.SpellID == 0 && Owner.Entity.ContainsFlag(Network.GamePackets.Update.Flags.Fly))
                                                                        {
                                                                            monster.MonsterInfo.InStig = 0;
                                                                            return;
                                                                        }

                                                                        if (Owner.Entity.Dead)
                                                                        {
                                                                            monster.MonsterInfo.InStig = 0;
                                                                            return;
                                                                        }
                                                                        if (distance > ServerBase.Constants.pScreenDistance)
                                                                        {
                                                                            monster.MonsterInfo.InStig = 0;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (distance <= monster.MonsterInfo.AttackRange)
                                                                            {
                                                                                if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.AttackSpeed))
                                                                                {
                                                                                    monster.MonsterInfo.LastMove = Time32.Now;
                                                                                    new Game.Attacking.Handle(null, monster, Owner.Entity);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (distance > monster.MonsterInfo.ViewRange / 2)
                                                                                {
                                                                                    if (distance < ServerBase.Constants.pScreenDistance)
                                                                                    {
                                                                                        if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.RunSpeed))
                                                                                        {
                                                                                            monster.MonsterInfo.LastMove = Time32.Now;

                                                                                            Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                            if (!monster.Move(facing))
                                                                                            {
                                                                                                facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                                if (monster.Move(facing))
                                                                                                {
                                                                                                    monster.Facing = facing;
                                                                                                    Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                    move.Direction = facing;
                                                                                                    move.UID = monster.UID;
                                                                                                    move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                    monster.MonsterInfo.SendScreen(move);
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                move.GroundMovementType = Network.GamePackets.GroundMovement.Run;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        monster.MonsterInfo.InStig = 0;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (Time32.Now >= monster.MonsterInfo.LastMove.AddMilliseconds(monster.MonsterInfo.MoveSpeed))
                                                                                    {
                                                                                        monster.MonsterInfo.LastMove = Time32.Now;
                                                                                        Enums.ConquerAngle facing = ServerBase.Kernel.GetAngle(monster.X, monster.Y, Owner.Entity.X, Owner.Entity.Y);
                                                                                        if (!monster.Move(facing))
                                                                                        {
                                                                                            facing = (Enums.ConquerAngle)ServerBase.Kernel.Random.Next(7);
                                                                                            if (monster.Move(facing))
                                                                                            {
                                                                                                monster.Facing = facing;
                                                                                                Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                                move.Direction = facing;
                                                                                                move.UID = monster.UID;
                                                                                                monster.MonsterInfo.SendScreen(move);
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            monster.Facing = facing;
                                                                                            Network.GamePackets.GroundMovement move = new PhoenixProject.Network.GamePackets.GroundMovement(true);
                                                                                            move.Direction = facing;
                                                                                            move.UID = monster.UID;
                                                                                            monster.MonsterInfo.SendScreen(move);
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                            #endregion
                                                        }
                                                        else
                                                        {
                                                            Remove(obj);
                                                        }
                                                    }
                                                        #endregion
                                                }
                                            }
                                            #endregion
                                        }
                                    }
                                }
                            }
                            if (obj.MapObjType == MapObjectType.Item)
                            {
                                Network.GamePackets.FloorItem item = obj as Network.GamePackets.FloorItem;
                                if (item.Type != Network.GamePackets.FloorItem.Effect)
                                {
                                    if (Time32.Now > item.OnFloor.AddSeconds(ServerBase.Constants.FloorItemSeconds))
                                    {
                                        item.Type = Network.GamePackets.FloorItem.Remove;
                                        foreach (Interfaces.IMapObject _obj in Objects)
                                        {
                                            if (_obj != null)
                                            {
                                                if (_obj.MapObjType == MapObjectType.Player)
                                                {
                                                    (_obj as Entity).Owner.Send(item);
                                                }
                                            }
                                        }
                                        Owner.Map.Floor[item.X, item.Y, MapObjectType.Item, null] = true;
                                        Remove(obj);
                                    }
                                }
                                else
                                {
                                    // Console.WriteLine("zaza");
                                    item.Type = Network.GamePackets.FloorItem.Effect;
                                    foreach (Interfaces.IMapObject _obj in Objects)
                                    {
                                        if (_obj != null)
                                        {
                                            if (_obj.MapObjType == MapObjectType.Player)
                                            {
                                                (_obj as Entity).Owner.Send(item);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e) { Program.SaveException(e); }

               /* foreach (IMapObject obj in toRemove)
                    Remove(obj);*/

                #endregion
            }
            catch { /*Console.WriteLine(e.ToString()); Console.WriteLine("erorrr screnn timer");*/ }
        }
        public void FullWipe()
        {
            bool remove;
            try
            {
                IEnumerator<IMapObject> obj_ = Objects.GetEnumerator();
                int count = Objects.Count;
                obj_.MoveNext();
                for (byte x = 0; x < count; x++)
                {
                    if (x >= count) break;
                    IMapObject Base = obj_.Current;

                    if (Base == null)
                        continue;
                    remove = true;
                    if (Base.MapObjType == MapObjectType.Monster)
                    {
                        remove = (Base as IBaseEntity).Dead ||
                            (ServerBase.Kernel.GetDistance(Owner.Entity.X, Owner.Entity.Y, Base.X, Base.Y) >= Constants.pScreenDistance);
                    }
                    else if (Base.MapObjType == MapObjectType.Player)
                    {
                        GameState pPlayer = Base.Owner as GameState;
                        pPlayer.Screen.Remove(Owner.Entity);
                        remove = true;
                    }
                    else if (Base.MapObjType == MapObjectType.Item)
                    {
                        remove = (Kernel.GetDistance(Owner.Entity.X, Owner.Entity.Y, Base.X, Base.Y) >= 22);

                    }
                    else
                    {
                        remove = (Kernel.GetDistance(Owner.Entity.X, Owner.Entity.Y, Base.X, Base.Y) >= Constants.pScreenDistance);
                    }
                    if (Base.MapID != Owner.Map.ID)
                        remove = true;
                    if (remove)
                    {
                        Network.GamePackets.Data data = new Network.GamePackets.Data(true);
                        data.UID = Owner.Entity.UID;
                        data.ID = Network.GamePackets.Data.RemoveEntity;

                        if (Base.MapObjType == Game.MapObjectType.Player)
                        {
                            GameState pPlayer = Base.Owner as GameState;
                            pPlayer.Send(data);
                        }
                    }
                    obj_.MoveNext();
                }
            }
            catch (Exception e) { Program.SaveException(e); }
            Clear();
        }