1package com.runehive.game.world.entity.mob.movement.waypoint;
3import com.runehive.game.task.Task;
4import com.runehive.game.world.Interactable;
5import com.runehive.game.world.World;
6import com.runehive.game.world.entity.mob.Mob;
7import com.runehive.game.world.entity.mob.data.PacketType;
8import com.runehive.game.world.entity.mob.npc.Npc;
9import com.runehive.game.world.entity.mob.player.Player;
10import com.runehive.game.world.object.GameObject;
11import com.runehive.game.world.object.GameObjectDefinition;
12import com.runehive.game.world.pathfinding.TraversalMap;
13import com.runehive.game.world.position.Position;
14import com.runehive.game.world.region.Region;
15import com.runehive.net.packet.out.SendMessage;
16import com.runehive.util.Utility;
18import java.util.Objects;
47 int rotation =
object.getDirection().getId();
48 if (rotation % 2 != 0) {
53 walkingFlag = (walkingFlag << rotation & 0xF) + (walkingFlag >> 4 - rotation);
55 if (sizeX != 0 && sizeY != 0) {
57 int destX = targetPosition.
getX();
58 int destY = targetPosition.
getY();
63 int cornerX = destX + sizeX - 1;
64 int cornerY = destY + sizeY - 1;
66 if (destX <= x && cornerX >= x && y >= destY && y <= cornerY) {
69 if (x == destX - 1 && destY <= y && y <= cornerY && (0x8 & flag) == 0 && (0x8 & walkingFlag) == 0) {
72 if (x == cornerX + 1 && destY <= y && cornerY >= y && (flag & 0x80) == 0 && (0x2 & walkingFlag) == 0) {
75 if (y == destY - 1 && destX <= x && cornerX >= x && (0x2 & flag) == 0 && (0x4 & walkingFlag) == 0) {
78 if (y == cornerY + 1 && destX <= x && cornerX >= x && (flag & 0x20) == 0 && (0x1 & walkingFlag) == 0) {
105 && !
mob.movement.needsPlacement()) {
114 mob.setFixingInside(
false);
123 if (gameObject.distance() > 1 &&
withinDistance(
mob.getPosition().getX(),
mob.getPosition().getY(),
target.getPosition().getX(),
target.getPosition().getY(),
target.width(), gameObject.length(), gameObject.distance())) {
164 if (smart &&
mob.movement.dijkstraPath(
target)) {
184 other.attributes.remove(
"mob-following");
190 if (obj ==
this)
return true;
191 if (obj instanceof
Waypoint other) {
192 return Objects.equals(
mob, other.mob)
193 && Objects.equals(
target, other.target);
200 return getClass().getSimpleName() +
"{" +
214 boolean withinDistance(
int x,
int y,
int x2,
int y2,
int width,
int height,
int distance) {
216 x2 += Math.min(width, x - x2) - 1;
219 y2 += Math.min(height, y - y2) - 1;
221 return Math.abs(x - x2) <= distance && Math.abs(y - y2) <= distance;
synchronized final void cancel()
Cancels all subsequent executions.
Task(boolean instant, int delay)
Creates a new Task.
Represents the game world.
static void schedule(Task task)
Submits a new event.
void interact(Mob mob)
Sets the mob interacting with another mob.
void move(Position position)
Moves the mob to a set position.
boolean hasPriorityIndex(Mob other)
boolean withinDistance(int x, int y, int x2, int y2, int width, int height, int distance)
Waypoint(Mob mob, Interactable target)
abstract void onDestination()
boolean equals(Object obj)
void onSchedule()
A function executed on registration.
void onCancel(boolean logout)
A function executed on cancellation.
void execute()
A function representing the unit of work that will be carried out.
Represents a non-player character in the in-game world.
This class represents a character controlled by a player.
Represents a single type of object.
Contains traversal data for a set of regions.
static int getFlags(int x, int y, int height)
Represents a single tile on the game world.
int getHeight()
Gets the height coordinate, or height.
int getY()
Gets the absolute y coordinate.
int getX()
Gets the absolute x coordinate.
Represents a single region.
static final int VIEW_DISTANCE
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
static boolean inside(Interactable source, Interactable target)
static int getDistance(Interactable source, Position target)
static void fixInsidePosition(Mob source, Interactable target)
An object implementing Interactable has uses.
Represents a game object.