1package com.runehive.game.world.entity.mob;
3import com.runehive.content.activity.Activity;
4import com.runehive.content.activity.ActivityType;
5import com.runehive.content.wintertodt.Wintertodt;
6import com.runehive.fs.cache.decoder.AnimationDefinition;
7import com.runehive.fs.cache.decoder.AnimationDefinitionDecoder;
8import com.runehive.game.Animation;
9import com.runehive.game.Graphic;
10import com.runehive.game.action.ActionManager;
11import com.runehive.game.task.impl.ForceMovementTask;
12import com.runehive.game.world.Interactable;
13import com.runehive.game.world.World;
14import com.runehive.game.world.entity.Entity;
15import com.runehive.game.world.entity.EntityType;
16import com.runehive.game.world.entity.combat.Combat;
17import com.runehive.game.world.entity.combat.CombatUtil;
18import com.runehive.game.world.entity.combat.PoisonType;
19import com.runehive.game.world.entity.combat.attack.listener.CombatListener;
20import com.runehive.game.world.entity.combat.attack.listener.CombatListenerManager;
21import com.runehive.game.world.entity.combat.effect.CombatEffectType;
22import com.runehive.game.world.entity.combat.hit.Hit;
23import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
24import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
25import com.runehive.game.world.entity.mob.data.LockType;
26import com.runehive.game.world.entity.mob.movement.Movement;
27import com.runehive.game.world.entity.mob.movement.waypoint.CombatWaypoint;
28import com.runehive.game.world.entity.mob.movement.waypoint.FollowWaypoint;
29import com.runehive.game.world.entity.mob.movement.waypoint.WalkToWaypoint;
30import com.runehive.game.world.entity.mob.movement.waypoint.Waypoint;
31import com.runehive.game.world.entity.mob.npc.Npc;
32import com.runehive.game.world.entity.mob.npc.NpcAssistant;
33import com.runehive.game.world.entity.mob.npc.NpcUtility;
34import com.runehive.game.world.entity.mob.npc.definition.NpcDefinition;
35import com.runehive.game.world.entity.mob.player.ForceMovement;
36import com.runehive.game.world.entity.mob.player.Player;
37import com.runehive.game.world.entity.mob.player.relations.ChatMessage;
38import com.runehive.game.world.entity.mob.prayer.PrayerBook;
39import com.runehive.game.world.entity.skill.Skill;
40import com.runehive.game.world.entity.skill.SkillManager;
41import com.runehive.game.world.object.GameObject;
42import com.runehive.game.world.pathfinding.TraversalMap;
43import com.runehive.game.world.position.Position;
44import com.runehive.net.packet.out.SendPoison;
45import com.runehive.util.MutableNumber;
46import com.runehive.util.Stopwatch;
47import com.runehive.util.Utility;
48import com.runehive.util.generic.BooleanInterface;
49import com.runehive.util.generic.GenericAttributes;
51import java.util.EnumSet;
52import java.util.LinkedList;
54import java.util.Optional;
55import java.util.concurrent.TimeUnit;
56import java.util.function.Function;
58import static com.runehive.game.world.entity.combat.CombatConstants.EMPTY_BONUSES;
89 private Optional<Animation>
animation = Optional.empty();
91 private Optional<Graphic>
graphic = Optional.empty();
116 this.lastPosition =
position.copy();
121 this.lastPosition =
position.copy();
164 final long now = System.currentTimeMillis();
169 final Optional<Animation> result = Optional.ofNullable(
animation);
176 if (definition !=
null) {
179 this.animation = result;
187 Optional<Graphic> result = Optional.ofNullable(
graphic);
190 if (!this.graphic.isPresent() || override ||
this.graphic.get().
compareTo(
graphic) > 0) {
191 this.graphic = result;
197 final String name = source.
getName().toLowerCase();
198 return "imp".equals(name) || name.contains(
"impling");
218 npc.pathfinderProjectiles =
Mob.pathfinderProjectiles(
npc);
228 if (listener !=
null) {
229 combat.addListener(listener);
282 this.interactingWith =
mob;
294 this.facePosition =
object.getPosition();
381 walkTo(interactable, onDestination);
391 walkTo(interactable, onDestination);
395 walkTo(target,
true, onDestination);
407 action.clearNonWalkableActions();
419 action.clearNonWalkableActions();
429 action.clearNonWalkableActions();
438 action.clearNonWalkableActions();
527 if (this.activity !=
null) {
537 this.teleportTarget =
null;
575 public final boolean isPlayer(Function<Player, Boolean> condition) {
605 if (
this instanceof
Player) {
614 if (
this instanceof
Player) {
657 return npc.pyroHealth;
690 bonuses =
new int[EMPTY_BONUSES.length];
696 bonuses =
new int[EMPTY_BONUSES.length];
717 this.animation = Optional.empty();
721 this.graphic = Optional.empty();
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
abstract void cleanup()
Cleans up the activity when finished.
static final int INCAPACITATED_PYROMANCER
static final int PYROMANCER
A class which parses animation definitions.
static final Int2ObjectMap< AnimationDefinition > definitions
Class that models a single animation used by an entity.
static final Animation RESET
Represents a single graphic that can be used by entities.
static final Graphic RESET
int compareTo(Graphic other)
The class which manages Actions executed by mobs.
Represents the game world.
static void schedule(Task task)
Submits a new event.
Entity(Position position)
void setLength(int length)
abstract EntityType getType()
Gets the EntityType.
abstract String getName()
Gets the name of this entity.
abstract boolean equals(Object obj)
void setPosition(Position position)
A collection of util methods and constants related to combat.
static boolean effect(Mob mob, CombatEffectType effect)
Applies the effect in any context.
static final Map< Integer, CombatListener< Npc > > NPC_LISTENERS
A Hit object holds the damage amount and hitsplat data.
int getDamage()
Gets the damage amount.
void modifyDamage(Function< Integer, Integer > modifier)
Sets the hit damage with a function.
static NpcMeleeStrategy get()
Optional< Graphic > getGraphic()
Optional< Animation > animation
MobAnimation mobAnimation
void appendBonus(int index, int amount)
abstract< T extends Mob > CombatStrategy<? super T > getStrategy()
The combat strategy of the mob.
PoisonType getPoisonType()
void poison(PoisonType type)
Applies poison with an intensity of type to the entity.
void graphic(Graphic graphic, boolean override)
Plays a graphic.
final SkillManager skills
final MutableNumber getPoisonDamage()
final boolean isNpc(BooleanInterface< Npc > condition)
Check if an entity is an npc.
ForceMovement getForceMovement()
void writeDamage(Hit hit)
void walkTo(Interactable target, boolean clearAction, Runnable onDestination)
final EnumSet< UpdateFlag > updateFlags
final boolean isPoisoned()
void speak(String forceChat)
Sets the mob's forced chat.
void setBonus(int equipSlot, int bonus)
void setFixingInside(boolean fixingInside)
final MutableNumber poisonDamage
void interact(Mob mob)
Sets the mob interacting with another mob.
void walkTo(Interactable target, Runnable onDestination)
final void resetWaypoint()
Resets the waypoint.
void forceMove(int animation, int x, int y)
abstract Combat<? extends Mob > getCombat()
The combat of the mob.
void setBonuses(int[] bonuses)
final boolean isPlayer(Function< Player, Boolean > condition)
Check if an entity is a player.
void setListIndex(int listIndex)
void setDead(boolean dead)
abstract boolean isAutoRetaliate()
State of the mob's auto retaliate.
void transform(int transformId)
abstract void appendDeath()
Handles the mob death.
boolean isUpdateRequired()
Checks if mob requires an update.
void walkExactlyTo(Position position, Runnable onDestination)
void setForceMovement(ForceMovement forceMovement)
ForceMovement forceMovement
final GenericAttributes attributes
abstract void sequence()
The method which is invoked every tick.
void animate(Animation animation, final boolean override)
Plays an animation.
void forceMove(int delay, int delay2, int animation, int startSpeed, int endSpeed, Position offset, Direction direction)
Optional< Animation > getAnimation()
void animate(int animation)
void walkTo(Position position, Runnable onDestination)
Hit decrementHealth(Hit hit)
void writeFakeDamage(Hit hit)
Mob(Position position, boolean visible)
boolean pathfinderProjectiles
Mob(Position position)
Constructs a new Mob.
void forceMove(int delay, int animation, int startSpeed, int endSpeed, Position offset, Direction direction)
static boolean pathfinderProjectiles(Mob source)
final SkillManager skills_copy
void move(Position position)
Moves the mob to a set position.
final Stopwatch freezeImmunity
void face(GameObject object)
Sets the client update flag to face a certain direction.
void animate(int animation, boolean override)
final boolean isVenomed()
boolean inActivity(ActivityType type)
void setWaypoint(Waypoint waypoint)
void forceMove(int delay, int delay2, int animation, int animationDelay, int startSpeed, int endSpeed, Position offset, Direction direction)
Creates a force movement action for an entity.
void graphic(Graphic graphic)
Plays a graphic.
final boolean isNpc()
Check if an entity is an npc.
boolean hasPriorityIndex(Mob other)
void face(Position position)
Sets the client update flag to face a certain direction.
final boolean isPlayer()
Check if an entity is a player.
void walk(Position position)
void setActivity(Activity activity)
MutableNumber getVenomDamage()
final MutableNumber venomDamage
void walkTo(Position position)
void animate(Animation animation)
Plays an animation.
void clearTeleportTarget()
Resets the teleport target.
void resetFace()
Resets the mob's face location.
final void reset()
Resets the mob after an update.
Optional< Graphic > graphic
void runTo(Position destination)
transient long nextAnimation
void graphic(int graphic)
void venom()
Applies venom to the entity.
void transform(int transformId, boolean reload)
Transforms the mob.
void face(Direction direction)
Sets the client update flag to face a certain direction.
void walk(Position destination, boolean ignoreClip)
void walkExactlyTo(Position position)
Handles the movement for the player.
boolean equals(Object obj)
Method handles small methods for npcs that do not have any parent class.
static Optional< CombatStrategy< Npc > > loadStrategy(Npc npc)
Represents a non-player character in the in-game world.
final NpcAssistant npcAssistant
void setStrategy(CombatStrategy< Npc > strategy)
Combat< Npc > getCombat()
The combat of the mob.
static final Map< Integer, Supplier< CombatStrategy< Npc > > > STRATEGIES
Contains the npc definitions.
static NpcDefinition get(int id)
Gets a npc definition from the definition array.
void close(int interfaceId)
This class represents a character controlled by a player.
final InterfaceManager interfaceManager
Represents a chat message that can be displayed over an entities head.
static final int CHARACTER_LIMIT
When a chat message decoded there's a character buffer that can only hold 100 characters.
A PrayerBook which stores prayers.
Represents a trainable and usable skill.
static final int HITPOINTS
The hitpoints skill id.
Manages all skills related to an mob.
Contains traversal data for a set of regions.
static boolean isTraversable(Position from, Direction direction, int size)
Tests whether or not a specified position is traversable in the specified direction.
Represents a single tile on the game world.
Position transform(int diffX, int diffY, int diffZ)
Creates a new location based on this location.
The container class that contains functions to simplify the modification of a number.
Handles miscellaneous methods.
static boolean isRegionChange(Position position, Position region)
Holds generic attributes.
Holds all activity types that are timed.
The enumerated type whose elements represent the different levels of poison.
The enumerated type whose values represent the collection of different combat effect types.
Represents the enumerated directions an entity can walk or face.
Position getFaceLocation()
Holds all the lock types.
An object implementing Interactable has uses.
static Interactable create(Position position)
Creates a new instance of an Interactable.
A combat attack is used to describe what the attacking and defending mobs should do in each stage of ...
Represents a game object.
boolean activated(final T player)