Example #1
0
        public override bool Execute()
        {
            if (DEBUG)
            {
                Console.WriteLine($"Executing Event: {EventType} ");
            }
            switch (EventType)
            {
            case "macro":
                switch ((int)Params[0].GetValue())
                {
                case 13:
                    ClientCommunication.SendToServer(new UseSkill((int)Params[1].GetValue()));
                    break;

                case 15:
                    World.Player.LastSpell = (int)Params[1].GetValue();
                    ClientCommunication.CastSpell((int)Params[1].GetValue());
                    break;

                case 16:
                    ClientCommunication.CastSpell(World.Player.LastSpell);
                    break;

                case 17:
                    var obj = Utility.EUO2StealthID(EUOInterpreter.GetVariable <string>("#lobjectid"));
                    ClientCommunication.SendToServer(new DoubleClick(obj));

                    break;

                case 22:
                    var targ = Utility.EUO2StealthID(EUOInterpreter.GetVariable <string>("#ltargetid"));
                    EUOVars.SendTargetLast();
                    break;

                case 23:
                    Targeting.Target(World.Player.Serial);
                    break;
                }
                break;

            case "gump":
            {
                switch (Params[0].GetValue().ToString())
                {
                case "wait":
                {
                    int timeout = 10000;
                    if (Params.Count > 1)
                    {
                        timeout = Params[1].GetValueInt();
                    }
                    int max = timeout / 250;
                    int cnt = 0;
                    while (!World.Player.HasGump && cnt++ < max)
                    {
                        Thread.Sleep(250);
                    }
                    if (!World.Player.HasGump)
                    {
                        World.Player?.SendMessage("Gump not found");
                    }
                }
                break;

                case "last":
                    if (World.Player?.HasGump == true)
                    {
                        World.Player?.LastGumpResponseAction?.Perform();
                    }
                    else
                    {
                        World.Player?.SendMessage("Gump not found");
                    }
                    break;

                case "button":
                    int button = Params[1].GetValueInt();
                    World.Player.LastGumpResponseAction = new GumpResponseAction(button, new int[] { }, new GumpTextEntry[] { });
                    if (World.Player?.HasGump == true)
                    {
                        World.Player?.LastGumpResponseAction?.Perform();
                    }
                    else
                    {
                        World.Player?.SendMessage("Gump not found");
                    }
                    break;
                }
            }
            break;

            case "contextmenu":
                uint   serial = Utility.EUO2StealthID(Params[0].GetValue().ToString());
                ushort index  = (ushort)Params[1].GetValueInt();
                ClientCommunication.SendToServer(new ContextMenuRequest(serial));
                ClientCommunication.SendToServer(new ContextMenuResponse(serial, index));
                break;
            }
            return(base.Execute());
        }