Пример #1
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);
                        }
                    }
                }
            }
        }
Пример #2
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);
                        }
                    }
                }
            }
        }
Пример #3
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;
        }
Пример #4
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 });
        }