1package com.runehive.game.world.entity.combat.magic;
3import com.runehive.game.world.entity.combat.CombatImpact;
4import com.runehive.game.world.entity.combat.CombatType;
5import com.runehive.game.world.entity.combat.CombatUtil;
6import com.runehive.game.world.entity.combat.PoisonType;
7import com.runehive.game.world.entity.combat.attack.FormulaFactory;
8import com.runehive.game.world.entity.combat.effect.CombatEffectType;
9import com.runehive.game.world.entity.combat.hit.CombatHit;
10import com.runehive.game.world.entity.combat.hit.Hit;
11import com.runehive.game.world.entity.mob.Mob;
12import com.runehive.game.world.entity.mob.data.LockType;
13import com.runehive.game.world.entity.mob.npc.Npc;
14import com.runehive.game.world.entity.mob.player.Player;
15import com.runehive.game.world.entity.skill.Skill;
16import com.runehive.util.RandomUtils;
19import java.util.concurrent.TimeUnit;
37 if (attacker.isPlayer() &&
hit.isAccurate()) {
42 Npc mob = defender.getNpc();
88 public boolean canAffect(
Mob attacker,
Mob defender,
Hit hit) {
89 return hit.isAccurate() &&
effect.canAffect(attacker, defender,
hit);
93 public void impact(
Mob attacker,
Mob defender,
Hit hit, List<Hit> hits) {
94 effect.impact(attacker, defender,
hit, hits);
112 if (
skill.getLevel() - 1 >= 0) {
113 skill.removeLevel(1);
126 double ratio = percentage / 100.0;
127 int limit = (int) (
skill.getMaxLevel() * (1 - ratio));
128 int amount = (int) (
skill.getLevel() * ratio);
130 if (
skill.getLevel() - amount < limit) {
131 amount =
skill.getLevel() - limit;
135 skill.removeLevel(amount);
145 if (!attacker.
isNpc() &&
hit.getDamage() < 1) {
157 defender.
freezeImmunity.
reset(TimeUnit.MILLISECONDS.convert(timer + 10, TimeUnit.SECONDS));
166 float heal =
hit.getDamage() / 40f;
212 heal(attacker, next);
220 heal(attacker, next);
247 if (!attacker.
getCombat().canAttack(other)) {
251 if (!attacker.
equals(other) && !defender.
equals(other)) {
255 if (extra !=
null) extra.add(
hit);
abstract boolean equals(Object obj)
A collection of util methods and constants related to combat.
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 void areaAction(Mob mob, Consumer< Mob > action)
Executes an action for mobs within a 3x3 square, including the source mob.
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
A Hit object holds the damage amount and hitsplat data.
int getDamage()
Gets the damage amount.
boolean isAccurate()
Checks if the hit is accurate.
void poison(PoisonType type)
Applies poison with an intensity of type to the entity.
final SkillManager skills
final boolean isPoisoned()
abstract Combat<? extends Mob > getCombat()
The combat of the mob.
final Stopwatch freezeImmunity
final boolean isNpc()
Check if an entity is an npc.
final boolean isPlayer()
Check if an entity is a player.
void reset()
Resets the walking queue so it contains no more steps.
Represents a non-player character in the in-game world.
This class represents a character controlled by a player.
Represents a trainable and usable skill.
static final int DEFENCE
The defence skill id.
static final int MAGIC
The magic skill id.
static final int ATTACK
The attack skill id.
static final int STRENGTH
The strength skill id.
static final int HITPOINTS
The hitpoints skill id.
int getLevel(int id)
Gets the level of a skill.
Skill get(int id)
Gets the skill for an id.
void refresh()
Refreshes all the skills for the mob.
A static-util class that provides additional functionality for generating pseudo-random numbers.
static int inclusiveExcludes(int min, int max, int... exclude)
Returns a pseudo-random int value between inclusive min and inclusive max excluding the specified num...
static int inclusive(int min, int max)
Returns a pseudo-random int value between inclusive min and inclusive max.
boolean valid(String name)
Checks if the npc is a slayer task assignment.
The enumerated type whose elements represent the different levels of poison.
DEFAULT_MAGIC
The default poison type for magic spells.
DEFAULT_NPC
The default poison type for poisonous NPCs.
SUPER_MAGIC
The strongest poison type for magic spells.
The enumerated type whose values represent the collection of different combat effect types.
static void iceBarrage(Mob attacker, Mob defender, Mob other, List< Hit > extra)
static void poison(Mob attacker, Mob defender, Hit hit, PoisonType type)
static void bloodBurst(Mob attacker, Mob defender, Mob other, Hit hit, List< Hit > extra)
static void bloodBarrage(Mob attacker, Mob defender, Mob other, Hit hit, List< Hit > extra)
MagicImpact(CombatImpact effect)
static void iceBurst(Mob attacker, Mob defender, Mob other, List< Hit > extra)
final CombatImpact effect
static void shadowBarrage(Mob attacker, Mob defender, Mob other, List< Hit > extra)
static void freeze(Mob defender, int timer)
static void teleblock(Mob defender)
static CombatHit hitEvent(Mob attacker, Mob defender, Mob other, int max, List< Hit > extra)
static void smokeBurst(Mob attacker, Mob defender, Mob other, Hit hit, List< Hit > extra)
static void lowerSkill(Mob defender, int id, int percentage)
static void heal(Mob attacker, Hit hit)
static void kbdShock(Mob defender)
static void shadowBurst(Mob attacker, Mob defender, Mob other, List< Hit > extra)
static void smokeBarrage(Mob attacker, Mob defender, Mob other, Hit hit, List< Hit > extra)
Holds all the lock types.
Represents a combat impact hit effect.