public static void Initialize()
    {
        Main.Log("Initialized");
        _petPulseThread.DoWork += PetThread;
        _petPulseThread.RunWorkerAsync();
        ZEBMHunterSettings.Load();
        _settings = ZEBMHunterSettings.CurrentSetting;
        Talents.InitTalents(_settings.AssignTalents, _settings.UseDefaultTalents, _settings.TalentCodes);

        // Set Steady Shot delay
        if (_settings.RangedWeaponSpeed > 2000)
        {
            _steadyShotSleep = _settings.RangedWeaponSpeed - 1600;
        }
        else
        {
            _steadyShotSleep = 500;
        }
        Main.LogDebug("Steady Shot delay set to : " + _steadyShotSleep.ToString() + "ms");

        FightEvents.OnFightStart += (WoWUnit unit, CancelEventArgs cancelable) =>
        {
            if (ObjectManager.Target.GetDistance >= 13f && !AutoShot.IsSpellUsable && !_isBackingUp)
            {
                _canOnlyMelee = true;
            }
            else
            {
                _canOnlyMelee = false;
            }
        };

        FightEvents.OnFightEnd += (ulong guid) =>
        {
            _isBackingUp       = false;
            _backupAttempts    = 0;
            _autoshotRepeating = false;
            _canOnlyMelee      = false;
        };

        FightEvents.OnFightLoop += (WoWUnit unit, CancelEventArgs cancelable) =>
        {
            // Do we need to backup?
            if (ObjectManager.Target.GetDistance < 10f && ObjectManager.Target.IsTargetingMyPet &&
                !MovementManager.InMovement &&
                Me.IsAlive &&
                ObjectManager.Target.IsAlive &&
                !ObjectManager.Pet.HaveBuff("Pacifying Dust") && !_canOnlyMelee &&
                !ObjectManager.Pet.IsStunned && !_isBackingUp &&
                !Me.IsCast && _settings.BackupFromMelee)
            {
                // Stop trying if we reached the max amount of attempts
                if (_backupAttempts >= _settings.MaxBackupAttempts)
                {
                    Main.Log($"Backup failed after {_backupAttempts} attempts. Going in melee");
                    _canOnlyMelee = true;
                    return;
                }

                _isBackingUp = true;

                // Using CTM
                if (_settings.BackupUsingCTM)
                {
                    Vector3 position = ToolBox.BackofVector3(Me.Position, Me, 12f);
                    MovementManager.Go(PathFinder.FindPath(position), false);
                    Thread.Sleep(500);

                    // Backup loop
                    int limiter = 0;
                    while (MovementManager.InMoveTo &&
                           Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause &&
                           ObjectManager.Me.IsAlive &&
                           ObjectManager.Target.GetDistance < 10f &&
                           limiter < 10)
                    {
                        // Wait follow path
                        Thread.Sleep(300);
                        limiter++;
                    }
                }
                // Using Keyboard
                else
                {
                    int limiter = 0;
                    while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause &&
                           ObjectManager.Me.IsAlive &&
                           ObjectManager.Target.GetDistance < 10f &&
                           limiter <= 6)
                    {
                        Move.Backward(Move.MoveAction.PressKey, 500);
                        limiter++;
                    }
                }

                _backupAttempts++;
                Main.Log($"Backup attempt : {_backupAttempts}");
                _isBackingUp = false;

                if (RaptorStrikeOn())
                {
                    Cast(RaptorStrike);
                }
                ReenableAutoshot();
            }
        };

        Rotation();
    }
 public static void ShowConfiguration()
 {
     ZEBMHunterSettings.Load();
     ZEBMHunterSettings.CurrentSetting.ToForm();
     ZEBMHunterSettings.CurrentSetting.Save();
 }
Ejemplo n.º 3
0
    public static void Initialize()
    {
        Main.Log("Initialized");
        _petPulseThread.DoWork += PetThread;
        _petPulseThread.RunWorkerAsync();
        ZEBMHunterSettings.Load();
        _settings = ZEBMHunterSettings.CurrentSetting;
        Talents.InitTalents(_settings.AssignTalents, _settings.UseDefaultTalents, _settings.TalentCodes);

        // Set Steady Shot delay
        if (_settings.RangedWeaponSpeed > 2000)
        {
            _steadyShotSleep = _settings.RangedWeaponSpeed - 1600;
        }
        else
        {
            _steadyShotSleep = 500;
        }
        Main.LogDebug("Steady Shot delay set to : " + _steadyShotSleep.ToString() + "ms");

        FightEvents.OnFightStart += (WoWUnit unit, CancelEventArgs cancelable) =>
        {
            if (ObjectManager.Target.GetDistance >= 13f && !AutoShot.IsSpellUsable && !_isBackingUp)
            {
                _canOnlyMelee = true;
            }
            else
            {
                _canOnlyMelee = false;
            }
        };

        FightEvents.OnFightEnd += (ulong guid) =>
        {
            _isBackingUp       = false;
            _backupAttempts    = 0;
            _autoshotRepeating = false;
            _canOnlyMelee      = false;
        };

        Radar3D.OnDrawEvent += () =>
        {
            if (ObjectManager.Me.TargetObject != null)
            {
                Radar3D.DrawCircle(ToolBox.BackofVector3(Me.Position, Me, 20f), 1f, Color.Cyan);
            }
        };

        FightEvents.OnFightLoop += (WoWUnit unit, CancelEventArgs cancelable) =>
        {
            if (ObjectManager.Target.GetDistance < 13f && ObjectManager.Target.IsTargetingMyPet && _backupAttempts < _settings.MaxBackupAttempts &&
                !MovementManager.InMovement && Me.IsAlive && !ObjectManager.Pet.HaveBuff("Pacifying Dust") && !_canOnlyMelee &&
                !ObjectManager.Pet.IsStunned && !_isBackingUp && !Me.IsCast && _settings.BackupFromMelee)
            {
                _isBackingUp = true;
                var pos = 1;
                if (ObjectManager.Me.IsAlive && ObjectManager.Target.IsAlive && pos == 1)
                {
                    Vector3 position = ToolBox.BackofVector3(Me.Position, Me, 20f);
                    MovementManager.Go(PathFinder.FindPath(position), false);

                    while (MovementManager.InMovement && Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause &&
                           ObjectManager.Target.GetDistance < 13f && _backupAttempts < _settings.MaxBackupAttempts && !_canOnlyMelee)
                    {
                        // Wait follow path
                        Thread.Sleep(2000);
                        pos = 0;
                        _backupAttempts++;
                    }
                }
                ReenableAutoshot();
                Main.LogDebug("Backup attempt : " + _backupAttempts);
                _isBackingUp = false;
                if (_backupAttempts >= _settings.MaxBackupAttempts)
                {
                    _canOnlyMelee = true;
                }
            }
        };

        Rotation();
    }