1package com.runehive.game.world.entity.combat;
3import com.runehive.content.activity.Activity;
4import com.runehive.content.activity.ActivityType;
5import com.runehive.content.lms.LMSGame;
6import com.runehive.content.skill.impl.slayer.SlayerTask;
7import com.runehive.game.Animation;
8import com.runehive.game.Projectile;
9import com.runehive.game.UpdatePriority;
10import com.runehive.game.world.World;
11import com.runehive.game.world.entity.combat.effect.AntifireDetails;
12import com.runehive.game.world.entity.combat.effect.CombatEffect;
13import com.runehive.game.world.entity.combat.effect.CombatEffectType;
14import com.runehive.game.world.entity.combat.hit.CombatHit;
15import com.runehive.game.world.entity.combat.hit.Hit;
16import com.runehive.game.world.entity.combat.hit.HitIcon;
17import com.runehive.game.world.entity.combat.hit.Hitsplat;
18import com.runehive.game.world.entity.combat.projectile.CombatProjectile;
19import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
20import com.runehive.game.world.entity.mob.Mob;
21import com.runehive.game.world.entity.mob.data.PacketType;
22import com.runehive.game.world.entity.mob.npc.Npc;
23import com.runehive.game.world.entity.mob.player.Player;
24import com.runehive.game.world.entity.mob.prayer.Prayer;
25import com.runehive.game.world.items.Item;
26import com.runehive.game.world.items.containers.equipment.Equipment;
27import com.runehive.game.world.position.Area;
28import com.runehive.net.packet.out.SendMessage;
29import com.runehive.util.RandomUtils;
30import com.runehive.util.Utility;
33import java.util.function.Consumer;
48 throw new UnsupportedOperationException(
"This class cannot be instantiated!");
76 players.sort((first, second) -> {
79 return firstD - secondD;
82 for (
Player other : players) {
83 if (other ==
null)
continue;
84 if (other.instance !=
mob.instance)
continue;
86 if (other.equals(
mob))
continue;
87 if (other.getCurrentHealth() <= 0 || other.isDead())
continue;
92 if (++added == max)
return;
96 npcs.sort((first, second) -> {
99 return firstD - secondD;
102 for (
Npc other : npcs) {
103 if (other ==
null)
continue;
104 if (other.instance !=
mob.instance)
continue;
106 if (other.equals(
mob))
continue;
107 if (other.getCurrentHealth() <= 0 || other.isDead())
continue;
109 if (!other.definition.isAttackable())
continue;
111 if (++added == max)
return;
129 if (combatProjectile !=
null) {
131 if (serverTicks > 0) {
141 return switch (type) {
143 case RANGED ->
Projectile.RANGED_DELAYS[distance] - 1;
144 case MAGIC ->
Projectile.MAGIC_DELAYS[distance] - 1;
224 attacker.
send(
new SendMessage(
"You do not meet the slayer requirements to attack this npc!"));
227 if (attacker.
equals(defender)) {
236 if (attacker.
getCombat().isUnderAttack() && !attacker.
getCombat().isUnderAttackBy(defender)) {
243 if (defender.
getCombat().isUnderAttack() && !defender.
getCombat().isUnderAttackBy(attacker)) {
248 attacker.
send(
new SendMessage(
"This monster is already under attack!"));
276 attacker.
message(defender.
getName() +
" is not in a PvP instance.");
280 attacker.
message(
"You must be in a PvP zone to attack " + defender.
getName() +
"!");
285 attacker.
message(defender.
getName() +
" must be in a PvP zone for you to attack!");
289 if (difference > 10) {
291 attacker.
message(
"Your combat level difference is too great!");
300 attacker.
send(
new SendMessage(
"Your combat level difference is too great!"));
319 if (attacker.
equals(defender)) {
325 if (attacker.
getCombat().isUnderAttack() && !attacker.
getCombat().isUnderAttackBy(defender)) {
330 if (defender.
getCombat().isUnderAttack() && !defender.
getCombat().isUnderAttackBy(attacker)) {
337 if (attacker.
equals(defender)) {
346 if (attacker.
getCombat().isUnderAttack() && !attacker.
getCombat().isUnderAttackBy(defender)) {
351 if (defender.
getCombat().isUnderAttack() && !defender.
getCombat().isUnderAttackBy(attacker)) {
372 return difference <= 10;
388 return mob !=
null && !
mob.isDead() &&
mob.isVisible() &&
mob.isValid() && !mob.teleporting && !
mob.inTeleport;
393 if (
mob.isPlayer()) {
395 if (
mob.getPlayer().equipment.hasShield() || shieldOverride) {
398 }
else if (
mob.isPlayer()) {
400 if (
mob.getPlayer().equipment.hasWeapon() || weaponOverride) {
402 animation =
weapon.getBlockAnimation().orElse(424);
411 int delay = (int)
mob.getCombat().lastBlocked.elapsedTime();
419 int hitsplatDelay = 1;
438 player.
send(
new SendMessage(
"Your dragonfire Shield Absorbs the Dragon breath."));
439 player.
face(attacker);
446 if (shield && potion) {
450 max -= type.getReduction();
467 player.
send(
new SendMessage(
"You are horribly burned by the dragonfire!",
true));
468 }
else if (!shield && !potion && !prayer && damage < 9 && damage > 0) {
469 player.
send(
new SendMessage(
"You manage to resist some of the dragonfire.",
true));
493 System.arraycopy(strategies, 0, array, 0, strategies.length);
494 System.arraycopy(moreStrategies, 0, array, strategies.length, moreStrategies.length);
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
static boolean evaluate(Mob mob, Predicate< Activity > predicate)
static boolean canAttack
Checks if the players are allowed to attack within the game.
static boolean inGameArea(Player player)
Handles checking if the player is in the LMS game area.
Class that models a single animation used by an entity.
Represents the game world.
static RegionManager getRegions()
abstract String getName()
Gets the name of this entity.
abstract boolean equals(Object obj)
static boolean cancelEffect(Mob mob, CombatEffectType effect)
Cancels the effect in any context.
static boolean validate(Mob mob)
static void areaAction(Mob mob, int max, int distance, Consumer< Mob > action)
Sends an action to Mob instance which is within a distance.
static CombatStrategy< Npc >[] createStrategyArray(CombatStrategy< Npc >[] strategies, CombatStrategy< Npc >... moreStrategies)
static CombatStrategy< Npc >[] createStrategyArray(CombatStrategy< Npc >... strategies)
static boolean validateMobs(Mob attacker, Mob defender)
static int getHitDelay(final Mob attacker, final Mob defender, final CombatType type)
Gets the hit delay for the specified type.
static boolean effect(Mob mob, CombatEffectType effect)
Applies the effect in any context.
static boolean validate(Mob attacker, Mob defender)
static CombatHit generateDragonfire(Mob attacker, Mob defender, int max, int hitDelay, int hitsplatDelay, boolean prayer)
static int getOldHitDelay(final Mob attacker, final Mob defender, final CombatType type)
CombatUtil()
The default constructor.
static boolean canAttack(Npc attacker, Mob defender)
static Animation getBlockAnimation(Mob mob)
static boolean canBasicAttack(Mob attacker, Mob defender)
static boolean canAttack(Mob attacker, Mob defender)
static CombatHit generateDragonfire(Mob attacker, Mob defender, int max, boolean prayer)
static boolean canAttack(Player attacker, Mob defender)
static CombatStrategy< Npc > randomStrategy(CombatStrategy< Npc >[] strategies)
static int getHitsplatDelay(CombatType type)
Gets the hitsplat delay for the specified type.
static void areaAction(Mob mob, Consumer< Mob > action)
Executes an action for mobs within a 3x3 square, including the source mob.
Some sort of temporary effect applied to a Mob during combat.
static final Map< CombatEffectType, CombatEffect > EFFECTS
The map of all of the combat effect types mapped to their respective listeners.
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
A Hit object holds the damage amount and hitsplat data.
boolean locked()
Checks if the mob is locked.
abstract< T extends Mob > CombatStrategy<? super T > getStrategy()
The combat strategy of the mob.
final SkillManager skills
abstract Combat<? extends Mob > getCombat()
The combat of the mob.
void animate(int animation)
void face(GameObject object)
Sets the client update flag to face a certain direction.
final boolean isNpc()
Check if an entity is an npc.
final boolean isPlayer()
Check if an entity is a player.
Optional< Graphic > graphic
Represents a non-player character in the in-game world.
boolean equals(Object obj)
Combat< Npc > getCombat()
The combat of the mob.
This class represents a character controlled by a player.
void message(String message)
final Equipment equipment
boolean equals(Object obj)
Optional< AntifireDetails > getAntifireDetails()
void send(OutgoingPacket encoder)
Combat< Player > getCombat()
The combat of the mob.
boolean isActive(Prayer... prayers)
Checks if all given prayers are active.
int getCombatLevel()
Gets the mob's combat level.
The container class that represents an item that can be interacted with.
final int getId()
Gets the identification of this item.
OptionalInt getBlockAnimation()
final boolean containsAny(int... identifiers)
Determines if this container contains any identifiers.
final void set(Item[] toSet)
The container that manages the equipment for a player.
static boolean isWearingDFS(Player player)
static final int WEAPON_SLOT
void refresh()
Forces a refresh of Equipment items to the EQUIPMENT_DISPLAY_ID widget.
static final int SHIELD_SLOT
Handles checking if mobs are in a certain area.
static boolean inMulti(Entity entity)
static boolean inWilderness(Position position)
static boolean inDuelObsticleArena(Interactable entity)
static boolean inPvP(Interactable entity)
List< Player > getLocalPlayers(Mob mob)
Gets the local players around an entity.
List< Npc > getLocalNpcs(Mob mob)
Gets the local npcs around an entity.
The OutgoingPacket that sends a message to a Players chatbox in the client.
A static-util class that provides additional functionality for generating pseudo-random numbers.
static int inclusive(int min, int max)
Returns a pseudo-random int value between inclusive min and inclusive max.
static< T > T random(T[] array)
Pseudo-randomly retrieves a element from array.
Handles miscellaneous methods.
static String formatName(final String input)
static int getDistance(Interactable source, Position target)
static boolean withinViewingDistance(Interactable source, Interactable target, int radius)
Holds all activity types that are timed.
Holds all the slayer task data.
static boolean canAttack(Player player, String npc)
Checks if a player can attack a slayer monster.
Represents different priorities for updating.
The enumerated type whose values represent the collection of different combat effect types.
The enumerated type whose elements represent the hit icon of a Hit.
NONE
Represents no hit icon at all.
NORMAL
Represents a normal hit type.