Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        public static void GetDynels(Client client)
        {
            foreach (Client clients in client.Server.Clients)
            {
                PacketWriter packetWriter;
                if ((clients.Character.PlayField == client.Character.PlayField) &&
                    (clients.Character.Id != client.Character.Id))
                {
                    SimpleCharFullUpdate.SendToOne(clients.Character, client);

                    // Send CharacterInPlay packet
                    // TODO: Move this out to own file
                    packetWriter = new PacketWriter();
                    packetWriter.PushByte(0xDF);
                    packetWriter.PushByte(0xDF);
                    packetWriter.PushShort(10);
                    packetWriter.PushShort(1);
                    packetWriter.PushShort(0);
                    packetWriter.PushInt(3086);
                    packetWriter.PushInt(client.Character.Id);
                    packetWriter.PushInt(0x570C2039);
                    packetWriter.PushIdentity(50000, clients.Character.Id);
                    packetWriter.PushByte(0);
                    byte[] reply2 = packetWriter.Finish();
                    client.SendCompressed(reply2);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// </summary>
        /// <param name="sendSCFUs">
        /// </param>
        public void SendSCFUsToClient(IMSendPlayerSCFUs sendSCFUs)
        {
            Identity dontSendTo = sendSCFUs.toClient.Character.Identity;

            foreach (IEntity entity in this.Entities)
            {
                if (entity.Identity != dontSendTo)
                {
                    if (entity.Identity.Type == IdentityType.CanbeAffected)
                    {
                        var temp = entity as INamedEntity;
                        if (temp != null)
                        {
                            // TODO: make it NPC-safe
                            SimpleCharFullUpdateMessage simpleCharFullUpdate =
                                SimpleCharFullUpdate.ConstructMessage((Character)temp);
                            sendSCFUs.toClient.SendCompressed(simpleCharFullUpdate);

                            var charInPlay = new CharInPlayMessage {
                                Identity = temp.Identity, Unknown = 0x00
                            };
                            sendSCFUs.toClient.SendCompressed(charInPlay);
                        }
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// </summary>
        /// <param name="sendSCFUs">
        /// </param>
        public void SendSCFUsToClient(IMSendPlayerSCFUs sendSCFUs)
        {
            Identity dontSendTo = sendSCFUs.toClient.Character.Identity;

            lock (this.Entities)
            {
                foreach (IEntity entity in
                         this.Entities.GetAll((int)IdentityType.CanbeAffected).Where(x => x is IPacketReceivingEntity))
                {
                    if (entity.Identity != dontSendTo)
                    {
                        var temp = entity as Character;
                        if (temp != null)
                        {
                            // TODO: make it NPC-safe
                            SimpleCharFullUpdateMessage simpleCharFullUpdate =
                                SimpleCharFullUpdate.ConstructMessage(temp);
                            sendSCFUs.toClient.SendCompressed(simpleCharFullUpdate);

                            var charInPlay = new CharInPlayMessage {
                                Identity = temp.Identity, Unknown = 0x00
                            };
                            sendSCFUs.toClient.SendCompressed(charInPlay);
                        }
                    }
                }
            }
        }
Пример #4
0
        public void SpawnRandomMob(ICharacter character)
        {
            Coordinate coord = character.Coordinates();

            DBMobTemplate[] templates = MobTemplateDao.Instance.GetAll().ToArray();
            Random          rnd       = new Random(Environment.TickCount);

            int mobNumber = rnd.Next(templates.Length);

            DBMobTemplate template      = templates[mobNumber];
            NPCController npcController = new NPCController();
            Character     mobCharacter  = NonPlayerCharacterHandler.SpawnMobFromTemplate(
                template.Hash,
                character.Playfield.Identity,
                character.Coordinates(),
                character.RawHeading,
                npcController);

            mobCharacter.Playfield = character.Playfield;
            SimpleCharFullUpdateMessage mess = SimpleCharFullUpdate.ConstructMessage(mobCharacter);

            character.Playfield.Announce(mess);
            AppearanceUpdateMessageHandler.Default.Send(mobCharacter);

            Vector3 v = new Vector3(coord.x, coord.y, coord.z + 5);

            mobCharacter.AddWaypoint(v, false);
            v.x += 10 - rnd.Next(20);
            v.z -= 10 - rnd.Next(20);

            mobCharacter.AddWaypoint(v, false);
            v.x += 10 - rnd.Next(20);
            v.z -= 10 - rnd.Next(20);
            mobCharacter.AddWaypoint(v, false);
            v.x += 10 - rnd.Next(20);
            v.z -= 10 - rnd.Next(20);
            mobCharacter.AddWaypoint(v, false);
            mobCharacter.Stats[StatIds.health].Value = 10000;
            mobCharacter.DoNotDoTimers = false;
        }
Пример #5
0
        /// <summary>
        /// </summary>
        /// <param name="charID">
        /// </param>
        /// <param name="client">
        /// </param>
        public void Read(int charID, ZoneClient client)
        {
            // Don't edit anything in this region
            // unless you are 300% sure you know what you're doing

            // Character is created and read when Client connects in Client.cs->CreateCharacter
            // client.CreateCharacter(charID);
            client.Server.Info(
                client,
                "Client connected. ID: {0} IP: {1} Character name: {2}",
                client.Character.Identity.Instance,
                client.ClientAddress,
                client.Character.Name);

            // now we have to start sending packets like
            // character stats, inventory, playfield info
            // and so on. I will put some packets here just
            // to get us in game. We have to start moving
            // these packets somewhere else and make packet
            // builders instead of sending (half) hardcoded
            // packets.

            /* send chat server info to client */
            ChatServerInfo.Send(client);

            /* send playfield info to client */
            PlayfieldAnarchyF.Send(client);

            var sendSCFUs = new IMSendPlayerSCFUs {
                toClient = client
            };

            ((Playfield)client.Playfield).SendSCFUsToClient(sendSCFUs);

            /* set SocialStatus to 0 */
            client.Character.Stats[521].BaseValue = 0;

            // Stat.SendDirect(client, 521, 0, false);

            var identity = new Identity {
                Type = IdentityType.CanbeAffected, Instance = charID
            };

            /* Action 167 Animation and Stance Data maybe? */
            var message = new CharacterActionMessage
            {
                Identity   = identity,
                Action     = CharacterActionType.ChangeAnimationAndStance,
                Target     = Identity.None,
                Parameter1 = 0x00000000,
                Parameter2 = 0x00000001
            };

            client.SendCompressed(message);

            var gameTimeMessage = new GameTimeMessage
            {
                Identity = identity,
                Unknown1 = 30024.0f,
                Unknown3 = 185408,
                Unknown4 = 80183.3125f
            };

            client.SendCompressed(gameTimeMessage);

            /* set SocialStatus to 0 */
            // Stat.SendDirect(client, 521, 0, false);

            /* again */
            // Stat.SendDirect(client, 521, 0, false);

            /* visual */
            SimpleCharFullUpdate.SendToPlayfield(client);

            /* inventory, items and all that */
            FullCharacter.Send(client);

            var specials = new[]
            {
                new SpecialAttackInfo
                {
                    Unknown1 = 0x0000AAC0,
                    Unknown2 = 0x00023569,
                    Unknown3 = 0x00000064,
                    Unknown4 = "MAAT"
                },
                new SpecialAttackInfo
                {
                    Unknown1 = 0x0000A431,
                    Unknown2 = 0x0000A430,
                    Unknown3 = 0x00000090,
                    Unknown4 = "DIIT"
                },
                new SpecialAttackInfo
                {
                    Unknown1 = 0x00011294,
                    Unknown2 = 0x00011295,
                    Unknown3 = 0x0000008E,
                    Unknown4 = "BRAW"
                }
            };
            var specialAttackWeaponMessage = new SpecialAttackWeaponMessage {
                Identity = identity, Specials = specials
            };

            client.SendCompressed(specialAttackWeaponMessage);

            // done

            // Timers are allowed to update client stats now.
            client.Character.DoNotDoTimers = false;

            // spawn all active monsters to client
            // TODO: Implement NonPlayerCharacterHandler
            // NonPlayerCharacterHandler.SpawnMonstersInPlayfieldToClient(client, client.Character.PlayField);

            // TODO: Implement VendorHandler
            // if (VendorHandler.GetNumberofVendorsinPlayfield(client.Character.PlayField) > 0)
            // {
            // Shops
            // VendorHandler.GetVendorsInPF(client);
            // }

            // WeaponItemFullCharUpdate  Maybe the right location , First Check if weapons present usually in equipment
            // Packets.WeaponItemFullUpdate.Send(client, client.Character);

            // TODO: create a better alternative to ProcessTimers
            // client.Character.ProcessTimers(DateTime.Now + TimeSpan.FromMilliseconds(200));
            client.Character.CalculateSkills();

            AppearanceUpdate.AnnounceAppearanceUpdate((Character)client.Character);

            // done, so we call a hook.
            // Call all OnConnect script Methods
            Program.csc.CallMethod("OnConnect", (Character)client.Character);
        }
Пример #6
0
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            if (string.Compare(args[0], "spawnrandom", true) == 0)
            {
                this.SpawnRandomMob(character);
                return;
            }

            if (string.Compare(args[0], "spawncount", true) == 0)
            {
                this.SpawnCount(character);
                return;
            }

            if (string.Compare(args[1], "list", true) == 0)
            {
                // list templates
                IEnumerable <DBMobTemplate> mobTemplates =
                    MobTemplateDao.Instance.GetMobTemplatesByName((args.Length > 2) ? args[2] : "%", false);

                StringBuilder text = new StringBuilder("List of mobtemplates (Hash, Name): ");
                foreach (DBMobTemplate mt in mobTemplates)
                {
                    text.AppendLine(string.Format("{0},'{1}'", mt.Hash, mt.Name));
                }

                character.Playfield.Publish(ChatTextMessageHandler.Default.CreateIM(character, text.ToString()));
            }
            else
            {
                // try spawning mob
                Character mobCharacter = null;
                if (args.Length == 3)
                {
                    // DBMobTemplate mt = MobTemplateDao.GetMobTemplateByHash(args[1])
                    // character.Playfield.Despawn
                    //NonPlayerCharacterHandler.SpawnMonster(client, args[1], uint.Parse(args[2]));
                    NPCController npcController = new NPCController();
                    mobCharacter = NonPlayerCharacterHandler.SpawnMobFromTemplate(
                        args[1],
                        character.Playfield.Identity,
                        character.Coordinates(),
                        character.RawHeading,
                        npcController,
                        int.Parse(args[2]));
                }
                if (args.Length == 2)
                {
                    NPCController npcController = new NPCController();
                    mobCharacter = NonPlayerCharacterHandler.SpawnMobFromTemplate(
                        args[1],
                        character.Playfield.Identity,
                        character.Coordinates(),
                        character.RawHeading,
                        npcController);
                }
                if (mobCharacter != null)
                {
                    mobCharacter.Playfield = character.Playfield;
                    SimpleCharFullUpdateMessage mess = SimpleCharFullUpdate.ConstructMessage(mobCharacter);
                    character.Playfield.Announce(mess);
                    AppearanceUpdateMessageHandler.Default.Send(mobCharacter);
                    // HEAL!!!!
                    mobCharacter.Stats[StatIds.health].Value = mobCharacter.Stats[StatIds.life].Value;
                    mobCharacter.DoNotDoTimers = false;
                }
            }

            // this.CommandHelp(client);

            //var check = new List<Type> { typeof(float), typeof(float), typeof(int) };

            //var coord = new Coordinate();
            //int pf = character.Playfield.Identity.Instance;
            //if (CheckArgumentHelper(check, args))
            //{
            //    coord = new Coordinate(
            //        float.Parse(args[1], NumberStyles.Any, CultureInfo.InvariantCulture),
            //        character.Coordinates.y,
            //        float.Parse(args[2], NumberStyles.Any, CultureInfo.InvariantCulture));
            //    pf = int.Parse(args[3]);
            //}

            //check.Clear();
            //check.Add(typeof(float));
            //check.Add(typeof(float));
            //check.Add(typeof(string));
            //check.Add(typeof(float));
            //check.Add(typeof(int));

            //if (CheckArgumentHelper(check, args))
            //{
            //    coord = new Coordinate(
            //        float.Parse(args[1], NumberStyles.Any, CultureInfo.InvariantCulture),
            //        float.Parse(args[4], NumberStyles.Any, CultureInfo.InvariantCulture),
            //        float.Parse(args[2], NumberStyles.Any, CultureInfo.InvariantCulture));
            //    pf = int.Parse(args[5]);
            //}

            //if (!Playfields.ValidPlayfield(pf))
            //{
            //    character.Playfield.Publish(
            //        new IMSendAOtomationMessageBodyToClient()
            //        {
            //            Body =
            //                new FeedbackMessage()
            //                {
            //                    CategoryId = 110,
            //                    MessageId = 188845972
            //                },
            //            client = character.Client
            //        });
            //    return;
            //}

            //character.Playfield.Teleport(
            //    (Character)character,
            //    coord,
            //    character.Heading,
            //    new Identity() { Type = IdentityType.Playfield, Instance = pf });
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="client"></param>
        public void Read(byte[] packet, Client client)
        {
            // Don't edit anything in this region
            // unless you are 300% sure you know what you're doing

            #region Do not edit
            MemoryStream memoryStream = new MemoryStream(packet);
            BinaryReader binaryReader = new BinaryReader(memoryStream);
            memoryStream.Position = 20;
            // we get character ID of a client and store
            // it in this ClientBase so we can use it later
            int charID = IPAddress.NetworkToHostOrder(binaryReader.ReadInt32());
            binaryReader.Close();
            memoryStream.Dispose();

            client.Character        = new Character(charID, 0);
            client.Character.Client = client;
            client.Character.ReadNames();

            client.Server.Info(
                client,
                "Client connected. ID: {0} IP: {1}",
                client.Character.Id,
                client.TcpIP + " Character name: " + client.Character.Name);

            // now we have to start sending packets like
            // character stats, inventory, playfield info
            // and so on. I will put some packets here just
            // to get us in game. We have to start moving
            // these packets somewhere else and make packet
            // builders instead of sending (half) hardcoded
            // packets.

            // lets get char ID as byte array
            byte[] chrID = new[] { packet[20], packet[21], packet[22], packet[23] };

            /* send chat server info to client */
            ChatServerInfo.Send(client);

            /* send playfield info to client */
            PlayfieldAnarchyF.Send(client);

            /* set SocialStatus to 0 */

            client.Character.Stats.SetBaseValue(521, 0);
            Stat.Send(client, 521, 0, false);

            /* Action 167 Animation and Stance Data maybe? */
            byte[] tempBytes = new byte[]
            {
                0xDF, 0xDF, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x0c, 0x0e, chrID[0], chrID[1], chrID[2],
                chrID[3], 0x5E, 0x47, 0x77, 0x70,                                                             // CharacterAction
                0x00, 0x00, 0xC3, 0x50, chrID[0], chrID[1], chrID[2], chrID[3], 0x00, 0x00, 0x00, 0x00, 0xA7, // 167
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
                , 0x00, 0x00, 0x01, 0x00, 0x00
            };
            client.SendCompressed(tempBytes);

            tempBytes = new byte[]
            {
                // current in game time

                0xDF, 0xDF, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x2D, 0x00, 0x00, 0x0c, 0x0e, chrID[0], chrID[1], chrID[2],
                chrID[3], 0x5F, 0x52, 0x41, 0x2E,                                                             // GameTime
                0x00, 0x00, 0xC3, 0x50, chrID[0], chrID[1], chrID[2], chrID[3], 0x01, 0x46, 0xEA, 0x90, 0x00, // 30024.0
                0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xD4, 0x40,                                               // 185408
                0x47, 0x9C, 0x9B, 0xA8                                                                        // 80183.3125
            };
            client.SendCompressed(tempBytes);

            /* set SocialStatus to 0 */
            Stat.Set(client, 521, 0, false);

            /* again */
            Stat.Set(client, 521, 0, false);

            /* visual */

            SimpleCharFullUpdate.SendToPlayfield(client);

            /* inventory, items and all that */
            FullCharacter.Send(client);

            tempBytes = new byte[]
            {
                // this packet gives you (or anyone else)
                // special attacks like brawl, fling shot and so

                0xDF, 0xDF, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x65, 0x00, 0x00, 0x0c, 0x0e, chrID[0], chrID[1], chrID[2],
                chrID[3], 0x1D, 0x3C, 0x0F, 0x1C,     // SpecialAttackWeapon
                0x00, 0x00, 0xC3, 0x50, chrID[0], chrID[1], chrID[2], chrID[3], 0x01, 0x00, 0x00, 0x0F, 0xC4,
                // (4036/1009)-1 = 3 special attacks
                0x00, 0x00, 0xAA, 0xC0,    // 43712
                0x00, 0x02, 0x35, 0x69,    // 144745
                0x00, 0x00, 0x00, 0x64,    // 100
                0x4D, 0x41, 0x41, 0x54,    // "MAAT"
                0x00, 0x00, 0xA4, 0x31,    // 42033
                0x00, 0x00, 0xA4, 0x30,    // 42032
                0x00, 0x00, 0x00, 0x90,    // 144
                0x44, 0x49, 0x49, 0x54,    // "DIIT"
                0x00, 0x01, 0x12, 0x94,    // 70292
                0x00, 0x01, 0x12, 0x95,    // 70293
                0x00, 0x00, 0x00, 0x8E,    // 142
                0x42, 0x52, 0x41, 0x57,    // "BRAW"
                0x00, 0x00, 0x00, 0x07,    // 7
                0x00, 0x00, 0x00, 0x07,    // 7
                0x00, 0x00, 0x00, 0x07,    // 7
                0x00, 0x00, 0x00, 0x0E,    // 14
                0x00, 0x00, 0x00, 0x64     // 100
            };

            client.SendCompressed(tempBytes);
            // done
            #endregion

            // Timers are allowed to update client stats now.
            client.Character.DoNotDoTimers = false;

            // spawn all active monsters to client
            NonPlayerCharacterHandler.SpawnMonstersInPlayfieldToClient(client, client.Character.PlayField);

            if (VendorHandler.GetNumberofVendorsinPlayfield(client.Character.PlayField) > 0)
            {
                /* Shops */
                VendorHandler.GetVendorsInPF(client);
            }

            // WeaponItemFullCharUpdate  Maybe the right location , First Check if weapons present usually in equipment
            //Packets.WeaponItemFullUpdate.Send(client, client.Character);

            client.Character.ProcessTimers(DateTime.Now + TimeSpan.FromMilliseconds(200));

            client.Character.CalculateSkills();

            AppearanceUpdate.AnnounceAppearanceUpdate(client.Character);

            // done, so we call a hook.
            // Call all OnConnect script Methods
            Program.csc.CallMethod("OnConnect", client.Character);
        }