RuneHive-Game
Loading...
Searching...
No Matches
ChromaticDragon.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.attack.listener.npc.dragon;
2
3import com.runehive.game.Animation;
4import com.runehive.game.UpdatePriority;
5import com.runehive.game.world.entity.combat.attack.FightType;
6import com.runehive.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
7import com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener;
8import com.runehive.game.world.entity.combat.hit.CombatHit;
9import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
10import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
11import com.runehive.game.world.entity.combat.strategy.npc.impl.DragonfireStrategy;
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/** @author Michael | Chex */
21 /* Lava */ 6593,
22 /* Green */ 260, 261, 262, 263, 264, 7868, 7869, 7870,
23 /* Red */ 247, 248, 249, 250, 251,
24 /* Blue */ 265, 4385, 5878, 5879, 5880, 5881, 5882, 267,
25 /* Black */ 252, 253, 254, 255, 256, 257, 258, 259, 2642, 6500, 6501, 6502, 6636, 6652
26})
30
31 static {
32 try {
33 DRAGONFIRE = new DragonfireStrategy(getDefinition("Chromatic dragonfire"));
34 STRATEGIES = createStrategyArray(new CrushMelee(), new StabMelee(), DRAGONFIRE);
35 } catch (Exception e) {
36 e.printStackTrace();
37 }
38 }
39
40 @Override
41 public boolean canAttack(Npc attacker, Mob defender) {
42 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
43 attacker.setStrategy(DRAGONFIRE);
44 }
45 return attacker.getStrategy().canAttack(attacker, defender);
46 }
47
48 @Override
49 public void finishOutgoing(Npc attacker, Mob defender) {
50 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
51 attacker.setStrategy(DRAGONFIRE);
52 } else {
53 attacker.setStrategy(randomStrategy(STRATEGIES));
54 }
55 }
56
57 private static final class CrushMelee extends NpcMeleeStrategy {
58 private static final Animation ANIMATION = new Animation(80, UpdatePriority.HIGH);
59
60 @Override
61 public int getAttackDistance(Npc attacker, FightType fightType) {
62 return 1;
63 }
64
65 @Override
66 public Animation getAttackAnimation(Npc attacker, Mob defender) {
67 return ANIMATION;
68 }
69
70 @Override
71 public CombatHit[] getHits(Npc attacker, Mob defender) {
72 return new CombatHit[]{nextMeleeHit(attacker, defender)};
73 }
74 }
75
76 private static final class StabMelee extends NpcMeleeStrategy {
77 private static final Animation ANIMATION = new Animation(91, UpdatePriority.HIGH);
78
79 @Override
80 public int getAttackDistance(Npc attacker, FightType fightType) {
81 return 1;
82 }
83
84 @Override
85 public Animation getAttackAnimation(Npc attacker, Mob defender) {
86 return ANIMATION;
87 }
88
89 @Override
90 public CombatHit[] getHits(Npc attacker, Mob defender) {
91 return new CombatHit[]{nextMeleeHit(attacker, defender)};
92 }
93 }
94
95}
Class that models a single animation used by an entity.
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
Handles the mob class.
Definition Mob.java:66
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.
The enumerated type whose elements represent the fighting types.