Example #1
0
        private Vector3 GetBestCombatPosition()
        {
            if (Time.NormalTime < _fightStartTime + MovePredictTimeout && _fightTarget.IsPathing)
            {
                //Correct Y axis using a raycast because mob waypoints do not follow the terrain
                Vector3 rayOrigin = _fightTarget.PathingDestination;
                rayOrigin.Y += 5f;
                Vector3 rayTarget = rayOrigin;
                rayTarget.Y = 0;

                if (Playfield.Raycast(rayOrigin, rayTarget, out Vector3 hitPos, out _))
                {
                    return(hitPos);
                }

                return(_fightTarget.PathingDestination);
            }

            if (_fightTarget.IsInAttackRange() && _fightTarget.IsInLineOfSight)
            {
                return(DynelManager.LocalPlayer.Position);
            }

            return(_fightTarget.Position);
        }
Example #2
0
        public IState GetNextState()
        {
            if (!_target.IsValid ||
                !_target.IsAlive ||
                Time.NormalTime > _fightStartTime + FightTimeout ||
                !_target.IsInAttackRange())
            {
                return(new DefendSpiritState());
            }

            return(null);
        }
Example #3
0
        private void OnUpdate(object sender, float e)
        {
            // do nothing if the bot is not enabled
            if (!_enabled)
            {
                return;
            }

            // if returnToDefensePos is true try to run back to the spot we want to defend
            if (_returnToDefensePos && DynelManager.LocalPlayer.Position.DistanceFrom(_posToDefend) > _tetherDistance)
            {
                if (!MovementController.Instance.IsNavigating)
                {
                    Chat.WriteLine($"Returning to {_posToDefend}");
                    MovementController.Instance.SetPath(new Path(_posToDefend)
                    {
                        DestinationReachedDist = _tetherDistance
                    });
                }
            }

            SimpleChar target = GetNextTarget();

            if (target != null)
            {
                Debug.DrawSphere(target.Position, 1, DebuggingColor.LightBlue);
                Debug.DrawLine(DynelManager.LocalPlayer.Position, target.Position, DebuggingColor.LightBlue);

                if (DynelManager.LocalPlayer.FightingTarget == null ||
                    DynelManager.LocalPlayer.FightingTarget.Identity != target.Identity)
                {
                    if (!target.IsInAttackRange())
                    {
                        Inventory.Find(TauntToolHigh, out Item tauntTool);
                        if (!Item.HasPendingUse && !DynelManager.LocalPlayer.Cooldowns.ContainsKey(Stat.Psychology) && tauntTool != null)
                        {
                            target.Target();
                            tauntTool.Use(target);
                        }
                    }
                    else
                    {
                        if (!DynelManager.LocalPlayer.IsAttackPending)
                        {
                            DynelManager.LocalPlayer.Attack(target);
                        }
                    }
                }
            }
        }
Example #4
0
        private void OnUpdate(object sender, float e)
        {
            try
            {
                // Draw possible targets
                double currentTime = Time.NormalTime;
                if (currentTime > _nextEffect)
                {
                    _nextEffect = currentTime + _effectDelay;
                    foreach (SimpleChar potentialTarget in GetValidTargets())
                    {
                        IntPtr pEffectHandler = _EffectHandler_t.GetInstance();
                        if (pEffectHandler != IntPtr.Zero)
                        {
                            _EffectHandler_t.CreateEffect2(pEffectHandler, 43005, potentialTarget.Pointer, 0);
                        }
                    }
                }

                SimpleChar target = GetNextTarget();

                if (target != null)
                {
                    Debug.DrawSphere(target.Position, 1, DebuggingColor.LightBlue);
                    Debug.DrawLine(DynelManager.LocalPlayer.Position, target.Position, DebuggingColor.LightBlue);

                    if (target.IsInAttackRange())
                    {
                        if (DynelManager.LocalPlayer.FightingTarget == null ||
                            DynelManager.LocalPlayer.FightingTarget.Identity != target.Identity)
                        {
                            if (!DynelManager.LocalPlayer.IsAttackPending)
                            {
                                DynelManager.LocalPlayer.Attack(target);
                            }
                        }

                        if (!target.Buffs.Contains(268684) && !Item.HasPendingUse && target.HealthPercent >= 21 && target.GetStat(Stat.NPCFamily) == 229 && Inventory.Find(LaserCage, out Item cage))
                        {
                            target.Target();
                            cage.Use(target);
                        }
                    }
                    else
                    {
                        float distanceToTarget = target.Position.DistanceFrom(DynelManager.LocalPlayer.Position);

                        if (distanceToTarget >= LeashDistance)
                        {
                            // Run into leash range if movement is enabled
                            if (_menu.GetBool("EnableMovement") && !MovementController.Instance.IsNavigating)
                            {
                                MovementController.Instance.SetPath(new Path(target.Position)
                                {
                                    DestinationReachedDist = LeashDistance
                                });
                            }
                        }
                        else
                        {
                            // stop running if we are running
                            if (!(target.FightingTarget != null &&
                                  target.FightingTarget.Identity == DynelManager.LocalPlayer.Identity))
                            {
                                if (!DynelManager.LocalPlayer.Cooldowns.ContainsKey(Stat.Psychology))
                                {
                                    Pull(target);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Chat.WriteLine(ex.ToString());
            }
        }