Rewrote the swing/attack handler for authenticity:

Fixed a lot of off-by-1 miscalculations
Fixed the void ranger bonus, which should be 20%
Fixed granite maul spec not giving xp and ignoring protection prayers
Fixed accuracy being too high
Fixed set bonuses that boost attack or defence being applied twice or to all attacks
Fixed ranged attacks not taking into account prayers that boost defence or defensive attack styles
Fixed red chinchompa having the same damage as normal chinchompas
Fixed some specs being boosted by offensive prayers
::calcmaxhit now has better formatting
::calc_accuracy renamed to ::calcaccuracy for consistency with other commands, and now also gives the actual hit chance
This commit is contained in:
Doggo
2024-10-06 12:23:24 +00:00
committed by Ryan
parent b2f7f86d6a
commit 9f61ffb153
40 changed files with 369 additions and 276 deletions
@@ -57,7 +57,7 @@ public final class AncientMaceSpecialHandler extends MeleeSwingHandler implement
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.1, 0.98)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1));
hit = RandomFunction.random(calculateHit(entity, victim, 1) + 1);
if (entity.getSkills().getPrayerPoints() < entity.getSkills().getStaticLevel(5)) {
entity.getSkills().setPrayerPoints(entity.getSkills().getPrayerPoints() + hit);
}
@@ -59,13 +59,10 @@ public final class BackstabSpecialHandler extends MeleeSwingHandler implements P
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
double accuracy = 1.0;
if (!victim.getProperties().getCombatPulse().isAttacking()) {
accuracy = 1.75;
}
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, accuracy, 0.98)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0));
victim.getSkills().updateLevel(Skills.DEFENCE, -hit / 10, 0);
if (!victim.getProperties().getCombatPulse().isAttacking() || isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
if (victim.getSkills().getStaticLevel(Skills.DEFENCE) >= victim.getSkills().getDynamicLevels()[Skills.DEFENCE])
victim.getSkills().updateLevel(Skills.DEFENCE, -hit, 0);
}
state.setEstimatedHit(hit);
return 1;
@@ -1,9 +1,7 @@
package content.global.handlers.item.equipment.special;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState;
import core.game.node.entity.combat.CombatStyle;
import core.game.node.entity.combat.DeathTask;
import core.game.node.entity.combat.*;
import core.game.node.entity.combat.ImpactHandler.HitsplatType;
import core.game.node.entity.impl.Animator.Priority;
import core.game.node.entity.impl.Projectile;
@@ -17,7 +15,6 @@ import core.game.world.update.flag.context.Graphics;
import core.plugin.Initializable;
import core.plugin.Plugin;
import core.tools.RandomFunction;
import core.game.node.entity.combat.RangeSwingHandler;
import core.game.world.GameWorld;
import core.game.world.repository.Repository;
import org.rs09.consts.Sounds;
@@ -34,6 +31,13 @@ import static core.api.ContentAPIKt.playGlobalAudio;
@Initializable
public final class ChainhitSpecialHandler extends RangeSwingHandler implements Plugin<Object> {
/**
* Constructs a new {@code ChainhitSpecialHandler} {@code Object}.
*/
public ChainhitSpecialHandler() {
super(SwingHandlerFlag.IGNORE_PRAYER_BOOSTS_DAMAGE);
}
/**
* The sp::ecial energy required.
*/
@@ -159,7 +163,7 @@ public final class ChainhitSpecialHandler extends RangeSwingHandler implements P
public boolean pulse() {
BattleState bs = new BattleState(entity, e);
bs.setMaximumHit(calculateHit(player, e, 1.0));
bs.setEstimatedHit(RandomFunction.RANDOM.nextInt(bs.getMaximumHit()));
bs.setEstimatedHit(RandomFunction.random(bs.getMaximumHit() + 1));
handleHit(victim, e, player, bs);
ChainhitSpecialHandler.super.visualizeImpact(player, e, bs);
return true;
@@ -31,13 +31,6 @@ public final class ChinchompaSwingHandler extends RangeSwingHandler {
*/
private static final Graphics END_GRAPHIC = new Graphics(157, 96);
/**
* Constructs a new {@code ChinchompaSwingHandler} {@code Object}.
*/
public ChinchompaSwingHandler() {
super(SwingHandlerFlag.IGNORE_STAT_BOOSTS_DAMAGE);
}
@Override
public int swing(Entity entity, Entity victim, BattleState state) {
boolean multi = entity.getProperties().isMultiZone() && victim.getProperties().isMultiZone();
@@ -72,7 +65,7 @@ public final class ChinchompaSwingHandler extends RangeSwingHandler {
s.setStyle(CombatStyle.RANGE);
int hit = 0;
if (isAccurateImpact(entity, e, CombatStyle.RANGE)) {
hit = RandomFunction.random(calculateHit(entity, e, 1.0));
hit = RandomFunction.random(calculateHit(entity, e, 1.0) + 1);
}
s.setEstimatedHit(hit);
}
@@ -57,8 +57,8 @@ public final class CleaveSpecialHandler extends MeleeSwingHandler implements Plu
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.18, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.2203));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.25) + 1);
}
state.setEstimatedHit(hit);
return 1;
@@ -30,7 +30,7 @@ public final class DescentOfDarknessSpecialHandler extends RangeSwingHandler imp
/**
* The special energy required.
*/
private static final int SPECIAL_ENERGY = 65;
private static final int SPECIAL_ENERGY = 55;
/**
* The descent of dragons projectile.
@@ -102,13 +102,13 @@ public final class DescentOfDarknessSpecialHandler extends RangeSwingHandler imp
state.setMaximumHit(max);
int hit = minDamage;
if (isAccurateImpact(entity, victim, CombatStyle.RANGE, 1.15, 1.0)) {
hit += RandomFunction.random(max - minDamage);
hit += RandomFunction.random(max - minDamage + 1);
}
state.setEstimatedHit(hit);
if (w.getType() == WeaponType.DOUBLE_SHOT) {
hit = minDamage;
if (isAccurateImpact(entity, victim, CombatStyle.RANGE, 1.15, 1.0)) {
hit += RandomFunction.random(max - minDamage);
hit += RandomFunction.random(max - minDamage + 1);
}
state.setSecondaryHit(hit);
}
@@ -57,8 +57,8 @@ public final class EnergyDrainSpecialHandler extends MeleeSwingHandler implement
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.2, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.25, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1) + 1);
}
if (victim instanceof Player) {
((Player) victim).getSettings().updateRunEnergy(10);
@@ -52,8 +52,9 @@ public final class FeintSpecialHandler extends MeleeSwingHandler implements Plug
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.0, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, RandomFunction.random(1.0, 1.2)));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.0, 0.25)) {
int minDamage = calculateHit(entity, victim, 0.2);
hit = minDamage + RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
}
state.setEstimatedHit(hit);
return 1;
@@ -46,7 +46,8 @@ public final class HamstringSpecialHandler extends RangeSwingHandler implements
state.setMaximumHit(max);
int hit = 0;
if (isAccurateImpact(entity, victim)) {
hit = RandomFunction.random(max);
int minDamage = calculateHit(entity, victim, 0.2);
hit = minDamage + RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
}
state.setEstimatedHit(hit);
Companion.useAmmo(entity, state, victim.getLocation());
@@ -57,20 +57,20 @@ public final class HealingBladeSpecialHandler extends MeleeSwingHandler implemen
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.12, 0.98)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.005));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 2.0, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.1) + 1);
int healthRestore = hit / 2;
double prayerRestore = hit * 0.25;
if (healthRestore < 10) {
healthRestore = 10;
}
if (prayerRestore < 5) {
prayerRestore = 5;
}
entity.getSkills().heal(healthRestore);
entity.getSkills().incrementPrayerPoints(prayerRestore);
}
state.setEstimatedHit(hit);
int healthRestore = hit / 2;
double prayerRestore = hit * 0.25;
if (healthRestore < 10) {
healthRestore = 10;
}
if (prayerRestore < 5) {
prayerRestore = 5;
}
entity.getSkills().heal(healthRestore);
entity.getSkills().incrementPrayerPoints(prayerRestore);
return 1;
}
@@ -57,8 +57,8 @@ public final class IceCleaveSpecialHandler extends MeleeSwingHandler implements
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.075, 0.98)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.005));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 2.0, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.1) + 1);
}
state.setEstimatedHit(hit);
return 1;
@@ -59,7 +59,7 @@ public final class ImpaleSpecialHandler extends MeleeSwingHandler implements Plu
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.1, 0.98)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.1));
hit = RandomFunction.random(calculateHit(entity, victim, 1.1) + 1);
}
state.setEstimatedHit(hit);
return 1;
@@ -57,8 +57,8 @@ public final class JudgementSpecialHandler extends MeleeSwingHandler implements
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.25, 0.98)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.25));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 2.0, 1.0)) {
hit = RandomFunction.random((int) (calculateHit(entity, victim, 1.1) * 1.25) + 1);
}
state.setEstimatedHit(hit);
return 1;
@@ -49,7 +49,7 @@ public final class PhantomStrikeSpecialHandler extends RangeSwingHandler impleme
state.setMaximumHit(max);
int hit = 0;
if (isAccurateImpact(entity, victim)) {
hit = RandomFunction.random(max);
hit = RandomFunction.random(max + 1);
}
state.setEstimatedHit(hit);
Companion.useAmmo(entity, state, victim.getLocation());
@@ -56,10 +56,7 @@ public final class PowershotSpecialHandler extends RangeSwingHandler implements
return -1;
}
state.setStyle(CombatStyle.RANGE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.RANGE, 1.98, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0));
}
int hit = RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
state.setEstimatedHit(hit);
Companion.useAmmo(entity, state, victim.getLocation());
return 1 + (int) Math.ceil(entity.getLocation().getDistance(victim.getLocation()) * 0.3);
@@ -85,7 +85,7 @@ public final class PowerstabSpecialHandler extends MeleeSwingHandler implements
BattleState s = targets[count++] = new BattleState(entity, e);
int hit = 0;
if (isAccurateImpact(entity, e)) {
hit = RandomFunction.random(calculateHit(entity, e, 1.0));
hit = RandomFunction.random(calculateHit(entity, e, 1.0) + 1);
}
s.setStyle(CombatStyle.MELEE);
s.setEstimatedHit(hit);
@@ -61,18 +61,13 @@ public final class PunctureSpecialHandler extends MeleeSwingHandler implements P
return -1;
}
state.setStyle(CombatStyle.MELEE);
// First hit
//double accuracyMod, double defenceMod
int hit = 0;
// accuracyMod defenceMod
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.05, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.1306));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.15, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.15) + 1);
}
state.setEstimatedHit(hit);
// Second hit
// accuracyMod defenceMod
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.05, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.1306));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.15, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.15) + 1);
} else {
hit = 0;
}
@@ -3,9 +3,11 @@ package content.global.handlers.item.equipment.special;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState;
import core.game.node.entity.combat.CombatStyle;
import core.game.node.entity.combat.DeathTask;
import core.game.node.entity.combat.MeleeSwingHandler;
import core.game.node.entity.impl.Animator.Priority;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.prayer.PrayerType;
import core.game.world.GameWorld;
import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics;
@@ -65,16 +67,22 @@ public final class QuickSmashSpecialHandler extends MeleeSwingHandler implements
return -1;
}
}
if (DeathTask.isDead(victim)) {
return -1;
}
if (!p.getSettings().drainSpecial(SPECIAL_ENERGY)) {
return -1;
}
// TODO: apply protection prayers/experience manually (since this is bypassing normal BattleState machinery)
visualize(entity, victim, null);
int hit = 0;
if (isAccurateImpact(entity, victim)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.));
hit = RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
}
victim.getImpactHandler().handleImpact(entity, hit, CombatStyle.MELEE);
if (victim.hasProtectionPrayer(CombatStyle.MELEE))
hit *= (victim instanceof Player) ? 0.6 : 0;
BattleState b = new BattleState();
b.setEstimatedHit(victim.getImpactHandler().handleImpact(entity, hit, CombatStyle.MELEE).getAmount());
addExperience(entity, victim, b);
return 1;
}
@@ -65,15 +65,15 @@ public final class RampageSpecialHandler extends MeleeSwingHandler implements Pl
p.visualize(ANIMATION, GRAPHIC);
@SuppressWarnings("unused")
int boost = 0;
for (int i = 0; i < 6; i++) {
if (i == 2 || i == 3 || i == 5) {
continue;
for (int i = 0; i < 7; i++) {
if (i == Skills.ATTACK || i == Skills.DEFENCE || i == Skills.RANGE || i == Skills.MAGIC) {
int drain = (int) (p.getSkills().getLevel(i) * 0.1);
boost += drain;
p.getSkills().updateLevel(i, -drain, 0);
}
double drain = p.getSkills().getLevel(i) * 0.1;
boost += drain;
p.getSkills().updateLevel(i, (int) -drain, (int) (p.getSkills().getStaticLevel(i) - drain));
}
p.getSkills().updateLevel(Skills.STRENGTH, (int) (p.getSkills().getStaticLevel(Skills.STRENGTH) * 0.20));
boost = 10 + (boost / 4);
p.getSkills().updateLevel(Skills.STRENGTH, boost, Math.max(p.getSkills().getStaticLevel(Skills.STRENGTH) + boost, p.getSkills().getLevel(Skills.STRENGTH)));
return -1;
}
@@ -52,9 +52,9 @@ public final class SaradominsLightningHandler extends MeleeSwingHandler implemen
state.setStyle(CombatStyle.MAGIC);
int hit = 0;
int secondary = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.10, 0.98)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.1));
secondary = 5 + RandomFunction.RANDOM.nextInt(14);
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.10, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.1) + 1);
secondary = 1 + RandomFunction.random(16);
}
state.setEstimatedHit(hit);
state.setSecondaryHit(secondary);
@@ -1,5 +1,6 @@
package content.global.handlers.item.equipment.special;
import core.game.node.entity.combat.SwingHandlerFlag;
import core.game.node.entity.skill.Skills;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState;
@@ -24,6 +25,13 @@ import static core.api.ContentAPIKt.playGlobalAudio;
@Initializable
public final class SeercullSpecialHandler extends RangeSwingHandler implements Plugin<Object> {
/**
* Constructs a new {@code SeercullSpecialHandler} {@code Object}.
*/
public SeercullSpecialHandler() {
super(SwingHandlerFlag.IGNORE_PRAYER_BOOSTS_DAMAGE);
}
/**
* The special energy required.
*/
@@ -57,11 +65,9 @@ public final class SeercullSpecialHandler extends RangeSwingHandler implements P
if (!((Player) entity).getSettings().drainSpecial(SPECIAL_ENERGY)) {
return -1;
}
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.RANGE, 1.05, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0));
int hit = RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
if (victim.getSkills().getLevel(Skills.MAGIC) >= victim.getSkills().getStaticLevel(Skills.MAGIC))
victim.getSkills().updateLevel(Skills.MAGIC, -hit, 0);
}
Companion.useAmmo(entity, state, victim.getLocation());
state.setEstimatedHit(hit);
return 1;
@@ -56,8 +56,8 @@ public final class SeverSpecialHandler extends MeleeSwingHandler implements Plug
return -1;
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.124, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.25, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
if (victim instanceof Player) {
Player p = (Player) victim;
if (p.getPrayer().get(PrayerType.PROTECT_FROM_MAGIC)) {
@@ -56,8 +56,8 @@ public final class ShatterSpecialHandler extends MeleeSwingHandler implements Pl
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 0.87, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.3546));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.25, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.5) + 1);
}
state.setEstimatedHit(hit);
return 1;
@@ -56,24 +56,25 @@ public final class SliceAndDiceSpecialHandler extends MeleeSwingHandler implemen
return -1;
}
int maximum = calculateHit(entity, victim, 1.0);
int[] hits = new int[] {0, 1};
int hit = getHit(entity, victim, maximum);
int[] hits;
int hit = getHit(entity, victim, maximum - 1, maximum / 2);
if (hit > 0) {
hits = new int[] {hit, hit / 2, (hit / 2) / 2, (hit / 2) - ((hit / 2) / 2)};
hits = new int[] {hit, hit / 2, (hit / 2) / 2, (hit / 2) / 2 + 1};
} else {
hit = getHit(entity, victim, maximum);
hit = getHit(entity, victim, maximum * 7 / 8, maximum * 3 / 8);
if (hit > 0) {
hits = new int[] {0, hit, hit / 2, hit - (hit / 2)};
hits = new int[] {0, hit, hit / 2, hit / 2 + 1};
} else {
hit = getHit(entity, victim, maximum);
hit = getHit(entity, victim, maximum * 3 / 4, maximum / 4);
if (hit > 0) {
hits = new int[] {0, 0, hit / 2, (hit / 2) + 10};
hits = new int[] {0, 0, hit, hit + 1};
} else {
hit = getHit(entity, victim, (int) (maximum * 1.5));
hit = getHit(entity, victim, maximum * 5 / 4, maximum / 4);
if (hit > 0) {
hits = new int[] {0, 0, 0, hit};
} else {
hits = new int[] {0, RandomFunction.random(2)};
hit = RandomFunction.random(2);
hits = new int[] {0, 0, hit, hit};
}
}
}
@@ -95,9 +96,9 @@ public final class SliceAndDiceSpecialHandler extends MeleeSwingHandler implemen
* @param maximum The maximum hit.
* @return The hit.
*/
private int getHit(Entity entity, Entity victim, int maximum) {
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.25, 0.98)) {
return RandomFunction.random(maximum);
private int getHit(Entity entity, Entity victim, int maximum, int minimum) {
if (isAccurateImpact(entity, victim, CombatStyle.MELEE)) {
return RandomFunction.random(minimum, maximum + 1);
}
return 0;
}
@@ -59,7 +59,8 @@ public final class SmashSpecialHandler extends MeleeSwingHandler implements Plug
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.0, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, RandomFunction.random(1.0, 1.5)));
int max = calculateHit(entity, victim, 1.0);
hit = max / 4 + RandomFunction.random(max + 1);
int lower = (int) (victim.getSkills().getLevel(Skills.DEFENCE) * 0.30);
victim.getSkills().updateLevel(Skills.DEFENCE, -lower, 0);
}
@@ -3,6 +3,7 @@ package content.global.handlers.item.equipment.special;
import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState;
import core.game.node.entity.combat.CombatStyle;
import core.game.node.entity.combat.SwingHandlerFlag;
import core.game.node.entity.impl.Animator.Priority;
import core.game.node.entity.impl.Projectile;
import core.game.node.entity.player.Player;
@@ -25,6 +26,13 @@ import static core.api.ContentAPIKt.playGlobalAudio;
@Initializable
public final class SnapshotSpecialHandler extends RangeSwingHandler implements Plugin<Object> {
/**
* Constructs a new {@code SnapshotSpecialHandler} {@code Object}.
*/
public SnapshotSpecialHandler() {
super(SwingHandlerFlag.IGNORE_PRAYER_BOOSTS_DAMAGE);
}
/**
* The special energy required.
*/
@@ -67,13 +75,13 @@ public final class SnapshotSpecialHandler extends RangeSwingHandler implements P
int max = calculateHit(entity, victim, 1.0);
state.setMaximumHit(max);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 0.9, 1.0)) {
hit = RandomFunction.random(max);
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.43, 1.0)) {
hit = RandomFunction.random(max + 1);
}
state.setEstimatedHit(hit);
hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 0.9, 1.0)) {
hit = RandomFunction.random(max);
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.43, 1.0)) {
hit = RandomFunction.random(max + 1);
}
state.setSecondaryHit(hit);
Companion.useAmmo(entity, state, victim.getLocation());
@@ -60,9 +60,10 @@ public final class SnipeSpecialHandler extends RangeSwingHandler implements Plug
}
state.setStyle(CombatStyle.RANGE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.RANGE, 1.05, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0));
victim.getSkills().updateLevel(Skills.DEFENCE, -hit, 0);
if (!victim.getProperties().getCombatPulse().isAttacking() || isAccurateImpact(entity, victim, CombatStyle.RANGE)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
if (victim.getSkills().getStaticLevel(Skills.DEFENCE) >= victim.getSkills().getDynamicLevels()[Skills.DEFENCE])
victim.getSkills().updateLevel(Skills.DEFENCE, -hit, 0);
}
Companion.useAmmo(entity, state, victim.getLocation());
state.setEstimatedHit(hit);
@@ -85,7 +85,7 @@ public final class SpearWallSpecialHandler extends MeleeSwingHandler implements
if (CombatStyle.RANGE.getSwingHandler().canSwing(entity, e) != InteractionType.NO_INTERACT) {
BattleState s = targets[count++] = new BattleState(entity, e);
int hit = 0;
hit = RandomFunction.random(calculateHit(entity, e, 1.0));
hit = RandomFunction.random(calculateHit(entity, e, 1.0) + 1);
s.setStyle(CombatStyle.MELEE);
s.setEstimatedHit(hit);
}
@@ -66,14 +66,14 @@ public final class SweepSpecialHandler extends MeleeSwingHandler implements Plug
for (BattleState s : targets) {
s.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, s.getVictim(), CombatStyle.MELEE, 1, 0.94)) {
hit = RandomFunction.random(calculateHit(entity, s.getVictim(), 1.1));
if (isAccurateImpact(entity, s.getVictim(), CombatStyle.MELEE)) {
hit = RandomFunction.random(calculateHit(entity, s.getVictim(), 1.1) + 1);
}
s.setEstimatedHit(hit);
if (s.getVictim().size() > 1) {
hit = 0;
if (isAccurateImpact(entity, s.getVictim(), CombatStyle.MELEE, 1, 0.94)) {
hit = RandomFunction.random(calculateHit(entity, s.getVictim(), 1.1));
if (isAccurateImpact(entity, s.getVictim(), CombatStyle.MELEE, 0.75, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, s.getVictim(), 1.1) + 1);
}
s.setSecondaryHit(hit);
}
@@ -57,8 +57,8 @@ public final class WarstrikeSpecialHandler extends MeleeSwingHandler implements
}
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.049, 0.98)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.1));
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 2.0, 1.0)) {
hit = RandomFunction.random((int) (calculateHit(entity, victim, 1.1) * 1.1) + 1);
}
state.setEstimatedHit(hit);
if (victim instanceof Player) {
@@ -68,10 +68,10 @@ public final class WarstrikeSpecialHandler extends MeleeSwingHandler implements
if (left > 0) {
left = -victim.getSkills().updateLevel(Skills.STRENGTH, -left, 0);
if (left > 0) {
left = -victim.getSkills().updateLevel(Skills.ATTACK, -left, 0);
left = (int) -(victim.getSkills().getPrayerPoints() + left);
victim.getSkills().decrementPrayerPoints(left);
if (left > 0) {
left = (int) -(victim.getSkills().getPrayerPoints() + left);
victim.getSkills().decrementPrayerPoints(left);
left = -victim.getSkills().updateLevel(Skills.ATTACK, -left, 0);
if (left > 0) {
left = -victim.getSkills().updateLevel(Skills.MAGIC, -left, 0);
if (left > 0)
@@ -57,18 +57,19 @@ public final class WeakenSpecialHandler extends MeleeSwingHandler implements Plu
state.setStyle(CombatStyle.MELEE);
int hit = 0;
if (isAccurateImpact(entity, victim, CombatStyle.MELEE, 1.0, 1.0)) {
hit = RandomFunction.random(calculateHit(entity, victim, 1.0));
hit = RandomFunction.random(calculateHit(entity, victim, 1.0) + 1);
if (victim instanceof Player) {
((Player) victim).getPacketDispatch().sendMessage("You have been drained.");
}
// TODO 10% drain to demons
int lower = (int) (victim.getSkills().getStaticLevel(Skills.DEFENCE) * 0.05) + 1;
victim.getSkills().updateLevel(Skills.DEFENCE, -lower, 0);
lower = (int) (victim.getSkills().getStaticLevel(Skills.ATTACK) * 0.05) + 1;
victim.getSkills().updateLevel(Skills.ATTACK, -lower, 0);
lower = (int) (victim.getSkills().getStaticLevel(Skills.STRENGTH) * 0.05) + 1;
victim.getSkills().updateLevel(Skills.STRENGTH, -lower, 0);
}
state.setEstimatedHit(hit);
if (victim instanceof Player) {
((Player) victim).getPacketDispatch().sendMessage("You have been drained.");
}
int lower = (int) (victim.getSkills().getLevel(Skills.DEFENCE) * 0.05);
victim.getSkills().updateLevel(Skills.DEFENCE, -lower, 0);
int lower2 = (int) (victim.getSkills().getLevel(Skills.ATTACK) * 0.05);
victim.getSkills().updateLevel(Skills.ATTACK, -lower2, 0);
int lower3 = (int) (victim.getSkills().getLevel(Skills.STRENGTH) * 0.05);
victim.getSkills().updateLevel(Skills.STRENGTH, -lower3, 0);
return hit;
}
@@ -72,7 +72,7 @@ object SlayerEquipmentFlags {
val isCape = SlayerManager.getInstance(player).flags.equipmentFlags == 0x3F
val hasMask = hasBlackMask(player)
return if(hasMask) 1.15
return if(hasMask) 1.1667
else if(isCape) 1.075
else 1.0
}