Exemplo n.º 1
0
        /// <summary>
        /// Loads the keyboard currently defined in the settings.
        /// </summary>
        /// <returns>The list of fonts that are not present on this system and might be downloaded for this keyboard.
        /// </returns>
        private List <SerializableFont> LoadKeyboard()
        {
            if (GlobalSettings.CurrentDefinition == null)
            {
                HookManager.DisableKeyboardHook();
                HookManager.DisableMouseHook();

                return(new List <SerializableFont>());
            }
            // Enable the mouse hook only if there are mouse keys on the screen.
            if (GlobalSettings.CurrentDefinition.Elements.Any(x => !(x is KeyboardKeyDefinition)))
            {
                HookManager.EnableMouseHook();
            }
            else
            {
                HookManager.DisableMouseHook();
            }

            // Enable the keyboard hook only if there are keyboard keys on the screen.
            if (GlobalSettings.CurrentDefinition.Elements.Any(x => x is KeyboardKeyDefinition))
            {
                HookManager.EnableKeyboardHook();
            }
            else
            {
                HookManager.DisableKeyboardHook();
            }

            //Prompt to download any fonts we don't have yet.
            var missingFonts = this.CheckMissingFonts();

            GlobalSettings.Settings.InitUndoHistory();

            // Reset all edit mode related fields, as we should be no longer in edit mode.
            if (this.mnuToggleEditMode.Checked)
            {
                this.mnuToggleEditMode.Checked = false;
                this.mnuToggleEditMode_Click(null, null);
            }

            this.currentlyManipulating = null;
            this.highlightedDefinition = null;
            this.selectedDefinition    = null;

            this.ClientSize = new Size(GlobalSettings.CurrentDefinition.Width, GlobalSettings.CurrentDefinition.Height);

            this.ResetBackBrushes();

            return(missingFonts);
        }
Exemplo n.º 2
0
        public void AttachProcess()
        {
            Process[] processes = Process.GetProcessesByName("HuniePop 2 - Double Date");

            foreach (Process process in processes)
            {
                // Simply attach to the first one found.

                // If the process doesn't have a mainwindowhandle yet, skip it (we need to be able to get the hwnd to set foreground etc)
                if (process.MainWindowHandle == IntPtr.Zero)
                {
                    continue;
                }

                // Skip if the process is already hooked (and we want to hook multiple applications)
                if (HookManager.IsHooked(process.Id))
                {
                    continue;
                }

                Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect;

                CaptureConfig cc = new CaptureConfig()
                {
                    Direct3DVersion = direct3DVersion,
                    ShowOverlay     = true
                };

                processId = process.Id;
                _process  = process;

                var captureInterface = new CaptureInterface();
                captureInterface.RemoteMessage += new MessageReceivedEvent(CaptureInterface_RemoteMessage);
                _captureProcess = new CaptureProcess(process, cc, captureInterface);

                break;
            }
            Thread.Sleep(10);

            if (_captureProcess == null)
            {
                this.parent.launcHuniePop2Listener();
                hooked = false;
            }
            else
            {
                this.message.Foreground = new SolidColorBrush(Colors.DarkGreen);
                this.message.Text       = "Attached to game";
                hooked = true;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Prepares capturing in the target process. Note that the process must not already be hooked, and must have a <see cref="Process.MainWindowHandle"/>.
        /// </summary>
        /// <param name="process">The process to inject into</param>
        /// <exception cref="ProcessHasNoWindowHandleException">Thrown if the <paramref name="process"/> does not have a window handle. This could mean that the process does not have a UI, or that the process has not yet finished starting.</exception>
        /// <exception cref="ProcessAlreadyHookedException">Thrown if the <paramref name="process"/> is already hooked</exception>
        /// <exception cref="InjectionFailedException">Thrown if the injection failed - see the InnerException for more details.</exception>
        /// <remarks>The target process will have its main window brought to the foreground after successful injection.</remarks>
        public OverlayProcess(Process process, OverlayConfig config, OverlayInterface overlayInterface)
        {
            // If the process doesn't have a mainwindowhandle yet, skip it (we need to be able to get the hwnd to set foreground etc)
            if (process.MainWindowHandle == IntPtr.Zero)
            {
                throw new ProcessHasNoWindowHandleException();
            }

            // Skip if the process is already hooked (and we want to hook multiple applications)
            if (HookManager.IsHooked(process.Id))
            {
                throw new ProcessAlreadyHookedException();
            }

            _serverInterface = overlayInterface;
            //_serverInterface = new OverlayInterface() { ProcessId = process.Id };

            // Initialise the IPC server (with our instance of _serverInterface)
            RemoteHooking.IpcCreateServer(
                ref _channelName,
                WellKnownObjectMode.Singleton,
                _serverInterface);

            try
            {
                RemoteHooking.Inject(
                    process.Id,
                    InjectionOptions.Default,
                    typeof(OverlayInterface).Assembly.Location,
                    typeof(OverlayInterface).Assembly.Location,
                    _channelName,
                    config
                    );
            }
            catch (Exception e)
            {
                throw new InjectionFailedException(e);
            }

            HookManager.AddHookedProcess(process.Id);

            Process = process;

            // Ensure the target process is in the foreground,
            // this prevents an issue where the target app appears to be in
            // the foreground but does not receive any user inputs.
            // Note: the first Alt+Tab out of the target application after injection
            //       may still be an issue - switching between windowed and
            //       fullscreen fixes the issue however (see ScreenshotInjection.cs for another option)
            BringProcessWindowToFront();
        }
Exemplo n.º 4
0
        private bool SearchNewTarget(ref WowUnit target, bool grinding)
        {
            if ((target != null && !(target.IsDead || target.Health == 0)) || (HookManager.GetBuffs(WowLuaUnit.Player).Any(e => e.Contains("tealth")) && ObjectManager.Player.HealthPercentage <= 20))
            {
                return(false);
            }

            List <WowUnit> wowUnits       = ObjectManager.WowObjects.OfType <WowUnit>().Where(e => HookManager.GetUnitReaction(ObjectManager.Player, e) != WowUnitReaction.Friendly && HookManager.GetUnitReaction(ObjectManager.Player, e) != WowUnitReaction.Neutral).ToList();
            bool           newTargetFound = false;
            int            targetHealth   = (target == null || target.IsDead) ? 0 : target.Health;
            bool           inCombat       = target == null ? false : target.IsInCombat;
            int            targetCount    = 0;

            foreach (WowUnit unit in wowUnits)
            {
                if (BotUtils.IsValidUnit(unit) && unit != target && !unit.IsDead)
                {
                    double tmpDistance = ObjectManager.Player.Position.GetDistance(unit.Position);
                    if (tmpDistance < 100.0)
                    {
                        if (tmpDistance < 6.0)
                        {
                            targetCount++;
                        }

                        if ((unit.IsInCombat && unit.Health > targetHealth) || (!inCombat && grinding && unit.Health > targetHealth))
                        {
                            target         = unit;
                            targetHealth   = unit.Health;
                            newTargetFound = true;
                            inCombat       = unit.IsInCombat;
                        }
                    }
                }
            }

            if (target == null || target.IsDead)
            {
                HookManager.ClearTarget();
                newTargetFound = false;
                target         = null;
            }

            if (newTargetFound)
            {
                HookManager.TargetGuid(target.Guid);
                spells.ResetAfterTargetDeath();
            }

            return(newTargetFound);
        }
Exemplo n.º 5
0
        private bool SearchNewTarget(ref WowUnit?target, bool grinding)
        {
            if (target != null && !(target.IsDead || target.Health == 0))
            {
                return(false);
            }
            List <WowUnit> wowUnits       = ObjectManager.WowObjects.OfType <WowUnit>().Where(e => HookManager.GetUnitReaction(ObjectManager.Player, e) != WowUnitReaction.Friendly && HookManager.GetUnitReaction(ObjectManager.Player, e) != WowUnitReaction.Neutral).ToList();
            bool           newTargetFound = false;
            int            targetHealth   = (target == null || target.IsDead) ? 2147483647 : target.Health;
            bool           inCombat       = target == null ? false : target.IsInCombat;
            int            targetCount    = 0;

            multipleTargets = false;
            foreach (WowUnit unit in wowUnits)
            {
                if (BotUtils.IsValidUnit(unit) && unit != target && !unit.IsDead)
                {
                    double tmpDistance = ObjectManager.Player.Position.GetDistance2D(unit.Position);
                    if (tmpDistance < 100.0)
                    {
                        if (tmpDistance < 6.0)
                        {
                            targetCount++;
                        }
                        if ((unit.IsInCombat && unit.Health < targetHealth) || (!inCombat && grinding && unit.Health < targetHealth))
                        {
                            target         = unit;
                            targetHealth   = unit.Health;
                            newTargetFound = true;
                            inCombat       = unit.IsInCombat;
                        }
                    }
                }
            }
            if (target == null || target.IsDead)
            {
                HookManager.ClearTarget();
                newTargetFound = false;
                target         = null;
            }
            else if (targetCount > 1)
            {
                multipleTargets = true;
            }
            if (newTargetFound)
            {
                HookManager.TargetGuid(target.Guid);
                Spells.ResetAfterTargetDeath();
            }
            return(newTargetFound);
        }
        /// <summary>
        /// Handles HTTP post requests
        /// </summary>
        /// <returns></returns>
        public IActionResult OnPost()
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Antiforgery check failed.");
                }
                Init();

                if (ErpRequestContext.Page == null)
                {
                    return(NotFound());
                }

                var globalHookInstances = HookManager.GetHookedInstances <IPageHook>(HookKey);
                foreach (IPageHook inst in globalHookInstances)
                {
                    var result = inst.OnPost(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }

                foreach (IApplicationNodePageHook inst in HookManager.GetHookedInstances <IApplicationNodePageHook>(HookKey))
                {
                    var result = inst.OnPost(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }
                BeforeRender();
                return(Page());
            }
            catch (ValidationException valEx)
            {
                Validation.Message = valEx.Message;
                Validation.Errors.AddRange(valEx.Errors);
                BeforeRender();
                return(Page());
            }
            catch (Exception ex)
            {
                new Log().Create(LogType.Error, "ApplicationNodePageModel Error on POST", ex);
                Validation.Message = ex.Message;
                BeforeRender();
                return(Page());
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Attaches any of the OTAPI Npc hooks to the existing <see cref="HookManager"/> implementation
        /// </summary>
        /// <param name="hookManager">HookManager instance which will receive the events</param>
        public static void AttachTo(HookManager hookManager)
        {
            _hookManager = hookManager;

            Hooks.Npc.PreSetDefaultsById = OnPreSetDefaultsById;
            Hooks.Npc.PreNetDefaults     = OnPreNetDefaults;
            Hooks.Npc.Strike             = OnStrike;
            Hooks.Npc.PreTransform       = OnPreTransform;
            Hooks.Npc.Spawn       = OnSpawn;
            Hooks.Npc.PreDropLoot = OnPreDropLoot;
            Hooks.Npc.BossBagItem = OnBossBagItem;
            Hooks.Npc.PreAI       = OnPreAI;
            Hooks.Npc.Killed      = OnKilled;
        }
Exemplo n.º 8
0
        public override void Create()
        {
            base.Create();

            preUpdate = HookManager.CreateHooks <NpcBehaviour, Func <bool> >(Behaviours, "PreUpdate");
            onUpdate  = HookManager.CreateHooks <NpcBehaviour, Action>(Behaviours, "OnUpdate");
            preAI     = HookManager.CreateHooks <NpcBehaviour, Func <bool> >(Behaviours, "PreAI");
            onAI      = HookManager.CreateHooks <NpcBehaviour, Action>(Behaviours, "OnAI");

            preDraw = HookManager.CreateHooks <NpcBehaviour, Func <SpriteBatch, bool, bool> >(Behaviours, "PreDraw");
            onDraw  = HookManager.CreateHooks <NpcBehaviour, Action <SpriteBatch, bool> >(Behaviours, "OnDraw");

            findFrame = HookManager.CreateHooks <NpcBehaviour, Action>(Behaviours, "FindFrame");
        }
        private bool AttachHookToProcess()
        {
            if (this.attached)
            {
                return(true);
            }

            Process[] processes = Process.GetProcessesByName(HEARTHSTONE_PROCESS_NAME);

            if (processes.Length <= 0)
            {
                Log.Debug("GetProcessesByName failed.");
                return(false);
            }
            var process = processes[0];

            // Check incompatible modules:
            foreach (ProcessModule module in process.Modules)
            {
                if (module.ModuleName.ToLower().StartsWith("rtsshooks"))
                {
                    Publish(new IncompatibleHooksFound("RTSSHooks", "MSI Afterburner / Riva Tuner Statistics Server"));
                }
            }

            //if (process.MainWindowHandle == IntPtr.Zero)
            //{
            //    Log.Debug("Could not get MainWindowHandle.");
            //    return false;
            //}

            if (HookManager.IsHooked(process.Id))
            {
                return(true);
            }

            if (captureProcess != null)
            {
                Log.Warn("Call DettachHookFromProcess first");
                DettachHookFromProcess();
                extraDelay = 200;
                Thread.Sleep(200);
            }

            captureInterface = new CaptureInterface();
            captureInterface.RemoteMessage += this.CaptureInterfaceOnRemoteMessage;
            this.captureProcess             = new CaptureProcess(process, captureConfig, captureInterface);
            this.attached = true;
            return(true);
        }
Exemplo n.º 10
0
        private void 开启目录保护_Click(object sender, EventArgs e)
        {
            HookManager hookManager = App.GetHookManager();

            if (hookManager.Statue == false)
            {
                App.GetHookManager().EnableHook();
            }
            else
            {
                App.GetHookManager().DisableHook();
            }
            开启目录保护.Checked = hookManager.Statue;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Default private constructor.
 /// </summary>
 private App()
 {
     _blocks       = new AppBlockList();
     _fields       = new AppFieldList();
     _modules      = new AppModuleList();
     _mediaTypes   = new MediaManager();
     _serializers  = new SerializerManager();
     _contentTypes = new ContentTypeManager();
     _hooks        = new HookManager();
     _permissions  = new PermissionManager();
     _pageTypes    = new ContentTypeList <Models.PageType>();
     _postTypes    = new ContentTypeList <Models.PostType>();
     _siteTypes    = new ContentTypeList <Models.SiteType>();
 }
Exemplo n.º 12
0
            private void GlobalKeyUp(object sender, KeyEventArgs e)
            {
                // update form
                foreach (Control c in AddForm.Controls)
                {
                    c.Enabled = true;
                }
                AddForm.button6.Enabled = true;
                AddForm.DrawKeyDisplay();
                AddForm.TextBoxKeyCombo.Select(AddForm.TextBoxKeyCombo.Text.Length, 0);

                // remove hook
                HookManager.CleanHook();
            }
Exemplo n.º 13
0
            private void CastSpell(string spell, ref int rage, int rageCosts, double cooldown, bool gcd)
            {
                HookManager.CastSpell(spell);
                rage -= rageCosts;
                if (cooldown > 0)
                {
                    nextActionTime[spell] = DateTime.Now.AddSeconds(cooldown);
                }

                if (gcd)
                {
                    NextGCDSpell = DateTime.Now.AddSeconds(1.5);
                }
            }
Exemplo n.º 14
0
        /// <summary>
        /// Handles HTTP get requests
        /// </summary>
        /// <returns></returns>
        public IActionResult OnGet()
        {
            try
            {
                var initResult = Init();
                if (initResult != null)
                {
                    return(initResult);
                }
                if (ErpRequestContext.Page == null)
                {
                    return(NotFound());
                }

                string hookKey = string.Empty;
                if (PageContext.HttpContext.Request.Query.ContainsKey("hookKey"))
                {
                    hookKey = HttpContext.Request.Query["hookKey"].ToString();
                }

                var globalHookInstances = HookManager.GetHookedInstances <IPageHook>(hookKey);
                foreach (IPageHook inst in globalHookInstances)
                {
                    var result = inst.OnGet(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }


                foreach (IApplicationNodePageHook inst in HookManager.GetHookedInstances <IApplicationNodePageHook>(hookKey))
                {
                    var result = inst.OnGet(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }
                BeforeRender();
                return(Page());
            }
            catch (Exception ex)
            {
                new Log().Create(LogType.Error, "ApplicationNodePageModel Error on GET", ex);
                Validation.Message = ex.Message;
                BeforeRender();
                return(Page());
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Attaches any of the OTAPI Net hooks to the existing <see cref="HookManager"/> implementation
        /// </summary>
        /// <param name="hookManager">HookManager instance which will receive the events</param>
        public static void AttachTo(HookManager hookManager)
        {
            _hookManager = hookManager;

            Hooks.Net.SendData                   = OnSendData;
            Hooks.Net.ReceiveBytes               = OnReceiveBytes;
            Hooks.Net.SendNetData                = OnSendNetData;
            Hooks.Net.ReceiveData                = OnReceiveData;
            Hooks.Player.PreGreet                = OnPreGreet;
            Hooks.Net.SendBytes                  = OnSendBytes;
            Hooks.Net.Socket.Accepted            = OnAccepted;
            Hooks.Net.BeforeBroadcastChatMessage = OnBroadcastChatMessage;
            Hooks.Player.NameCollision           = OnNameCollision;
        }
Exemplo n.º 16
0
        public override void Create()
        {
            base.Create();

            preUpdate = HookManager.CreateHooks <ProjectileBehaviour, Func <bool> >(Behaviours, "PreUpdate");
            onUpdate  = HookManager.CreateHooks <ProjectileBehaviour, Action>(Behaviours, "OnUpdate");
            preAI     = HookManager.CreateHooks <ProjectileBehaviour, Func <bool> >(Behaviours, "PreAI");
            onAI      = HookManager.CreateHooks <ProjectileBehaviour, Action>(Behaviours, "OnAI");

            preDraw = HookManager.CreateHooks <ProjectileBehaviour, Func <SpriteBatch, bool> >(Behaviours, "PreDraw");
            onDraw  = HookManager.CreateHooks <ProjectileBehaviour, Action <SpriteBatch> >(Behaviours, "OnDraw");

            colliding = HookManager.CreateHooks <ProjectileBehaviour, Func <Rectangle, Rectangle, bool> >(Behaviours, "IsColliding");
        }
        public IActionResult OnGet()
        {
            try
            {
                var initResult = Init();
                if (initResult != null)
                {
                    return(initResult);
                }

                if (ErpRequestContext.Page == null)
                {
                    return(NotFound());
                }
                if (PageName != ErpRequestContext.Page.Name)
                {
                    var queryString = HttpContext.Request.QueryString.ToString();
                    return(Redirect($"/{ErpRequestContext.App.Name}/{ErpRequestContext.SitemapArea.Name}/{ErpRequestContext.SitemapNode.Name}/r/{ErpRequestContext.ParentRecordId}/rl/{ErpRequestContext.RelationId}/l/{ErpRequestContext.Page.Name}{queryString}"));
                }

                var globalHookInstances = HookManager.GetHookedInstances <IPageHook>(HookKey);
                foreach (IPageHook inst in globalHookInstances)
                {
                    var result = inst.OnGet(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }

                var hookInstances = HookManager.GetHookedInstances <IRecordRelatedRecordsListPageHook>(HookKey);
                foreach (IRecordRelatedRecordsListPageHook inst in hookInstances)
                {
                    var result = inst.OnGet(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }
                BeforeRender();
                return(Page());
            }
            catch (Exception ex)
            {
                new Log().Create(LogType.Error, "RecordRelatedRecordsListPageModel Error on GET", ex);
                Validation.Message = ex.Message;
                BeforeRender();
                return(Page());
            }
        }
        /// <summary>
        /// Loads the form, setting the controls to the initial style.
        /// </summary>
        private void DirectInputButtonPropertiesForm_Load(object sender, EventArgs e)
        {
            this.txtText.Text      = this.initialDefinition.Text;
            this.txtShiftText.Text = this.initialDefinition.ShiftText;
            this.txtTextPosition.X = this.initialDefinition.TextPosition.X;
            this.txtTextPosition.Y = this.initialDefinition.TextPosition.Y;
            this.lstBoundaries.Items.AddRange(this.initialDefinition.Boundaries.Cast <object>().ToArray());
            this.chkChangeOnCaps.Checked = this.initialDefinition.ChangeOnCaps;
            this.txtDeviceId.Text        = this.initialDefinition.DeviceId.ToString();

            // Retrieves all of the currently available joysticks and lists them here
            this.devices = HookManager.GetCurrentlyActiveJoysticks();
            var data = new List <JoystickComboBoxItem>();

            data.Add(new JoystickComboBoxItem(Guid.Empty.ToString(), "No Device Selected"));

            foreach (var device in this.devices)
            {
                data.Add(new JoystickComboBoxItem(device.Information.ProductGuid.ToString(), device.Information.ProductName));
            }

            // Sets the Joystick Combobox DataSource
            this.comboBoxDevicesList.ValueMember   = "ID";
            this.comboBoxDevicesList.DisplayMember = "Text";
            this.comboBoxDevicesList.DataSource    = data;

            // If one of the currently available joysticks matches the ID of the currentDefinition, we take it as the currently selected one
            foreach (var joystick in this.devices)
            {
                if (joystick.Information.ProductGuid == this.currentDefinition.DeviceId)
                {
                    this.selectedJoystick = joystick;
                    this.comboBoxDevicesList.SelectedValue = joystick.Information.ProductGuid.ToString();
                    break;
                }
            }

            // Refreshes the Buttons dropdown
            RefreshFormOnJoystickChange();

            // Only add the event handlers after the initial properties have been set.
            this.lstBoundaries.SelectedIndexChanged += this.lstBoundaries_SelectedIndexChanged;
            this.txtText.TextChanged                      += this.txtText_TextChanged;
            this.txtTextPosition.ValueChanged             += this.txtTextPosition_ValueChanged;
            this.txtShiftText.TextChanged                 += this.txtShiftText_TextChanged;
            this.chkChangeOnCaps.CheckedChanged           += this.chkChangeOnCaps_CheckedChanged;
            this.txtDeviceId.TextChanged                  += this.txtDeviceId_TextChanged;
            this.cmbButtonNumber.SelectedIndexChanged     += this.cmbButtonNumber_SelectedIndexChanged;
            this.comboBoxDevicesList.SelectedIndexChanged += this.comboBoxDevicesList_SelectedIndexChanged;
        }
Exemplo n.º 19
0
        private void AttachProcess()
        {
            string exeName = "Bejeweled3";

            Process[] processes = Process.GetProcessesByName(exeName);
            foreach (Process process in processes)
            {
                // Simply attach to the first one found.

                // If the process doesn't have a mainwindowhandle yet, skip it (we need to be able to get the hwnd to set foreground etc)
                if (process.MainWindowHandle == IntPtr.Zero)
                {
                    continue;
                }

                // Skip if the process is already hooked (and we want to hook multiple applications)
                if (HookManager.IsHooked(process.Id))
                {
                    continue;
                }

                Direct3DVersion direct3DVersion = Direct3DVersion.AutoDetect;

                CaptureConfig cc = new CaptureConfig()
                {
                    Direct3DVersion = direct3DVersion,
                    ShowOverlay     = cbDrawOverlay.Checked
                };

                capturing.ProcessId = process.Id;
                capturing.Process   = process;

                var captureInterface = new CaptureInterface();
                captureInterface.RemoteMessage += new MessageReceivedEvent(CaptureInterface_RemoteMessage);
                capturing.CaptureProcess        = new CaptureProcess(process, cc, captureInterface);

                break;
            }
            Thread.Sleep(10);

            if (capturing.CaptureProcess == null)
            {
                MessageBox.Show("No executable found matching: '" + exeName + "'");
            }
            else
            {
                btnLoadTest.Enabled = true;
                btnCapture.Enabled  = true;
            }
        }
Exemplo n.º 20
0
        public void OutOfCombatExecute()
        {
            if (!LastPlayerPosition.Equals(ObjectManager.Player.Position))
            {
                distanceTraveled   = ObjectManager.Player.Position.GetDistance(LastPlayerPosition);
                LastPlayerPosition = new Vector3(ObjectManager.Player.Position.X, ObjectManager.Player.Position.Y, ObjectManager.Player.Position.Z);
            }

            if (distanceTraveled < 0.001)
            {
                ulong   leaderGuid = ObjectManager.PartyleaderGuid;
                WowUnit target     = null;
                if (leaderGuid == ObjectManager.PlayerGuid && SearchNewTarget(ref target, true))
                {
                    if (!LastTargetPosition.Equals(target.Position))
                    {
                        hasTargetMoved     = true;
                        LastTargetPosition = new Vector3(target.Position.X, target.Position.Y, target.Position.Z);
                        distanceToTarget   = LastPlayerPosition.GetDistance(LastTargetPosition);
                    }
                    else
                    {
                        computeNewRoute = true;
                        hasTargetMoved  = false;
                    }

                    Dancing = false;
                    HandleMovement(target);
                    HandleAttacking(target);
                }
                else if (!Dancing || standing)
                {
                    standing = false;
                    HookManager.ClearTarget();
                    HookManager.SendChatMessage(standingEmotes[new Random().Next(standingEmotes.Length)]);
                    Dancing = true;
                }
            }
            else
            {
                if (!Dancing || !standing)
                {
                    standing = true;
                    HookManager.ClearTarget();
                    HookManager.SendChatMessage(runningEmotes[new Random().Next(runningEmotes.Length)]);
                    Dancing = true;
                }
            }
        }
        public IActionResult OnPost()
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Antiforgery check failed.");
                }
                Init();
                if (ErpRequestContext.Page == null)
                {
                    return(NotFound());
                }
                if (!RecordsExists())
                {
                    return(NotFound());
                }

                var globalHookInstances = HookManager.GetHookedInstances <IPageHook>(HookKey);
                foreach (IPageHook inst in globalHookInstances)
                {
                    var result = inst.OnPost(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }

                var hookInstances = HookManager.GetHookedInstances <IRecordRelatedRecordDetailsPageHook>(HookKey);
                foreach (IRecordRelatedRecordDetailsPageHook inst in hookInstances)
                {
                    var result = inst.OnPost(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }

                BeforeRender();
                return(Page());
            }
            catch (Exception ex)
            {
                new Log().Create(LogType.Error, "RecordRelatedRecordDetailsPageModel Error on POST", ex);
                Validation.Message = ex.Message;
                BeforeRender();
                return(Page());
            }
        }
Exemplo n.º 22
0
        private bool HandleCounterspell()
        {
            (string, int)castinInfo = HookManager.GetUnitCastingInfo(WowLuaUnit.Target);

            bool isCasting = castinInfo.Item1.Length > 0 && castinInfo.Item2 > 0;

            if (isCasting &&
                CastSpellIfPossible(counterspellSpell, true))
            {
                return(true);
            }

            LastEnemyCastingCheck = DateTime.Now;
            return(false);
        }
Exemplo n.º 23
0
        private bool HandleDebuffing()
        {
            List <string> targetDebuffs = HookManager.GetDebuffs(WowLuaUnit.Target);

            if ((!targetDebuffs.Any(e => e.Equals(huntersMarkSpell, StringComparison.OrdinalIgnoreCase)) &&
                 CastSpellIfPossible(huntersMarkSpell, true)) ||
                (!targetDebuffs.Any(e => e.Equals(serpentStingSpell, StringComparison.OrdinalIgnoreCase)) &&
                 CastSpellIfPossible(serpentStingSpell, true)))
            {
                return(true);
            }

            LastDebuffCheck = DateTime.Now;
            return(false);
        }
Exemplo n.º 24
0
 public void OnDisabled()
 {
     IsEnabled = false;
     TabUi.RemoveTab();
     HookManager.ReplaceTreeHooks();
     Navigator.PlayerMover               = new DefaultPlayerMover();
     Navigator.StuckHandler              = new DefaultStuckHandler();
     CombatTargeting.Instance.Provider   = new DefaultCombatTargetingProvider();
     LootTargeting.Instance.Provider     = new DefaultLootTargetingProvider();
     ObstacleTargeting.Instance.Provider = new DefaultObstacleTargetingProvider();
     ItemManager.Current             = new BlankItemManager();
     Zeta.Bot.RoutineManager.Current = null;
     ModuleManager.Disable();
     Core.Logger.Log($"is now DISABLED!");
 }
Exemplo n.º 25
0
        private bool HandleBuffs()
        {
            List <string> myBuffs = HookManager.GetBuffs(WowLuaUnit.Player);

            if ((!myBuffs.Any(e => e.Equals(sliceAndDiceSpell, StringComparison.OrdinalIgnoreCase)) &&
                 CastSpellIfPossible(sliceAndDiceSpell, false, true, 1)) ||
                (!myBuffs.Any(e => e.Equals(coldBloodSpell, StringComparison.OrdinalIgnoreCase)) &&
                 CastSpellIfPossible(coldBloodSpell)))
            {
                return(true);
            }

            LastBuffCheck = DateTime.Now;
            return(false);
        }
Exemplo n.º 26
0
 private void disableAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (disableAllToolStripMenuItem.Text == "Disable All")
     {
         GlobalDisable = true;
         HookManager.CleanHook();
         disableAllToolStripMenuItem.Text = "Enable All";
     }
     else
     {
         GlobalDisable = false;
         AddListeners();
         disableAllToolStripMenuItem.Text = "Disable All";
     }
 }
Exemplo n.º 27
0
 public override void Execute()
 {
     if (ObjectManager.Player.IsDead)
     {
         HookManager.ReleaseSpirit();
     }
     else if (HookManager.IsGhost("player"))
     {
         AmeisenBotStateMachine.SetState(AmeisenBotState.Ghost);
     }
     else
     {
         AmeisenBotStateMachine.SetState(AmeisenBotState.Idle);
     }
 }
Exemplo n.º 28
0
        /// <summary>
        /// Handles the setting of a new trap hotkey, if we are capturing, the pressed key is stored and the capturing
        /// state is removed.
        /// </summary>
        private void txtToggleKey_KeyUp(object sender, KeyEventArgs e)
        {
            if (!this.capturingKey)
            {
                return;
            }

            this.txtToggleKey.Text = e.KeyCode.ToString();
            this.trapToggleKey     = (int)e.KeyCode;

            e.SuppressKeyPress = true;
            this.capturingKey  = false;
            HookManager.EnableMouseHook();
            HookManager.EnableKeyboardHook();
        }
Exemplo n.º 29
0
        public IActionResult OnGet()
        {
            try
            {
                Debug.WriteLine("<><><><> ERP Index Start");
                var initResult = Init();
                Debug.WriteLine("<><><><> ERP Index Inited");
                if (initResult != null)
                {
                    Debug.WriteLine("<><><><> ERP Index Inited With Result NULL - NOT FOUND");
                    return(initResult);
                }

                if (ErpRequestContext.Page == null)
                {
                    return(NotFound());
                }

                var globalHookInstances = HookManager.GetHookedInstances <IPageHook>(HookKey);
                foreach (IPageHook inst in globalHookInstances)
                {
                    var result = inst.OnGet(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }

                var hookInstances = HookManager.GetHookedInstances <IHomePageHook>(HookKey);
                foreach (IHomePageHook inst in hookInstances)
                {
                    var result = inst.OnGet(this);
                    if (result != null)
                    {
                        return(result);
                    }
                }

                BeforeRender();
                return(Page());
            }
            catch (Exception ex)
            {
                new Log().Create(LogType.Error, "HomePageModel Error on GET", ex);
                BeforeRender();
                return(Page());
            }
        }
Exemplo n.º 30
0
        public void Execute()
        {
            // we dont want to do anything if we are casting something...
            if (ObjectManager.Player.CurrentlyCastingSpellId > 0 ||
                ObjectManager.Player.CurrentlyChannelingSpellId > 0)
            {
                return;
            }

            if (!ObjectManager.Player.IsAutoAttacking)
            {
                HookManager.StartAutoAttack();
            }

            if ((DateTime.Now - LastBuffCheck > TimeSpan.FromSeconds(buffCheckTime) &&
                 HandleBuffing()) ||
                (DateTime.Now - LastJudgementCheck > TimeSpan.FromSeconds(judgementCheckTime) &&
                 HandleJudgement()) ||
                (DateTime.Now - LastEnemyCastingCheck > TimeSpan.FromSeconds(enemyCastingCheckTime) &&
                 HandleHammerOfJustice()) ||
                (ObjectManager.Player.HealthPercentage < 20 &&
                 CastSpellIfPossible(layOnHandsSpell)) ||
                (ObjectManager.Player.HealthPercentage < 60 &&
                 CastSpellIfPossible(holyLightSpell, true)) ||
                CastSpellIfPossible(avengingWrathSpell, true) ||
                (ObjectManager.Player.ManaPercentage < 80 &&
                 CastSpellIfPossible(divinePleaSpell, true)))
            {
                return;
            }

            WowUnit target = ObjectManager.WowObjects.OfType <WowUnit>().FirstOrDefault(e => e.Guid == ObjectManager.TargetGuid);

            if (target != null)
            {
                if ((ObjectManager.Player.HealthPercentage < 20 &&
                     CastSpellIfPossible(hammerOfWrathSpell, true)) ||
                    CastSpellIfPossible(crusaderStrikeSpell, true) ||
                    CastSpellIfPossible(divineStormSpell, true) ||
                    CastSpellIfPossible(divineStormSpell, true) ||
                    CastSpellIfPossible(consecrationSpell, true) ||
                    CastSpellIfPossible(exorcismSpell, true) ||
                    CastSpellIfPossible(holyWrathSpell, true))
                {
                    return;
                }
            }
        }