Skip to content

Commit d17539a

Browse files
committed
Combat melee max hit formula
1 parent 3dbc2af commit d17539a

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/main/java/io/luna/game/model/mob/combat/CombatAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ public boolean run() {
2626
if (mob.getInteractingWith() instanceof Mob) {
2727
Mob target = (Mob) mob.getInteractingWith();
2828

29-
target.damage(1, Hit.HitType.NORMAL);
30-
target.getCombat().getDamageStack().push(mob, CombatDamage.simple(1, Hit.HitType.NORMAL, CombatDamageType.MELEE));
29+
CombatDamage dmg = CombatDamage.calculated(target, mob, Hit.HitType.NORMAL, CombatDamageType.MELEE);
30+
target.damage(dmg.getAmount(), Hit.HitType.NORMAL);
31+
target.getCombat().getDamageStack().push(mob, dmg);
3132

3233
if (target.getHealth() <= 0) {
3334
return true;

src/main/java/io/luna/game/model/mob/combat/CombatDamage.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package io.luna.game.model.mob.combat;
22

3+
import engine.combat.prayer.CombatPrayer;
4+
import io.luna.game.model.item.Equipment;
35
import io.luna.game.model.mob.Mob;
6+
import io.luna.game.model.mob.Player;
7+
import io.luna.game.model.mob.Skill;
48
import io.luna.game.model.mob.block.Hit.HitType;
59
import io.luna.util.RandomUtils;
610

@@ -11,8 +15,24 @@ public static CombatDamage simple(int damage, HitType hitType, CombatDamageType
1115
}
1216

1317
// apply damage based on target
14-
public static CombatDamage calculated(Mob target, HitType hitType, CombatDamageType damageType) {
15-
int maxHit = -1;
18+
public static CombatDamage calculated(Mob target, Mob source, HitType hitType, CombatDamageType damageType) {
19+
int maxHit = 1;
20+
21+
if (source instanceof Player) {
22+
Player p = source.asPlr();
23+
double equipmentStrengthBonus = p.getEquipment().getBonus(Equipment.EquipmentBonus.STRENGTH);
24+
double strength = p.skill(Skill.STRENGTH).getStaticLevel();
25+
if (p.getCombat().getPrayers().isActive(CombatPrayer.BURST_OF_STRENGTH)) {
26+
strength *= 1.05d;
27+
} else if (p.getCombat().getPrayers().isActive(CombatPrayer.SUPERHUMAN_STRENGTH)) {
28+
strength *= 1.1d;
29+
} else if (p.getCombat().getPrayers().isActive(CombatPrayer.ULTIMATE_STRENGTH)) {
30+
strength *= 1.15d;
31+
}
32+
strength += 8d;
33+
maxHit = (int)(0.5d + strength * ((equipmentStrengthBonus + 64d)/640d));
34+
}
35+
1636
return new CombatDamage(RandomUtils.inclusive(maxHit), hitType, damageType);
1737
}
1838

0 commit comments

Comments
 (0)