RuneHive-Game
Loading...
Searching...
No Matches
Alkahrid.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.attack.listener.npc;
2
3import com.runehive.game.world.entity.combat.CombatType;
4import com.runehive.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
5import com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener;
6import com.runehive.game.world.entity.combat.hit.Hit;
7import com.runehive.game.world.entity.mob.Mob;
8import com.runehive.game.world.entity.mob.npc.Npc;
9import com.runehive.game.world.entity.mob.player.Player;
10import com.runehive.util.Utility;
11
12/** @author Daniel */
13@NpcCombatListenerSignature(npcs = {3103})
14public class Alkahrid extends SimplifiedListener<Npc> {
15
16 @Override
17 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
18 if (!attacker.isPlayer())
19 return;
20
21 int currentHealth = defender.getCurrentHealth();
22 int maximumHealth = defender.getMaximumHealth();
23
24 if (currentHealth == maximumHealth) {
25 Player player = attacker.getPlayer();
26
27 for (Npc monster : player.viewport.getNpcsInViewport()) {
28 if (monster.id != 3103) continue;
29 if (monster.equals(defender)) continue;
30 if (monster.getCombat().inCombat() && monster.getCombat().getDefender() != null) continue;
31 if (!Utility.within(attacker.getPosition(), monster.getPosition(), 10)) continue;
32 monster.speak("Brother, I will help thee with this infidel!");
33 monster.getCombat().attack(attacker);
34 }
35 }
36 }
37}
void block(Mob attacker, Npc defender, Hit hit, CombatType combatType)
Definition Alkahrid.java:17
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
Handles the mob class.
Definition Mob.java:66
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
List< Npc > getNpcsInViewport()
The collection of npcs in this viewport.
Represents a non-player character in the in-game world.
Definition Npc.java:29
This class represents a character controlled by a player.
Definition Player.java:125
Handles miscellaneous methods.
Definition Utility.java:27
static boolean within(Position source, Position target, int distance)
Definition Utility.java:676