RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
MutantTarn.java
1package com.osroyale.game.world.entity.combat.strategy.npc.boss;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.Projectile;
5import com.osroyale.game.UpdatePriority;
6import com.osroyale.game.world.World;
7import com.osroyale.game.world.entity.combat.attack.FightType;
8import com.osroyale.game.world.entity.combat.hit.CombatHit;
9import com.osroyale.game.world.entity.combat.hit.Hit;
10import com.osroyale.game.world.entity.combat.projectile.CombatProjectile;
11import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
12import com.osroyale.game.world.entity.combat.strategy.npc.MultiStrategy;
13import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
14import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
15import com.osroyale.game.world.entity.mob.Mob;
16import com.osroyale.game.world.entity.mob.npc.Npc;
17import com.osroyale.game.world.position.Position;
18import com.osroyale.util.RandomUtils;
19import com.osroyale.util.Utility;
20
21import java.util.Deque;
22import java.util.LinkedList;
23
24import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
25
63
64public class MutantTarn extends MultiStrategy {
65 private static final NpcMeleeStrategy MELEE = NpcMeleeStrategy.get();
66 private static final MagicAttack MAGIC = new MagicAttack();
67 private static final RangedAttack RANGED = new RangedAttack();
68
69 private static final FrozenSpecial FROZEN_SPECIAL = new FrozenSpecial();
70 private static final IceSpecial ICE_SPECIAL = new IceSpecial();
71
72 private static final CombatStrategy<Npc>[] FULL_STRATEGIES = createStrategyArray(MELEE, MAGIC, RANGED);
73 private static final CombatStrategy<Npc>[] NON_MELEE = createStrategyArray(MAGIC, RANGED);
74 private final CombatStrategy<Npc>[] SPECIALS = createStrategyArray(ICE_SPECIAL, FROZEN_SPECIAL);
75
76 private final Deque<CombatStrategy<Npc>> strategyQueue = new LinkedList<>();
77 private int specialIndex;
78
79 public MutantTarn() {
80 currentStrategy = MELEE;
81 }
82
83 @Override
84 public void init(Npc attacker, Mob defender) {
85 if (strategyQueue.isEmpty()) {
86 for (int index = 0; index < 6; index++) {
87 strategyQueue.add(RandomUtils.random(FULL_STRATEGIES));
88 }
89 strategyQueue.add(SPECIALS[specialIndex++ % SPECIALS.length]);
90 }
91 currentStrategy = strategyQueue.poll();
92 }
93
94 @Override
95 public boolean canAttack(Npc attacker, Mob defender) {
96 if (currentStrategy == MELEE && !MELEE.canAttack(attacker, defender)) {
97 currentStrategy = RandomUtils.random(NON_MELEE);
98 }
99 return currentStrategy.canAttack(attacker, defender);
100 }
101
102 @Override
103 public boolean withinDistance(Npc attacker, Mob defender) {
104 if (currentStrategy == MELEE && !MELEE.withinDistance(attacker, defender)) {
105 currentStrategy = RandomUtils.random(NON_MELEE);
106 }
107 return currentStrategy.canAttack(attacker, defender);
108 }
109
110 private static class IceSpecial extends NpcMagicStrategy {
111 IceSpecial() {
112 super(CombatProjectile.getDefinition("EMPTY"));
113 }
114
115 @Override
116 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
117 return 30;
118 }
119
120 @Override
121 public CombatHit[] getHits(Npc attacker, Mob defender) {
122 CombatHit combatHit = nextMagicHit(attacker, defender, 0);
123 combatHit.setAccurate(true);
124 combatHit.setDamage(-1);
125 return new CombatHit[] { combatHit };
126 }
127 }
128
129 private static class RangedAttack extends NpcMagicStrategy {
130
131 RangedAttack() {
132 super(CombatProjectile.getDefinition("Mutant Tarn Ranged"));
133 }
134
135 @Override
136 public Animation getAttackAnimation(Npc attacker, Mob defender) {
137 return new Animation(5617, UpdatePriority.HIGH);
138 }
139
140 @Override
141 public CombatHit[] getHits(Npc attacker, Mob defender) {
142 return new CombatHit[] { nextRangedHit(attacker, defender, 32) };
143 }
144 }
145
146 private static class MagicAttack extends NpcMagicStrategy {
147
148 MagicAttack() {
149 super(CombatProjectile.getDefinition("Shadow Rush"));
150 }
151
152 @Override
153 public Animation getAttackAnimation(Npc attacker, Mob defender) {
154 return new Animation(5617, UpdatePriority.HIGH);
155 }
156
157 @Override
158 public CombatHit[] getHits(Npc attacker, Mob defender) {
159 return new CombatHit[] { nextRangedHit(attacker, defender, 32) };
160 }
161
162 }
163
164 private static class FrozenSpecial extends NpcMagicStrategy {
165 private final Projectile PROJECTILE = new Projectile(1324, 5, 85, 85, 25);
166
167 FrozenSpecial() {
168 super(CombatProjectile.getDefinition("Mutant Frozen Special"));
169 }
170
171 @Override
172 public Animation getAttackAnimation(Npc attacker, Mob defender) {
173 return new Animation(5617, UpdatePriority.HIGH);
174 }
175
176 @Override
177 public void hit(Npc attacker, Mob defender, Hit hit) {
178 World.schedule(4, () -> {
179 int randomHit = Utility.random(1, 30);
180 Npc shadow = new Npc(7586, new Position(2524, 4655, 0)) {
181
182 @Override
183 public void appendDeath() {
184 super.appendDeath();
185
186 }
187 };
188 shadow.register();
189 shadow.walkTo(defender, () -> {
190 // World.sendGraphic(new Graphic(1460, true), shadow.getPosition());
191 defender.damage(new Hit(randomHit * shadow.getCurrentHealth() / shadow.getMaximumHealth()));
192 defender.graphic(287);
193 defender.graphic(910);
194 shadow.unregister();
195 });
196 });
197
198 }
199
200 @Override
201 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
202 return 15;
203 }
204
205 @Override
206 public CombatHit[] getHits(Npc attacker, Mob defender) {
207 CombatHit combatHit = nextMagicHit(attacker, defender, -1);
208 combatHit.setAccurate(false);
209 return new CombatHit[] { combatHit };
210 }
211 }
212}
static void schedule(Task task)
Definition World.java:284