Exemplo n.º 1
0
        private void proxy_UsePortal(Client client, Packet real_packet)
        {
            UsePortalPacket packet = (UsePortalPacket)real_packet;

            TeleportQueue = new List <Client>();

            foreach (var c in Clients)
            {
                if (c == Master)
                {
                    continue;
                }

                TeleportQueue.Add(c);
            }
            ;

            TeleportQueue.Add(Master);

            var cl = TeleportQueue[0];

            TeleportQueue.Remove(cl);

            packet.ObjectId = Dungeons[cl].Choose(
                (x1, x2) => x1 < x2,
                (obj) => obj.Status.Position.DistanceSquaredTo(cl.PlayerData.Pos),
                4
                ).Status.ObjectId;

            cl.SendToServer(packet);

            packet.Send = false;
        }
Exemplo n.º 2
0
        private async void AttemptConnection(Client client, int portalId)
        {
            UsePortalPacket packet = (UsePortalPacket)Packet.Create(PacketType.USEPORTAL);

            packet.ObjectId = portalId;

            if (!portals.Exists(ptl => ptl.ObjectId == portalId))
            {
                gotoRealm = true;
                MoveToRealms(client);
                return;
            }

            var pCount = portals.Find(p => p.ObjectId == portalId).PlayerCount;

            if (connectedClient.Connected && pCount < 999)
            {
                client.SendToServer(packet);
            }
            await Task.Delay(TimeSpan.FromSeconds(0.2));

            if (client.Connected && enabled)
            {
                AttemptConnection(client, portalId);
            }
            else if (enabled)
            {
                Log("Connection successful.");
            }
            else
            {
                Log("Bot disabled, cancelling connection attempt.");
            }
        }
Exemplo n.º 3
0
        public void OnUsePortal(Client client, Packet packet)
        {
            UsePortalPacket upp = (UsePortalPacket)packet;

            // Check if the master client used a portal
            if (_enabled && listOfClients[client].Master)
            {
                // Go through each client in the list and send the same packet if they are a slave
                foreach (var ci in listOfClients)
                {
                    if (ci.Value.Slave)
                    {
                        ci.Value.client.SendToServer(upp);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void UsePortal(RealmTime time, UsePortalPacket pkt)
        {
            Portal entity = Owner.GetEntity(pkt.ObjectId) as Portal;

            if (entity == null || !entity.Usable)
            {
                return;
            }
            World world = entity.WorldInstance;

            if (world == null)
            {
                switch (entity.ObjectType)
                {
                case 0x0712:
                case 0x071d:
                    world = RealmManager.GetWorld(World.NEXUS_ID); break;

                case 0x071c:
                    world = RealmManager.Monitor.GetRandomRealm(); break;

                case 0x0720:
                    world = RealmManager.GetWorld(World.VAULT_ID); break;

                case 0x071e:
                    world = RealmManager.AddWorld(new Kitchen()); break;

                case 0x233D:
                    world = RealmManager.AddWorld(new Banana()); break;

                case 0x2553:
                    world = RealmManager.AddWorld(new Gee()); break;     //map creating tutorial world
                }
                entity.WorldInstance = world;
            }
            psr.Reconnect(new ReconnectPacket()
            {
                Host   = "",
                Port   = 2050,
                GameId = world.Id,
                Name   = world.Name,
                Key    = Empty <byte> .Array,
            });
        }
Exemplo n.º 5
0
        private void proxy_ClientConnected(Client client)
        {
            GotoSkipList.Add(client, new List <int>());
            Dungeons.Add(client, new FMList <Entity>());
            TeleportState.Add(client, -1);
            Time.Add(client, 0);
            LastManualGoto.Add(client, 0);

            Clients.Add(client);

            if (TeleportQueue != null)
            {
                // we are in the process of teleporting everyone to a new realm

                var cl = TeleportQueue[0];

                // Master is teleported last
                if (TeleportQueue.Count == 1)
                {
                    MasterID      = cl.PlayerData.AccountId;
                    TeleportQueue = null;
                }
                else
                {
                    TeleportQueue.Remove(cl);
                }

                var packet = (UsePortalPacket)UsePortalPacket.Create(PacketType.USEPORTAL);
                packet.ObjectId = Dungeons[cl].Choose(
                    (x1, x2) => x1 < x2,
                    (Entity obj) => obj.Status.Position.DistanceSquaredTo(cl.PlayerData.Pos),
                    4
                    ).Status.ObjectId;

                cl.SendToServer(packet);
            }
        }
Exemplo n.º 6
0
        public void UsePortal(RealmTime time, UsePortalPacket pkt)
        {
            Entity entity = Owner.GetEntity(pkt.ObjectId);

            if (entity == null || !entity.Usable)
            {
                return;
            }
            World  world = null;
            Portal p     = null;

            if (entity is Portal)
            {
                p     = entity as Portal;
                world = p.WorldInstance;
            }
            if (world == null)
            {
                if (p != null)
                {
                    bool   setWorldInstance = true;
                    string d = "";
                    if (XmlDatas.IdToDungeon.TryGetValue(entity.ObjectType, out d))
                    {
                        world = RealmManager.AddWorld(new XMLWorld(XmlDatas.DungeonDescs[d]));
                    }
                    else
                    {
                        switch (entity.ObjectType) //handling default case for not found. Add more as implemented
                        {
                        case 0x070e:
                        case 0x0703:                                                         //portal of cowardice
                        {
                            if (RealmManager.PlayerWorldMapping.ContainsKey(this.AccountId)) //may not be valid, realm recycled?
                            {
                                world = RealmManager.PlayerWorldMapping[this.AccountId];     //also reconnecting to vault is a little unexpected
                            }
                            else if (world.Id == -5 || world.Id == -11)
                            {
                                world = RealmManager.GetWorld(World.NEXUS_ID);
                            }
                            else
                            {
                                world = RealmManager.GetWorld(World.NEXUS_ID);
                            }
                        } break;

                        case 0x0712:
                            world = RealmManager.GetWorld(World.NEXUS_ID); break;

                        case 0x071d:
                            world = RealmManager.GetWorld(World.NEXUS_ID); break;

                        case 0x071c:
                            world = RealmManager.Monitor.GetRandomRealm(); break;

                        case 0x0720:
                            world            = RealmManager.PlayerVault(psr);
                            setWorldInstance = false; break;

                        case 0x071e:
                            world = RealmManager.AddWorld(new Kitchen()); break;

                        case 0x0ffa:                                            //these need to match IDs
                            //world = RealmManager.GetWorld(World.GauntletMap); break; //this creates a singleton dungeon
                            world = RealmManager.AddWorld(new Island()); break; //this allows each dungeon to be unique

                        case 0x0ffc:
                            world = RealmManager.AddWorld(new WineCellarMap()); break;

                        case 0x1900:
                            world = RealmManager.AddWorld(new ArenaMap()); break;

                        case 0x0730:
                            world = RealmManager.AddWorld(new OceanTrench()); break;

                        case 0x070c:
                            world = RealmManager.AddWorld(new SpriteWorld()); break;

                        case 0x071b:
                            world = RealmManager.AddWorld(new Abyss()); break;

                        case 0x071a:
                            world = RealmManager.AddWorld(new UndeadLair()); break;

                        case 0x1901:
                            world = RealmManager.AddWorld(new VoidWorld()); break;

                        case 0x072c:
                            world = RealmManager.AddWorld(new TombMap()); break;

                        case 0x0742:
                            world = RealmManager.AddWorld(new BeachZone()); break;

                        case 0x0718:
                            world = RealmManager.AddWorld(new SnakePit()); break;

                        case 0x0890:
                            world = RealmManager.AddWorld(new MadLabMap()); break;

                        case 0x1905:
                            world            = RealmManager.AddWorld(new BattleArenaMap());
                            setWorldInstance = false; break;

                        case 0x1919:
                            world = RealmManager.AddWorld(new Secret()); break;

                        case 0x1923:
                            world = RealmManager.AddWorld(new ZombieMap()); break;

                        case 0x195d:
                            world = RealmManager.AddWorld(new MarketMap()); break;

                        case 0x195f:
                            world = RealmManager.AddWorld(new Mine()); break;

                        default: SendError("Portal Not Implemented!"); break;
                        }
                    }
                    if (setWorldInstance)
                    {
                        p.WorldInstance = world;
                    }
                }
                else
                {
                    switch (entity.ObjectType) // Special Portals that cannot be the portal class
                    {
                    case 0x072f:
                        world = RealmManager.GuildHallWorld(Guild);
                        break;

                    default: psr.SendPacket(new TextPacket
                        {
                            BubbleTime = 0,
                            Stars      = -1,
                            Name       = "",
                            Text       = "Semi-Portal Not Implemented!"
                        }); break;
                    }
                }
            }

            //used to match up player to last realm they were in, to return them to it. Sometimes is odd, like from Vault back to Vault...
            if (RealmManager.PlayerWorldMapping.ContainsKey(this.AccountId))
            {
                World tempWorld;
                RealmManager.PlayerWorldMapping.TryRemove(this.AccountId, out tempWorld);
            }
            RealmManager.PlayerWorldMapping.TryAdd(this.AccountId, Owner);
            psr.Reconnect(new ReconnectPacket()
            {
                Host   = "",
                Port   = 2050,
                GameId = world.Id,
                Name   = world.Name,
                Key    = Empty <byte> .Array,
            });
        }
Exemplo n.º 7
0
        public void UsePortal(RealmTime time, UsePortalPacket pkt)
        {
            var entity = Owner.GetEntity(pkt.ObjectId);

            if (entity == null || !entity.Usable)
            {
                return;
            }
            World  world  = null;
            var    player = this;
            Portal p      = null;

            if (entity is Portal)
            {
                p     = entity as Portal;
                world = p.WorldInstance;
            }
            if (world == null)
            {
                if (p != null)
                {
                    var setWorldInstance = true;
                    var d = "";
                    if (XmlDatas.IdToDungeon.TryGetValue(entity.ObjectType, out d))
                    {
                        world = RealmManager.AddWorld(new XmlWorld(XmlDatas.DungeonDescs[d]));
                    }
                    else
                    {
                        switch (entity.ObjectType) //handling default case for not found. Add more as implemented
                        {
                        case 0x0703:               //portal of cowardice
                        {
                            if (RealmManager.PlayerWorldMapping.ContainsKey(AccountId))
                            {
                                //may not be valid, realm recycled?
                                world = RealmManager.PlayerWorldMapping[AccountId];
                            }
                            //also reconnecting to vault is a little unexpected
                            else if (world.Id == -5 || world.Id == -11)
                            {
                                world = RealmManager.GetWorld(World.NEXUS_ID);
                            }
                            else
                            {
                                world = RealmManager.GetWorld(World.NEXUS_ID);
                            }
                        }
                        break;

                        case 0x0d40:
                        {
                            if (RealmManager.PlayerWorldMapping.ContainsKey(AccountId))
                            {
                                //may not be valid, realm recycled?
                                world = RealmManager.PlayerWorldMapping[AccountId];
                            }
                            //also reconnecting to vault is a little unexpected
                            else if (world.Id == -5 || world.Id == -11)
                            {
                                world = RealmManager.GetWorld(World.NEXUS_ID);
                            }
                            else
                            {
                                world = RealmManager.GetWorld(World.NEXUS_ID);
                            }
                        }
                        break;

                        case 0x0712:
                            world = RealmManager.GetWorld(World.NEXUS_ID);
                            break;

                        case 0x071d:
                            world = RealmManager.GetWorld(World.NEXUS_ID);
                            break;

                        case 0x071c:
                            world = RealmManager.Monitor.GetRandomRealm();
                            break;

                        case 0x0720:
                            world            = RealmManager.PlayerVault(psr);
                            setWorldInstance = false;
                            break;

                        case 0x071e:
                            world = RealmManager.AddWorld(new Kitchen());
                            break;

                        case 0x0ffa:     //these need to match IDs
                            //world = RealmManager.GetWorld(World.GauntletMap); break; //this creates a singleton dungeon
                            world = RealmManager.AddWorld(new Island());
                            break;     //this allows each dungeon to be unique

                        case 0x0ffc:
                            world = RealmManager.AddWorld(new WineCellarMap());
                            break;

                        case 0x1900:
                            world = RealmManager.AddWorld(new ArenaMap());
                            break;

                        case 0x0730:
                            world = RealmManager.AddWorld(new OceanTrench());
                            break;

                        case 0x070c:
                            world = RealmManager.AddWorld(new SpriteWorld());
                            break;

                        case 0x071b:
                            world = RealmManager.AddWorld(new Abyss());
                            break;

                        case 0x071a:
                            world = RealmManager.AddWorld(new UndeadLair());
                            break;

                        case 0x1901:
                            world = RealmManager.AddWorld(new VoidWorld());
                            break;

                        case 0x072c:
                            world = RealmManager.AddWorld(new TombMap());
                            break;

                        case 0x1905:
                        {
                            psr.SendPacket(new TextBoxPacket
                                {
                                    Button1 = "Enter",
                                    Button2 = "Cancel",
                                    Message = "Join the arena at the price of 150 fame?",
                                    Title   = "Arena Confirmation",
                                    Type    = "EnterArena1"
                                });
                        }
                        break;

                        case 0x1908:

                            psr.SendPacket(new TextBoxPacket
                            {
                                Button1 = "Enter",
                                Button2 = "Cancel",
                                Message = "Join the free arena?",
                                Title   = "Arena Confirmation",
                                Type    = "EnterArena2"
                            });
                            break;

                        case 0x0742:
                            world = RealmManager.AddWorld(new BeachZone());
                            break;

                        case 0x0718:
                            world = RealmManager.AddWorld(new SnakePit());
                            break;

                        case 0x0890:
                            world = RealmManager.AddWorld(new MadLabMap());
                            break;

                        case 0x1919:
                            world = RealmManager.AddWorld(new Secret());
                            break;

                        case 0x1923:
                            world = RealmManager.AddWorld(new ZombieMap());
                            break;

                        default:
                            SendError("Portal Not Implemented!");
                            break;

                        case 0x195d:
                            world = RealmManager.AddWorld(new MarketMap());
                            break;

                        case 0x070d:
                            world = RealmManager.Monitor.GetRandomRealm();
                            break;

                        case 0x070e:
                            world = RealmManager.Monitor.GetRandomRealm();
                            break;

                        case 0x0704:
                            world = RealmManager.Monitor.GetRandomRealm();
                            break;

                        case 0x753E:
                            world = RealmManager.AddWorld(new LairofDraconis());
                            break;

                        case 0x7002:
                            world = RealmManager.AddWorld(new PartyCellarMap());
                            break;

                        case 0x701c:
                        {
                            psr.SendPacket(new TextBoxPacket
                                {
                                    Button1 = "Enter",
                                    Button2 = "Cancel",
                                    Message = "Join sheep herding at the price of 500 fame?",
                                    Title   = "Sheep Herding",
                                    Type    = "SheepHerding"
                                });
                        }
                        break;

                        case 0x7024:
                        {
                            psr.SendPacket(new TextBoxPacket
                                {
                                    Button1 = "Yes",
                                    Button2 = "Cancel",
                                    Message = "Join zombies at the price of 100 fame?",
                                    Title   = "Zombies",
                                    Type    = "Zombies"
                                });
                        }
                        break;

                        case 0x4a2b:
                        {
                            psr.SendPacket(new TextBoxPacket
                                {
                                    Button1 = "Yes",
                                    Button2 = "Cancel",
                                    Message = "Sorry, this isn't quite done yet. Look forward to it, though.",
                                    Title   = "Nexus Defense",
                                    Type    = "Nexus Defense"
                                });
                        }
                        break;

                        case 0x7025:
                            world = RealmManager.AddWorld(new ForestMap());
                            break;

                        case 0x4a29:
                            world = RealmManager.AddWorld(new ChristmasCellarMap());
                            break;

                        case 0x4a2a:
                            world = RealmManager.AddWorld(new TurkeyMap());
                            break;

                        case 0x5050:
                            world = RealmManager.AddWorld(new Shatters());
                            break;

                        case 0x2fbb:
                            world = RealmManager.AddWorld(new EC());
                            break;

                        case 0x0d7b:
                            world = RealmManager.AddWorld(new OryxChamberMap());
                            break;
                        }
                    }
                    if (setWorldInstance)
                    {
                        p.WorldInstance = world;
                    }
                }
                else
                {
                    switch (entity.ObjectType) // Special Portals that cannot be the portal class
                    {
                    case 0x072f:
                        world = RealmManager.GuildHallWorld(Guild);
                        break;

                    default:
                        psr.SendPacket(new TextPacket
                        {
                            BubbleTime = 0,
                            Stars      = -1,
                            Name       = "",
                            Text       = "Semi-Portal Not Implemented!"
                        });
                        break;
                    }
                }
            }

            //used to match up player to last realm they were in, to return them to it. Sometimes is odd, like from Vault back to Vault...

            if (RealmManager.PlayerWorldMapping.ContainsKey(AccountId))
            {
                World tempWorld;
                RealmManager.PlayerWorldMapping.TryRemove(AccountId, out tempWorld);
            }
            RealmManager.PlayerWorldMapping.TryAdd(AccountId, Owner);
            psr.Reconnect(new ReconnectPacket
            {
                Host   = "",
                Port   = 2050,
                GameId = world.Id,
                Name   = world.Name,
                Key    = Empty <byte> .Array,
            });
        }