public override void OnStart() { if (PathPrecision == 0) { PathPrecision = 15; } if (PathPointLimit == 0) { PathPointLimit = 250; } if (Timeout == 0) { Timeout = 180; } _lastGeneratedNavPoint = DateTime.MinValue; _lastMoveResult = MoveResult.Moved; _tagStartTime = DateTime.UtcNow; PositionCache.Cache.Clear(); Navigator.Clear(); if (SetPositionOnStart != null) { Position = SetPositionOnStart.Invoke(null); } Logger.Log("Initialized {0}", Status()); }
public override void Update(GameTime gameTime) { _animatedSprite.Update(gameTime); UpdatePosition(); if (_activated) { // Update eye orbit rotation according to Player's position var playerPosition = _playerPositionDelegate.Invoke(); Rotation = (float)Math.Atan2(_parent.Position.Y - playerPosition.Y, _parent.Position.X - playerPosition.X) - MathHelper.PiOver2; // Bullet pattern if (_moverManager.movers.Count == 0) { FirePattern(); } } base.Update(gameTime); }
public static Composite MoveTo(PositionDelegate positionDelegate, XyzPositionDelegate xyzPositionDelegate = null, MovementSpec spec = null) { return(new Sequence( new Action(delegate(object context) { var position = positionDelegate(context); if (position == null) { WillBot.LogMessageCombo($"Unable to set path to null position"); return RunStatus.Failure; } bool didSetPath = WillBot.Mover.SetPath((Vector2)position); if (didSetPath == false) { WillBot.LogMessageCombo($"Unable to set path to {position}"); return RunStatus.Failure; } else { WillBot.LogMessageCombo($"Successfully found path to {position}"); ControlTimer.Restart(); return RunStatus.Success; } }), new Action(delegate(object context) { bool isZDifferenceOk = true; var entityPos = xyzPositionDelegate?.Invoke(context); var entityGridPos = positionDelegate?.Invoke(context); if (entityPos != null) { isZDifferenceOk = Math.Abs(GameController.Player.Pos.Z - entityPos.GetValueOrDefault().Z) < WillBot.Settings.MovementCancelingForLootZThreshold; } // if zdifferencenotOk, but the path is relatively straight to the object and close -> use movement skill WillBot.LogMessageCombo($"Remaining path distance squared : {WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget}"); var airDistanceSquared = entityGridPos.GetValueOrDefault().DistanceSquared(WillBot.gameController.Player.GridPos); if (isZDifferenceOk == false && (WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < 1300) && WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < 1.07 * airDistanceSquared) { WillBot.LogMessageCombo($"Using movement skill to most likely jump a cliff which incorrectly is set to walkable"); InputWrapper.ResetMouseButtons(); var screenPos = Camera.WorldToScreen((Vector3)entityPos); Mouse.SetCursorPosAndLeftOrRightClick(screenPos, 10, clickType: Mouse.MyMouseClicks.NoClick); InputWrapper.KeyPress(Keys.E); //MoverHelper.ClickToStopCharacter(); return RunStatus.Failure; } switch (spec.cancelReason) { case CancelReason.None: break; case CancelReason.PathDistanceLessThanRange: if ((WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < (spec.cancelRangeSquared)) && isZDifferenceOk) { WillBot.LogMessageCombo($"Canceled movement in range to object {spec.cancelRange}"); InputWrapper.ResetMouseButtons(); //MoverHelper.ClickToStopCharacter(); return RunStatus.Failure; } break; case CancelReason.PathDistanceLessThanRangeIfStraightPath: /* Cancel pathfinding if path distance to object is less than X and distance to object and path distance are roughly equal * use 1: Looting, avoid having to pathfind really close to loot before clicking the label. */ //var airDistanceSquared = entityGridPos.GetValueOrDefault().DistanceSquared(WillBot.gameController.Player.GridPos); if ((WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < spec.cancelRangeSquared) && WillBot.Mover.pathFindingWrapper.RemainingPathDistanceSquaredToTarget < 1.07 * airDistanceSquared) { WillBot.LogMessageCombo($"Canceled movement in range to object with straight line {spec.cancelRange}"); InputWrapper.ResetMouseButtons(); //MoverHelper.ClickToStopCharacter(); return RunStatus.Failure; } break; } if (spec.cancelForMonster && DoCombat()) { WillBot.LogMessageCombo($"Canceled movement to do combat"); InputWrapper.ResetMouseButtons(); return RunStatus.Failure; } if (spec.cancelForLoot && DoLooting()) { WillBot.LogMessageCombo($"Canceled movement to do looting"); InputWrapper.ResetMouseButtons(); return RunStatus.Failure; } if (spec.cancelForOpenables && (WillBot.Me.StrongBox != null || WillBot.Me.HarvestChest != null || WillBot.Me.EssenceMonsterMonolith != null)) { InputWrapper.ResetMouseButtons(); WillBot.LogMessageCombo($"Canceled movement to do openables"); return RunStatus.Failure; } if (ControlTimer.ElapsedMilliseconds > 3500 && StuckTracker.GetDistanceMoved() < 40) { InputWrapper.ResetMouseButtons(); WillBot.LogMessageCombo($"Canceled movement due to being stuck!. Using movement ability"); InputWrapper.KeyPress(WillBot.Settings.MovementAbilityKey); return RunStatus.Failure; } // If movement last x duration less than .. return return WillBot.Mover.FollowPath(); }) )); }
public override void OnPointerUp(PointerEventData eventData) { onUp?.Invoke(gameObject, eventData.position); }