public void StartPatrolling() { Waypoint next = this.FindNextWaypoint(); // If a suitable waypoint is found if (next != null) { if (next.Running) { this.Run(); } else { this.Walk(); } this.followCoordinates = next.Position; Vector3 temp = this.Character.Coordinates().coordinate - next.Position; temp.y = 0; this.Character.Heading = (Quaternion)Quaternion.GenerateRotationFromDirectionVector(temp).Normalize(); LogUtil.Debug(DebugInfoDetail.Movement, "Direction: " + this.Character.Heading.ToString()); FollowTargetMessageHandler.Default.Send( this.Character, this.Character.Coordinates().coordinate, next.Position); this.StartMovement(); LogUtil.Debug(DebugInfoDetail.Movement, "Walking to: " + this.followCoordinates); } }
public void MoveTo(SmokeLounge.AOtomation.Messaging.GameData.Vector3 destination) { FollowTargetMessageHandler.Default.Send(this.Character, this.Character.RawCoordinates, destination); Vector3 dest = destination; Vector3 start = this.Character.RawCoordinates; dest = start - dest; dest = dest.Normalize(); this.Character.Heading = (Quaternion)Quaternion.GenerateRotationFromDirectionVector(dest); this.Run(); Coordinate c = new Coordinate(destination); this.followCoordinates = c.coordinate; /*bool arrived = false; * double lastDistance = double.MaxValue; * while (!arrived) * { * Coordinate temp = this.Character.Coordinates; * double distance = this.Character.Coordinates.Distance2D(c); * arrived = (distance < 0.2f) || (lastDistance < distance); * lastDistance = distance; * // LogUtil.Debug(DebugInfoDetail.Movement,"Moving..."); * Thread.Sleep(100); * } * LogUtil.Debug(DebugInfoDetail.Movement, "Arrived at "+this.Character.Coordinates.ToString()); * this.StopMovement();*/ }
public void DoFollow() { Coordinate sourceCoord = this.Character.Coordinates(); Vector3 targetPosition = this.followCoordinates; if (!this.followIdentity.Equals(Identity.None)) { ICharacter targetChar = Pool.Instance.GetObject <ICharacter>( this.Character.Playfield.Identity, this.followIdentity); if (targetChar == null) { // If target does not longer exist (death or zone or logoff) then stop following this.followIdentity = Identity.None; this.followCoordinates = new Vector3(); return; } targetPosition = targetChar.Coordinates().coordinate; } // Do we have coordinates to follow? if (targetPosition.Distance2D(new Vector3()) < 0.01f) { return; } // /!\ If target flies away, there has to be some kind of adjustment Vector3 start = sourceCoord.coordinate; Vector3 dest = targetPosition; // Check if we have arrived if (start.Distance2D(dest) < 0.3f) { this.StopMovement(); this.Character.RawCoordinates = dest; FollowTargetMessageHandler.Default.Send(this.Character, dest); this.followCoordinates = new Vector3(); return; } LogUtil.Debug(DebugInfoDetail.Movement, "Distance to target: " + start.Distance2D(dest).ToString()); // If target moved or first call, then issue a new follow if (targetPosition.Distance2D(this.followCoordinates) > 2.0f) { this.StopMovement(); this.Character.Coordinates(start); FollowTargetMessageHandler.Default.Send(this.Character, start); Vector3 temp = start - dest; temp.y = 0; this.Character.Heading = (Quaternion)Quaternion.GenerateRotationFromDirectionVector(temp); this.followCoordinates = dest; FollowTargetMessageHandler.Default.Send(this.Character, start, dest); this.StartMovement(); } }
public bool Follow(Identity target) { this.followIdentity = target; ICharacter npc = Pool.Instance.GetObject <ICharacter>(this.Character.Playfield.Identity, target); if (npc != null) { Vector3 temp = npc.Coordinates().coordinate - this.Character.Coordinates().coordinate; temp.y = 0; this.Character.Heading = (Quaternion)Quaternion.GenerateRotationFromDirectionVector(temp).Normalize(); FollowTargetMessageHandler.Default.Send( this.Character, this.Character.Coordinates().coordinate, npc.Coordinates().coordinate); this.Run(); this.StartMovement(); } return(true); }