public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            PacketReader reader = new PacketReader(data);

            reader.ReadUInt64(); // Skip 8 bytes
            if(reader.ReadUInt32() != 0x10)
            {
                Logger.WriteWarning("[WRN] Packet 0x3 0x34's first value was not 0x10! Investigate.");
            }

            uint partOfLobby = reader.ReadUInt32();
            PSOLocation destination;
            if(partOfLobby == 0) // Gate area
            {
                destination = new PSOLocation(0f, 1f, 0f, 0f, -0.22f, 2.4f, 198.75f);
            }
            else // Shop area
            {
                destination = new PSOLocation(0f, 1f, 0f, 20f, 0.20f, 1.23f, -175.25f);
            }
            Map lobbyMap = ZoneManager.Instance.MapFromInstance("lobby", "lobby");
            lobbyMap.SpawnClient(context, destination, "lobby");
        }
Exemplo n.º 2
0
        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            PacketReader reader = new PacketReader(data);
            reader.ReadBytes(12); // Padding MAYBE???????????
            ObjectHeader srcObject = reader.ReadStruct<ObjectHeader>();
            byte[] someBytes = reader.ReadBytes(4); // Dunno what this is yet.
            ObjectHeader dstObject = reader.ReadStruct<ObjectHeader>(); // Could be wrong
            reader.ReadBytes(16); // Not sure what this is yet
            string command = reader.ReadAscii(0xD711, 0xCA);
            PSOObject srcObj;
            if(srcObject.EntityType == EntityType.Object)
            {
                srcObj = ObjectManager.Instance.getObjectByID(context.CurrentZone.Name, srcObject.ID);
            }
            else if(srcObject.EntityType == EntityType.Player)
            {
                srcObj = new PSOObject();
                srcObj.Header = srcObject;
                srcObj.Name = "Player";
            }
            else
            {
                srcObj = null;
            }

            Logger.WriteInternal("[OBJ] {0} (ID {1}) <{2}> --> Ent {3} (ID {4})", srcObj.Name, srcObj.Header.ID, command, (EntityType)dstObject.EntityType, dstObject.ID);

            // TODO: Delete this code and do this COMPLETELY correctly!!!
            if (command == "Transfer" && context.CurrentZone.Name == "lobby")
            {
                // Try and get the teleport definition for the object...
                using (var db = new PolarisEf())
                {
                    db.Configuration.AutoDetectChangesEnabled = true;
                    var teleporterEndpoint = db.Teleports.Find("lobby", (int)srcObject.ID);

                    if (teleporterEndpoint == null)
                    {
                        Logger.WriteError("[OBJ] Teleporter for {0} in {1} does not contain a destination!", srcObj.Header.ID, "lobby");
                        // Teleport Player to default point
                        context.SendPacket(new TeleportTransferPacket(srcObj, new PSOLocation(0f, 1f, 0f, -0.000031f, -0.417969f, 0.000031f, 134.375f)));
                        // Unhide player
                        context.SendPacket(new ObjectActionPacket(dstObject, srcObject, new ObjectHeader(), new ObjectHeader(), "Forwarded"));
                    }
                    else
                    {
                        PSOLocation endpointLocation = new PSOLocation()
                        {
                            RotX = teleporterEndpoint.RotX,
                            RotY = teleporterEndpoint.RotY,
                            RotZ = teleporterEndpoint.RotZ,
                            RotW = teleporterEndpoint.RotW,
                            PosX = teleporterEndpoint.PosX,
                            PosY = teleporterEndpoint.PosY,
                            PosZ = teleporterEndpoint.PosZ,
                        };
                        // Teleport Player
                        context.SendPacket(new TeleportTransferPacket(srcObj, endpointLocation));
                        // Unhide player
                        context.SendPacket(new ObjectActionPacket(dstObject, srcObject, new ObjectHeader(), new ObjectHeader(), "Forwarded"));
                    }
                }
            }

            if (command == "READY")
            {
                context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player), srcObj.Header, srcObj.Header,
                    new ObjectHeader(), "FavsNeutral"));
                context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player), srcObj.Header, srcObj.Header,
                    new ObjectHeader(), "AP")); // Short for Appear, Thanks Zapero!
            }

            if (command == "Sit")
            {
                foreach (var client in Server.Instance.Clients)
                {
                    if (client.Character == null || client == context)
                        continue;

                    client.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)client.User.PlayerId, EntityType.Player), srcObj.Header,
                        new ObjectHeader(dstObject.ID, EntityType.Player), new ObjectHeader(), "SitSuccess"));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Spawns a client into a map at a given location
        /// </summary>
        /// <param name="c">Client to spawn into map</param>
        /// <param name="location">Location to spawn client at</param>
        /// <param name="questOveride">If this also sets the quest data, specify the quest name here to load the spawn from the bin rather then generate it.</param>
        public void SpawnClient(Client c, PSOLocation location, string questOveride = "")
        {
            if (Clients.Contains(c))
            {
                return;
            }

            // Set area
            if (questOveride != "") // TODO: This is a temporary hack, fix me!!
            {
                var setAreaPacket = File.ReadAllBytes("Resources/quests/" + questOveride + ".bin");
                c.SendPacket(0x03, 0x24, 4, setAreaPacket);
            }
            else
            {
                PacketWriter writer = new PacketWriter();
                writer.WriteStruct(new ObjectHeader(3, EntityType.Map));
                writer.WriteStruct(new ObjectHeader((uint)c.User.PlayerId, EntityType.Player));
                writer.Write(0x1); // 8 Zeros
                writer.Write(0); // 8 Zeros
                writer.Write(~(uint)Type); // F4 FF FF FF
                writer.Write(MapID); // Map ID maybe
                writer.Write((uint)Flags);
                writer.Write(GenerationArgs.seed); // 81 8F E6 19 (Maybe seed)
                writer.Write(VariantID); // Randomgen enable / disable maybe
                writer.Write(GenerationArgs.xsize); // X Size
                writer.Write(GenerationArgs.ysize); // Y Size
                writer.Write(1);
                writer.Write(1);
                writer.Write(~0); // FF FF FF FF FF FF FF FF
                writer.Write(0x301);

                c.SendPacket(0x3, 0x0, 0x0, writer.ToArray());
            }

            if (c.CurrentZone != null)
            {
                c.CurrentZone.RemoveClient(c);
            }

            var setPlayerId = new PacketWriter();
            setPlayerId.WritePlayerHeader((uint)c.User.PlayerId);
            c.SendPacket(0x06, 0x00, 0, setPlayerId.ToArray());

            // Spawn Character
            c.SendPacket(new CharacterSpawnPacket(c.Character, location));
            c.CurrentLocation = location;
            c.CurrentZone = this;

            // Objects
            foreach (PSOObject obj in Objects)
            {
                c.SendPacket(0x08, 0x0B, 0x0, obj.GenerateSpawnBlob());
            }

            // NPCs
            foreach (PSONPC npc in NPCs)
            {
                c.SendPacket(0x08, 0xC, 0x4, npc.GenerateSpawnBlob());
            }

            // Spawn for others, Spawn others for me
            CharacterSpawnPacket spawnMe = new CharacterSpawnPacket(c.Character, location, false);
            foreach (Client other in Clients)
            {
                other.SendPacket(spawnMe);
                c.SendPacket(new CharacterSpawnPacket(other.Character, other.CurrentLocation, false));
            }

            // Unlock Controls
            c.SendPacket(new NoPayloadPacket(0x03, 0x2B)); // Inital spawn only, move this!

            Clients.Add(c);

            Logger.Write("[MAP] {0} has spawned in {1}.", c.User.Username, Name);

            if (InstanceName != null && ZoneManager.Instance.playerCounter.ContainsKey(InstanceName))
            {
                ZoneManager.Instance.playerCounter[InstanceName] += 1;
            }
        }
Exemplo n.º 4
0
        public PSOLocation GetDefaultLocation()
        {
            PSOLocation location;

            switch (Type)
            {
                case MapType.Lobby:
                    location = new PSOLocation(0f, 1f, 0f, 0f, -0.417969f, 0f, 137.375f);
                    break;

                case MapType.Casino:
                    location = new PSOLocation(0, 1f, 0, 0, 2, 6, 102);
                    break;

                default:
                    location = new PSOLocation(0f, 1f, 0f, 0f, 0f, 0f, 0f);
                    break;
            }

            return location;
        }
 public PackedVec4(PSOLocation location)
 {
     this.x = Helper.FloatToHalfPrecision(location.RotX);
     this.y = Helper.FloatToHalfPrecision(location.RotY);
     this.z = Helper.FloatToHalfPrecision(location.RotZ);
     this.w = Helper.FloatToHalfPrecision(location.RotW);
 }
Exemplo n.º 6
0
        private void TeleportPlayer_POS(string[] args, int length, string full, Client client)
        {
            var foundPlayer = false;
            var id = 0;
            if (client != null)
            {
                id = client.User.PlayerId;
                foundPlayer = true;
            }
            else
            {
                var name = args[4].Trim('\"');

                Helper.FindPlayerByUsername(name);
                if (id != -1)
                    foundPlayer = true;

                client = PolarisApp.Instance.Server.Clients[id];
            }

            // Couldn't find the username
            if (!foundPlayer)
            {
                Logger.WriteError("[CMD] Could not find user.");
                return;
            }

            PSOLocation destination = new PSOLocation(0f, 1f, 0f, 0f,
                float.Parse(args[1]), float.Parse(args[2]), float.Parse(args[3]));

            client.SendPacket(new TeleportTransferPacket(ObjectManager.Instance.getObjectByID("lobby", 443), destination));
        }
 public PackedVec3(PSOLocation location)
 {
     this.x = Helper.FloatToHalfPrecision(location.PosX);
     this.y = Helper.FloatToHalfPrecision(location.PosY);
     this.z = Helper.FloatToHalfPrecision(location.PosZ);
 }
 public TeleportTransferPacket(PSOObject srcTeleporter, PSOLocation destination)
 {
     src = srcTeleporter;
     dst = destination;
 }
 public CharacterSpawnPacket(Character character, PSOLocation locatiion, bool isme)
 {
     _character = character;
     IsItMe = isme;
     Position = locatiion;
 }
Exemplo n.º 10
0
 public CharacterSpawnPacket(Character character, PSOLocation locatiion)
 {
     _character = character;
     Position = locatiion;
 }
Exemplo n.º 11
0
        private void TeleportPlayer(string[] args, int length, string full, Client client)
        {
            var name = args[1].Trim('\"');
            var foundPlayer = false;

            var id = Helper.FindPlayerByUsername(name);
            if (id != -1)
                foundPlayer = true;

            // Couldn't find the username
            if (!foundPlayer)
            {
                Logger.WriteError("[CMD] Could not find user " + name);
                return;
            }

            PSOLocation destination = new PSOLocation(float.Parse(args[2]), float.Parse(args[3]), float.Parse(args[4]), float.Parse(args[5]),
                float.Parse(args[6]), float.Parse(args[7]), float.Parse(args[8]));

            PolarisApp.Instance.Server.Clients[id].SendPacket(new TeleportTransferPacket(ObjectManager.Instance.getObjectByID("lobby", 443), destination));
        }