RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
FightCavesListener.java
1package com.osroyale.content.activity.impl.fightcaves;
2
3import com.osroyale.game.world.entity.combat.CombatType;
4import com.osroyale.game.world.entity.combat.hit.Hit;
5import com.osroyale.game.world.entity.mob.Mob;
6import com.osroyale.game.world.entity.mob.npc.Npc;
7import com.osroyale.content.activity.ActivityListener;
8import com.osroyale.util.Utility;
9
15public class FightCavesListener extends ActivityListener<FightCaves> {
16
18 public FightCavesListener(FightCaves minigame) {
19 super(minigame);
20 }
21
22 @Override
23 public void block(Mob attacker, Mob defender, Hit hit, CombatType combatType) {
24 if (!defender.isNpc())
25 return;
26 if (defender.id != 3127)
27 return;
28 if (Utility.getPercentageAmount(defender.getCurrentHealth(), defender.getMaximumHealth()) > 49)
29 return;
30 for (Npc npc : activity.npcs) {
31 if (npc.id == 3128 && (npc.getCombat().inCombatWith(attacker) || Utility.withinDistance(defender, npc, 5))) {
32 defender.heal(1);
33 }
34 }
35 }
36
37 @Override
38 public void onDeath(Mob attacker, Mob defender, Hit hit) {
39 activity.handleDeath(defender);
40 }
41}
static double getPercentageAmount(int progress, int total)
Definition Utility.java:73