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); } } } } }
private void Pull(SimpleChar target) { if (Item.HasPendingUse) { return; } if (Inventory.Find(TauntToolLow, TauntToolHigh, out Item tauntTool)) { target.Target(); tauntTool.Use(target); } else { Chat.WriteLine("No taunt tool found in inventory"); } }
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()); } }