Exemplo n.º 1
0
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            if ((character.Stats[StatIds.externaldoorinstance].Value == 0) ||
                (character.Stats[StatIds.externalplayfieldinstance].Value == 0))
            {
                ChatTextMessageHandler.Default.Create(character, "Please enter a proxyfied playfield first.");
            }

            Coordinate    tempCoordinate = character.Coordinates();
            PlayfieldData pfData         = PlayfieldLoader.PFData[character.Playfield.Identity.Instance];
            StatelData    o = null;

            foreach (StatelData s in pfData.Statels)
            {
                if (o == null)
                {
                    o = s;
                }
                else
                {
                    if (Coordinate.Distance2D(tempCoordinate, s.Coord())
                        < Coordinate.Distance2D(tempCoordinate, o.Coord()))
                    {
                        o = s;
                    }
                }
            }
            if (o == null)
            {
                ChatTextMessageHandler.Default.Create(
                    character,
                    "No statel on this playfield... Very odd, where exactly are you???");
            }
            else
            {
                DBTeleport tel = new DBTeleport();
                tel.playfield            = character.Stats[StatIds.externalplayfieldinstance].Value;
                tel.statelType           = 0xc748; // Door only for now
                tel.statelInstance       = character.Stats[StatIds.externaldoorinstance].BaseValue;
                tel.destinationPlayfield = o.PlayfieldId;
                tel.destinationType      = (int)o.Identity.Type;
                tel.destinationInstance  = BitConverter.ToUInt32(BitConverter.GetBytes(o.Identity.Instance), 0);

                var temp = TeleportDao.Instance.GetWhere(new { tel.playfield, tel.statelType, tel.statelInstance });
                foreach (var t in temp)
                {
                    TeleportDao.Instance.Delete(t.Id);
                }
                TeleportDao.Instance.Add(tel);
                character.Playfield.Publish(
                    ChatTextMessageHandler.Default.CreateIM(character, "Proxy saved"));
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            List <MessageBody> replies = new List <MessageBody>();
            string             reply   = "Looking up for statel in playfield " + character.Playfield.Identity.Instance;

            replies.Add(ChatTextMessageHandler.Default.Create(character, reply));
            StatelData  o              = null;
            StaticDynel o2             = null;
            Vendor      o3             = null;
            Coordinate  tempCoordinate = character.Coordinates();

            if (!PlayfieldLoader.PFData.ContainsKey(character.Playfield.Identity.Instance))
            {
                reply = "Could not find data for playfield " + character.Playfield.Identity.Instance;
                replies.Add(ChatTextMessageHandler.Default.Create(character, reply));
            }
            else
            {
                if (target.Equals(Identity.None))
                {
                    PlayfieldData pfData = PlayfieldLoader.PFData[character.Playfield.Identity.Instance];
                    foreach (StatelData s in pfData.Statels)
                    {
                        if (o == null)
                        {
                            o = s;
                        }
                        else
                        {
                            if (Coordinate.Distance2D(tempCoordinate, s.Coord())
                                < Coordinate.Distance2D(tempCoordinate, o.Coord()))
                            {
                                o = s;
                            }
                        }
                    }

                    foreach (StaticDynel sd in Pool.Instance.GetAll <StaticDynel>(character.Playfield.Identity))
                    {
                        if (o2 == null)
                        {
                            o2 = sd;
                        }
                        else
                        {
                            if (Coordinate.Distance2D(tempCoordinate, sd.Coordinate)
                                < Coordinate.Distance2D(tempCoordinate, o2.Coordinate))
                            {
                                o2 = sd;
                            }
                        }
                    }
                }
                else
                {
                    o =
                        PlayfieldLoader.PFData[character.Playfield.Identity.Instance].Statels.FirstOrDefault(
                            x => x.Identity == target);
                    o2 =
                        Pool.Instance.GetAll <StaticDynel>(character.Playfield.Identity)
                        .FirstOrDefault(x => x.Identity == target);
                    o3 =
                        Pool.Instance.GetAll <Vendor>(character.Playfield.Identity)
                        .FirstOrDefault(x => x.Identity == target);
                }

                if ((o == null) && (o2 == null) && (o3 == null))
                {
                    replies.Add(
                        ChatTextMessageHandler.Default.Create(
                            character,
                            "No statel/static dynel on this playfield... Very odd, where exactly are you???"));
                }
                else
                {
                    if (o3 != null)
                    {
                        replies.Add(
                            ChatTextMessageHandler.Default.Create(
                                character,
                                o3.Identity.Type.ToString() + " " + ((int)o3.Identity.Type).ToString("X8") + ":"
                                + o3.Identity.Instance.ToString("X8")));
                        replies.Add(
                            ChatTextMessageHandler.Default.Create(character, "Item Template Id: " + o3.Template.ID));
                        foreach (Event se in o3.Events)
                        {
                            replies.Add(ChatTextMessageHandler.Default.Create(character, se.ToString()));
                        }
                    }
                    else if (((o != null) && (o2 == null)) ||
                             ((o != null) && (Coordinate.Distance2D(tempCoordinate, o.Coord())
                                              < Coordinate.Distance2D(tempCoordinate, o2.Coordinate))))
                    {
                        replies.Add(
                            ChatTextMessageHandler.Default.Create(
                                character,
                                o.Identity.Type.ToString() + " " + ((int)o.Identity.Type).ToString("X8") + ":"
                                + o.Identity.Instance.ToString("X8")));
                        replies.Add(
                            ChatTextMessageHandler.Default.Create(character, "Item Template Id: " + o.TemplateId));
                        foreach (Event se in o.Events)
                        {
                            replies.Add(ChatTextMessageHandler.Default.Create(character, se.ToString()));
                        }
                    }
                    else
                    {
                        replies.Add(ChatTextMessageHandler.Default.Create(character, o2.Identity.ToString() + " " + o2.Identity.ToString()));
                        replies.Add(ChatTextMessageHandler.Default.Create(character, "Item template Id: " + o2.Stats[(int)StatIds.acgitemtemplateid].ToString()));
                        foreach (Event se in o2.Events)
                        {
                            replies.Add(ChatTextMessageHandler.Default.Create(character, se.ToString()));
                        }
                    }
                }
            }

            character.Playfield.Publish(Bulk.CreateIM(character.Controller.Client, replies.ToArray()));
        }
Exemplo n.º 3
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)
        {
            List <MessageBody> replies = new List <MessageBody>();
            string             reply   = "Looking up for statel in playfield " + character.Playfield.Identity.Instance;

            replies.Add(ChatText.Create(character, reply));
            StatelData o = null;

            if (!PlayfieldLoader.PFData.ContainsKey(character.Playfield.Identity.Instance))
            {
                reply = "Could not find data for playfield " + character.Playfield.Identity.Instance;
                replies.Add(ChatText.Create(character, reply));
            }
            else
            {
                PlayfieldData pfData = PlayfieldLoader.PFData[character.Playfield.Identity.Instance];
                foreach (StatelData s in pfData.Statels)
                {
                    if (o == null)
                    {
                        o = s;
                    }
                    else
                    {
                        if (Coordinate.Distance2D(character.Coordinates, s.Coord())
                            < Coordinate.Distance2D(character.Coordinates, o.Coord()))
                        {
                            o = s;
                        }
                    }
                }

                if (o == null)
                {
                    replies.Add(
                        ChatText.Create(character, "No statel on this playfield... Very odd, where exactly are you???"));
                }
                else
                {
                    replies.Add(
                        ChatText.Create(
                            character,
                            o.StatelIdentity.Type.ToString() + " " + ((int)o.StatelIdentity.Type).ToString("X8") + ":"
                            + o.StatelIdentity.Instance.ToString("X8")));
                    replies.Add(ChatText.Create(character, "Item Template Id: " + o.TemplateId));
                    foreach (Events se in o.Events)
                    {
                        replies.Add(
                            ChatText.Create(
                                character,
                                "Event: " + se.EventType.ToString() + " # of Functions: "
                                + se.Functions.Count.ToString()));

                        foreach (Functions sf in se.Functions)
                        {
                            string Fargs = string.Empty;
                            foreach (MessagePackObject obj in sf.Arguments.Values)
                            {
                                if (Fargs.Length > 0)
                                {
                                    Fargs = Fargs + ", ";
                                }

                                Fargs = Fargs + obj.ToString();
                            }

                            replies.Add(
                                ChatText.Create(
                                    character,
                                    "    Fn: " + ((FunctionType)sf.FunctionType).ToString() + "("
                                    + sf.FunctionType.ToString() + "), # of Args: "
                                    + sf.Arguments.Values.Count.ToString()));
                            replies.Add(ChatText.Create(character, "    Args: " + Fargs));

                            foreach (Requirements sfr in sf.Requirements)
                            {
                                string req;
                                req = "Attr: " + sfr.Statnumber.ToString() + " Value: " + sfr.Value.ToString()
                                      + " Target: " + sfr.Target.ToString() + " Op: " + sfr.Operator.ToString();
                                replies.Add(ChatText.Create(character, req));
                            }
                        }
                    }
                }
            }

            character.Playfield.Publish(Bulk.CreateIM(character.Client, replies.ToArray()));
        }