RuneHive-Game
Loading...
Searching...
No Matches
KrakenActivityListener.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl.kraken;
2
3import com.runehive.content.activity.ActivityListener;
4import com.runehive.game.world.Interactable;
5import com.runehive.game.world.entity.combat.attack.FightType;
6import com.runehive.game.world.entity.combat.hit.Hit;
7import com.runehive.game.world.entity.mob.Mob;
8import com.runehive.game.world.position.Position;
9import com.runehive.net.packet.out.SendMessage;
10import com.runehive.util.Utility;
11
12/**
13 * Created by Daniel on 2017-09-17.
14 */
15public class KrakenActivityListener extends ActivityListener<KrakenActivity> {
16
18 super(minigame);
19 }
20
21 @Override
22 public boolean withinDistance(Mob attacker, Mob defender) {
23 if (!attacker.isPlayer())
24 return true;
25 FightType fightType = attacker.getCombat().getFightType();
26 int distance = attacker.getStrategy().getAttackDistance(attacker, fightType);
27 Interactable kraken = Interactable.create(new Position(2278, 10035, attacker.getHeight()), 4, 4);
28 return Utility.getDistance(attacker, kraken) <= distance
29 && attacker.getStrategy().withinDistance(attacker, activity.kraken);
30 }
31
32 @Override
33 public boolean canAttack(Mob attacker, Mob defender) {
34 if (attacker.isPlayer() && defender.isNpc() && defender.getNpc().id == 496 && activity.count != 4) {
35 attacker.getPlayer()
36 .send(new SendMessage("You must activate all four whirlpools before awakening the Kraken."));
37 return false;
38 }
39 return activity.kraken == null || !activity.kraken.isDead();
40 }
41
42 @Override
43 public void hit(Mob attacker, Mob defender, Hit hit) {
44 if (!attacker.isPlayer() && !defender.isNpc()) {
45 return;
46 }
47
48 if (attacker.isPlayer() && defender.getNpc().id == 493) {
49 activity.transform(defender.getNpc(), 5535);
50 } else if (attacker.isPlayer() && defender.getNpc().id == 496) {
51 activity.transform(defender.getNpc(), 494);
52 }
53 }
54
55 @Override
56 public void onDeath(Mob attacker, Mob defender, Hit hit) {
57 }
58}
ActivityListener(T activity)
Constructs a new ActivityListener for a activity.
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.
abstract Combat<? extends Mob > getCombat()
The combat 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 single tile on the game world.
Definition Position.java:14
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static int getDistance(Interactable source, Position target)
Definition Utility.java:363
The enumerated type whose elements represent the fighting types.
An object implementing Interactable has uses.
static Interactable create(Position position)
Creates a new instance of an Interactable.