RuneHive-Game
Loading...
Searching...
No Matches
KingBlackDragonStrategy.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.npc.boss;
2
3import com.runehive.game.Animation;
4import com.runehive.game.UpdatePriority;
5import com.runehive.game.world.entity.combat.CombatType;
6import com.runehive.game.world.entity.combat.CombatUtil;
7import com.runehive.game.world.entity.combat.attack.FightType;
8import com.runehive.game.world.entity.combat.hit.CombatHit;
9import com.runehive.game.world.entity.combat.hit.Hit;
10import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
11import com.runehive.game.world.entity.combat.strategy.npc.MultiStrategy;
12import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
13import com.runehive.game.world.entity.combat.strategy.npc.impl.DragonfireStrategy;
14import com.runehive.game.world.entity.mob.Mob;
15import com.runehive.game.world.entity.mob.npc.Npc;
16
17import static com.runehive.game.world.entity.combat.CombatUtil.createStrategyArray;
18import static com.runehive.game.world.entity.combat.CombatUtil.randomStrategy;
19import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
20
21/** @author Michael | Chex */
23 private static final StabMelee STAB = new StabMelee();
24 private static final CrushMelee CRUSH = new CrushMelee();
25 private static final Dragonfire DRAGONFIRE = new Dragonfire();
26 private static final Poison POISON = new Poison();
27 private static final Freeze FREEZE = new Freeze();
28 private static final Shock SHOCK = new Shock();
29
30 private static final CombatStrategy<Npc>[] FULL_STRATEGIES = createStrategyArray(CRUSH, STAB, DRAGONFIRE, POISON, FREEZE, SHOCK);
31 private static final CombatStrategy<Npc>[] NON_MELEE = createStrategyArray(DRAGONFIRE, POISON, FREEZE, SHOCK);
32
34 currentStrategy = randomStrategy(NON_MELEE);
35 }
36
37 @Override
38 public boolean withinDistance(Npc attacker, Mob defender) {
39 if (!currentStrategy.withinDistance(attacker, defender)) {
40 currentStrategy = randomStrategy(NON_MELEE);
41 }
42 return currentStrategy.withinDistance(attacker, defender);
43 }
44
45 @Override
46 public boolean canAttack(Npc attacker, Mob defender) {
47 if (!currentStrategy.canAttack(attacker, defender)) {
48 currentStrategy = randomStrategy(NON_MELEE);
49 }
50 return currentStrategy.canAttack(attacker, defender);
51 }
52
53 @Override
54 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
55 currentStrategy.block(attacker, defender, hit, combatType);
56 defender.getCombat().attack(attacker);
57 }
58
59 @Override
60 public void finishOutgoing(Npc attacker, Mob defender) {
61 currentStrategy.finishOutgoing(attacker, defender);
62 if (STAB.withinDistance(attacker, defender)) {
63 currentStrategy = randomStrategy(FULL_STRATEGIES);
64 } else {
65 currentStrategy = randomStrategy(NON_MELEE);
66 }
67 }
68
69 @Override
70 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
71 return attacker.definition.getAttackDelay();
72 }
73
74 private static final class CrushMelee extends NpcMeleeStrategy {
75 private static final Animation ANIMATION = new Animation(80, UpdatePriority.HIGH);
76
77 @Override
78 public int getAttackDistance(Npc attacker, FightType fightType) {
79 return 1;
80 }
81
82 @Override
83 public Animation getAttackAnimation(Npc attacker, Mob defender) {
84 return ANIMATION;
85 }
86
87 @Override
88 public CombatHit[] getHits(Npc attacker, Mob defender) {
89 return new CombatHit[]{nextMeleeHit(attacker, defender)};
90 }
91 }
92
93 private static final class StabMelee extends NpcMeleeStrategy {
94 private static final Animation ANIMATION = new Animation(91, UpdatePriority.HIGH);
95
96 @Override
97 public int getAttackDistance(Npc attacker, FightType fightType) {
98 return 1;
99 }
100
101 @Override
102 public Animation getAttackAnimation(Npc attacker, Mob defender) {
103 return ANIMATION;
104 }
105
106 @Override
107 public CombatHit[] getHits(Npc attacker, Mob defender) {
108 return new CombatHit[]{nextMeleeHit(attacker, defender)};
109 }
110 }
111
112 private static final class Dragonfire extends DragonfireStrategy {
113
115 super(getDefinition("KBD fire"));
116 }
117
118 @Override
119 public int getAttackDistance(Npc attacker, FightType fightType) {
120 return 10;
121 }
122
123 @Override
124 public CombatHit[] getHits(Npc attacker, Mob defender) {
125 return new CombatHit[]{CombatUtil.generateDragonfire(attacker, defender, 65, true)};
126 }
127 }
128
129 private static final class Freeze extends DragonfireStrategy {
130
132 super(getDefinition("KBD freeze"));
133 }
134
135 @Override
136 public int getAttackDistance(Npc attacker, FightType fightType) {
137 return 10;
138 }
139
140 @Override
141 public CombatHit[] getHits(Npc attacker, Mob defender) {
142 return new CombatHit[]{CombatUtil.generateDragonfire(attacker, defender, 65, true)};
143 }
144 }
145
146 private static final class Shock extends DragonfireStrategy {
147
149 super(getDefinition("KBD shock"));
150 }
151
152 @Override
153 public int getAttackDistance(Npc attacker, FightType fightType) {
154 return 10;
155 }
156
157 @Override
158 public CombatHit[] getHits(Npc attacker, Mob defender) {
159 return new CombatHit[]{CombatUtil.generateDragonfire(attacker, defender, 65, true)};
160 }
161 }
162
163 private static final class Poison extends DragonfireStrategy {
164
166 super(getDefinition("KBD poison"));
167 }
168
169 @Override
170 public int getAttackDistance(Npc attacker, FightType fightType) {
171 return 10;
172 }
173
174 @Override
175 public CombatHit[] getHits(Npc attacker, Mob defender) {
176 return new CombatHit[]{CombatUtil.generateDragonfire(attacker, defender, 65, true)};
177 }
178 }
179
180}
Class that models a single animation used by an entity.
A collection of util methods and constants related to combat.
static CombatHit generateDragonfire(Mob attacker, Mob defender, int max, boolean prayer)
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
void block(Mob attacker, Npc defender, Hit hit, CombatType combatType)
Handles the mob class.
Definition Mob.java:66
Represents a non-player character in the in-game world.
Definition Npc.java:29
Combat< Npc > getCombat()
The combat of the mob.
Definition Npc.java:156
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.