1package com.runehive.game.world.entity.combat.accuracy;
3import com.runehive.game.world.entity.combat.FormulaUtils;
4import com.runehive.game.world.entity.mob.Mob;
5import com.runehive.game.world.entity.mob.npc.Npc;
6import com.runehive.game.world.entity.mob.player.Player;
7import com.runehive.game.world.entity.mob.prayer.Prayer;
8import com.runehive.game.world.entity.skill.Skill;
9import com.runehive.game.world.items.containers.equipment.Equipment;
11import java.security.SecureRandom;
19 public static final SecureRandom
srand =
new SecureRandom();
23 if (attacker instanceof
Player player) {
32 if (attackRoll > defenceRoll)
33 chance = 1D - (defenceRoll + 2D) / (2D * (attackRoll + 1D));
35 chance = attackRoll / (2D * (defenceRoll + 1D));
37 double roll =
srand.nextDouble();
53 double effectiveLevel;
54 if (defender instanceof
Player) {
58 switch (defender.
getCombat().getFightType().getStyle()) {
59 case DEFENSIVE -> defenceLevel += 3;
60 case CONTROLLED -> defenceLevel += 1;
63 effectiveLevel = magicLevel * 0.7 + defenceLevel * 0.3 + 8;
65 effectiveLevel = magicLevel + 9;
68 return effectiveLevel * (defenceBonus + 64);
73 if (
mob instanceof
Npc npc) {
74 int[] skills = npc.definition.getSkills();
85 double prayerBonus = 1;
98 double prayerBonus = 1;
100 prayerBonus *= 1.25D;
108 double effectiveLevel;
109 if (attacker instanceof
Player) {
112 effectiveLevel = magicLevel + 9;
115 return effectiveLevel * (attackBonus + 64);
static double getPrayerBonusDefender(Mob defender)
static int getAttackBonus(Mob attacker)
static int getDefenceBonus(Mob defender)
static boolean successful(Mob attacker, Mob defender)
static double getDefenceRoll(Mob defender)
static double getAttackRoll(Mob attacker)
static int getMagicLevel(Mob mob)
static final SecureRandom srand
static double getPrayerBonus(Mob attacker)
final SkillManager skills
abstract Combat<? extends Mob > getCombat()
The combat of the mob.
Represents a non-player character in the in-game world.
This class represents a character controlled by a player.
boolean isActive(Prayer... prayers)
Checks if all given prayers are active.
Represents a trainable and usable skill.
static final int DEFENCE
The defence skill id.
static final int MAGIC
The magic skill id.
int getLevel(int id)
Gets the level of a skill.
The container that manages the equipment for a player.
static final int MAGIC_DEFENSE
static final int MAGIC_OFFENSE