1package com.runehive.game.world.entity.combat.accuracy;
3import com.runehive.game.world.entity.combat.CombatType;
4import com.runehive.game.world.entity.combat.FormulaUtils;
5import com.runehive.game.world.entity.combat.attack.FightStyle;
6import com.runehive.game.world.entity.mob.Mob;
7import com.runehive.game.world.entity.mob.npc.Npc;
8import com.runehive.game.world.entity.mob.player.Player;
9import com.runehive.game.world.entity.mob.prayer.Prayer;
10import com.runehive.game.world.entity.skill.Skill;
11import com.runehive.game.world.items.Item;
12import com.runehive.game.world.position.Area;
13import com.runehive.util.Items;
15import java.security.SecureRandom;
23 public static final SecureRandom
srand =
new SecureRandom();
28 double successfulRoll;
29 double selectedChance =
srand.nextDouble();
31 if (attackBonus > defenceBonus)
32 successfulRoll = 1D - (defenceBonus + 2D) / (2D * (attackBonus + 1D));
34 successfulRoll = attackBonus / (2D * (defenceBonus + 1D));
37 return successfulRoll > selectedChance;
41 double prayerBonus = 1;
64 effectiveLevel += 3.0D;
73 effectiveLevel *= 1.10D;
74 effectiveLevel = Math.floor(effectiveLevel);
78 effectiveLevel *= 1.10D;
81 if (((
Player) attacker).equipment.contains(22550)) {
82 effectiveLevel *= 1.50D;
85 if (attacker.
isNpc()) {
87 effectiveLevel *= 1.05D;
90 effectiveLevel *= 1.10D;
95 return Math.floor(effectiveLevel);
104 if (attacker instanceof
Npc npc) {
105 if (npc.definition.getSkills() !=
null)
106 rangeLevel = npc.definition.getSkills()[4];
115 double magicLevel = 1;
122 if (defender instanceof
Npc n) {
123 if (n.definition.getSkills() !=
null)
126 magicLevel = getMagicLevel;
128 bonus += ((140 + (((10 * 3) * magicLevel) - 10) / 100D) - ((((3 * magicLevel) - 100D) * 2)) / 100D);
150 if (defender instanceof
Npc) {
163 double maxRoll = effectiveRangeLevel * (equipmentRangeBonus);
165 return (
int) (maxRoll);
173 double maxRoll = effectiveDefenceLevel * (equipmentRangeBonus);
175 return (
int) maxRoll;
static double getAttackRoll(Mob attacker)
static double getDefenceRoll(Mob defender)
static double getEffectiveLevelDefender(Mob defender)
static double getEffectiveRanged(Mob attacker, CombatType style)
static double getDefenceRoll(Mob defender, CombatType style)
static int getRangeLevel(Mob attacker)
static int getDefenceNpc(Mob defender)
static boolean successful(Mob attacker, Mob defender, CombatType style)
static double getAttackRoll(Mob attacker, Mob defender, CombatType style)
static int getRangeDefenceLevelNpc(Mob defender, CombatType style)
static double getPrayerAttackBonus(Mob attacker)
static int getGearAttackBonus(Mob attacker, Mob defender, CombatType style)
static double twistedBowBonus(Mob attacker, Mob defender)
static final SecureRandom srand
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.
final boolean isNpc()
Check if an entity is an npc.
final boolean isPlayer()
Check if an entity is a player.
Represents a non-player character in the in-game world.
This class represents a character controlled by a player.
final Equipment equipment
boolean isActive(Prayer... prayers)
Checks if all given prayers are active.
Represents a trainable and usable skill.
static final int RANGED
The ranged skill id.
static final int MAGIC
The magic skill id.
int getLevel(int id)
Gets the level of a skill.
int getMaxLevel(int id)
Gets the highest possible level of a skill.
The container class that represents an item that can be interacted with.
boolean contains(int[] bowsWithNoArrowsRequired)
Handles checking if mobs are in a certain area.
static boolean inWilderness(Position position)
static final int RED_SLAYER_HELMET
static final int PURPLE_SLAYER_HELMET
static final int SLAYER_HELMET
static final int BLACK_SLAYER_HELMET
static final int SALVE_AMULET
static final int GREEN_SLAYER_HELMET
The enumerated type whose elements represent the fighting styles.