Example #1
0
        public static IAction Create(ICommand command)
        {
            int objectId;
            if (command.Arguments.Count == 0)
            {
                objectId = REPlugin.Instance.Actions.CurrentSelection;
            }
            else if (command.Arguments.Count > 1)
            {
                throw new DisplayToUserException(string.Format("Multi argument use is not currently supported : {0}", command.RebuildArgumentString()), command);
            }
            else
            {
                objectId = int.Parse(command.Arguments[0].Trim());
            }

            return Create(command, objectId);
        }
        internal static void HandleCommand(ICommand command)
        {
            REPlugin.Instance.Debug.WriteObject(command);

            // If a command is for slaves only and the command is from ourself,
            // then we must be the Master and therefore we should ignore slave only commands
            if (command.IsSlaveOnlyAndFromSelf())
            {
                return;
            }

            // make sure someone isn't trying to pull a fast one on my guys
            if (!MyUtilities.IsCharacterOnMasterWhiteList(command.SourceCharacter))
            {
                return;
            }

            switch (command.Name.ToLower())
            {
                #region Generic Stuff & Shortcuts to Plugin Commands

                case "cmd":
                case "c":
                    ACUtilities.ProcessArbitraryCommand(command.RebuildArgumentsWithSpaceSeparator());
                    break;

                // short cut for running vt commands
                case "vt":
                    ACUtilities.ProcessArbitraryCommand(string.Format("/vt {0}", command.RebuildArgumentsWithSpaceSeparator()));
                    break;

                // Shortcut for running mt commands
                case "mt":
                    ACUtilities.ProcessArbitraryCommand(string.Format("/mt {0}", command.RebuildArgumentsWithSpaceSeparator()));
                    break;

                // Shortcut for local redox extensions commands
                case "re":
                    ACUtilities.ProcessArbitraryCommand(string.Format("/re {0}", command.RebuildArgumentsWithSpaceSeparator()));
                    break;

                case "rew":
                    ACUtilities.ProcessArbitraryCommand(string.Format("/rew {0}", command.RebuildArgumentsWithSpaceSeparator()));
                    break;

                #endregion

                #region Simple Shortcuts to built in commands

                // Shortcuts for simple commands.
                case "ls":
                    ACUtilities.ProcessArbitraryCommand("/ls");
                    break;
                case "ah":
                    ACUtilities.ProcessArbitraryCommand("/ah");
                    break;
                case "hom":
                    ACUtilities.ProcessArbitraryCommand("/hom");
                    break;
                case "tn":
                    ACUtilities.ProcessArbitraryCommand("/tn");
                    break;

                #endregion

                #region Login & Exit

                case "logout":
                case "logoff":
                    SimpleActions.Logout();
                    break;
                case "exit":
                    SimpleActions.ExitGame();
                    break;

                #endregion

                #region Using

                case "use":
                    Actions.Dispatched.UseObject.Create(command).Enqueue();
                    break;

                #endregion

                #region Give

                case "give":
                    Actions.Dispatched.GiveItems.Create(command).Enqueue();
                    break;

                #endregion

                #region List

                case "list":
                    Actions.Dispatched.ListItems.Create(command).Enqueue();
                    break;

                #endregion

                #region Cram

                case "cram":
                    Actions.Dispatched.CramItems.Create(command).Enqueue();
                    break;

                #endregion

                #region Jumping

                case "hop":
                    if(!SourceIsWithinJumpRange(command))
                    {
                        command.GiveFeedback(FeedbackType.Ignored, "You are too far away");
                        return;
                    }

                    Actions.Dispatched.Jump.CreateHop(command).Enqueue();
                    break;
                case "shifthop":
                case "shop":
                    if (!SourceIsWithinJumpRange(command))
                    {
                        command.GiveFeedback(FeedbackType.Ignored, "You are too far away");
                        return;
                    }

                    Actions.Dispatched.Jump.CreateShiftHop(command).Enqueue();
                    break;
                case "hopfull":
                case "hopf":
                    if (!SourceIsWithinJumpRange(command))
                    {
                        command.GiveFeedback(FeedbackType.Ignored, "You are too far away");
                        return;
                    }

                    Actions.Dispatched.Jump.CreateHopFull(command).Enqueue();
                    break;
                case "shifthopfull":
                case "shopf":
                    if (!SourceIsWithinJumpRange(command))
                    {
                        command.GiveFeedback(FeedbackType.Ignored, "You are too far away");
                        return;
                    }

                    Actions.Dispatched.Jump.CreateShiftHopFull(command).Enqueue();
                    break;

                #endregion

                #region Recalling - Spell Casting

                case "recall":
                case "r":
                    SimpleActions.CastSelfSpell("Portal Recall");
                    break;
                case "rprimary":
                case "rp":
                    // TODO
                    throw new NotImplementedException();

                case "rsecondary":
                case "rs":
                    // TODO
                    throw new NotImplementedException();

                case "rls":
                case "rl":
                    // TODO
                    throw new NotImplementedException();

                case "regroup":
                    // TODO : Will regroup the fellow at a known location.  So, probably just do portal recall.
                    // wil also turn off combat (before recalling), rebuff, etc.  This will be used after someone in the fellow dies.
                    throw new NotImplementedException();

                #endregion

                #region Plugin Management

                // Plugin Management Options
                case "reunload":
                    ACUtilities.ProcessArbitraryCommand("/rew unload");
                    break;
                case "rereload":
                    ACUtilities.ProcessArbitraryCommand("/rew reload");
                    break;

                #endregion

                #region Diagnostic / Troubleshooting

                case "clearqueue":
                    // Clears the dispatch pipeline queue
                    REPlugin.Instance.Dispatch.Pipeline.Clear();
                    break;

                case "distancecheck":
                case "distcheck":
                    var distanceFromSelf = WorldUtilities.GetDistanceFromSelf(command);
                    command.GiveFeedback(FeedbackType.Successful, "Distance from you = {0}", distanceFromSelf);
                    break;

                #endregion

                case "init":
                    SimpleActions.InitState(command);
                    break;
                case "profile":
                    // No Args = default
                    // Standard Values :
                    //     normal
                    //     support
                    //     light
                    SimpleActions.SetMainProfile(command);
                    break;
                case "followme":
                case "come":
                    SimpleActions.FollowMe(command);
                    break;
                case "wait":
                    SimpleActions.Wait(command);
                    break;
                case "waitnice":
                case "waitn":
                    SimpleActions.WaitNice(command);
                    break;

                case "range":
                    SimpleActions.SetAttackRange(command);
                    break;

                case "petrange":
                case "prange":
                    SimpleActions.SetPetRange(command);
                    break;

                case "fight":
                    SimpleActions.Fight();
                    break;

                case "loot":
                    SimpleActions.Loot();
                    break;

                case "buff":
                    SimpleActions.Buff();
                    break;
                case "fbuff":
                    SimpleActions.ForceBuff();
                    break;

                case "peace":
                    SimpleActions.Peace();
                    break;

                case "camp":
                    SimpleActions.Camp(command);
                    break;

                // nav controls
                case "nav":
                    SimpleActions.ProcessNavCommand(command);
                    break;
                case "navt":
                    SimpleActions.NavDistanceTight(command);
                    break;
                case "navn":
                    SimpleActions.NavDistanceNormal(command);
                    break;
                case "navl":
                    SimpleActions.NavDistanceLoose(command);
                    break;

                case "formation":
                    SimpleActions.SetFormation(command);
                    break;

                // Pets
                case "pets":
                    SimpleActions.ProcessPetsCommand(command);
                    break;

                // VT State short cuts
                case "buffon":
                    VTActions.EnableBuffing();
                    break;

                default:
                    CommandResponseHandler.TellSource(command, "Unknown Command : {0} , with value of : {1}", command.Name, command.RebuildArgumentString());
                    break;
            }
        }