RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
StoneGuardian.java
1package com.osroyale.game.world.entity.combat.strategy.npc.boss;
2
3import com.osroyale.content.bloodmoney.BloodMoneyChest;
4import com.osroyale.game.Animation;
5import com.osroyale.game.Graphic;
6import com.osroyale.game.Projectile;
7import com.osroyale.game.UpdatePriority;
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.Mob;
21import com.osroyale.game.world.entity.mob.data.LockType;
22import com.osroyale.game.world.entity.mob.npc.Npc;
23import com.osroyale.game.world.entity.mob.player.Player;
24import com.osroyale.game.world.entity.mob.prayer.Prayer;
25import com.osroyale.game.world.position.Position;
26import com.osroyale.util.RandomUtils;
27import com.osroyale.util.Utility;
28
29import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
30import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
31
68
69public class StoneGuardian extends MultiStrategy {
70
71 private static final Integer[] GUARDIAN_IDS = {8064, 8065, 8066};
72 private final static Transform TRANSFORM = new Transform();
73 private final static NpcMeleeStrategy MELEE = NpcMeleeStrategy.get();
74 private final static Magic MAGIC = new Magic();
75 private final static Ranged RANGED = new Ranged();
76 private static final BarrageAttack BARRAGE = new BarrageAttack();
77 private final static PrayerAttack PRAYER = new PrayerAttack();
78 private final static BoomAttack BOOM = new BoomAttack();
79
80 private static int nextForm(int id) {
81 return RandomUtils.randomExclude(GUARDIAN_IDS, id);
82 }
83
84 @Override
85 public boolean canAttack(Npc attacker, Mob defender) {
86 if (!attacker.attributes.has("STONE_GUARDIAN_ATTACK")) {
87 attacker.attributes.put("STONE_GUARDIAN_ATTACK", 0);
88 }
89
90 if (!attacker.attributes.has("STONE_GUARDIAN_BLOCK")) {
91 attacker.attributes.put("STONE_GUARDIAN_BLOCK", 0);
92 }
93 int attackCount = attacker.attributes.get("STONE_GUARDIAN_ATTACK", Integer.class);
94 int blockCount = attacker.attributes.get("STONE_GUARDIAN_BLOCK", Integer.class);
95
96 if (attackCount >= 10 || blockCount >= 10) {
97 currentStrategy = TRANSFORM;
98 return true;
99 }
100
101 switch (attacker.id) {
102 case 8064: {
103 CombatStrategy<Npc>[] SPECIALS = createStrategyArray(MELEE, PRAYER, BARRAGE, BOOM);
104 currentStrategy = randomStrategy(SPECIALS);
105 break;
106 }
107 case 8065: {
108 CombatStrategy<Npc>[] SPECIALS = createStrategyArray(RANGED, PRAYER, BARRAGE, BOOM);
109 currentStrategy = randomStrategy(SPECIALS);
110 break;
111 }
112 case 8066: {
113 CombatStrategy<Npc>[] SPECIALS = createStrategyArray(MAGIC, PRAYER, BARRAGE, BOOM);
114 currentStrategy = randomStrategy(SPECIALS);
115 break;
116 }
117 }
118
119 return currentStrategy.canAttack(attacker, defender);
120 }
121
122 @Override
123 public void preDeath(Mob attacker, Npc defender, Hit hit) {
124 defender.speak("NOOOOOOOOOO!!!");
125 super.preDeath(attacker, defender, hit);
126 World.schedule(5, () -> {
127 defender.unregister();
129 });
130 }
131
132 @Override
133 public void hitsplat(Npc attacker, Mob defender, Hit hit) {
134 super.hitsplat(attacker, defender, hit);
135 int count = attacker.attributes.get("STONE_GUARDIAN_ATTACK", Integer.class);
136 attacker.attributes.put("STONE_GUARDIAN_ATTACK", count + 1);
137 }
138
139 @Override
140 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
141 super.block(attacker, defender, hit, combatType);
142
143 if (!attacker.attributes.has("STON_GUARDIAN_BLOCK")) {
144 attacker.attributes.put("STON_GUARDIAN_BLOCK", 0);
145 return;
146 }
147
148 int count = attacker.attributes.get("STON_GUARDIAN_BLOCK", Integer.class);
149 attacker.attributes.put("STON_GUARDIAN_BLOCK", count + 1);
150
151 }
152
153 @Override
154 public int modifyAccuracy(Npc attacker, Mob defender, int roll) {
155 return roll + 10000;
156 }
157
158 @Override
159 public int modifyDefensive(Mob attacker, Npc defender, int roll) {
160 return roll + 500;
161 }
162
164 private static class Transform extends NpcMagicStrategy {
165 Transform() {
166 super(CombatProjectile.getDefinition("EMPTY"));
167 }
168
169 @Override
170 public void hit(Npc attacker, Mob defender, Hit hit) {
171 }
172
173 @Override
174 public void attack(Npc attacker, Mob defender, Hit hit) {
175 }
176
177 @Override
178 public void start(Npc attacker, Mob defender, Hit[] hits) {
179 attacker.speak("AH!!! Give me a minute here...");
180 attacker.animate(new Animation(7924, UpdatePriority.VERY_HIGH));
181 attacker.graphic(new Graphic(1237, UpdatePriority.VERY_HIGH));
182 attacker.attributes.set("STONE_GUARDIAN_ATTACK", 0);
183 attacker.attributes.set("STONE_GUARDIAN_BLOCK", 0);
184 attacker.damageImmunity.reset(3_000);
185
186 World.schedule(5, () -> {
187 attacker.animate(new Animation(7927, UpdatePriority.VERY_HIGH));
188 attacker.speak("That feels better!");
189 attacker.transform(nextForm(attacker.id));
190 });
191 }
192
193 @Override
194 public CombatHit[] getHits(Npc attacker, Mob defender) {
195 CombatHit hit = nextMagicHit(attacker, defender, -1);
196 hit.setAccurate(false);
197 return new CombatHit[]{hit};
198 }
199
200 @Override
201 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
202 return 8;
203 }
204 }
205
206 private static class BoomAttack extends NpcMagicStrategy {
207 BoomAttack() {
208 super(CombatProjectile.getDefinition("EMPTY"));
209 }
210
211 @Override
212 public void hit(Npc attacker, Mob defender, Hit hit) {
213 }
214
215 @Override
216 public void attack(Npc attacker, Mob defender, Hit hit) {
217 }
218
219 @Override
220 public void start(Npc attacker, Mob defender, Hit[] hits) {
221 attacker.speak("BOOM!");
222 attacker.animate(new Animation(7923, UpdatePriority.VERY_HIGH));
223 Position target = defender.getPosition();
224 Projectile projectile = new Projectile(1242, 10, 80, 45, 31);
225 projectile.send(attacker, target);
226
227 World.schedule(3, () -> {
228 for (Player player : attacker.getRegion().getPlayers(attacker.getHeight())) {
229 if (player != null && !player.isDead() && player.getPosition().equals(target)) {
230 int damage = player.prayer.isActive(Prayer.PROTECT_FROM_MELEE) ? 30 : 60;
231 player.writeDamage(new Hit(Utility.random(15, damage)));
232 player.graphic(new Graphic(659, false, UpdatePriority.VERY_HIGH));
233 }
234 }
235 });
236 }
237
238 @Override
239 public CombatHit[] getHits(Npc attacker, Mob defender) {
240 CombatHit hit = nextMagicHit(attacker, defender, -1);
241 hit.setAccurate(false);
242 return new CombatHit[]{hit};
243 }
244
245 @Override
246 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
247 return 4;
248 }
249 }
250
252 private static class BarrageAttack extends NpcMagicStrategy {
253 BarrageAttack() {
254 super(CombatProjectile.getDefinition("EMPTY"));
255 }
256
257 @Override
258 public void hit(Npc attacker, Mob defender, Hit hit) {
259 }
260
261 @Override
262 public void attack(Npc attacker, Mob defender, Hit hit) {
263 }
264
265 @Override
266 public void start(Npc attacker, Mob defender, Hit[] hits) {
267 attacker.speak("GET READY FOR A CHILL!!");
268 attacker.animate(new Animation(7923, UpdatePriority.VERY_HIGH));
269 Projectile projectile = new Projectile(1456, 10, 65, 45, 31);
270
271 CombatUtil.areaAction(defender, mob -> {
272 projectile.send(attacker, defender);
273
274 World.schedule(2, () -> {
275 if (mob.isPlayer() && !mob.locking.locked(LockType.FREEZE)) {
276 mob.getPlayer().message(true, "The stone guardian has frozen you!");
277 mob.graphic(new Graphic(369, false, UpdatePriority.VERY_HIGH));
278 mob.damage(nextMagicHit(attacker, defender, 30));
279 mob.locking.lock(25, LockType.FREEZE);
280 mob.graphic(new Graphic(1457, true, UpdatePriority.VERY_HIGH));
281 } else {
282 mob.writeDamage(new Hit(0));
283 }
284 });
285 });
286 }
287
288 @Override
289 public CombatHit[] getHits(Npc attacker, Mob defender) {
290 CombatHit hit = nextMagicHit(attacker, defender, -1);
291 hit.setAccurate(false);
292 return new CombatHit[]{hit};
293 }
294
295 @Override
296 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
297 return 4;
298 }
299 }
300
302 private static class PrayerAttack extends NpcMagicStrategy {
303 PrayerAttack() {
304 super(CombatProjectile.getDefinition("EMPTY"));
305 }
306
307 @Override
308 public void hit(Npc attacker, Mob defender, Hit hit) {
309 }
310
311 @Override
312 public void attack(Npc attacker, Mob defender, Hit hit) {
313 }
314
315 @Override
316 public void start(Npc attacker, Mob defender, Hit[] hits) {
317 attacker.speak("YOUR GODS CAN'T SAVE YOU!");
318 attacker.animate(new Animation(7923, UpdatePriority.VERY_HIGH));
319 Projectile projectile = new Projectile(1471, 10, 65, 45, 31);
320
321 CombatUtil.areaAction(defender, mob -> {
322 projectile.send(attacker, defender);
323
324 World.schedule(2, () -> {
325 if (mob.isPlayer() && mob.prayer.hasOverhead()) {
326 mob.prayer.deactivateOverhead();
327 mob.writeDamage(new Hit(Utility.random(15, 20)));
328 mob.getPlayer().message("The stone guardian has deactivated your overhead prayers!");
329 mob.graphic(new Graphic(1473, true, UpdatePriority.VERY_HIGH));
330 } else {
331 mob.writeDamage(new Hit(0));
332 }
333 });
334
335 });
336 }
337
338 @Override
339 public CombatHit[] getHits(Npc attacker, Mob defender) {
340 CombatHit hit = nextMagicHit(attacker, defender, -1);
341 hit.setAccurate(false);
342 return new CombatHit[]{hit};
343 }
344
345 @Override
346 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
347 return 4;
348 }
349 }
350
352 private static class Magic extends NpcMagicStrategy {
353 public Magic() {
354 super(CombatProjectile.getDefinition("Stone guardian magic"));
355 }
356
357 @Override
358 public CombatHit[] getHits(Npc attacker, Mob defender) {
359 CombatHit hit = nextMagicHit(attacker, defender, 20);
360 hit.setAccurate(true);
361 return new CombatHit[]{hit};
362 }
363 }
364
366 private static class Ranged extends NpcRangedStrategy {
367 public Ranged() {
368 super(CombatProjectile.getDefinition("Stone guardian ranged"));
369 }
370
371 @Override
372 public CombatHit[] getHits(Npc attacker, Mob defender) {
373 CombatHit hit = nextMagicHit(attacker, defender, 20);
374 hit.setAccurate(true);
375 return new CombatHit[]{hit};
376 }
377 }
378}
static void schedule(Task task)
Definition World.java:284
static void areaAction(Mob mob, Consumer< Mob > action)
void speak(String forceChat)
Definition Mob.java:164
Collection< Player > getPlayers(int height)
Definition Region.java:142