1package com.osroyale.game.world.entity.combat.strategy.npc.boss;
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.Task;
8import com.osroyale.game.world.World;
9import com.osroyale.game.world.entity.combat.attack.FightType;
10import com.osroyale.game.world.entity.combat.hit.CombatHit;
11import com.osroyale.game.world.entity.combat.hit.Hit;
12import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
13import com.osroyale.game.world.entity.combat.strategy.npc.MultiStrategy;
14import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
15import com.osroyale.game.world.entity.combat.strategy.npc.NpcRangedStrategy;
16import com.osroyale.game.world.entity.mob.Mob;
17import com.osroyale.game.world.entity.mob.npc.Npc;
18import com.osroyale.game.world.position.Position;
19import com.osroyale.util.RandomUtils;
20import com.osroyale.util.Utility;
24import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
25import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
26import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
61public class Hydra
extends MultiStrategy {
62 private static final Magic MAGIC =
new Magic();
63 private static final Ranged RANGED =
new Ranged();
64 private static final CombatStrategy<Npc>[] STRATEGIES = createStrategyArray(MAGIC, RANGED);
65 private int attackCount = 0;
68 this.currentStrategy = randomStrategy(STRATEGIES);
71 private CombatStrategy getNextStrategy() {
72 return RandomUtils.randomExclude(STRATEGIES, currentStrategy);
76 public void hit(
Npc attacker,
Mob defender,
Hit hit) {
77 super.hit(attacker, defender, hit);
79 if (attackCount > 2) {
81 poisonAttack(attacker, defender);
83 currentStrategy = getNextStrategy();
88 private static void poisonAttack(
Npc attacker,
Mob defender) {
90 List<Position> positions = Arrays.asList(boundaries);
91 Collections.shuffle(positions);
95 attacker.attributes.set(
"HYDRA_POISON", Boolean.TRUE);
98 World.
schedule(poisonTask(attacker, defender, positions.get(0)));
99 World.
schedule(poisonTask(attacker, defender, positions.get(1)));
108 protected void execute() {
111 }
else if (count == 18) {
112 attacker.attributes.set(
"HYDRA_POISON", Boolean.FALSE);
116 if (count % 2 == 0 && defender.
getPosition().equals(position)) {
118 if (defender.getPlayer().getPoisonImmunity().get() > 0) {
119 damage =
Utility.random(1, 3,
true);
120 defender.getPlayer().message(
"Your poison immunity reduces the damage taken from the acidic pool.");
122 defender.writeDamage(
new Hit(damage));
129 private static class Magic
extends NpcMagicStrategy {
133 super(getDefinition(
"Hydra Magic"));
138 CombatHit combatHit = nextMagicHit(attacker, defender, 22);
139 combatHit.setAccurate(
true);
149 public int getAttackDistance(
Npc attacker,
FightType fightType) {
154 private static class Ranged
extends NpcRangedStrategy {
158 super(getDefinition(
"Hydra Ranged"));
163 return new CombatHit[]{nextRangedHit(attacker, defender, 22)};
172 public int getAttackDistance(
Npc attacker,
FightType fightType) {
static void sendGraphic(Graphic graphic, Position position, int instance)
static void schedule(Task task)
static void sendProjectile(Projectile projectile, Position position, int instance, int lock, byte offsetX, byte offsetY)