RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Justiciar.java
1package com.osroyale.game.world.entity.combat.strategy.npc.boss.magearena;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.Graphic;
5import com.osroyale.game.Projectile;
6import com.osroyale.game.UpdatePriority;
7import com.osroyale.game.task.impl.ForceMovementTask;
8import com.osroyale.game.world.World;
9import com.osroyale.game.world.entity.combat.CombatType;
10import com.osroyale.game.world.entity.combat.CombatUtil;
11import com.osroyale.game.world.entity.combat.attack.FightType;
12import com.osroyale.game.world.entity.combat.hit.CombatHit;
13import com.osroyale.game.world.entity.combat.hit.Hit;
14import com.osroyale.game.world.entity.combat.projectile.CombatProjectile;
15import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
16import com.osroyale.game.world.entity.combat.strategy.npc.MultiStrategy;
17import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
18import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
19import com.osroyale.game.world.entity.combat.strategy.npc.NpcRangedStrategy;
20import com.osroyale.game.world.entity.mob.Direction;
21import com.osroyale.game.world.entity.mob.Mob;
22import com.osroyale.game.world.entity.mob.npc.Npc;
23import com.osroyale.game.world.entity.mob.player.ForceMovement;
24import com.osroyale.game.world.pathfinding.path.SimplePathChecker;
25import com.osroyale.game.world.position.Position;
26import com.osroyale.net.packet.out.SendMessage;
27import com.osroyale.util.RandomUtils;
28import com.osroyale.util.Utility;
29
30import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
31import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
32
74
75public class Justiciar extends MultiStrategy {
76 private static Magic MAGIC = new Magic();
77 private static Melee MELEE = new Melee();
78 private static LightingRain LIGHTNING_RAIN = new LightingRain();
79 private static TeleGrab TELE_GRAB = new TeleGrab();
80
81 private static final CombatStrategy<Npc>[] FULL_STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), MAGIC,
82 TELE_GRAB, LIGHTNING_RAIN);
83 private static final CombatStrategy<Npc>[] MAGIC_STRATEGIES = createStrategyArray(MAGIC, MAGIC, MAGIC, TELE_GRAB,
84 LIGHTNING_RAIN);
85 private static final CombatStrategy<Npc>[] NON_MELEE = createStrategyArray(MAGIC, MELEE, MELEE, MAGIC, MAGIC,
86 TELE_GRAB, LIGHTNING_RAIN);
87
89 public Justiciar() {
90 currentStrategy = MAGIC;
91 currentStrategy = MELEE;
92 }
93
94 @Override
95 public boolean canAttack(Npc attacker, Mob defender) {
96 if (!currentStrategy.withinDistance(attacker, defender)) {
97 currentStrategy = randomStrategy(MAGIC_STRATEGIES);
98 currentStrategy = randomStrategy(NON_MELEE);
99 }
100 return currentStrategy.canAttack(attacker, defender);
101 }
102
103 @Override
104 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
105 currentStrategy.block(attacker, defender, hit, combatType);
106 defender.getCombat().attack(attacker);
107
108 if (!defender.getCombat().isAttacking()) {
109 defender.animate(new Animation(7962, UpdatePriority.VERY_HIGH));
110 defender.graphic(1196);
111 defender.graphic(481);
112 defender.speak("Night King, Lend me your powers for i am your faithful servant!");
113
114 CombatUtil.areaAction(attacker, 64, 18, mob -> {
115 if (RandomUtils.success(.65))
116 return;
117
118 World.schedule(2, () -> {
119 Position destination = Utility.randomElement(defender.boundaries);
120 World.sendGraphic(new Graphic(481), destination);
121 attacker.move(destination);
122
123 });
124 });
125 }
126 }
127
128 @Override
129 public void finishOutgoing(Npc attacker, Mob defender) {
130 currentStrategy.finishOutgoing(attacker, defender);
131 if (NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
132 currentStrategy = randomStrategy(FULL_STRATEGIES);
133 } else {
134 currentStrategy = randomStrategy(MAGIC_STRATEGIES);
135 }
136 }
137
138 @Override
139 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
140 return attacker.definition.getAttackDelay();
141 }
142
143 private static class Melee extends NpcRangedStrategy {
144
145 public Melee() {
146 super(CombatProjectile.getDefinition("EMPTY"));
147 }
148
149 @Override
150 public void hit(Npc attacker, Mob defender, Hit hit) {
151 }
152
153 @Override
154 public void attack(Npc attacker, Mob defender, Hit hit) {
155 }
156
157 @Override
158 public void start(Npc attacker, Mob defender, Hit[] hits) {
159
160 attacker.animate(new Animation(7962, UpdatePriority.VERY_HIGH));
161 Projectile projectile = new Projectile(162, 50, 80, 85, 25);
162 CombatHit hit = nextMeleeHit(attacker, defender, 21);
163 defender.graphic(163);
164 CombatUtil.areaAction(attacker, 64, 18, mob -> {
165 projectile.send(attacker, defender);
166 mob.damage(nextMagicHit(attacker, defender, 35));
167 });
168
169 /*
170 * if (Utility.random(0, 8) == 1) { attacker.animate(new Animation(7965,
171 * UpdatePriority.VERY_HIGH)); attacker.graphic(new Graphic(1296,
172 * UpdatePriority.VERY_HIGH)); attacker.heal(50);
173 * attacker.speak("Time To HEAL!"); System.out.println("It executes!");
174 *
175 * }
176 */
177
178 }
179
180 @Override
181 public CombatHit[] getHits(Npc attacker, Mob defender) {
182 CombatHit hit = nextRangedHit(attacker, defender, 38);
183 hit.setAccurate(false);
184 return new CombatHit[] { hit };
185 }
186
187 @Override
188 public int modifyAccuracy(Npc attacker, Mob defender, int roll) {
189 return roll + 50_000;
190 }
191
192 }
193
195 private static class Magic extends NpcMagicStrategy {
196 public Magic() {
197 super(CombatProjectile.getDefinition("EMPTY"));
198 }
199
200 @Override
201 public void hit(Npc attacker, Mob defender, Hit hit) {
202 }
203
204 @Override
205 public void attack(Npc attacker, Mob defender, Hit hit) {
206 }
207
208 @Override
209 public void start(Npc attacker, Mob defender, Hit[] hits) {
210 Projectile projectile = new Projectile(393, 50, 80, 85, 25);
211 attacker.animate(new Animation(7853, UpdatePriority.VERY_HIGH));
212 CombatUtil.areaAction(attacker, 64, 18, mob -> {
213 projectile.send(attacker, defender);
214 defender.graphic(157);
215 mob.damage(nextMagicHit(attacker, defender, 35));
216
217 });
218
219 if (Utility.random(0, 20) == 1) {
220 attacker.animate(new Animation(7965, UpdatePriority.VERY_HIGH));
221 attacker.graphic(new Graphic(1296, UpdatePriority.VERY_HIGH));
222 attacker.heal(130);
223 attacker.speak("Time To HEAL!");
224
225 }
226
227 }
228
229 @Override
230 public CombatHit[] getHits(Npc attacker, Mob defender) {
231 CombatHit hit = nextMagicHit(attacker, defender, 38);
232 hit.setAccurate(false);
233 return new CombatHit[] { hit };
234 }
235
236 @Override
237 public int modifyAccuracy(Npc attacker, Mob defender, int roll) {
238 return roll + 50_000;
239 }
240 }
241
242 private static class TeleGrab extends NpcMagicStrategy {
243 TeleGrab() {
244 super(CombatProjectile.getDefinition("EMPTY"));
245 }
246
247 @Override
248 public void hit(Npc attacker, Mob defender, Hit hit) {
249 }
250
251 @Override
252 public void attack(Npc attacker, Mob defender, Hit hit) {
253 }
254
255 @Override
256 public void start(Npc attacker, Mob defender, Hit[] hits) {
257
258 attacker.animate(new Animation(7964, UpdatePriority.VERY_HIGH));
259 Projectile projectile = new Projectile(1479, 50, 80, 85, 25);
260 projectile.send(attacker, defender);
261 defender.damage(new Hit(Utility.random(20, 50)));
262 attacker.speak("I AM A DECENDENT OF HELL!");
263
264
265 }
266
267
268
269 @Override
270 public CombatHit[] getHits(Npc attacker, Mob defender) {
271 CombatHit hit = nextMagicHit(attacker, defender, 38);
272 hit.setAccurate(false);
273 return new CombatHit[] { hit };
274 }
275 }
276
277 private static class LightingRain extends NpcMagicStrategy {
278 LightingRain() {
279 super(CombatProjectile.getDefinition("Vorkath Frozen Special"));
280 }
281
282 @Override
283 public void hit(Npc attacker, Mob defender, Hit hit) {
284 }
285
286 @Override
287 public void attack(Npc attacker, Mob defender, Hit hit) {
288 }
289
290 @Override
291 public void start(Npc attacker, Mob defender, Hit[] hits) {
292 attacker.animate(new Animation(7962, UpdatePriority.VERY_HIGH));
293 World.sendProjectile(attacker, defender, new Projectile(395, 46, 80, 43, 31));
294 World.schedule(1, () -> {
295 if (defender.isPlayer()) {
296 Position current = defender.getPosition();
297 Position best = Utility.findBestInside(defender, attacker);
298 int dx = current.getX() - best.getX();
299 int dy = current.getY() - best.getY();
300 int y = dy / (dx == 0 ? dy : dx);
301
302 Position destination = current.transform(dx, y);
303 if (SimplePathChecker.checkLine(defender, destination)) {
304 }
305 defender.damage(new Hit(Utility.random(1, 3)));
306 defender.interact(attacker);
307
308 }
309 });
310 }
311
312 @Override
313 public CombatHit[] getHits(Npc attacker, Mob defender) {
314 CombatHit hit = nextMagicHit(attacker, defender, 38);
315 hit.setAccurate(false);
316 return new CombatHit[] { hit };
317 }
318 }
319}
static void sendGraphic(Graphic graphic, Position position, int instance)
Definition World.java:305
static void schedule(Task task)
Definition World.java:284
static void areaAction(Mob mob, Consumer< Mob > action)
void move(Position position)
Definition Mob.java:377
void speak(String forceChat)
Definition Mob.java:164
Position transform(int diffX, int diffY, int diffZ)
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285