Allows use of the undocumented MacroEvaluator class to run arbitrary code in the editor. This can be very useful for ad-hoc operations on game objects and for experimentation.
Inheritance: EditorWindow
Example #1
0
    protected void SettingsSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (!string.IsNullOrEmpty(txtAkismetId.Text.Trim()))
            {
                Macros m = new Macros();
                Joel.Net.Akismet akismet = new Joel.Net.Akismet(txtAkismetId.Text.Trim(), m.FullUrl(new Urls().Home), SiteSettings.Version);
                if (!akismet.VerifyKey())
                {
                    Message.Text = "Your Akismet key could not be verified. Please check it and re-enter it.";
                    Message.Type = StatusType.Error;
                    return;
                }
            }

            CommentSettings settings = CommentSettings.Get();
            settings.EnableCommentsDefault = EnableComments.Checked;
            settings.CommentDays = Int32.Parse(CommentDays.SelectedValue);
            settings.Email = txtEmail.Text;
            settings.SpamScore = Int32.Parse(txtSpamScore.Text);

            if (chkUseAkismet.Checked && String.IsNullOrEmpty(txtAkismetId.Text))
            {
                Message.Text = "Please provide your Akismet Id.";
                Message.Type = StatusType.Error;
                return;
            }

            settings.UseAkismet = chkUseAkismet.Checked;

            settings.AkismetId = txtAkismetId.Text;
            settings.AkismetScore = Int32.Parse(txtAkismetScore.Text);

            settings.Save();

            Message.Text = "Your Comment & Spam settings have been updated!";
            Message.Type = StatusType.Success;
        }
        catch(Exception ex)
        {
            Message.Text = "Your Comment & Spam settings could not be updated. Reason: " + ex.Message;
            Message.Type = StatusType.Error;
        }
    }
Example #2
0
        public override void Initialize()
        {
            Aimsharp.DebugMode();
            Aimsharp.PrintMessage("Vid Marksman - v 1.0", Color.Yellow);

            Aimsharp.PrintMessage("These macros can be used for manual control:", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx NoAOE --Toggles AOE mode on/off.", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx Potions --Toggles using buff potions on/off.", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx SaveCooldowns --Toggles the use of big cooldowns on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("--Replace xxxxx with first 5 letters of your addon, lowercase.", Color.Blue);


            MajorPower  = GetDropDown("Major Power");
            TopTrinket  = GetDropDown("Top Trinket");
            BotTrinket  = GetDropDown("Bot Trinket");
            RacialPower = GetDropDown("Racial Power");
            usableitems = GetString("Use item: Case Sens");
            AzeriteFocusedFireEnabled  = GetCheckBox("Azerite Focused Fire");
            AzeriteSurgingShotsEnabled = GetCheckBox(("Azerite Surging Shots"));
            AzeriteInTheRythmRank      = GetSlider("Azerite In the Rythm Rank: ");


            if (RacialPower == "Orc")
            {
                Spellbook.Add("Blood Fury");
            }
            if (RacialPower == "Troll")
            {
                Spellbook.Add("Berserking");
            }
            if (RacialPower == "Dark Iron Dwarf")
            {
                Spellbook.Add("Fireblood");
            }
            if (RacialPower == "Mag'har Orc")
            {
                Spellbook.Add("Ancestral Call");
            }
            if (RacialPower == "Lightforged Draenei")
            {
                Spellbook.Add("Light's Judgment");
            }
            if (RacialPower == "Furry")
            {
                Spellbook.Add("Bag of Tricks");
            }

            Spellbook.Add(MajorPower);
            Spellbook.Add("Rapid Fire");
            Spellbook.Add("Hunter's Mark");
            Spellbook.Add("Aimed Shot");
            Spellbook.Add("Steady Shot");
            Spellbook.Add("Multi-Shot");
            Spellbook.Add("Trueshot");
            Spellbook.Add("Barrage");
            Spellbook.Add("Explosive Shot");
            Spellbook.Add("Arcane Shot");
            Spellbook.Add("Kill Shot");
            Spellbook.Add("Bursting Shot");
            Spellbook.Add("Exhilaration");
            Spellbook.Add("Double Tap");
            Spellbook.Add("Chimaera Shot");
            Spellbook.Add("A Murder of Crows");



            Buffs.Add("Lifeblood");
            Buffs.Add("Precise Shots");
            Buffs.Add("Trick Shots");
            Buffs.Add("Trueshot");


            Debuffs.Add("Razor Coral");
            Debuffs.Add("Hunter's Mark");

            Items.Add(TopTrinket);
            Items.Add(BotTrinket);
            Items.Add(usableitems);

            Macros.Add("ItemUse", "/use " + usableitems);
            Macros.Add("TopTrink", "/use 13");
            Macros.Add("BotTrink", "/use 14");

            CustomCommands.Add("NoAOE");
            CustomCommands.Add("Potions");
            CustomCommands.Add("SaveCooldowns");
        }
Example #3
0
        public override void Initialize()
        {
            Aimsharp.PrintMessage("Kyber Vengenace DH Shadowlands - v 2.3", Color.Blue);
            Aimsharp.PrintMessage("Recommended talents: 1233221", Color.Blue);
            Aimsharp.PrintMessage("These macros can be used for manual control:", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx SaveMeta", Color.Blue);
            Aimsharp.PrintMessage("--Toggles the use of Metamorphosis on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx SaveCovenant", Color.Blue);
            Aimsharp.PrintMessage("--Toggles the use of Covenant abilities on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx AOE", Color.Blue);
            Aimsharp.PrintMessage("--Toggles AOE mode on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx Autodisrupt", Color.Blue);
            Aimsharp.PrintMessage("--Toggles Auto interrupt mode on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx Autoinfernal", Color.Blue);
            Aimsharp.PrintMessage("--Toggles Auto infernal Strike mode on/off.", Color.Blue);
            Aimsharp.PrintMessage("will use 1 charge for added dps and save 1 charge for movement.", Color.Purple);
            Aimsharp.PrintMessage("--Replace xxxxx with first 5 letters of your addon, lowercase.", Color.Blue);

            Aimsharp.Latency    = 50;
            Aimsharp.QuickDelay = 125;
            Aimsharp.SlowDelay  = 250;

            //Main Skills
            foreach (string skill in VengeanceSpells)
            {
                Spellbook.Add(skill);
            }

            //Covenant
            foreach (string Spell in CovenantAbilities)
            {
                Spellbook.Add(Spell);
            }

            //Buffs
            foreach (string buff in VengeanceBuffs)
            {
                Buffs.Add(buff);
            }

            //Debuffs
            foreach (string debuff in VengeanceDebuffs)
            {
                Debuffs.Add(debuff);
            }


            foreach (string Buff in BloodlustEffects)
            {
                Buffs.Add(Buff);
            }


            Items.Add(GetString("Potion name:"));

            Macros.Add("DPS Pot", "/use " + GetString("Potion name:"));
            Macros.Add("TopTrinket", "/use 13");
            Macros.Add("BottomTrinket", "/use 14");

            Macros.Add("sigil self", "/cast [@player] Sigil of Flame");
            Macros.Add("infernal self", "/cast [@player] Infernal Strike");
            Macros.Add("Elysian self", "/cast [@player] Elysian Decree");

            CustomCommands.Add("SaveMeta");
            CustomCommands.Add("AOE");
            CustomCommands.Add("Autoinfernal");
            CustomCommands.Add("Autodisrupt");
            CustomCommands.Add("SaveCovenant");

            CustomFunctions.Add("GetCovenant", "local spell = 0 local i = 1 while true do local spellName, spellSub = GetSpellBookItemName(i, BOOKTYPE_SPELL) if not spellName then do break end end if spellName == 'Fodder to the Flame' then spell = 4 elseif spellName == 'The Hunt' then spell = 3 elseif spellName == 'Sinful Brand' then spell = 2 elseif spellName == 'Elysian Decree' then spell = 1 end i = i + 1 end return spell");
            CustomFunctions.Add("GetLegendarySpellID", "local power = 0 for i=1,15,1 do local xcs = ItemLocation:CreateFromEquipmentSlot(i) if(C_Item.DoesItemExist(xcs)) then if(C_LegendaryCrafting.IsRuneforgeLegendary(xcs)) then local id = C_LegendaryCrafting.GetRuneforgeLegendaryComponentInfo(xcs)[\"powerID\"] power = C_LegendaryCrafting.GetRuneforgePowerInfo(id)[\"descriptionSpellID\"] end end end return power");
        }
Example #4
0
        protected override void WndProc(ref Message message)
        {
            switch (message.Msg)
            {
            case WM_COMMAND: {
                // need to dispatch the message for the context menu
                if (message.LParam == IntPtr.Zero)
                {
                    commandDispatch.Invoke(null, new object[] {
                            message.WParam.ToInt32()& 0xFFFF
                        });
                }
            } break;

            case WM_NCHITTEST: {
                message.Result = (IntPtr)HitResult.Caption;
                if (HitTest != null)
                {
                    Point p = new Point(
                        Macros.GET_X_LPARAM(message.LParam) - location.X,
                        Macros.GET_Y_LPARAM(message.LParam) - location.Y
                        );
                    HitTestEventArgs e = new HitTestEventArgs(p, HitResult.Caption);
                    HitTest(this, e);
                    message.Result = (IntPtr)e.HitResult;
                }
            } break;

            case WM_NCLBUTTONDBLCLK: {
                if (MouseDoubleClick != null)
                {
                    MouseDoubleClick(this, new MouseEventArgs(MouseButtons.Left, 2,
                                                              Macros.GET_X_LPARAM(message.LParam) - location.X,
                                                              Macros.GET_Y_LPARAM(message.LParam) - location.Y, 0));
                }
                message.Result = IntPtr.Zero;
            } break;

            case WM_NCRBUTTONDOWN: {
                message.Result = IntPtr.Zero;
            } break;

            case WM_NCRBUTTONUP: {
                if (contextMenu != null)
                {
                    ShowContextMenu(new Point(
                                        Macros.GET_X_LPARAM(message.LParam),
                                        Macros.GET_Y_LPARAM(message.LParam)
                                        ));
                }
                message.Result = IntPtr.Zero;
            } break;

            case WM_WINDOWPOSCHANGING: {
                WindowPos wp = (WindowPos)Marshal.PtrToStructure(
                    message.LParam, typeof(WindowPos));

                if (!lockPositionAndSize)
                {
                    // prevent the window from leaving the screen
                    if ((wp.flags & SWP_NOMOVE) == 0)
                    {
                        Rectangle rect = Screen.GetWorkingArea(
                            new Rectangle(wp.x, wp.y, wp.cx, wp.cy));
                        const int margin = 16;
                        wp.x = Math.Max(wp.x, rect.Left - wp.cx + margin);
                        wp.x = Math.Min(wp.x, rect.Right - margin);
                        wp.y = Math.Max(wp.y, rect.Top - wp.cy + margin);
                        wp.y = Math.Min(wp.y, rect.Bottom - margin);
                    }

                    // update location and fire event
                    if ((wp.flags & SWP_NOMOVE) == 0)
                    {
                        if (location.X != wp.x || location.Y != wp.y)
                        {
                            location = new Point(wp.x, wp.y);
                            if (LocationChanged != null)
                            {
                                LocationChanged(this, EventArgs.Empty);
                            }
                        }
                    }

                    // update size and fire event
                    if ((wp.flags & SWP_NOSIZE) == 0)
                    {
                        if (size.Width != wp.cx || size.Height != wp.cy)
                        {
                            size = new Size(wp.cx, wp.cy);
                            if (SizeChanged != null)
                            {
                                SizeChanged(this, EventArgs.Empty);
                            }
                        }
                    }

                    // update the size of the layered window
                    if ((wp.flags & SWP_NOSIZE) == 0)
                    {
                        NativeMethods.UpdateLayeredWindow(Handle, IntPtr.Zero,
                                                          IntPtr.Zero, ref size, IntPtr.Zero, IntPtr.Zero, 0,
                                                          IntPtr.Zero, 0);
                    }

                    // update the position of the layered window
                    if ((wp.flags & SWP_NOMOVE) == 0)
                    {
                        NativeMethods.SetWindowPos(Handle, IntPtr.Zero,
                                                   location.X, location.Y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE |
                                                   SWP_NOZORDER | SWP_NOSENDCHANGING);
                    }
                }

                // do not forward any move or size messages
                wp.flags |= SWP_NOSIZE | SWP_NOMOVE;

                // suppress any frame changed events
                wp.flags &= ~SWP_FRAMECHANGED;

                Marshal.StructureToPtr(wp, message.LParam, false);
                message.Result = IntPtr.Zero;
            } break;

            default: {
                base.WndProc(ref message);
            } break;
            }
        }
        private void SaveMacros()
        {
            var lineValues = Macros.Select(m => new[] { m.Name, m.IsActive.ToString() }).ToArray();

            FileUtil.SaveFile(lineValues, MACROS_FILE_NAME, MACROS_FILE_SEPARATOR);
        }
Example #6
0
        public override void Unload()
        {
            Client.Game.SetWindowTitle(string.Empty);

            ItemHold.Clear();

            try
            {
                Plugin.OnDisconnected();
            }
            catch
            {
            }
            // ## BEGIN - END ## //
            try
            {
                ModulesManager.Unload();
            }
            catch
            {
            }
            // ## BEGIN - END ## //
            TargetManager.Reset();

            // special case for wmap. this allow us to save settings
            UIManager.GetGump <WorldMapGump>()?.SaveSettings();

            ProfileManager.CurrentProfile?.Save(ProfileManager.ProfilePath);

            Macros.Save();
            InfoBars.Save();
            ProfileManager.UnLoadProfile();

            StaticFilters.CleanCaveTextures();
            StaticFilters.CleanTreeTextures();

            NetClient.Socket.Disconnected -= SocketOnDisconnected;
            NetClient.Socket.Disconnect();
            _lightRenderTarget?.Dispose();
            _world_render_target?.Dispose();

            CommandManager.UnRegisterAll();
            Weather.Reset();
            UIManager.Clear();
            World.Clear();
            ChatManager.Clear();
            DelayedObjectClickManager.Clear();

            _useItemQueue?.Clear();
            _useItemQueue = null;
            Hotkeys       = null;
            Macros        = null;
            MessageManager.MessageReceived -= ChatOnMessageReceived;


            Settings.GlobalSettings.WindowSize = new Point
                                                     (Client.Game.Window.ClientBounds.Width, Client.Game.Window.ClientBounds.Height);

            Settings.GlobalSettings.IsWindowMaximized = Client.Game.IsWindowMaximized();
            Client.Game.SetWindowBorderless(false);

            base.Unload();
        }
Example #7
0
 public static bool IsWindows8Point1OrGreater() => IsWindowsVersionOrGreater(Macros.HIBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WINBLUE), Macros.LOBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WINBLUE), 0);
Example #8
0
        public void CreateMacros()
        {
            StopAllRecord();

            if (SequenceCollection.Count == 0)
            {
                MessageBox.Show("Sequence is empty", "Error", MessageBoxButton.OK);
                return;
            }
            if (MacroCollection.Count == 0)
            {
                MessageBox.Show("Macros is empty", "Error", MessageBoxButton.OK);
                return;
            }
            if (MacrosModeCollection.Count == 0)
            {
                MessageBox.Show("Macros mode hotkey is empty", "Error", MessageBoxButton.OK);
                return;
            }

            ReturnFalseFuctionState<IInput> functionState = new ReturnFalseFuctionState<IInput>(mInputEqualityComparer);
            IEnumerable<ReturnFalseFuctionState<IInput>> functionStateEnum = Enumerable.Repeat(functionState, SequenceCollection.Count);
            Branch<IInput> branchSequence = new Branch<IInput>(SequenceCollection, functionStateEnum, mInputEqualityComparer);
            SendKeyDelayFuctionState<IInput> sendDelayFunctionState = new SendKeyDelayFuctionState<IInput>(mKeySenderInput, mMouseSenderInput, MacroCollection.ToArray(), mInputEqualityComparer);
            branchSequence.LastBranchState = sendDelayFunctionState;

            mTreeSequence.AddState(branchSequence);

            Macros macro = new Macros(MacrosName, SequenceCollection, MacroCollection.Select(item => item.Data));
            MacrosCollection.Add(macro);

            MacrosName = string.Empty;
            SequenceCollection.Clear();
            MacroCollection.Clear();
        }
Example #9
0
 public Nutrients Clone() => new Nutrients(Macros.Clone(), Micros.Clone());
Example #10
0
 public Nutrients(Macros macros, Micros micros)
 {
     Macros = macros;
     Micros = micros;
 }
Example #11
0
 public static bool IsWindows7SP1OrGreater() => IsWindowsVersionOrGreater(Macros.HIBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WIN7), Macros.LOBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WIN7), 1);
Example #12
0
 public static bool IsWindows10OrGreater() => IsWindowsVersionOrGreater(Macros.HIBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WIN10), Macros.LOBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WIN10), 0);
Example #13
0
 public static bool IsWindowsXPSP3OrGreater() => IsWindowsVersionOrGreater(Macros.HIBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WINXP), Macros.LOBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WINXP), 3);
Example #14
0
 public static bool IsWindowsVistaSP2OrGreater() => IsWindowsVersionOrGreater(Macros.HIBYTE((ushort)WIN32_WINNT._WIN32_WINNT_VISTA), Macros.LOBYTE((ushort)WIN32_WINNT._WIN32_WINNT_VISTA), 2);
Example #15
0
 public static bool IsWindowsThresholdOrGreater() => IsWindowsVersionOrGreater(Macros.HIBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WINTHRESHOLD), Macros.LOBYTE((ushort)WIN32_WINNT._WIN32_WINNT_WINTHRESHOLD), 0);
        private void txtArea_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                Macros m = new Macros((string)e.Data.GetData(typeof(string)));
           

                if (string.IsNullOrEmpty(Document.Text))
                    m.IncludeCommand += System.Environment.NewLine;                
                else
                    m.IncludeCommand = System.Environment.NewLine + m.IncludeCommand + System.Environment.NewLine;
                    

                Document.SelectedText = m.IncludeCommand;

            }
            catch (IllegalMacrosException ex)
            { 
                MessageBox.Show(ex.Message, "Illegal macro directory", MessageBoxButtons.OK, MessageBoxIcon.Error); 
            }
        }
Example #17
0
		public void ProcessTemplate(SharedBasePage page, string templateString, Control contentPlaceHolder, Macros macros)
		{
			ProcessTemplate(page, null, templateString, contentPlaceHolder, macros);
		}
Example #18
0
        public override void Initialize()
        {
            Aimsharp.PrintMessage("Perfect Simcraft Series: Fury Warrior - v 1.0", Color.Blue);
            Aimsharp.PrintMessage("Recommended talents: 2123123", Color.Blue);
            Aimsharp.PrintMessage("These macros can be used for manual control:", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx Potions", Color.Blue);
            Aimsharp.PrintMessage("--Toggles using buff potions on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx SaveCooldowns", Color.Blue);
            Aimsharp.PrintMessage("--Toggles the use of big cooldowns on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx AOE", Color.Blue);
            Aimsharp.PrintMessage("--Toggles AOE mode on/off.", Color.Blue);
            // Aimsharp.PrintMessage(" ");
            // Aimsharp.PrintMessage("/xxxxx Prepull 10", Color.Blue);
            // Aimsharp.PrintMessage("--Starts the prepull actions.", Color.Blue);
            // Aimsharp.PrintMessage(" ");
            // Aimsharp.PrintMessage("--Replace xxxxx with first 5 letters of your addon, lowercase.", Color.Blue);

            Aimsharp.Latency    = 100;
            Aimsharp.QuickDelay = 125;

            MajorPower  = GetDropDown("Major Power");
            TopTrinket  = GetDropDown("Top Trinket");
            BotTrinket  = GetDropDown("Bot Trinket");
            RacialPower = GetDropDown("Racial Power");

            Spellbook.Add(MajorPower);

            if (RacialPower == "Orc")
            {
                Spellbook.Add("Blood Fury");
            }
            if (RacialPower == "Troll")
            {
                Spellbook.Add("Berserking");
            }
            if (RacialPower == "Dark Iron Dwarf")
            {
                Spellbook.Add("Fireblood");
            }
            if (RacialPower == "Mag'har Orc")
            {
                Spellbook.Add("Ancestral Call");
            }
            if (RacialPower == "Lightforged Draenei")
            {
                Spellbook.Add("Light's Judgment");
            }

            Spellbook.Add("Charge");
            Spellbook.Add("Heroic Leap");
            Spellbook.Add("Rampage");
            Spellbook.Add("Recklessness");
            Spellbook.Add("Siegebreaker");
            Spellbook.Add("Whirlwind");
            Spellbook.Add("Execute");
            Spellbook.Add("Furious Slash");
            Spellbook.Add("Bladestorm");
            Spellbook.Add("Bloodthirst");
            Spellbook.Add("Dragon Roar");
            Spellbook.Add("Raging Blow");

            Buffs.Add("Bloodlust");
            Buffs.Add("Heroism");
            Buffs.Add("Time Warp");
            Buffs.Add("Ancient Hysteria");
            Buffs.Add("Netherwinds");
            Buffs.Add("Drums of Rage");
            Buffs.Add("Lifeblood");
            Buffs.Add("Memory of Lucid Dreams");
            Buffs.Add("Reckless Force");
            Buffs.Add("Guardian of Azeroth");

            Buffs.Add("Recklessness");
            Buffs.Add("Meat Cleaver");
            Buffs.Add("Enrage");
            Buffs.Add("Furious Slash");
            Buffs.Add("Whirlwind");

            Debuffs.Add("Razor Coral");
            Debuffs.Add("Conductive Ink");
            Debuffs.Add("Shiver Venom");
            Debuffs.Add("Siegebreaker");

            Items.Add(TopTrinket);
            Items.Add(BotTrinket);
            Items.Add(GetDropDown("Potion Type"));

            Macros.Add(TopTrinket, "/use " + TopTrinket);
            Macros.Add(BotTrinket, "/use " + BotTrinket);
            Macros.Add("potion", "/use " + GetDropDown("Potion Type"));
            Macros.Add("leap cursor", "/cast [@cursor] Heroic Leap");
            Macros.Add("TopTrink", "/use 13");
            Macros.Add("BotTrink", "/use 14");

            CustomCommands.Add("Potions");
            CustomCommands.Add("SaveCooldowns");
            CustomCommands.Add("AOE");
        }
Example #19
0
    void Start()
    {
        GameObject bc = GameObject.Find ("BehaviorController");
        eventManager = bc.GetComponent<EventManager> ();
        macros = bc.GetComponent<Macros> ();

        objSelector = GameObject.Find ("BlocksWorld").GetComponent<ObjectSelector> ();

        commBridge = GameObject.Find ("CommunicationsBridge").GetComponent<PluginImport> ();

        //inputRect = new Rect (5, 5, 50, 25);
        inputRect = new Rect (5, 5, 365, inputHeight);
    }
Example #20
0
        protected override Task <ArgumentParseResult> ParseArgumentsGuildAsync(IGuildCommandContext context)
        {
            ArgumentContainer argOut = new ArgumentContainer();

            if (!Enum.TryParse(context.Arguments.First, true, out argOut.Filter))
            {
                return(Task.FromResult(new ArgumentParseResult(Arguments[0], $"Could not select a filter mode from `{context.Arguments.First}`!")));
            }

            if (argOut.Filter == SelectFilter.User)
            {
                context.Arguments.Index++;
                if (!ArgumentParsing.TryParseGuildUser(context, context.Arguments.First, out argOut.User))
                {
                    return(Task.FromResult(new ArgumentParseResult(Arguments[1], $"Could not select a user from `{context.Arguments.First}`!")));
                }
            }

            context.Arguments.Index++;

            if (!Enum.TryParse(context.Arguments.First, true, out argOut.End))
            {
                return(Task.FromResult(new ArgumentParseResult(Arguments[2], $"Could not select an end mode from `{context.Arguments.First}`!")));
            }

            context.Arguments.Index++;

            if (context.Arguments.Count == 0)
            {
                return(Task.FromResult(new ArgumentParseResult(Arguments[3], $"You need to supply an argument for the endmode!")));
            }

            switch (argOut.End)
            {
            case EndMode.Count:
                if (uint.TryParse(context.Arguments.First, out argOut.RemoveCount))
                {
                    if (argOut.Filter == SelectFilter.All)
                    {
                        argOut.InitalCount = (int)argOut.RemoveCount;
                    }
                    else
                    {
                        argOut.InitalCount = 1000;
                    }
                }
                else
                {
                    return(Task.FromResult(new ArgumentParseResult(Arguments[3], $"Could not parse `{context.Arguments.First}` to a valid number!")));
                }
                break;

            case EndMode.Time:
                if (!DateTimeOffset.TryParseExact(context.Arguments.First, "H:mm", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out argOut.DeleteAfter))
                {
                    return(Task.FromResult(new ArgumentParseResult(Arguments[3], $"Could not parse `{context.Arguments.First}` to a valid date and time. Required Format: `hh:mm` UTC!")));
                }
                argOut.InitalCount = 1000;
                break;

            case EndMode.TimeRelative:
                if (Macros.TryParseHumanTimeString(context.Arguments.First, out TimeSpan maxAge))
                {
                    if (maxAge.TotalHours > MAXHOURS)
                    {
                        return(Task.FromResult(new ArgumentParseResult(Arguments[3], "Can not purge messages older than 24 hours!")));
                    }
                    else
                    {
                        argOut.DeleteAfter = DateTimeOffset.UtcNow - maxAge;
                    }
                }
                else
                {
                    return(Task.FromResult(new ArgumentParseResult(Arguments[3], $"Could not parse `{context.Arguments.First}` to a valid timespan. Use Format `##h` or `##m`!")));
                }
                argOut.InitalCount = 1000;
                break;
            }

            return(Task.FromResult(new ArgumentParseResult(argOut)));
        }
        // = false;
        // not an instantiable class
        /// <summary>Usage: java edu.stanford.nlp.trees.tregex.tsurgeon.Tsurgeon [-s] -treeFile file-with-trees [-po matching-pattern operation] operation-file-1 operation-file-2 ...</summary>
        /// <remarks>
        /// Usage: java edu.stanford.nlp.trees.tregex.tsurgeon.Tsurgeon [-s] -treeFile file-with-trees [-po matching-pattern operation] operation-file-1 operation-file-2 ... operation-file-n
        /// <h4>Arguments:</h4>
        /// Each argument should be the name of a transformation file that contains a list of pattern
        /// and transformation operation list pairs.  That is, it is a sequence of pairs of a
        /// <see cref="Edu.Stanford.Nlp.Trees.Tregex.TregexPattern"/>
        /// pattern on one or more lines, then a
        /// blank line (empty or whitespace), then a list of transformation operations one per line
        /// (as specified by <b>Legal operation syntax</b> below) to apply when the pattern is matched,
        /// and then another blank line (empty or whitespace).
        /// Note the need for blank lines: The code crashes if they are not present as separators
        /// (although the blank line at the end of the file can be omitted).
        /// The script file can include comment lines, either whole comment lines or
        /// trailing comments introduced by %, which extend to the end of line.  A needed percent
        /// mark can be escaped by a preceding backslash.
        /// <p>
        /// For example, if you want to excise an SBARQ node whenever it is the parent of an SQ node,
        /// and relabel the SQ node to S, your transformation file would look like this:
        /// <blockquote>
        /// <code>
        /// SBARQ=n1 &lt; SQ=n2<br />
        /// <br />
        /// excise n1 n1<br />
        /// relabel n2 S
        /// </code>
        /// </blockquote>
        /// <h4>Options:</h4>
        /// <ul>
        /// <li>
        /// <c>-treeFile &lt;filename&gt;</c>
        /// specify the name of the file that has the trees you want to transform.
        /// <li>
        /// <c>-po &lt;matchPattern&gt; &lt;operation&gt;</c>
        /// Apply a single operation to every tree using the specified match pattern and the specified operation.  Use this option
        /// when you want to quickly try the effect of one pattern/surgery combination, and are too lazy to write a transformation file.
        /// <li>
        /// <c>-s</c>
        /// Print each output tree on one line (default is pretty-printing).
        /// <li>
        /// <c>-m</c>
        /// For every tree that had a matching pattern, print "before" (prepended as "Operated on:") and "after" (prepended as "Result:").  Unoperated on trees just pass through the transducer as usual.
        /// <li>
        /// <c>-encoding X</c>
        /// Uses character set X for input and output of trees.
        /// <li>
        /// <c>-macros &lt;filename&gt;</c>
        /// A file of macros to use on the tregex pattern.  Macros should be one per line, with original and replacement separated by tabs.
        /// <li>
        /// <c>-hf &lt;headFinder-class-name&gt;</c>
        /// use the specified
        /// <see cref="Edu.Stanford.Nlp.Trees.IHeadFinder"/>
        /// class to determine headship relations.
        /// <li>
        /// <c>-hfArg &lt;string&gt;</c>
        /// pass a string argument in to the
        /// <see cref="Edu.Stanford.Nlp.Trees.IHeadFinder"/>
        /// class's constructor.
        /// <c>-hfArg</c>
        /// can be used multiple times to pass in multiple arguments.
        /// <li>
        /// <c>-trf &lt;TreeReaderFactory-class-name&gt;</c>
        /// use the specified
        /// <see cref="Edu.Stanford.Nlp.Trees.ITreeReaderFactory"/>
        /// class to read trees from files.
        /// </ul>
        /// <h4>Legal operation syntax:</h4>
        /// <ul>
        /// <li>
        /// <c>delete &lt;name&gt;</c>
        /// deletes the node and everything below it.
        /// <li>
        /// <c>prune &lt;name&gt;</c>
        /// Like delete, but if, after the pruning, the parent has no children anymore, the parent is pruned too.  Pruning continues to affect all ancestors until one is found with remaining children.  This may result in a null tree.
        /// <li>
        /// <c>excise &lt;name1&gt; &lt;name2&gt;</c>
        /// The name1 node should either dominate or be the same as the name2 node.  This excises out everything from
        /// name1 to name2.  All the children of name2 go into the parent of name1, where name1 was.
        /// <li>
        /// <c>relabel &lt;name&gt; &lt;new-label&gt;</c>
        /// Relabels the node to have the new label. <br />
        /// There are three possible forms: <br />
        /// <c>relabel nodeX VP</c>
        /// - for changing a node label to an
        /// alphanumeric string <br />
        /// <c>relabel nodeX /''/</c>
        /// - for relabeling a node to
        /// something that isn't a valid identifier without quoting <br />
        /// <c>relabel nodeX /^VB(.*)$/verb\\/$1/</c>
        /// - for regular
        /// expression based relabeling. In this case, all matches of the
        /// regular expression against the node label are replaced with the
        /// replacement String.  This has the semantics of Java/Perl's
        /// replaceAll: you may use capturing groups and put them in
        /// replacements with $n. For example, if the pattern is /foo/bar/
        /// and the node matched is "foo", the replaceAll semantics result in
        /// "barbar".  If the pattern is /^foo(.*)$/bar$1/ and node matched is
        /// "foofoo", relabel will result in "barfoo".  <br />
        /// When using the regex replacement method, you can also use the
        /// sequences ={node} and %{var} in the replacement string to use
        /// captured nodes or variable strings in the replacement string.
        /// For example, if the Tregex pattern was "duck=bar" and the relabel
        /// is /foo/={bar}/, "foofoo" will be replaced with "duckduck". <br />
        /// To concatenate two nodes named in the tregex pattern, for
        /// example, you can use the pattern /^.*$/={foo}={bar}/.  Note that
        /// the ^.*$ is necessary to make sure the regex pattern only matches
        /// and replaces once on the entire node name. <br />
        /// To get an "=" or a "%" in the replacement, using \ escaping.
        /// Also, as in the example you can escape a slash in the middle of
        /// the second and third forms with \\/ and \\\\. <br />
        /// <li>
        /// <c>insert &lt;name&gt; &lt;position&gt;</c>
        /// or
        /// <c>insert &lt;tree&gt; &lt;position&gt;</c>
        /// inserts the named node or tree into the position specified.
        /// <li>
        /// <c>move &lt;name&gt; &lt;position&gt;</c>
        /// moves the named node into the specified position.
        /// <p>Right now the  only ways to specify position are:
        /// <p>
        /// <c>$+ &lt;name&gt;</c>
        /// the left sister of the named node<br />
        /// <c>$- &lt;name&gt;</c>
        /// the right sister of the named node<br />
        /// <c>&gt;i &lt;name&gt;</c>
        /// the i_th daughter of the named node<br />
        /// <c>&gt;-i &lt;name&gt;</c>
        /// the i_th daughter, counting from the right, of the named node.
        /// <li>
        /// <c>replace &lt;name1&gt; &lt;name2&gt;</c>
        /// deletes name1 and inserts a copy of name2 in its place.
        /// <li>
        /// <c>replace &lt;name&gt; &lt;tree&gt; &lt;tree2&gt;...</c>
        /// deletes name and inserts the new tree(s) in its place.  If
        /// more than one replacement tree is given, each of the new
        /// subtrees will be added in order where the old tree was.
        /// Multiple subtrees at the root is an illegal operation and
        /// will throw an exception.
        /// <li>
        /// <c>createSubtree &lt;auxiliary-tree-or-label&gt; &lt;name1&gt; [&lt;name2&gt;]</c>
        /// Create a subtree out of all the nodes from
        /// <c>&lt;name1&gt;</c>
        /// through
        /// <c>&lt;name2&gt;</c>
        /// . The subtree is moved to the foot of the given
        /// auxiliary tree, and the tree is inserted where the nodes of
        /// the subtree used to reside. If a simple label is provided as
        /// the first argument, the subtree is given a single parent with
        /// a name corresponding to the label.  To limit the operation to
        /// just one node, elide
        /// <c>&lt;name2&gt;</c>
        /// .
        /// <li>
        /// <c>adjoin &lt;auxiliary_tree&gt; &lt;name&gt;</c>
        /// Adjoins the specified auxiliary tree into the named node.
        /// The daughters of the target node will become the daughters of the foot of the auxiliary tree.
        /// <li>
        /// <c>adjoinH &lt;auxiliary_tree&gt; &lt;name&gt;</c>
        /// Similar to adjoin, but preserves the target node
        /// and makes it the root of
        /// <c>&lt;tree&gt;</c>
        /// . (It is still accessible as
        /// <c>name</c>
        /// .  The root of the
        /// auxiliary tree is ignored.)
        /// <li>
        /// <c>adjoinF &lt;auxiliary_tree&gt; &lt;name&gt;</c>
        /// Similar to adjoin,
        /// but preserves the target node and makes it the foot of
        /// <c>&lt;tree&gt;</c>
        /// .
        /// (It is still accessible as
        /// <c>name</c>
        /// , and retains its status as parent of its children.
        /// The root of the auxiliary tree is ignored.)
        /// <li> <dt>
        /// <c>coindex &lt;name1&gt; &lt;name2&gt; ... &lt;nameM&gt;</c>
        /// Puts a (Penn Treebank style)
        /// coindexation suffix of the form "-N" on each of nodes name_1 through name_m.  The value of N will be
        /// automatically generated in reference to the existing coindexations in the tree, so that there is never
        /// an accidental clash of indices across things that are not meant to be coindexed.
        /// </ul>
        /// <p>
        /// In the context of
        /// <c>adjoin</c>
        /// ,
        /// <c>adjoinH</c>
        /// ,
        /// <c>adjoinF</c>
        /// , and
        /// <c>createSubtree</c>
        /// , an auxiliary
        /// tree is a tree in Penn Treebank format with
        /// <c>@</c>
        /// on
        /// exactly one of the leaves denoting the foot of the tree.
        /// The operations which use the foot use the labeled node.
        /// For example:
        /// </p>
        /// <blockquote>
        /// Tsurgeon:
        /// <c>adjoin (FOO (BAR@)) foo</c>
        /// <br />
        /// Tregex:
        /// <c>B=foo</c>
        /// <br />
        /// Input:
        /// <c>(A (B 1 2))</c>
        /// Output:
        /// <c>(A (FOO (BAR 1 2)))</c>
        /// </blockquote>
        /// <p>
        /// Tsurgeon applies the same operation to the same tree for as long
        /// as the given tregex operation matches.  This means that infinite
        /// loops are very easy to cause.  One common situation where this comes up
        /// is with an insert operation will repeats infinitely many times
        /// unless you add an expression to the tregex that matches against
        /// the inserted pattern.  For example, this pattern will infinite loop:
        /// </p>
        /// <blockquote>
        /// <code>
        /// TregexPattern tregex = TregexPattern.compile("S=node &lt;&lt; NP"); <br />
        /// TsurgeonPattern tsurgeon = Tsurgeon.parseOperation("insert (NP foo) &gt;-1 node");
        /// </code>
        /// </blockquote>
        /// <p>
        /// This pattern, though, will terminate:
        /// </p>
        /// <blockquote>
        /// <code>
        /// TregexPattern tregex = TregexPattern.compile("S=node &lt;&lt; NP !&lt;&lt; foo"); <br />
        /// TsurgeonPattern tsurgeon = Tsurgeon.parseOperation("insert (NP foo) &gt;-1 node");
        /// </code>
        /// </blockquote>
        /// <p>
        /// Tsurgeon has (very) limited support for conditional statements.
        /// If a pattern is prefaced with
        /// <c>if exists &lt;name&gt;</c>
        /// ,
        /// the rest of the pattern will only execute if
        /// the named node was found in the corresponding TregexMatcher.
        /// </p>
        /// </remarks>
        /// <param name="args">
        /// a list of names of files each of which contains a single tregex matching pattern plus a list, one per line,
        /// of transformation operations to apply to the matched pattern.
        /// </param>
        /// <exception cref="System.Exception">If an I/O or pattern syntax error</exception>
        public static void Main(string[] args)
        {
            string headFinderClassName = null;
            string headFinderOption    = "-hf";

            string[] headFinderArgs      = null;
            string   headFinderArgOption = "-hfArg";
            string   encoding            = "UTF-8";
            string   encodingOption      = "-encoding";

            if (args.Length == 0)
            {
                log.Info("Usage: java edu.stanford.nlp.trees.tregex.tsurgeon.Tsurgeon [-s] -treeFile <file-with-trees> [-po <matching-pattern> <operation>] <operation-file-1> <operation-file-2> ... <operation-file-n>");
                System.Environment.Exit(0);
            }
            string treePrintFormats;
            string singleLineOption = "-s";
            string verboseOption    = "-v";
            string matchedOption    = "-m";
            // if set, then print original form of trees that are matched & thus operated on
            string patternOperationOption = "-po";
            string treeFileOption         = "-treeFile";
            string trfOption     = "-trf";
            string macroOption   = "-macros";
            string macroFilename = string.Empty;
            IDictionary <string, int> flagMap = Generics.NewHashMap();

            flagMap[patternOperationOption] = 2;
            flagMap[treeFileOption]         = 1;
            flagMap[trfOption]        = 1;
            flagMap[singleLineOption] = 0;
            flagMap[encodingOption]   = 1;
            flagMap[headFinderOption] = 1;
            flagMap[macroOption]      = 1;
            IDictionary <string, string[]> argsMap = StringUtils.ArgsToMap(args, flagMap);

            args = argsMap[null];
            if (argsMap.Contains(headFinderOption))
            {
                headFinderClassName = argsMap[headFinderOption][0];
            }
            if (argsMap.Contains(headFinderArgOption))
            {
                headFinderArgs = argsMap[headFinderArgOption];
            }
            if (argsMap.Contains(verboseOption))
            {
                verbose = true;
            }
            if (argsMap.Contains(singleLineOption))
            {
                treePrintFormats = "oneline,";
            }
            else
            {
                treePrintFormats = "penn,";
            }
            if (argsMap.Contains(encodingOption))
            {
                encoding = argsMap[encodingOption][0];
            }
            if (argsMap.Contains(macroOption))
            {
                macroFilename = argsMap[macroOption][0];
            }
            TreePrint          tp    = new TreePrint(treePrintFormats, new PennTreebankLanguagePack());
            PrintWriter        pwOut = new PrintWriter(new OutputStreamWriter(System.Console.Out, encoding), true);
            ITreeReaderFactory trf;

            if (argsMap.Contains(trfOption))
            {
                string trfClass = argsMap[trfOption][0];
                trf = ReflectionLoading.LoadByReflection(trfClass);
            }
            else
            {
                trf = new TregexPattern.TRegexTreeReaderFactory();
            }
            Treebank trees = new DiskTreebank(trf, encoding);

            if (argsMap.Contains(treeFileOption))
            {
                trees.LoadPath(argsMap[treeFileOption][0]);
            }
            if (trees.IsEmpty())
            {
                log.Info("Warning: No trees specified to operate on.  Use -treeFile path option.");
            }
            TregexPatternCompiler compiler;

            if (headFinderClassName == null)
            {
                compiler = new TregexPatternCompiler();
            }
            else
            {
                IHeadFinder hf;
                if (headFinderArgs == null)
                {
                    hf = ReflectionLoading.LoadByReflection(headFinderClassName);
                }
                else
                {
                    hf = ReflectionLoading.LoadByReflection(headFinderClassName, (object[])headFinderArgs);
                }
                compiler = new TregexPatternCompiler(hf);
            }
            Macros.AddAllMacros(compiler, macroFilename, encoding);
            IList <Pair <TregexPattern, TsurgeonPattern> > ops = new List <Pair <TregexPattern, TsurgeonPattern> >();

            if (argsMap.Contains(patternOperationOption))
            {
                TregexPattern   matchPattern = compiler.Compile(argsMap[patternOperationOption][0]);
                TsurgeonPattern p            = ParseOperation(argsMap[patternOperationOption][1]);
                ops.Add(new Pair <TregexPattern, TsurgeonPattern>(matchPattern, p));
            }
            else
            {
                foreach (string arg in args)
                {
                    IList <Pair <TregexPattern, TsurgeonPattern> > pairs = GetOperationsFromFile(arg, encoding, compiler);
                    foreach (Pair <TregexPattern, TsurgeonPattern> pair in pairs)
                    {
                        if (verbose)
                        {
                            log.Info(pair.Second());
                        }
                        ops.Add(pair);
                    }
                }
            }
            foreach (Tree t in trees)
            {
                Tree original = t.DeepCopy();
                Tree result   = ProcessPatternsOnTree(ops, t);
                if (argsMap.Contains(matchedOption) && matchedOnTree)
                {
                    pwOut.Println("Operated on: ");
                    DisplayTree(original, tp, pwOut);
                    pwOut.Println("Result: ");
                }
                DisplayTree(result, tp, pwOut);
            }
        }
Example #22
0
 public AccessLogin()
 {
     Macros.SafeAdd(_connProperties, "Provider", "Microsoft.Jet.OLEDB.4.0");
 }
Example #23
0
        protected override string BuildFeed()
        {
            Macros macros            = new Macros();
            string downloadUrlPrefix = macros.FullUrl(VirtualPathUtility.ToAbsolute("~/download/"));

            StringWriter sw = new StringWriter();

            sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            XmlTextWriter writer = new XmlTextWriter(sw);

            writer.WriteStartElement("items");

            foreach (Post post in GetPosts())
            {
                Dictionary <int, ItemStatistics> stats = DataHelper.GetMarketplaceCategoryStats(_categoryId);

                writer.WriteStartElement("itemInfo");
                writer.WriteAttributeString("id", post.Id.ToString());
                writer.WriteAttributeString("categoryId", post.CategoryId.ToString());
                writer.WriteAttributeString("creatorId", post.Custom("Creator"));
                writer.WriteElementString("name", post.Title);
                writer.WriteElementString("description", Util.FullyQualifyRelativeUrls(post.Excerpt("", "", "Read More", 300), SiteSettings.BaseUrl));
                writer.WriteElementString("version", post.Custom("Version"));
                writer.WriteElementString("downloadUrl", downloadUrlPrefix + post.Id.ToString());

                string fileName = post.Custom("FileName");
                if (!string.IsNullOrEmpty(fileName))
                {
                    if (fileName.Contains('/'))
                    {
                        fileName = fileName.Substring(fileName.LastIndexOf('/') + 1);
                    }
                    writer.WriteElementString("fileName", fileName);
                }
                else
                {
                    writer.WriteElementString("fileName", post.Name);
                }


                if (!string.IsNullOrEmpty(post.Custom("ImageLarge")))
                {
                    writer.WriteElementString("screenshotUrl", macros.FullUrl(post.Custom("ImageLarge")));
                }
                if (!string.IsNullOrEmpty(post.ImageUrl))
                {
                    writer.WriteElementString("iconUrl", macros.FullUrl(post.ImageUrl));
                }
                writer.WriteElementString("worksWithMajorVersion", post.Custom("RequiredMajorVersion"));
                writer.WriteElementString("worksWithMinorVersion", post.Custom("RequiredMinorVersion"));
                writer.WriteElementString("requiresManualIntervention", post.Custom("RequiresManualIntervention") ?? "False");
                writer.WriteElementString("isApproved", post.IsPublished.ToString());
                writer.WriteElementString("dateAdded", post.Published.ToUniversalTime().ToString("u"));

                writer.WriteStartElement("statisticsInfo");
                if (stats.ContainsKey(post.Id))
                {
                    writer.WriteElementString("downloadCount", stats[post.Id].DownloadCount.ToString());
                }
                else
                {
                    writer.WriteElementString("downloadCount", "0");
                }
                writer.WriteElementString("viewCount", post.Views.ToString());
                writer.WriteEndElement(); // End statisticsInfo

                writer.WriteStartElement("purchaseInfo");
                writer.WriteElementString("price", post.Custom("Price") ?? "0.0");
                if (!string.IsNullOrEmpty(post.Custom("BuyUrl")))
                {
                    writer.WriteElementString("buyUrl", post.Custom("BuyUrl"));
                }
                writer.WriteEndElement(); // End purchaseInfo

                writer.WriteStartElement("tags");
                foreach (string tag in Util.ConvertStringToList(post.TagList))
                {
                    writer.WriteElementString("tag", tag);
                }
                writer.WriteEndElement(); // End tags

                writer.WriteEndElement(); // End itemInfo
            }

            writer.WriteEndElement();             // End items

            return(sw.ToString());
        }
Example #24
0
        private EmbedBuilder GetEDSMCMDREmbed(JSONContainer json, string backupName)
        {
            EmbedBuilder result;

            if (json.TryGetField("msg", out string msg))
            {
                if (msg == "OK")
                {
                    string system_link     = null;
                    bool   system_id_found = json.TryGetField("systemId", out uint system_id, 0);
                    if (json.TryGetField("system", out string system_name, null) && system_id_found)
                    {
                        system_link = $"https://www.edsm.net/en/system/id/{system_id}/name/{system_name.Replace(' ', '+')}";
                    }
                    string user_name = backupName;
                    if (json.TryGetField("url", out string profile_url, "https://www.edsm.net"))
                    {
                        string[] urlsections = profile_url.Split('/');
                        if (urlsections.Length > 1)
                        {
                            user_name = urlsections[urlsections.Length - 1];
                        }
                    }
                    json.TryGetField("shipType", out string shipType, null);
                    string station_name = null;
                    string station_link = null;
                    if (json.TryGetField("isDocked", out bool isDocked, false))
                    {
                        json.TryGetField("station", out station_name, "Unknown Station");
                        if (json.TryGetField("stationId", out uint station_id) && system_link != null)
                        {
                            station_link = $"https://www.edsm.net/en/system/stations/id/{system_id}/name/{system_name.Replace(' ', '+')}/details/idS/{station_id}/nameS/{station_name.Replace(' ', '+')}";
                        }
                    }

                    result = new EmbedBuilder()
                    {
                        Author = new EmbedAuthorBuilder()
                        {
                            Url  = profile_url,
                            Name = $"{user_name}'s EDSM Profile"
                        },
                        Color = BotCore.EmbedColor
                    };
                    if (system_name != null)
                    {
                        if (system_link != null)
                        {
                            result.AddField("System", $"[{system_name}]({system_link})");
                        }
                        else
                        {
                            result.AddField("System", system_name);
                        }
                    }
                    if (shipType != null)
                    {
                        result.AddField("Ship", shipType);
                    }
                    if (isDocked)
                    {
                        if (station_link != null)
                        {
                            result.AddField("Docked At", $"[{station_name}]({station_link})");
                        }
                        else
                        {
                            result.AddField("Docked At", station_name);
                        }
                    }
                }
                else
                {
                    result = new EmbedBuilder()
                    {
                        Author = new EmbedAuthorBuilder()
                        {
                            Name = backupName
                        },
                        Color       = BotCore.ErrorColor,
                        Description = msg
                    };
                }
            }
            else
            {
                result = new EmbedBuilder()
                {
                    Author = new EmbedAuthorBuilder()
                    {
                        Name = backupName
                    },
                    Color       = BotCore.ErrorColor,
                    Description = $"Internal Error - {Macros.GetCodeLocation()}"
                };
            }
            return(result);
        }
Example #25
0
        public override void Initialize()
        {
            Aimsharp.PrintMessage("Perfect Simcraft Series: Shadow Priest - v 1.0", Color.Blue);
            Aimsharp.PrintMessage("Recommended talents: 3111111", Color.Blue);
            Aimsharp.PrintMessage("These macros can be used for manual control:", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx AOE", Color.Blue);
            Aimsharp.PrintMessage("--Toggles AOE mode on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx Potions", Color.Blue);
            Aimsharp.PrintMessage("--Toggles using buff potions on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx SaveCooldowns", Color.Blue);
            Aimsharp.PrintMessage("--Toggles the use of big cooldowns on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("--Replace xxxxx with first 5 letters of your addon, lowercase.", Color.Blue);


            Aimsharp.Latency    = 0;
            Aimsharp.QuickDelay = 125;
            Aimsharp.SlowDelay  = 300;

            MajorPower = GetDropDown("Major Power");
            TopTrinket = GetDropDown("Top Trinket");
            BotTrinket = GetDropDown("Bot Trinket");

            Spellbook.Add(MajorPower);
            Spellbook.Add("Void Eruption");
            Spellbook.Add("Dark Ascension");
            Spellbook.Add("Void Bolt");
            Spellbook.Add("Mind Sear");
            Spellbook.Add("Shadow Word: Death");
            Spellbook.Add("Surrender to Madness");
            Spellbook.Add("Dark Void");
            Spellbook.Add("Mindbender");
            Spellbook.Add("Shadowfiend");
            Spellbook.Add("Shadow Crash");
            Spellbook.Add("Mind Blast");
            Spellbook.Add("Void Torrent");
            Spellbook.Add("Shadow Word: Pain");
            Spellbook.Add("Vampiric Touch");
            Spellbook.Add("Mind Flay");
            Spellbook.Add("Shadowform");
            Spellbook.Add("Shadow Word: Void");

            Buffs.Add("Bloodlust");
            Buffs.Add("Heroism");
            Buffs.Add("Time Warp");
            Buffs.Add("Ancient Hysteria");
            Buffs.Add("Netherwinds");
            Buffs.Add("Drums of Rage");
            Buffs.Add("Chorus of Insanity");
            Buffs.Add("Lifeblood");
            Buffs.Add("Harvested Thoughts");
            Buffs.Add("Voidform");
            Buffs.Add("Shadowform");

            Debuffs.Add("Shadow Word: Pain");
            Debuffs.Add("Vampiric Touch");
            Debuffs.Add("Shiver Venom");

            Items.Add(TopTrinket);
            Items.Add(BotTrinket);
            Items.Add(GetDropDown("Potion Type"));

            Macros.Add(TopTrinket, "/use " + TopTrinket);
            Macros.Add(BotTrinket, "/use " + BotTrinket);
            Macros.Add("TopTrink", "/use 13");
            Macros.Add("BotTrink", "/use 14");
            Macros.Add("potion", "/use " + GetDropDown("Potion Type"));
            Macros.Add("crash cursor", "/cast [@cursor] Shadow Crash");

            CustomCommands.Add("AOE");
            CustomCommands.Add("Prepull");
            CustomCommands.Add("Potions");
            CustomCommands.Add("SaveCooldowns");
        }
Example #26
0
        public override void Initialize()
        {
            //Aimsharp.DebugMode();
            Aimsharp.PrintMessage("Perfect Simcraft Series: Elemental Shaman - v 1.0", Color.Blue);
            Aimsharp.PrintMessage("These macros can be used for manual control:", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx Potions", Color.Blue);
            Aimsharp.PrintMessage("--Toggles using buff potions on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx SaveCooldowns", Color.Blue);
            Aimsharp.PrintMessage("--Toggles the use of big cooldowns on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx AOE", Color.Blue);
            Aimsharp.PrintMessage("--Toggles AOE mode on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx LightAOE", Color.Blue);
            Aimsharp.PrintMessage("--Toggles light AOE mode on/off (3 targets).", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx Prepull 10", Color.Blue);
            Aimsharp.PrintMessage("--Starts the prepull actions.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("--Replace xxxxx with first 5 letters of your addon, lowercase.", Color.Blue);

            Aimsharp.Latency    = 150;
            Aimsharp.QuickDelay = 100;
            Aimsharp.SlowDelay  = 350;

            MajorPower  = GetDropDown("Major Power");
            TopTrinket  = GetDropDown("Top Trinket");
            BotTrinket  = GetDropDown("Bot Trinket");
            RacialPower = GetDropDown("Racial Power");

            Spellbook.Add(MajorPower);

            if (RacialPower == "Orc")
            {
                Spellbook.Add("Blood Fury");
            }
            if (RacialPower == "Troll")
            {
                Spellbook.Add("Berserking");
            }
            if (RacialPower == "Dark Iron Dwarf")
            {
                Spellbook.Add("Fireblood");
            }
            if (RacialPower == "Mag'har Orc")
            {
                Spellbook.Add("Ancestral Call");
            }

            Spellbook.Add("Totem Mastery");
            Spellbook.Add("Fire Elemental");
            Spellbook.Add("Storm Elemental");
            Spellbook.Add("Earth Elemental");
            Spellbook.Add("Blood Fury");
            Spellbook.Add("Berserking");
            Spellbook.Add("Fireblood");
            Spellbook.Add("Ancestral Call");
            Spellbook.Add("Icefury");
            Spellbook.Add("Ascendance");
            Spellbook.Add("Stormkeeper");
            Spellbook.Add("Flame Shock");
            Spellbook.Add("Lava Burst");
            Spellbook.Add("Elemental Blast");
            Spellbook.Add("Liquid Magma Totem");
            Spellbook.Add("Lightning Bolt");
            Spellbook.Add("Earthquake");
            Spellbook.Add("Earth Shock");
            Spellbook.Add("Lightning Lasso");
            Spellbook.Add("Frost Shock");
            Spellbook.Add("Lava Beam");
            Spellbook.Add("Chain Lightning");
            Spellbook.Add("Call Lightning");
            Spellbook.Add("Eye of the Storm");

            Buffs.Add("Bloodlust");
            Buffs.Add("Heroism");
            Buffs.Add("Time Warp");
            Buffs.Add("Ancient Hysteria");
            Buffs.Add("Netherwinds");
            Buffs.Add("Drums of Rage");
            Buffs.Add("Resonance Totem");
            Buffs.Add("Stormkeeper");
            Buffs.Add("Lifeblood");
            Buffs.Add("Memory of Lucid Dreams");
            Buffs.Add("Icefury");
            Buffs.Add("Ascendance");
            Buffs.Add("Wind Gust");
            Buffs.Add("Lava Surge");
            Buffs.Add("Surge of Power");
            Buffs.Add("Master of the Elements");
            Buffs.Add("Lava Shock");
            Buffs.Add("Call Lightning");

            Debuffs.Add("Razor Coral");
            Debuffs.Add("Conductive Ink");
            Debuffs.Add("Flame Shock");
            Debuffs.Add("Shiver Venom");

            Items.Add(TopTrinket);
            Items.Add(BotTrinket);
            Items.Add(GetDropDown("Potion Type"));
            Items.Add("Neural Synapse Enhancer");

            Macros.Add(TopTrinket, "/use " + TopTrinket);
            Macros.Add(BotTrinket, "/use " + BotTrinket);
            Macros.Add("potion", "/use " + GetDropDown("Potion Type"));
            Macros.Add("eq cursor", "/cast [@cursor] Earthquake");
            Macros.Add("Magma Cursor", "/cast [@cursor] Liquid Magma Totem");
            Macros.Add("nse", "/use Neural Synapse Enhancer");
            Macros.Add("TopTrink", "/use 13");
            Macros.Add("BotTrink", "/use 14");

            CustomCommands.Add("Potions");
            CustomCommands.Add("SaveCooldowns");
            CustomCommands.Add("AOE");
            CustomCommands.Add("Prepull");
            CustomCommands.Add("LightAOE");
        }
Example #27
0
 /// <summary>
 /// Adds a macro to this mixin.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="value">The value.</param>
 public void AddMacro(string name, object value)
 {
     Macros.Add(new ShaderMacro(name, value));
 }
Example #28
0
        protected override async Task Execute(IDMCommandContext context)
        {
            string            radiusRequest       = WebRequestService.EDSM_MultipleSystemsRadius(SystemName, 50);
            RequestJSONResult requestResultRadius = await WebRequestService.GetWebJSONAsync(radiusRequest);

            if (!requestResultRadius.IsSuccess)
            {
                if (requestResultRadius.IsException)
                {
                    await context.Channel.SendEmbedAsync(string.Format("Could not connect to EDSMs services. Exception Message: `{0}`", requestResultRadius.ThrownException.Message), true);
                }
                else
                {
                    await context.Channel.SendEmbedAsync(string.Format("Could not connect to EDSMs services. HTTP Error: `{0} {1}`", (int)requestResultRadius.Status, requestResultRadius.Status.ToString()), true);
                }
                return;
            }

            if (requestResultRadius.JSON.IsObject)
            {
                await context.Channel.SendEmbedAsync("System not found in database!", true);

                return;
            }

            Dictionary <string, System> systemInfos = GetNames(requestResultRadius.JSON);

            List <System> allSystems = new List <System>(systemInfos.Values);

            foreach (System system in allSystems)
            {
                system.SetETTA(JumpRange);
            }

            allSystems.Sort(new SystemComparer()
            {
                RawDistance = true
            });

            const int requestCnt = 20;

            System[] requestSystems = new System[requestCnt];

            allSystems.CopyTo(0, requestSystems, 0, requestCnt);

            string            infoRequest       = WebRequestService.EDSM_MultipleSystemsInfo_URL(requestSystems.Select(system => { return(system.Name); }), true, true, true, true);
            RequestJSONResult requestResultInfo = await WebRequestService.GetWebJSONAsync(infoRequest);

            if (!requestResultInfo.IsSuccess)
            {
                if (requestResultInfo.IsException)
                {
                    await context.Channel.SendEmbedAsync(string.Format("Could not connect to EDSMs services. Exception Message: `{0}`", requestResultInfo.ThrownException.Message), true);
                }
                else
                {
                    await context.Channel.SendEmbedAsync(string.Format("Could not connect to EDSMs services. HTTP Error: `{0} {1}`", (int)requestResultInfo.Status, requestResultInfo.Status.ToString()), true);
                }
                return;
            }

            System targetSystem = default;

            if (requestResultInfo.JSON.IsArray)
            {
                foreach (JSONField systemField in requestResultInfo.JSON.Array)
                {
                    if (systemField.IsObject)
                    {
                        if (systemField.Container.TryGetField("name", out string name))
                        {
                            if (systemInfos.TryGetValue(name, out System system))
                            {
                                system.FromJSON(systemField.Container);
                                if (system.Distance == 0)
                                {
                                    targetSystem = system;
                                }
                            }
                        }
                    }
                }
            }

            if (targetSystem.Name == null)
            {
                await context.Channel.SendEmbedAsync(string.Format("Internal Error! " + Macros.GetCodeLocation(), true));

                return;
            }

            string hideFaction = Mode == CommandMode.Crime ? targetSystem.Name : null;

            List <System> validSystems = new List <System>();

            foreach (System system in requestSystems)
            {
                if (await system.GetBestStation())
                {
                    system.SetETTA(JumpRange);
                    validSystems.Add(system);
                }
            }

            validSystems.Sort(new SystemComparer());

            EmbedBuilder embed = new EmbedBuilder()
            {
                Author = new EmbedAuthorBuilder()
                {
                    Url  = targetSystem.GetEDSM_URL(),
                    Name = $"Suggestions for a temporary base near {targetSystem.Name}"
                },
                Color = BotCore.EmbedColor
            };

            for (int i = 0; i < 5 && i < validSystems.Count; i++)
            {
                System system = validSystems[i];
                embed.AddField($"\"{system.Name}\" - \"{system.BestStation.Name}\"", $"{(system.RequirePermit ? $"{UnicodeEmoteService.Warning} Permit: `{system.PermitName}` " : string.Empty)} {system.BestStation.Services_Link}");
            }

            await context.Channel.SendEmbedAsync(embed);
        }
Example #29
0
 protected override void AdjustConnProperties()
 {
     Macros.SafeAdd(_connProperties, "Version", SqliteVersion);
 }
Example #30
0
        public override void Initialize()
        {
            Aimsharp.PrintMessage("Kyber Destruction Warlock - v 1.0", Color.Blue);
            Aimsharp.PrintMessage("These macros can be used for manual control:", Color.Blue);
            Aimsharp.PrintMessage("Recommended talents: 3203012", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx SaveCovenant", Color.Blue);
            Aimsharp.PrintMessage("--Toggles using Covenant abilities on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx SaveCooldowns", Color.Blue);
            Aimsharp.PrintMessage("--Toggles the use of big cooldowns on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx AOE", Color.Blue);
            Aimsharp.PrintMessage("--Toggles AOE mode on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("--Replace xxxxx with first 5 letters of your addon, lowercase.", Color.Blue);
            Aimsharp.PrintMessage("This rotation will use Havoc on your focus target, so please make a macro to set focus quickly.", Color.Blue);
            Aimsharp.PrintMessage("/focus [@mouseover,nodead,exists]; [@target,exists]", Color.Blue);

            Aimsharp.Latency    = 50;
            Aimsharp.QuickDelay = 125;
            Aimsharp.SlowDelay  = 250;

            foreach (string Spell in SpellsList)
            {
                Spellbook.Add(Spell);
            }

            foreach (string Spell in CovenantAbilities)
            {
                Spellbook.Add(Spell);
            }

            foreach (string Spell in Racials)
            {
                Spellbook.Add(Spell);
            }

            foreach (string Buff in GeneralBuffs)
            {
                Buffs.Add(Buff);
            }

            foreach (string Buff in BuffsList)
            {
                Buffs.Add(Buff);
            }

            foreach (string Buff in BloodlustEffects)
            {
                Buffs.Add(Buff);
            }

            foreach (string Debuff in DebuffsList)
            {
                Debuffs.Add(Debuff);
            }

            foreach (string Debuff in GeneralDebuffs)
            {
                Debuffs.Add(Debuff);
            }

            foreach (string Totem in TotemsList)
            {
                Totems.Add(Totem);
            }

            Items.Add(GetString("Potion name:"));

            Macros.Add("DPS Pot", "/use " + GetString("Potion name:"));
            Macros.Add("havoc focus", "/cast [@focus] Havoc");
            Macros.Add("cata cursor", "/cast [@cursor] Cataclysm");
            Macros.Add("rof cursor", "/cast [@cursor] Rain of Fire");
            Macros.Add("inf cursor", "/cast [@cursor] Summon Infernal");
            Macros.Add("TopTrink", "/use 13");
            Macros.Add("BotTrink", "/use 14");

            foreach (string MacroCommand in MacroCommands)
            {
                CustomCommands.Add(MacroCommand);
            }

            CustomFunctions.Add("GetCovenant", "local spell = 0 local i = 1 while true do local spellName, spellSub = GetSpellBookItemName(i, BOOKTYPE_SPELL) if not spellName then do break end end if spellName == 'Decimating Bolt' then spell = 4 elseif spellName == 'Soul Rot' then spell = 3 elseif spellName == 'Impending Catastrophe' then spell = 2 elseif spellName == 'Scouring Tithe' then spell = 1 end i = i + 1 end return spell");
            CustomFunctions.Add("GetLegendarySpellID", "local power = 0 for i=1,15,1 do local xcs = ItemLocation:CreateFromEquipmentSlot(i) if(C_Item.DoesItemExist(xcs)) then if(C_LegendaryCrafting.IsRuneforgeLegendary(xcs)) then local id = C_LegendaryCrafting.GetRuneforgeLegendaryComponentInfo(xcs)[\"powerID\"] power = C_LegendaryCrafting.GetRuneforgePowerInfo(id)[\"descriptionSpellID\"] end end end return power");
        }
 private string EvaluateMacro(Macros macro, string parameter)
 {
     switch (macro)
     {
         case Macros.MACHINENAME:
             {
                 return Environment.MachineName.ToString();
             }
         case Macros.YEAR:
             {
                 return DateTime.Today.Year.ToString();
             }
         case Macros.MONTH:
             {
                 return DateTime.Today.Month.ToString().PadLeft(2, '0');
             }
         case Macros.DAY:
             {
                 return DateTime.Today.Day.ToString().PadLeft(2, '0');
             }
         case Macros.HOUR:
             {
                 return DateTime.Now.Hour.ToString().PadLeft(2, '0');
             }
         case Macros.MINUTE:
             {
                 return DateTime.Now.Minute.ToString().PadLeft(2, '0');
             }
         case Macros.SOURCEFILENAME:
             {
                 return SourceFileName;
             }
         case Macros.DATE:
             {
                 return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddT000000");
             }
         case Macros.DATETIME:
             {
                 return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHHmmss");
             }
         case Macros.DATETIME_TZ:
             {
                 DateTime now = DateTime.Now;
                 return string.Concat(now.ToString("yyyyMMddHHmmsss"), GetTZD(now));
             }
         case Macros.MESSAGEID:
             {
                 return MessageID;
             }
         case Macros.MESSAGEID_NOBRA:
             {
                 return MessageID.Replace("{", "").Replace("}", "");
             }
         case Macros.MESSAGEID_NOSYM:
             {
                 return MessageID.Replace("{", "").Replace("}", "").Replace("-", "");
             }
         case Macros.TIME:
             {
                 return DateTime.Now.ToUniversalTime().ToString("HHmmss");
             }
         case Macros.TIME_TZ:
             {
                 DateTime now = DateTime.Now;
                 return string.Concat(now.ToUniversalTime().ToString("HHmmss"), GetTZD(now));
             }
         case Macros.LOCALDATETIME:
             {
                 return DateTime.Now.ToString("yyyy-MM-ddTHHmmss");
             }
         case Macros.LOCALDATE:
             {
                 return DateTime.Now.ToString("yyyyMMdd");
             }
         case Macros.LOCALDATE_SHORT:
             {
                 return DateTime.Now.ToString("yyMMdd");
             }
         case Macros.LOCALDATETIME_COMPACT:
             {
                 return DateTime.Now.ToString("yyyyMMddHHmmsss");
             }
         case Macros.LOCALTIME:
             {
                 return DateTime.Now.ToString("HHmmss");
             }
         default:
             {
                 throw new ArgumentException(string.Format("Macro '{0}' not available", macro), "macro");
             }
     }
 }
Example #32
0
        public static void do_aid(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() && ch.IsAffected(AffectedByTypes.Charm),
                                           Resources.CANNOT_CONCENTRATE))
            {
                return;
            }

            var arg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, arg, Resources.AID_WHO))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(arg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNpc(ch, victim, "Not on mobs."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNotNullObject(ch, ch.CurrentMount, "You can't do that while mounted."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Aid yourself?"))
            {
                return;
            }

            if ((int)victim.CurrentPosition >= (int)PositionTypes.Stunned)
            {
                comm.act(ATTypes.AT_PLAIN, "$N doesn't need your help.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (victim.CurrentHealth <= -6)
            {
                comm.act(ATTypes.AT_PLAIN, "$N's condition is beyond your aiding ability.", ch, null, victim, ToTypes.Character);
                return;
            }

            var percent = SmaugRandom.D100() - ch.GetCurrentLuck() - 13;

            var skill = RepositoryManager.Instance.GetEntity <SkillData>("aid");

            if (skill == null)
            {
                throw new ObjectNotFoundException("Skill 'aid' was not found.");
            }

            Macros.WAIT_STATE(ch, skill.Rounds);
            if (!ch.CanUseSkill(percent, skill))
            {
                ch.SendTo("You fail.");
                skill.LearnFromFailure((PlayerInstance)ch);
                return;
            }

            comm.act(ATTypes.AT_SKILL, "You aid $N!", ch, null, victim, ToTypes.Character);
            comm.act(ATTypes.AT_SKILL, "$n aids $N!", ch, null, victim, ToTypes.Room);
            skill.LearnFromSuccess((PlayerInstance)ch);
            ((PlayerInstance)ch).AdjustFavor(DeityFieldTypes.Aid, 1);

            if (victim.CurrentHealth < 1)
            {
                victim.CurrentHealth = 1;
            }

            victim.UpdatePositionByCurrentHealth();
            comm.act(ATTypes.AT_SKILL, "$n aids you!", ch, null, victim, ToTypes.Victim);
        }
 public void ProcessTemplate(SharedBasePage page, string templateString, Control contentPlaceHolder, Macros macros)
 {
     ProcessTemplate(page, null, templateString, contentPlaceHolder, macros);
 }
        public void ProcessTemplate(SharedBasePage page, Entry entry, string templateString, Control contentPlaceHolder, Macros macros)
        {
            int lastIndex = 0;

            MatchCollection matches = templateFinder.Matches(templateString);

            foreach (Match match in matches)
            {
                if (match.Index > lastIndex)
                {
                    contentPlaceHolder.Controls.Add(new LiteralControl(templateString.Substring(lastIndex, match.Index - lastIndex)));
                }
                Group   g = match.Groups["macro"];
                Capture c = g.Captures[0];

                Control ctrl           = null;
                object  targetMacroObj = macros;
                string  captureValue   = c.Value;

                //Check for a string like: <%foo("bar", "bar")|assemblyConfigName%>
                int assemblyNameIndex = captureValue.IndexOf(")|");
                if (assemblyNameIndex != -1)                 //use the default Macros
                {
                    //The QN minus the )|
                    string macroAssemblyName = captureValue.Substring(assemblyNameIndex + 2);
                    //The method, including the )
                    captureValue = captureValue.Substring(0, assemblyNameIndex + 1);

                    try
                    {
                        targetMacroObj = MacrosFactory.CreateCustomMacrosInstance(page, entry, macroAssemblyName);
                    }
                    catch (Exception ex)
                    {
                        string ExToString = ex.ToString();
                        if (ex.InnerException != null)
                        {
                            ExToString += ex.InnerException.ToString();
                        }
                        page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error, String.Format("Error executing Macro: {0}", ExToString), string.Empty));
                    }
                }

                try
                {
                    ctrl = InvokeMacro(targetMacroObj, captureValue) as Control;
                    if (ctrl != null)
                    {
                        contentPlaceHolder.Controls.Add(ctrl);
                    }
                    else
                    {
                        page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error, String.Format("Error executing Macro: {0} returned null.", captureValue), string.Empty));
                    }
                }
                catch (Exception ex)
                {
                    string error = String.Format("Error executing macro: {0}. Make sure it you're calling it in your BlogTemplate with parentheses like 'myMacro()'. Macros with parameter lists and overloads must be called in this way. Exception: {1}", c.Value, ex.ToString());
                    page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error, error, string.Empty));
                }
                lastIndex = match.Index + match.Length;
            }
            if (lastIndex < templateString.Length)
            {
                contentPlaceHolder.Controls.Add(new LiteralControl(templateString.Substring(lastIndex, templateString.Length - lastIndex)));
            }
        }
Example #35
0
		public void ProcessTemplate(SharedBasePage page, Entry entry, string templateString, Control contentPlaceHolder, Macros macros)
		{
			int lastIndex = 0;

			MatchCollection matches = templateFinder.Matches(templateString);
			foreach( Match match in matches )
			{
				if ( match.Index > lastIndex )
				{
					contentPlaceHolder.Controls.Add(new LiteralControl(templateString.Substring(lastIndex,match.Index-lastIndex)));
				}
				Group g = match.Groups["macro"];
				Capture c = g.Captures[0];
				
				Control ctrl = null;
				object targetMacroObj = macros;
				string captureValue = c.Value;
				
				//Check for a string like: <%foo("bar", "bar")|assemblyConfigName%>
				int assemblyNameIndex = captureValue.IndexOf(")|");
				if (assemblyNameIndex != -1) //use the default Macros
				{
					//The QN minus the )| 
					string macroAssemblyName = captureValue.Substring(assemblyNameIndex+2);
					//The method, including the )
					captureValue = captureValue.Substring(0,assemblyNameIndex+1);

					try
					{
						targetMacroObj = MacrosFactory.CreateCustomMacrosInstance(page, entry, macroAssemblyName);
					}
					catch (Exception ex)
					{
						string ExToString = ex.ToString();
						if (ex.InnerException != null)
						{
							ExToString += ex.InnerException.ToString();
						}
						page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error,String.Format("Error executing Macro: {0}",ExToString),string.Empty));
					}
				}

				try
				{
					ctrl = InvokeMacro(targetMacroObj,captureValue) as Control;
					if (ctrl != null)
					{
						contentPlaceHolder.Controls.Add(ctrl);
					}
					else 
					{
						page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error,String.Format("Error executing Macro: {0} returned null.",captureValue),string.Empty));
					}
				}
				catch (Exception ex)
				{
					string error = String.Format("Error executing macro: {0}. Make sure it you're calling it in your BlogTemplate with parentheses like 'myMacro()'. Macros with parameter lists and overloads must be called in this way. Exception: {1}",c.Value, ex.ToString());
					page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error,error,string.Empty));
				}
				lastIndex = match.Index+match.Length;
			}
			if ( lastIndex < templateString.Length)
			{
				contentPlaceHolder.Controls.Add(new LiteralControl(templateString.Substring(lastIndex,templateString.Length-lastIndex)));
			}
		}
Example #36
0
 void Start()
 {
     GameObject bc = GameObject.Find ("BehaviorController");
     preds = bc.GetComponent<Predicates> ();
     eventManager = bc.GetComponent<EventManager> ();
     macros = bc.GetComponent<Macros> ();
 }
Example #37
0
 public void RemoveMacros(Macros param)
 {
     int index = MacrosCollection.IndexOf(param);
     mTreeSequence.RemoveAtState(index);
     MacrosCollection.Remove(param);
 }
Example #38
0
        public override void Initialize()
        {
            // Aimsharp.DebugMode();

            Aimsharp.PrintMessage("Vid Protection Warrior", Color.Blue);
            Aimsharp.PrintMessage("These macros can be used for manual control:", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx Potions", Color.Blue);
            Aimsharp.PrintMessage("--Toggles using buff potions on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx SaveCooldowns", Color.Blue);
            Aimsharp.PrintMessage("--Toggles the use of big cooldowns on/off.", Color.Blue);
            Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("/xxxxx AOE", Color.Blue);
            Aimsharp.PrintMessage("--Toggles AOE mode on/off.", Color.Blue);
            Aimsharp.PrintMessage("/xxxxx StormBolt --Queues Storm Bolt up to be used on the next GCD.", Color.Red);
            Aimsharp.PrintMessage("/xxxxx RallyingCry --Queues Rallying Cry up to be used on the next GCD.", Color.Red);
            Aimsharp.PrintMessage("/xxxxx IntimidatingShout --Queues Intimidating SHout up to be used on the next GCD.", Color.Red);
            //Aimsharp.PrintMessage(" ");
            // Aimsharp.PrintMessage("/xxxxx Prepull 10", Color.Blue);
            // Aimsharp.PrintMessage("--Starts the prepull actions.", Color.Blue);
            // Aimsharp.PrintMessage(" ");
            Aimsharp.PrintMessage("--Replace xxxxx with first 5 letters of your addon, lowercase.", Color.Blue);

            Aimsharp.Latency    = 50;
            Aimsharp.QuickDelay = 125;
            Aimsharp.SlowDelay  = 250;

            MajorPower  = GetDropDown("Major Power");
            TopTrinket  = GetDropDown("Top Trinket");
            BotTrinket  = GetDropDown("Bot Trinket");
            RacialPower = GetDropDown("Racial Power");
            FiveLetters = GetString("First 5 Letters of the Addon:");

            Spellbook.Add(MajorPower);

            if (RacialPower == "Orc")
            {
                Spellbook.Add("Blood Fury");
            }
            if (RacialPower == "Troll")
            {
                Spellbook.Add("Berserking");
            }
            if (RacialPower == "Dark Iron Dwarf")
            {
                Spellbook.Add("Fireblood");
            }
            if (RacialPower == "Mag'har Orc")
            {
                Spellbook.Add("Ancestral Call");
            }
            if (RacialPower == "Lightforged Draenei")
            {
                Spellbook.Add("Light's Judgment");
            }
            if (RacialPower == "Bloodelf")
            {
                Spellbook.Add("Arcane Torrent");
            }

            Spellbook.Add("Intercept");
            Spellbook.Add("Avatar");
            Spellbook.Add("Ignore Pain");
            Spellbook.Add("Demoralizing Shout");
            Spellbook.Add("Last Stand");
            Spellbook.Add("Thunder Clap");
            Spellbook.Add("Ravager");
            Spellbook.Add("Shield Block");
            Spellbook.Add("Shield Slam");
            Spellbook.Add("Devastate");
            Spellbook.Add("Victory Rush");
            Spellbook.Add("Revenge");
            Spellbook.Add("Intimidating Shout");
            Spellbook.Add("Shockwave");
            Spellbook.Add("Storm Bolt");
            Spellbook.Add("Rallying Cry");

            Buffs.Add("Bloodlust");
            Buffs.Add("Heroism");
            Buffs.Add("Time Warp");
            Buffs.Add("Ancient Hysteria");
            Buffs.Add("Netherwinds");
            Buffs.Add("Drums of Rage");
            Buffs.Add("Lifeblood");
            Buffs.Add("Memory of Lucid Dreams");
            Buffs.Add("Reckless Force");
            Buffs.Add("Guardian of Azeroth");

            Buffs.Add("Victorious");
            Buffs.Add("Avatar");
            Buffs.Add("Ignore Pain");
            Buffs.Add("Shield Block");
            Buffs.Add("Revenge!");

            Debuffs.Add("Razor Coral");
            Debuffs.Add("Conductive Ink");
            Debuffs.Add("Shiver Venom");

            Items.Add(TopTrinket);
            Items.Add(BotTrinket);
            Items.Add(GetDropDown("Potion Type"));

            Macros.Add(TopTrinket, "/use " + TopTrinket);
            Macros.Add(BotTrinket, "/use " + BotTrinket);
            Macros.Add("potion", "/use " + GetDropDown("Potion Type"));
            Macros.Add("StormBoltOff", "/" + FiveLetters + " StormBolt");
            Macros.Add("IntimidatingShoutOff", "/" + FiveLetters + " IntimidatingShout");
            Macros.Add("RallyingCryOff", "/" + FiveLetters + " RallyingCry");
            Macros.Add("ShockWaveOff", "/" + FiveLetters + " ShockWave");

            CustomCommands.Add("Potions");
            CustomCommands.Add("SaveCooldowns");
            CustomCommands.Add("AOE");
            // CustomCommands.Add("Prepull");
            CustomCommands.Add("StormBolt");
            CustomCommands.Add("RallyingCry");
            CustomCommands.Add("IntimidatingShout");
            CustomCommands.Add("ShockWave");

            Macros.Add("RavageSelf", "/cast [@player] Ravager");
        }
Example #39
0
 void Start()
 {
     eventManager = gameObject.GetComponent<EventManager> ();
     aStarSearch = GameObject.Find ("BlocksWorld").GetComponent<AStarSearch> ();
     objSelector = GameObject.Find ("BlocksWorld").GetComponent<ObjectSelector> ();
     macros = GameObject.Find ("BehaviorController").GetComponent<Macros> ();
 }
Example #40
0
        public static void do_bury(CharacterInstance ch, string argument)
        {
            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "What do you wish to bury?"))
            {
                return;
            }
            if (handler.FindObject_CheckMentalState(ch))
            {
                return;
            }

            var shovel = ch.Carrying.FirstOrDefault(x => x.ItemType == ItemTypes.Shovel);
            var obj    = ch.GetObjectOnMeOrInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, obj, "You can't find it."))
            {
                return;
            }

            obj.Split();
            if (!obj.WearFlags.IsSet(ItemWearFlags.Take))
            {
                if (!obj.ExtraFlags.IsSet((int)ItemExtraFlags.ClanCorpse) || ch.IsNpc() ||
                    !((PlayerInstance)ch).PlayerData.Flags.IsSet(PCFlags.Deadly))
                {
                    comm.act(ATTypes.AT_PLAIN, "You cannot bury $p.", ch, obj, null, ToTypes.Character);
                    return;
                }
            }

            var sectorType = ch.CurrentRoom.SectorType;

            if (CheckFunctions.CheckIfTrue(ch, sectorType == SectorTypes.City || sectorType == SectorTypes.Inside,
                                           "The floor is too hard to dig through."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           sectorType == SectorTypes.DeepWater || sectorType == SectorTypes.ShallowWater ||
                                           sectorType == SectorTypes.Underwater, "you cannot bury something here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, sectorType == SectorTypes.Air, "What?  In the air?!"))
            {
                return;
            }

            var carryWeight = 5.GetHighestOfTwoNumbers(ch.CanCarryMaxWeight() / 10);

            if (CheckFunctions.CheckIfTrue(ch, shovel == null && obj.GetWeight() > carryWeight,
                                           "You'd need a shovel to bury something that big."))
            {
                return;
            }

            var move = obj.GetWeight() * 50 * (shovel != null ? 1 : 5) /
                       1.GetHighestOfTwoNumbers(ch.CanCarryMaxWeight());

            move = 2.GetNumberThatIsBetween(move, 1000);
            if (CheckFunctions.CheckIfTrue(ch, move > ch.CurrentMovement,
                                           "You don't have the energy to bury something of that size."))
            {
                return;
            }

            ch.CurrentMovement -= move;
            if (obj.ItemType == ItemTypes.NpcCorpse || obj.ItemType == ItemTypes.PlayerCorpse)
            {
                ((PlayerInstance)ch).AdjustFavor(DeityFieldTypes.BuryCorpse, 1);
            }

            comm.act(ATTypes.AT_ACTION, "You solemnly bury $p...", ch, obj, null, ToTypes.Character);
            comm.act(ATTypes.AT_ACTION, "$n solemnly buries $p...", ch, obj, null, ToTypes.Room);
            obj.ExtraFlags.SetBit((int)ItemExtraFlags.Buried);
            Macros.WAIT_STATE(ch, 10.GetNumberThatIsBetween(move / 2, 100));
        }