RuneHive-Game
Loading...
Searching...
No Matches
GodwarsListener.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl.godwars;
2
3import com.runehive.content.activity.ActivityListener;
4import com.runehive.game.world.entity.combat.CombatType;
5import com.runehive.game.world.entity.combat.hit.Hit;
6import com.runehive.game.world.entity.mob.Mob;
7import com.runehive.game.world.entity.mob.npc.Npc;
8
9import static com.runehive.content.activity.impl.godwars.GodwarsActivity.*;
10
11/**
12 * The combat listener for the god wars activity.
13 *
14 * @author Daniel
15 */
16public class GodwarsListener extends ActivityListener<GodwarsActivity> {
17
21
22 @Override
23 public boolean canAttack(Mob attacker, Mob defender) {
24 System.out.println(defender);
25 if (!attacker.isPlayer() && !defender.isNpc()) {
26 return super.canAttack(attacker, defender);
27 }
28
29 Npc npc = defender.getNpc();
30
31 if (npc.id == 3166 || npc.id == 3167 || npc.id == 3168 || npc.id == 3172 || npc.id == 3176 || npc.id == 3183) {
32 if (attacker.getStrategy().getCombatType().equals(CombatType.MELEE)) {
33 attacker.getPlayer().message("You can't attack Armadyl with melee!");
34 return false;
35 }
36 }
37
38 return super.canAttack(attacker, defender);
39 }
40
41 @Override
42 public void onKill(Mob attacker, Mob defender, Hit hit) {
43 if (defender.isNpc()) {
44 Npc npc = defender.getNpc();
45 if (npc.npcAssistant.isArmadyl()) {
46 activity.increment(ARMADYL);
47 } else if (npc.npcAssistant.isBandos()) {
48 activity.increment(BANDOS);
49 } else if (npc.npcAssistant.isSaradomin()) {
50 activity.increment(SARADOMIN);
51 } else if (npc.npcAssistant.isZamorak()) {
52 activity.increment(ZAMORAK);
53 }
54 }
55 }
56}
void hit(Mob attacker, Mob defender, Hit hit)
ActivityListener(T activity)
Constructs a new ActivityListener for a activity.
void onKill(Mob attacker, Mob defender, Hit hit)
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
Handles the mob class.
Definition Mob.java:66
abstract< T extends Mob > CombatStrategy<? super T > getStrategy()
The combat strategy of the mob.
final boolean isNpc()
Check if an entity is an npc.
Definition Mob.java:550
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
Represents a non-player character in the in-game world.
Definition Npc.java:29