RuneHive-Game
Loading...
Searching...
No Matches
Dessourt.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.attack.listener.npc;
2
3import com.runehive.game.Animation;
4import com.runehive.game.UpdatePriority;
5import com.runehive.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
6import com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener;
7import com.runehive.game.world.entity.combat.hit.CombatHit;
8import com.runehive.game.world.entity.combat.hit.Hit;
9import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
10import com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
11import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
12import com.runehive.game.world.entity.mob.Mob;
13import com.runehive.game.world.entity.mob.npc.Npc;
14
15import static com.runehive.game.world.entity.combat.CombatUtil.createStrategyArray;
16import static com.runehive.game.world.entity.combat.CombatUtil.randomStrategy;
17import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
18
19/**
20 * @author Daniel
21 */
22@NpcCombatListenerSignature(npcs = { 4883 })
23public class Dessourt extends SimplifiedListener<Npc> {
24
25 private static MagicAttack MAGIC;
27
28 static {
29 try {
30 MAGIC = new MagicAttack();
31 STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), MAGIC);
32 } catch(Exception e) {
33 e.printStackTrace();
34 }
35 }
36
37 @Override
38 public boolean canAttack(Npc attacker, Mob defender) {
39 if(!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
40 attacker.setStrategy(MAGIC);
41 }
42 return attacker.getStrategy().canAttack(attacker, defender);
43 }
44
45 @Override
46 public void start(Npc attacker, Mob defender, Hit[] hits) {
47 if(!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
48 attacker.setStrategy(MAGIC);
49 } else {
50 attacker.setStrategy(randomStrategy(STRATEGIES));
51 }
52 }
53
54 @Override
55 public void hit(Npc attacker, Mob defender, Hit hit) {
56 super.hit(attacker, defender, hit);
57 attacker.speak("Hssssssssssssssss");
58 }
59
60 private static class MagicAttack extends NpcMagicStrategy {
61 private MagicAttack() {
62 super(getDefinition("Toktz-xil-ul"));
63 }
64
65 @Override
66 public Animation getAttackAnimation(Npc attacker, Mob defender) {
67 return new Animation(3508, UpdatePriority.HIGH);
68 }
69
70 @Override
71 public CombatHit[] getHits(Npc attacker, Mob defender) {
72 CombatHit combatHit = nextMagicHit(attacker, defender, combatProjectile);
73 combatHit.setAccurate(true);
74 return new CombatHit[] { combatHit };
75 }
76 }
77}
Class that models a single animation used by an entity.
void start(Npc attacker, Mob defender, Hit[] hits)
Definition Dessourt.java:46
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
final CombatHit nextMagicHit(T attacker, Mob defender)
Handles the mob class.
Definition Mob.java:66
void speak(String forceChat)
Sets the mob's forced chat.
Definition Mob.java:127
Represents a non-player character in the in-game world.
Definition Npc.java:29
void setStrategy(CombatStrategy< Npc > strategy)
Definition Npc.java:212
CombatStrategy< Npc > getStrategy()
The combat strategy of the mob.
Definition Npc.java:161
Represents different priorities for updating.