RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
PrayerListener.java
1package com.osroyale.game.world.entity.combat.attack.listener.other;
2
3import com.osroyale.game.Graphic;
4import com.osroyale.game.UpdatePriority;
5import com.osroyale.game.world.entity.combat.CombatType;
6import com.osroyale.game.world.entity.combat.CombatUtil;
7import com.osroyale.game.world.entity.combat.attack.listener.SimplifiedListener;
8import com.osroyale.game.world.entity.combat.hit.Hit;
9import com.osroyale.game.world.entity.combat.hit.HitIcon;
10import com.osroyale.game.world.entity.mob.Mob;
11import com.osroyale.game.world.entity.mob.prayer.Prayer;
12import com.osroyale.game.world.entity.skill.Skill;
13import com.osroyale.game.world.position.Area;
14import com.osroyale.util.RandomUtils;
15
16public class PrayerListener extends SimplifiedListener<Mob> {
17
18 private static final PrayerListener INSTANCE = new PrayerListener();
19
20 private PrayerListener() {}
21
22 @Override
23 public void hit(Mob attacker, Mob defender, Hit hit) {
24 if (attacker.prayer.isActive(Prayer.SMITE)) {
25 defender.skills.get(Skill.PRAYER).removeLevel(hit.getDamage() / 4);
26 defender.skills.refresh(Skill.PRAYER);
27 }
28 }
29
30 @Override
31 public void block(Mob attacker, Mob defender, Hit hit, CombatType combatType) {
32 int health = defender.getCurrentHealth() - hit.getDamage();
33 if (defender.prayer.isActive(Prayer.REDEMPTION) && health < defender.getMaximumHealth() / 10) {
34 Skill skill = defender.skills.get(Skill.PRAYER);
35 int amount = skill.getLevel() / 4;
36 defender.heal(amount);
37 defender.graphic(new Graphic(436, UpdatePriority.HIGH));
38 if (defender.isPlayer())
39 defender.getPlayer().playerAssistant.drainPrayer(skill.getLevel());
40 }
41 }
42
43 @Override
44 public void preDeath(Mob attacker, Mob defender, Hit hit) {
45 if (defender.prayer.isActive(Prayer.RETRIBUTION)) {
46 int max = defender.skills.getMaxLevel(Skill.PRAYER) / 4;
47 defender.graphic(new Graphic(437, UpdatePriority.HIGH));
48
49 if (!Area.inMulti(defender)) {
50 attacker.damage(new Hit(RandomUtils.inclusive(max), HitIcon.NONE));
51 } else {
52 CombatUtil.areaAction(defender, 3 * 3, 1, other -> {
53 int damage = RandomUtils.inclusive(max);
54 other.damage(new Hit(damage, HitIcon.NONE));
55 });
56 }
57 }
58 }
59
60 public static PrayerListener get() {
61 return INSTANCE;
62 }
63
64}