public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length == 0)
            {
                return(ShowUsage());
            }
            int argsUsed;
            List <SimObject> PS = WorldSystem.GetPrimitives(args, out argsUsed);

            if (IsEmpty(PS))
            {
                return(Failure("Cannot find objects from " + args.str));
            }
            GridClient client = TheBotClient;

            foreach (var currentPrim in PS)
            {
                AddSuccess(Name + " on " + currentPrim);
                if (TheSimAvatar.TakeObject(currentPrim) == null)
                {
                    Failure("Cannot Take " + currentPrim);
                }
            }
            return(SuccessOrFailure());
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int argsUsed;

            TheSimAvatar.StopMoving();
            return(Success(string.Format("Stopped moving")));
        }
Exemple #3
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage()); // " goto sim/x/y/z";
            }
            int         argsUsed;
            SimPosition position = WorldSystem.GetVector(args, out argsUsed);

            if (position == null)
            {
                return(Failure("Teleport - Cannot resolve to a location: " + args.str));
            }
            SimPathStore ps     = position.PathStore;
            ulong        handle = SimRegion.GetRegionHandle(ps);

            TheSimAvatar.StopMoving();
            if (Client.Self.Teleport(handle, position.SimPosition))
            {
                return(Success("Teleported to " + Client.Network.CurrentSim));
            }
            else
            {
                return(Failure("Teleport failed: " + Client.Self.TeleportMessage));
            }
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            string to_op   = args.GetString("verb");
            string objname = args.GetString("target");

            if (objname == "")
            {
                return(Failure("$bot don't know what object to use."));
            }
            if (to_op == "")
            {
                SimObject objToUse;
                if (WorldSystem.tryGetPrim(objname, out objToUse))
                {
                    if ((BotNeeds)TheSimAvatar["CurrentNeeds"] == null)
                    {
                        TheSimAvatar["CurrentNeeds"] = new BotNeeds(90.0f);
                    }
                    SimTypeUsage usage = objToUse.Affordances.GetBestUse((BotNeeds)TheSimAvatar["CurrentNeeds"]);
                    if (usage == null)
                    {
                        //usage = new MoveToLocation(TheSimAvatar, objToUse);
                        return(Failure("$bot don't have a use for " + objToUse + " yet."));
                    }
                    TheSimAvatar.Do(usage, objToUse);
                    return(Success("used " + objToUse));
                }
                return(Failure("$bot don't know what to do with " + objname));
            }
            WriteLine("Trying to (" + to_op + ") with (" + objname + ")");
            TheBotClient.UseInventoryItem(to_op, objname);
            return(Success("completed to (" + to_op + ") with (" + objname + ")"));
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage());
            }
            if (args.ContainsFlag("--all"))
            {
                List <uint> ids = new List <uint>();
                foreach (SimObject o in TheSimAvatar.Children)
                {
                    Success("Detatching " + o);
                    ids.Add(o.LocalID);
                }
                Client.Objects.DetachObjects(TheSimAvatar.GetSimulator(), ids);
                return(Success("detatched all " + ids.Count));
            }

            int argsUsed;

            string[]         keyargs = args.GetProperty("targets");
            List <SimObject> PS      = WorldSystem.GetPrimitives(keyargs, out argsUsed);
            List <uint>      idz     = new List <uint>();

            foreach (var o in PS)
            {
                Success("Detatching " + o);
                idz.Add(o.LocalID);
            }
            Client.Objects.DetachObjects(TheSimAvatar.GetSimulator(), idz);
            return(Success("detatched  " + args.str + " " + idz.Count));
        }
Exemple #6
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length == 0)
            {
                return(ShowUsage());
            }

            int argsUsed;
            List <SimObject> PS = WorldSystem.GetPrimitives(args, out argsUsed);

            if (IsEmpty(PS))
            {
                return(Failure("Cannot find objects from " + args.str));
            }

            foreach (var currentPrim in PS)
            {
                AddSuccess(Name + " on " + currentPrim);
                if (!TheSimAvatar.AttachToSelf(currentPrim))
                {
                    Failure("Cannot Attach " + currentPrim);
                }
            }
            return(SuccessOrFailure());
        }
        public override void Network_OnCurrentSimChanged(object sender, SimChangedEventArgs e)
        {
            var PreviousSimulator = e.PreviousSimulator;

            if (TheSimAvatar.GetSimulator() == PreviousSimulator)
            {
                Debug("TheSimAvatar._CurrentRegion.TheSimulator == PreviousSimulator " + PreviousSimulator);
            }
            On_ChangeSims(PreviousSimulator, client.Network.CurrentSim);
        }
 private void LeaveSimulator(Simulator simulator)
 {
     if (IsMaster(simulator))
     {
         Debug("SIM LOOSING ITS MASTER!" + this + " " + simulator);
         MasteringRegions.Remove(simulator.Handle);
         FindNewMaster(simulator.Handle);
     }
     if (TheSimAvatar.GetSimulator() == simulator)
     {
         Debug("TheSimAvatar._CurrentRegion.TheSimulator == simulator " + simulator);
     }
 }
 private void On_ChangeSims(Simulator PreviousSimulator, Simulator newSim)
 {
     if (PreviousSimulator != null)
     {
         LeaveSimulator(PreviousSimulator);
         //  new Thread(() => client.Appearance.SetPreviousAppearance(false)).Start();
     }
     else
     {
         //                new Thread(() => client.Appearance.WearOutfit(new string[] { "Clothing", "Default", "IRobot" })).Start();
     }
     EnsureSimulator(newSim);
     TheSimAvatar.ResetRegion(newSim.Handle);
 }
        public string describeAvatar(Avatar avatar)
        {
            //	string verb;
            //if (avatar.SittingOn == 0)
            //    verb = "standing";
            //else
            //    verb = "sitting";
            //WriteLine(avatar.Name + " is " + verb + " in " + avatar.CurrentSim.Name + ".");
            if (avatar == null)
            {
                return("NULL avatar");
            }
            string s = String.Empty;

            s += (avatar.Name + " is " + TheSimAvatar.DistanceVectorString(GetSimObject(avatar)) + " distant.");
            if (!HasValue(avatar.ProfileProperties))
            {
                return(s);
            }
            if (avatar.ProfileProperties.BornOn != null)
            {
                s += ("Born on: " + avatar.ProfileProperties.BornOn);
            }
            if (avatar.ProfileProperties.AboutText != null)
            {
                s += ("About their second life: " + avatar.ProfileProperties.AboutText);
            }
            if (avatar.ProfileProperties.FirstLifeText != null)
            {
                s += ("About their first life: " + avatar.ProfileProperties.FirstLifeText);
            }
            if (avatar.ProfileInterests.LanguagesText != null)
            {
                s += ("Languages spoken: " + avatar.ProfileInterests.LanguagesText);
            }
            if (avatar.ProfileInterests.SkillsText != null)
            {
                s += ("Skills: " + avatar.ProfileInterests.SkillsText);
            }
            if (avatar.ProfileInterests.WantToText != null)
            {
                s += ("Wants to: " + avatar.ProfileInterests.WantToText);
            }
            return(s);
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage()); // " siton UUID";
            }
            int         argsUsed;
            SimPosition pos;

            if (!args.TryGetValue("on", out pos))
            {
                sittingOnGround = WorldSystem.TheSimAvatar.SitOnGround();
                return(!sittingOnGround
                           ? Failure("$bot did not yet sit on the ground.")
                           : Success("$bot sat on the ground."));
            }
            if (pos is SimObject)
            {
                if (WorldSystem.TheSimAvatar.SitOn(pos as SimObject))
                {
                    Success("$bot sat on " + pos);
                }
                if (!args.IsTrue("down"))
                {
                    return(Failure("$bot did not yet sit on " + pos));
                }
            }
            else if (pos == null)
            {
                return(Failure("$bot did not yet find " + args.str));
            }
            // @todo use autoppoiolot to the location andf then sit
            TheSimAvatar.GotoTargetAStar(pos);
            sittingOnGround = WorldSystem.TheSimAvatar.SitOnGround();
            if (sittingOnGround)
            {
                return(Success("$bot sat at " + pos));
            }
            return(Failure("$bot did not sit at " + pos));
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int argsUsed;
            ICollection <SimObject> objs;
            bool rightNow = true;

            if (!args.TryGetValue("targets", out objs))
            {
                objs     = (ICollection <SimObject>)WorldSystem.GetAllSimObjects();
                rightNow = false;
            }
            WriteLine("Unmeshing " + objs.Count);
            foreach (SimObject o2 in objs)
            {
                SimObjectPathFinding o = o2.PathFinding;

                o.IsWorthMeshing = true;
                if (rightNow)
                {
                    o.RemoveCollisions();
                }
                else
                {
                    o.RemoveCollisions();
                }
            }
            if (rightNow)
            {
                TheSimAvatar.GetSimRegion().GetPathStore(TheSimAvatar.SimPosition).RemoveAllCollisionPlanes();
            }
            else
            {
                TheSimAvatar.GetSimRegion().GetPathStore(TheSimAvatar.SimPosition).RemoveAllCollisionPlanes();
            }

            return(TheBotClient.ExecuteCommand("meshinfo", args.CallerAgent, args.Output, args.CmdFlags));
        }
Exemple #13
0
        public override CmdResult ExecuteRequest(CmdRequest argsI)
        {
            ListAsSet <SimPosition> objs = TheSimAvatar.GetSelectedObjects();

            if (argsI.Length == 0)
            {
                foreach (var o in objs)
                {
                    WriteLine(" " + o);
                }
                return(SuccessOrFailure());
            }
            if (argsI.ContainsFlag("--clear"))
            {
                objs.Clear();
                bool was = TheSimAvatar.SelectedBeam;
                TheSimAvatar.SelectedBeam = !was;
                TheSimAvatar.SelectedBeam = was;
            }
            var args = argsI.GetProperty("targets");

            {
                int  used   = 0;
                bool remove = false;
                while (used < args.Length)
                {
                    args = Parser.SplitOff(args, used);
                    string s = args[0];
                    if (s.StartsWith("-"))
                    {
                        remove = true;
                        s      = s.Substring(1);
                    }
                    if (s.StartsWith("+"))
                    {
                        remove = false;
                        s      = s.Substring(1);
                    }
                    if (s.Length < 0)
                    {
                        used = 1;
                        continue;
                    }
                    args[0] = s;
                    List <SimObject> PS = WorldSystem.GetPrimitives(args, out used);
                    foreach (var P in PS)
                    {
                        if (P == null)
                        {
                            WriteLine("Cannot find " + s);
                            used = 1;
                            continue;
                        }
                        if (remove)
                        {
                            WriteLine("Removing " + P);
                            TheSimAvatar.SelectedRemove(P);
                        }
                        else
                        {
                            WriteLine("Adding " + P);
                            TheSimAvatar.SelectedAdd(P);
                        }
                    }
                    if (used == 0)
                    {
                        break;
                    }
                }
            }
            return(Success("selected objects count=" + objs.Count));
        }
Exemple #14
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            SimPosition position;

            if (!args.TryGetValue("is", out position))
            {
                return(Failure("I don't understand how to move " + args.str));
            }

            {
                double RAD2DEG = 180 / Math.PI;
                if (position != null)
                {
                    //avatar = ((SimAvatar)position).theAvatar;
                    //Client.Self.Movement.Camera.AtAxis
                    Vector3d   myPos        = TheSimAvatar.GlobalPosition;
                    Vector3    forward      = new Vector3(1, 0, 0);
                    Vector3d   positionVect = position.GlobalPosition;
                    Vector3d   offsetG      = positionVect - myPos;
                    Vector3    offset       = new Vector3((float)offsetG.X, (float)offsetG.Y, (float)offsetG.Z);
                    Quaternion newRot2      = Vector3.RotationBetween(forward, offset);

                    //Quaternion newRot1 = Vector3d.RotationBetween(positionVect, Client.Self.RelativePosition);
                    double newDist = Vector3d.Distance(positionVect, myPos);
                    WriteLine("Where Found: {0}", position);

                    // Absolute
                    WriteLine(" SimPosition = " + Vector3Str(position.SimPosition));
                    WriteLine(" SimRotation = {0:0.#}*", WorldObjects.GetZHeading(position.SimRotation) * RAD2DEG);

                    // Relative
                    WriteLine(" RelSimPosition = {0} ", Vector3Str(offset));
                    double relAngle = (Math.Atan2(-offset.X, -offset.Y) + Math.PI); // 2P
                    WriteLine(" RelSimPolar = {0:0.#}*{1:0.0#}", relAngle * RAD2DEG, newDist);

                    double selfFacing = WorldObjects.GetZHeading(TheSimAvatar.SimRotation);
                    WriteLine(" SelfFacingPolar = {0:+0.0#;-0.0#}*{1:0.0#}", (relAngle - selfFacing) * RAD2DEG, newDist);

                    if (false)
                    {
                        //WriteLine(" newRot1 = {0:0.#}*", WorldObjects.GetZHeading(newRot1) * RAD2DEG);
                        //WriteLine(" newRot2 = {0:0.#}*", WorldObjects.GetZHeading(newRot2) * RAD2DEG);
                        WriteLine(" Client.Self.Movement.Camera.AtAxis = " +
                                  Vector3Str(Client.Self.Movement.Camera.AtAxis));
                        WriteLine(" Client.Self.RelativePosition = " + Vector3Str(Client.Self.RelativePosition));
                        WriteLine(" SelfFacing = {0:0.#}*{1:0.0#}", selfFacing * RAD2DEG,
                                  Client.Self.Movement.Camera.AtAxis.Length());
                    }
                    SimObjectImpl o = position as SimObjectImpl;
                    if (o != null)
                    {
                        position = o.GetHeading();
                    }

                    //WriteLine(avatar.Rotation.X + ", " + avatar.Rotation.Y + ", " + avatar.Rotation.Z);
                    //WriteLine(Client.Self.RelativeRotation.X + ", " + Client.Self.RelativeRotation.Y + ", " + Client.Self.RelativeRotation.Z + "\n");

                    return(Success("At: " + position + " " + TheSimAvatar.DistanceVectorString(position)));
                }
                else
                {
                    return(Failure("I don't know where " + args.str + "."));
                }
            }
        }
        private void Self_OnMessage(string FromAgentName, UUID FromAgentID, UUID ToAgentID,
                                    string Message, UUID IMSessionID, bool GroupIM,
                                    UUID RegionID, Vector3 Position,
                                    InstantMessageDialog Dialog, ChatType Type, EventArgs origin)
        {
            if (Dialog == InstantMessageDialog.GroupNotice)
            {
                GroupIM = true;
            }

            BotPermissions perms = GetSecurityLevel(FromAgentID, FromAgentName);

            // Received an IM from someone that is authenticated
            if (Type == ChatType.OwnerSay)
            {
                perms |= BotPermissions.Owner;
            }

            bool displayedMessage = false;

            if (origin is ChatEventArgs && Message.Length > 0 && Dialog == InstantMessageDialog.MessageFromAgent)
            {
                WriteLine(String.Format("{0} says, \"{1}\".", FromAgentName, Message));
                PosterBoard["/posterboard/onchat"] = Message;
                if (FromAgentName == Self.Name)
                {
                    PosterBoard["/posterboard/onchat-said"] = Message;
                }
                else
                {
                    PosterBoard["/posterboard/onchat-heard"] = Message;
                }
            }

            bool groupIM = GroupIM && GroupMembers != null && GroupMembers.ContainsKey(FromAgentID) ? true : false;


            switch (Dialog)
            {
            case InstantMessageDialog.MessageBox:
                break;

            case InstantMessageDialog.GroupInvitation:
                if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0)
                {
                    string groupName = Message;
                    int    found     = groupName.IndexOf("Group:");
                    if (found > 0)
                    {
                        groupName = groupName.Substring(found + 6);
                    }
                    Self.InstantMessage(Self.Name, FromAgentID, string.Empty, IMSessionID,
                                        InstantMessageDialog.GroupInvitationAccept, InstantMessageOnline.Offline,
                                        Self.SimPosition,
                                        UUID.Zero, new byte[0]);
                    found = groupName.IndexOf(":");
                    if (found > 0)
                    {
                        groupName = groupName.Substring(0, found).Trim();
                        ExecuteCommand("joingroup " + groupName, CMDFLAGS.NoResult);
                    }
                }
                break;

            case InstantMessageDialog.InventoryOffered:
                break;

            case InstantMessageDialog.InventoryAccepted:
                break;

            case InstantMessageDialog.InventoryDeclined:
                break;

            case InstantMessageDialog.GroupVote:
                break;

            case InstantMessageDialog.TaskInventoryOffered:
                break;

            case InstantMessageDialog.TaskInventoryAccepted:
                break;

            case InstantMessageDialog.TaskInventoryDeclined:
                break;

            case InstantMessageDialog.NewUserDefault:
                break;

            case InstantMessageDialog.SessionAdd:
                break;

            case InstantMessageDialog.SessionOfflineAdd:
                break;

            case InstantMessageDialog.SessionGroupStart:
                break;

            case InstantMessageDialog.SessionCardlessStart:
                break;

            case InstantMessageDialog.SessionSend:
                break;

            case InstantMessageDialog.SessionDrop:
                break;

            case InstantMessageDialog.BusyAutoResponse:
                break;

            case InstantMessageDialog.ConsoleAndChatHistory:
                break;

            case InstantMessageDialog.Lure911:
            case InstantMessageDialog.RequestTeleport:
                if ((perms & BotPermissions.AcceptTeleport) != 0)
                {
                    TheSimAvatar.StopMoving();
                    if (RegionID != UUID.Zero)
                    {
                        if (!displayedMessage)
                        {
                            DisplayNotificationInChat("TP to Lure from " + FromAgentName);
                            displayedMessage = true;
                        }
                        SimRegion R = SimRegion.GetRegion(RegionID, gridClient);
                        if (R != null)
                        {
                            Self.Teleport(R.RegionHandle, Position);
                            return;
                        }
                    }
                    DisplayNotificationInChat("Accepting TP Lure from " + FromAgentName);
                    displayedMessage = true;
                    Self.TeleportLureRespond(FromAgentID, IMSessionID, true);
                }
                break;

            case InstantMessageDialog.AcceptTeleport:
                break;

            case InstantMessageDialog.DenyTeleport:
                break;

            case InstantMessageDialog.GodLikeRequestTeleport:
                break;

            //  case InstantMessageDialog.CurrentlyUnused:
            //    break;
            case InstantMessageDialog.GotoUrl:
                break;

            case InstantMessageDialog.Session911Start:
                break;

            case InstantMessageDialog.FromTaskAsAlert:
                break;

            case InstantMessageDialog.GroupNotice:
                break;

            case InstantMessageDialog.GroupNoticeInventoryAccepted:
                break;

            case InstantMessageDialog.GroupNoticeInventoryDeclined:
                break;

            case InstantMessageDialog.GroupInvitationAccept:
                break;

            case InstantMessageDialog.GroupInvitationDecline:
                break;

            case InstantMessageDialog.GroupNoticeRequested:
                break;

            case InstantMessageDialog.FriendshipOffered:
                if ((perms & BotPermissions.AcceptGroupAndFriendRequests) != 0)
                {
                    DisplayNotificationInChat("Accepting Friendship from " + FromAgentName);
                    Friends.AcceptFriendship(FromAgentID, IMSessionID);
                    displayedMessage = true;
                }
                break;

            case InstantMessageDialog.FriendshipAccepted:
                break;

            case InstantMessageDialog.FriendshipDeclined:
                break;

            case InstantMessageDialog.StartTyping:
                break;

            case InstantMessageDialog.StopTyping:
                break;

            case InstantMessageDialog.MessageFromObject:
            case InstantMessageDialog.MessageFromAgent:
                // message from self
                if (FromAgentName == GetName())
                {
                    return;
                }
                // message from system
                if (FromAgentName == "System")
                {
                    return;
                }
                // message from others
                CommandInstance ci;
                if (Commands.TryGetValue("im", out ci))
                {
                    var whisper = ci.WithBotClient as Cogbot.Actions.Communication.ImCommand;
                    if (whisper != null)
                    {
                        whisper.currentAvatar  = FromAgentID;
                        whisper.currentSession = IMSessionID;
                    }
                }
                var cea = origin as ChatEventArgs;
                if ((perms & BotPermissions.ExecuteCommands) != 0)
                {
                    OutputDelegate WriteLine;
                    if (origin is InstantMessageEventArgs)
                    {
                        WriteLine = new OutputDelegate(
                            (string text, object[] ps) =>
                        {
                            string reply0 = DLRConsole.SafeFormat(text, ps);
                            InstantMessage(FromAgentID, reply0, IMSessionID);
                        });
                    }
                    else
                    {
                        WriteLine = new OutputDelegate(
                            (string text, object[] ps) =>
                        {
                            string reply0 = DLRConsole.SafeFormat(text, ps);
                            Talk(reply0, 0, Type);
                        });
                    }
                    string   cmd        = Message;
                    CMDFLAGS needResult = CMDFLAGS.Console;
                    if (cmd.StartsWith("cmcmd "))
                    {
                        cmd = cmd.Substring(6);
                        WriteLine("");
                        WriteLine(string.Format("invokecm='{0}'", cmd));
                        ClientManager.DoCommandAll(cmd, FromAgentID, WriteLine);
                    }
                    else if (cmd.StartsWith("cmd "))
                    {
                        cmd = cmd.Substring(4);
                        WriteLine(string.Format("invoke='{0}'", cmd));
                        var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult);
                        WriteLine("iresult='" + res + "'");
                    }
                    else if (cmd.StartsWith("/") || cmd.StartsWith("@"))
                    {
                        cmd = cmd.Substring(1);
                        WriteLine("");
                        WriteLine(string.Format("invoke='{0}'", cmd));
                        var res = ExecuteCommand(cmd, FromAgentID, WriteLine, needResult);
                        WriteLine("iresult='" + res + "'");
                    }
                }
                if (cea != null && cea.AudibleLevel == ChatAudibleLevel.Barely)
                {
                    return;
                }
                break;

            default:
                break;
            }
            //if (Dialog != InstantMessageDialog.MessageFromAgent && Dialog != InstantMessageDialog.MessageFromObject)
            {
                string debug = String.Format("{0} {1} {2} {3} {4} {5}: {6}",
                                             groupIM ? "GroupIM" : "IM", Dialog, Type, perms, FromAgentID, FromAgentName,
                                             Helpers.StructToString(origin));
                if (!displayedMessage)
                {
                    DisplayNotificationInChat(debug);
                    displayedMessage = true;
                }
            }
        }
        private void acceptInput0(string verb, Parser parser)
        {
            String[] args = parser.GetProperty("to");
            string   ToS  = Parser.Rejoin(args, 0);

            if (String.IsNullOrEmpty(ToS))
            {
                ToS = parser.str;
            }
            int argUsed;

            if (ToS == "home")
            {
                Client.Self.GoHome();
                AddSuccess("teleporting home");
                return;
            }
            SimPosition pos = WorldSystem.GetVector(args, out argUsed);

            if (argUsed > 0)
            {
                Vector3d global = pos.GlobalPosition;
                WriteLine("Teleporting to " + pos + "...");
                float x, y;
                TheSimAvatar.StopMoving();
                bool res =
                    Client.Self.Teleport(
                        SimRegion.GlobalPosToRegionHandle((float)global.X, (float)global.Y, out x, out y),
                        pos.SimPosition, pos.SimPosition);
                if (res)
                {
                    AddSuccess("Teleported to " + pos);
                }
                else
                {
                    Failure("Teleport Failed to " + pos);
                }
                return;
            }
            char[] splitchar = null;
            if (ToS.Contains("/"))
            {
                splitchar = new char[] { '/' };
            }
            string[] tokens = ToS.Split(splitchar);
            if (tokens.Length == 0)
            {
                WriteLine("Provide somewhere to teleport to.");
            }
            else
            {
                Vector3 coords  = new Vector3(128, 128, 40);
                string  simName = ""; //CurSim.Name;

                bool ifCoordinates = false;

                if (tokens.Length >= 3)
                {
                    try
                    {
                        coords.X      = float.Parse(tokens[tokens.Length - 3]);
                        coords.Y      = float.Parse(tokens[tokens.Length - 2]);
                        coords.Z      = float.Parse(tokens[tokens.Length - 1]);
                        ifCoordinates = true;
                    }
                    catch (Exception e)
                    {
                    }
                }

                if (!ifCoordinates)
                {
                    for (int i = 0; i < tokens.Length; i++)
                    {
                        simName += tokens[i] + " ";
                    }
                    simName = simName.Trim();
                }
                else
                {
                    for (int i = 0; i < tokens.Length - 3; i++)
                    {
                        simName += tokens[i] + " ";
                    }
                    simName = simName.Trim();
                }
                {
                    if (String.IsNullOrEmpty(simName))
                    {
                        simName = Client.Network.CurrentSim.Name;
                    }
                    TeleportFinished.Reset();
                    Client.Self.TeleportProgress += On_Teleport;
                    WriteLine("Trying to teleport to " + simName + " " + coords);
                    Client.Self.Teleport(simName, coords);
                    // wait 30 seconds
                    if (!TeleportFinished.WaitOne(30000, false))
                    {
                        Client.Self.TeleportProgress -= On_Teleport;
                        WriteLine("Timeout on teleport to " + simName + " " + coords);
                    }
                }
            }
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (NOSEARCH_ANIM)
            {
                String str = args.str;
                WriteLine("PLAY ECHO " + str);
                return(Success("\nStart assets " + str + "\n"));
            }
            bool writeInfo = !args.IsFFI;

            if (args.Length < 1)
            {
                Dictionary <UUID, int> gestures = WorldSystem.TheSimAvatar.GetCurrentAnimDict();
                string alist = String.Empty;
                foreach (var anim in gestures)
                {
                    AppendItem("assets", WorldSystem.GetAsset(anim.Key));
                    if (!writeInfo)
                    {
                        continue;
                    }
                    alist += WorldSystem.GetAnimationName(anim.Key);
                    alist += " ";
                    alist += anim.Value;
                    alist += Environment.NewLine;
                }
                if (writeInfo)
                {
                    WriteLine("Currently: {0}", alist);
                }
                return(SuccessOrFailure());
                // " anim [seconds] HOVER [seconds] 23423423423-4234234234-234234234-23423423  +CLAP -JUMP STAND";
            }
            int argStart = 0;

            int time = 1300; //should be long enough for most animations

            base.SetWriteLine("message");
            string    directive       = args[0].ToLower();
            int       mode            = 0;
            int       defaultAnimTime = 2;
            int       animsRan        = 0;
            AssetType defaultSearch   = AssetType.Gesture;

            for (int i = argStart; i < args.Length; i++)
            {
                string a = args[i];
                if (String.IsNullOrEmpty(a))
                {
                    continue;
                }
                try
                {
                    float ia;
                    if (float.TryParse(a, out ia))
                    {
                        if (ia > 0.0)
                        {
                            time = (int)(ia * 1000);
                            Thread.Sleep(time);
                            continue;
                        }
                    }
                }
                catch (Exception)
                {
                }
                char c = a.ToCharArray()[0];
                if (c == '-')
                {
                    mode = -1;
                    a    = a.Substring(1);
                }
                else if (c == '+')
                {
                    mode = 1;
                    a    = a.Substring(1);
                }
                else
                {
                    mode = 0;
                }
                if (a == "")
                {
                    continue;
                }

                if (a.ToLower() == "stopall")
                {
                    Dictionary <UUID, bool> animations = new Dictionary <UUID, bool>();
                    var anims = TheSimAvatar.GetCurrentAnims();
                    foreach (var ani in anims)
                    {
                        animations[ani] = false;
                    }
                    int knownCount = animations.Count;

                    Client.Self.Animate(animations, true);
                    WriteLine("stopping all");
                    continue;
                }

                try
                {
                    defaultSearch = (AssetType)Enum.Parse(typeof(AssetType), a, true);
                    continue;
                }
                catch
                {
                }

                UUID anim = WorldSystem.GetAssetUUID(a, defaultSearch);

                if (anim == UUID.Zero)
                {
                    try
                    {
                        if (a.Substring(2).Contains("-"))
                        {
                            anim = UUIDParse(a);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                if (anim == UUID.Zero)
                {
                    anim = WorldSystem.GetAssetUUID(a, AssetType.Unknown);
                }
                if (anim == UUID.Zero)
                {
                    Failure("skipping unknown animation/gesture " + a);
                    continue;
                }
                SimAsset asset = SimAssetStore.FindAsset(anim);
                animsRan++;
                AppendItem("assets", WorldSystem.GetAsset(anim));
                if (asset is SimGesture)
                {
                    Client.Self.PlayGesture(asset.AssetID);
                    continue;
                }
                if (asset is SimSound)
                {
                    Client.Sound.PlaySound(asset.AssetID);
                    continue;
                }
                if (asset != null && !(asset is SimAnimation))
                {
                    Failure("Dont know how to play " + asset);
                    continue;
                }
                try
                {
                    switch (mode)
                    {
                    case -1:
                        Client.Self.AnimationStop(anim, true);
                        if (writeInfo)
                        {
                            WriteLine("\nStop anim " + WorldSystem.GetAnimationName(anim));
                        }
                        continue;

                    case +1:
                        Client.Self.AnimationStart(anim, true);
                        if (writeInfo)
                        {
                            WriteLine("\nStart anim " + WorldSystem.GetAnimationName(anim));
                        }
                        continue;

                    default:
                        try
                        {
                            int val = time;
                            Client.Self.AnimationStart(anim, true);
                            if (writeInfo)
                            {
                                WriteLine("\nRan anim " + WorldSystem.GetAnimationName(anim) + " for " + val / 1000 +
                                          " seconds.");
                            }
                            Thread.Sleep(val);
                        }
                        finally
                        {
                            Client.Self.AnimationStop(anim, true);
                        }
                        continue;
                    }
                }
                catch (Exception e)
                {
                    return(Failure("\nRan " + animsRan + " asserts but " + e));
                }
            }
            return(SuccessOrFailure());
        }