RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Vetion.java
1package com.osroyale.game.world.entity.combat.strategy.npc.boss;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.Graphic;
5import com.osroyale.game.UpdatePriority;
6import com.osroyale.game.task.Task;
7import com.osroyale.game.world.World;
8import com.osroyale.game.world.entity.combat.CombatType;
9import com.osroyale.game.world.entity.combat.CombatUtil;
10import com.osroyale.game.world.entity.combat.attack.FightType;
11import com.osroyale.game.world.entity.combat.hit.CombatHit;
12import com.osroyale.game.world.entity.combat.hit.Hit;
13import com.osroyale.game.world.entity.combat.hit.HitIcon;
14import com.osroyale.game.world.entity.combat.projectile.CombatProjectile;
15import com.osroyale.game.world.entity.combat.strategy.npc.MultiStrategy;
16import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
17import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
18import com.osroyale.game.world.entity.mob.Mob;
19import com.osroyale.game.world.entity.mob.npc.Npc;
20import com.osroyale.game.world.position.Position;
21import com.osroyale.game.world.region.RegionManager;
22import com.osroyale.net.packet.out.SendMessage;
23import com.osroyale.util.RandomUtils;
24import com.osroyale.util.Utility;
25
26import java.util.Arrays;
27import java.util.LinkedList;
28
59
60public class Vetion extends MultiStrategy {
61 private static Earthquake EARTHQUAKE = new Earthquake();
62 private static Magic MAGIC = new Magic();
63
64 private Npc pet1, pet2;
65 private boolean spawnPets, secondTrans;
66
67 public Vetion() {
68 currentStrategy = MAGIC;
69 }
70
71 @Override
72 public boolean withinDistance(Npc attacker, Mob defender) {
73 if (!currentStrategy.withinDistance(attacker, defender)) {
74 currentStrategy = MAGIC;
75 }
76 return currentStrategy.withinDistance(attacker, defender);
77 }
78
79 @Override
80 public boolean canAttack(Npc attacker, Mob defender) {
81 if (!currentStrategy.withinDistance(attacker, defender)) {
82 currentStrategy = MAGIC;
83 }
84 return currentStrategy.canAttack(attacker, defender);
85 }
86
87 @Override
88 public boolean canOtherAttack(Mob attacker, Npc defender) {
89 if (pet1 != null || pet2 != null) {
90 if (attacker.isPlayer()) {
91 attacker.getPlayer().message("You must kill his hellhounds before dealing damage!");
92 }
93 return false;
94 }
95 return currentStrategy.canOtherAttack(attacker, defender);
96 }
97
98 @Override
99 public void onDeath(Mob attacker, Npc defender, Hit hit) {
100 if (pet1 != null) pet1.unregister();
101 if (pet2 != null) pet2.unregister();
102 }
103
104 @Override
105 public void preDeath(Mob attacker, Npc defender, Hit hit) {
106 super.preDeath(attacker, defender, hit);
107
108 if (secondTrans) {
109 return;
110 }
111
112 secondTrans = true;
113 spawnPets = false;
114 defender.setDead(false);
115 defender.heal(255);
116 defender.transform(6612);
117 defender.speak("Do it again!");
118 defender.getCombat().attack(attacker);
119
120 World.schedule(new Task(500) {
121 @Override
122 public void execute() {
123 cancel();
124 if (defender.isDead())
125 return;
126 defender.transform(6611);
127 defender.getCombat().reset();
128 secondTrans = false;
129 spawnPets = false;
130 }
131 });
132 }
133
134 @Override
135 public void finishIncoming(Mob attacker, Npc defender) {
136 if (spawnPets || defender.getCurrentHealth() > defender.getMaximumHealth() / 2) {
137 return;
138 }
139
140 Position[] innerBoundary = Utility.getInnerBoundaries(defender.getPosition().transform(-2, -2), defender.width() + 4, defender.length() + 4);
141 defender.speak(defender.id == 6611 ? "Kill, my pets!" : "Bahh! Go, dogs!!");
142 spawnPets = true;
143
144 if (!secondTrans) {
145 pet1 = new Npc(6613, RandomUtils.random(innerBoundary)) {
146 @Override
147 public void appendDeath() {
148 super.appendDeath();
149 pet1 = null;
150 }
151 };
152 pet2 = new Npc(6613, RandomUtils.random(innerBoundary)) {
153 @Override
154 public void appendDeath() {
155 super.appendDeath();
156 pet2 = null;
157 }
158 };
159 } else {
160 pet1 = new Npc(6614, RandomUtils.random(innerBoundary)) {
161 @Override
162 public void appendDeath() {
163 super.appendDeath();
164 pet1 = null;
165 }
166 };
167 pet2 = new Npc(6614, RandomUtils.random(innerBoundary)) {
168 @Override
169 public void appendDeath() {
170 super.appendDeath();
171 pet2 = null;
172 }
173 };
174 }
175 pet1.register();
176 pet2.register();
177 pet1.definition.setRespawnTime(-1);
178 pet2.definition.setRespawnTime(-1);
179 pet1.speak("GRRRRRRRRRRRR");
180 pet2.speak("GRRRRRRRRRRRR");
181 pet1.getCombat().attack(attacker);
182 pet2.getCombat().attack(attacker);
183 }
184
185 @Override
186 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
187 currentStrategy.block(attacker, defender, hit, combatType);
188 defender.getCombat().attack(attacker);
189 }
190
191 @Override
192 public void finishOutgoing(Npc attacker, Mob defender) {
193 currentStrategy.finishOutgoing(attacker, defender);
194 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
195 currentStrategy = MAGIC;
196 } else if (RandomUtils.success(0.25)) {
197 currentStrategy = EARTHQUAKE;
198 } else {
199 currentStrategy = NpcMeleeStrategy.get();
200 }
201 }
202
203 @Override
204 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
205 return attacker.definition.getAttackDelay();
206 }
207
208 private static final class Earthquake extends NpcMeleeStrategy {
209 private static final Animation ANIMATION = new Animation(9974, UpdatePriority.HIGH);
210
211 @Override
212 public void hit(Npc attacker, Mob defender, Hit hit) {
213 RegionManager.forNearbyPlayer(defender, 11, player -> {
214 player.send(new SendMessage("Vet'ion pummels the ground sending a shattering earthquake shockwave through you."));
215 if (player.equals(defender)) {
216 hit.setDamage(25 + RandomUtils.inclusive(20));
217 return;
218 }
219 player.damage(new Hit(25 + RandomUtils.inclusive(20), HitIcon.MELEE));
220 });
221 }
222
223 @Override
224 public Animation getAttackAnimation(Npc attacker, Mob defender) {
225 return ANIMATION;
226 }
227
228 @Override
229 public CombatHit[] getHits(Npc attacker, Mob defender) {
230 return new CombatHit[]{nextMeleeHit(attacker, defender)};
231 }
232 }
233
234 private static final class Magic extends NpcMagicStrategy {
235 private static final Animation ANIMATION = new Animation(9969, UpdatePriority.HIGH);
236
237 public Magic() {
238 super(CombatProjectile.getDefinition("Vet'ion"));
239 }
240
241 @Override
242 public void start(Npc attacker, Mob defender, Hit[] hits) {
243 Position[] bounds = Utility.getInnerBoundaries(defender.getPosition().transform(-1, -1), defender.width() + 2, defender.length() + 2);
244 LinkedList<Position> positions = new LinkedList<>(Arrays.asList(bounds));
245 for (int index = 0; index < 3; index++) {
246 Position bound = index == 0 ? defender.getPosition() : RandomUtils.random(positions);
247 positions.remove(bound);
248 combatProjectile.getProjectile().ifPresent(projectile -> World.sendProjectile(attacker, bound, projectile));
249 World.sendGraphic(new Graphic(775, 100), bound, attacker.instance);
250 World.schedule(CombatUtil.getHitDelay(attacker, defender, CombatType.MAGIC) + 2, () -> RegionManager.forNearbyPlayer(bound, 0, player -> {
251 player.speak("OUCH!");
252 player.damage(new Hit(RandomUtils.inclusive(45), HitIcon.MAGIC));
253 }));
254 }
255 }
256
257 @Override
258 public void hit(Npc attacker, Mob defender, Hit hit) {
259 hit.setAccurate(false);
260 }
261
262 @Override
263 public Animation getAttackAnimation(Npc attacker, Mob defender) {
264 return ANIMATION;
265 }
266
267 @Override
268 public CombatHit[] getHits(Npc attacker, Mob defender) {
269 return new CombatHit[]{nextMagicHit(attacker, defender)};
270 }
271 }
272
273}
static void sendGraphic(Graphic graphic, Position position, int instance)
Definition World.java:305
static void schedule(Task task)
Definition World.java:284
static void sendProjectile(Projectile projectile, Position position, int instance, int lock, byte offsetX, byte offsetY)
Definition World.java:332
static int getHitDelay(final Mob attacker, final Mob defender, final CombatType type)
void speak(String forceChat)
Definition Mob.java:164
abstract Combat<? extends Mob > getCombat()
Position transform(int diffX, int diffY, int diffZ)
static void forNearbyPlayer(Mob mob, int distance, Consumer< Player > action)