RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Callisto.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.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.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.projectile.CombatProjectile;
14import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
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.Direction;
19import com.osroyale.game.world.entity.mob.Mob;
20import com.osroyale.game.world.entity.mob.npc.Npc;
21import com.osroyale.game.world.entity.mob.player.ForceMovement;
22import com.osroyale.game.world.pathfinding.path.SimplePathChecker;
23import com.osroyale.game.world.position.Position;
24import com.osroyale.net.packet.out.SendMessage;
25import com.osroyale.util.RandomUtils;
26import com.osroyale.util.Utility;
27
28import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
29import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
30import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
31
65
66public class Callisto extends MultiStrategy {
67
68 private static Roar ROAR = new Roar();
69 private static Shockwave SHOCKWAVE = new Shockwave();
70 private static Melee MELEE = new Melee();
71 private static final CombatStrategy<Npc>[] FULL = createStrategyArray(MELEE, MELEE, MELEE, SHOCKWAVE);
72
73 public Callisto() {
74 currentStrategy = SHOCKWAVE;
75 }
76
77 @Override
78 public boolean canAttack(Npc attacker, Mob defender) {
79 if (!currentStrategy.withinDistance(attacker, defender)) {
80 if (RandomUtils.success(0.10)) {
81 currentStrategy = ROAR;
82 } else {
83 currentStrategy = SHOCKWAVE;
84 }
85 }
86 return currentStrategy.canAttack(attacker, defender);
87 }
88
89 @Override
90 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
91 currentStrategy.block(attacker, defender, hit, combatType);
92 defender.getCombat().attack(attacker);
93 }
94
95 @Override
96 public void finishOutgoing(Npc attacker, Mob defender) {
97 currentStrategy.finishOutgoing(attacker, defender);
98 if (RandomUtils.success(0.10)) {
99 currentStrategy = ROAR;
100 } else {
101 currentStrategy = randomStrategy(FULL);
102 }
103 }
104
105 @Override
106 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
107 return attacker.definition.getAttackDelay();
108 }
109
110 private static class Roar extends NpcMagicStrategy {
111 Roar() {
112 super(CombatProjectile.getDefinition("EMPTY"));
113 }
114
115 @Override
116 public void start(Npc attacker, Mob defender, Hit[] hits) {
117 attacker.animate(new Animation(4921, UpdatePriority.VERY_HIGH));
118 World.sendProjectile(attacker, defender, new Projectile(395, 46, 80, 43, 31));
119 World.schedule(1, () -> {
120 if (defender.isPlayer()) {
121 Position current = defender.getPosition();
122 Position best = Utility.findBestInside(defender, attacker);
123 int dx = current.getX() - best.getX();
124 int dy = current.getY() - best.getY();
125
126 Direction opposite = Direction.getFollowDirection(attacker.getPosition(), defender.getPosition());
127// for (int x = 1; x <= 2; x++) {
128 int y = dy / (dx == 0 ? dy : dx);
129 Position destination = current.transform(dx, y);
130 if (SimplePathChecker.checkLine(defender, destination))
131 current = destination;
132// }
133 defender.damage(new Hit(Utility.random(1, 3)));
134 defender.interact(attacker);
135 defender.getPlayer().send(new SendMessage("Callisto's roar throws you backwards."));
136
137 Position offset = new Position(current.getX() - defender.getX(), current.getY() - defender.getY());
138 ForceMovement movement = new ForceMovement(defender.getPosition().copy(), offset, 33, 60, Direction.getOppositeDirection(opposite));
139
140 int anim = defender.mobAnimation.getWalk();
141 World.schedule(new ForceMovementTask(defender, 3, 0, movement, new Animation(1157, UpdatePriority.VERY_HIGH)) {
142 @Override
143 protected void onSchedule() {
144 super.onSchedule();
145 defender.mobAnimation.setWalk(1157);
146 defender.locking.lock();
147 }
148
149 @Override
150 protected void onCancel(boolean logout) {
151 super.onCancel(logout);
152 defender.mobAnimation.setWalk(anim);
153 defender.locking.unlock();
154 }
155 });
156 }
157 });
158 }
159
160 @Override
161 public void hit(Npc attacker, Mob defender, Hit hit) {
162 }
163
164 @Override
165 public void attack(Npc attacker, Mob defender, Hit hit) {
166 }
167
168 @Override
169 public CombatHit[] getHits(Npc attacker, Mob defender) {
170 CombatHit hit = nextMagicHit(attacker, defender, 3);
171 hit.setAccurate(true);
172 return new CombatHit[]{hit};
173 }
174 }
175
176 private static class Shockwave extends NpcMagicStrategy {
177 private static final Animation ANIMATION = new Animation(4922, UpdatePriority.HIGH);
178
179 Shockwave() {
180 super(getDefinition("Callisto Shockwave"));
181 }
182
183 @Override
184 public void hit(Npc attacker, Mob defender, Hit hit) {
185 super.hit(attacker, defender, hit);
186 if (defender.isPlayer()) {
187 defender.getPlayer().send(new SendMessage("Callisto's fury sends an almighty shockwave through you."));
188 defender.graphic(new Graphic(80, true));
189 }
190 }
191
192 @Override
193 public CombatHit[] getHits(Npc attacker, Mob defender) {
194 CombatHit hit = nextMagicHit(attacker, defender, 23);
195 hit.setAccurate(true);
196 return new CombatHit[]{hit};
197 }
198
199 @Override
200 public Animation getAttackAnimation(Npc attacker, Mob defender) {
201 return ANIMATION;
202 }
203 }
204
205 private static final class Melee extends NpcMeleeStrategy {
206 private static final Animation ANIMATION = new Animation(4925, UpdatePriority.HIGH);
207
208 @Override
209 public int getAttackDistance(Npc attacker, FightType fightType) {
210 return 2;
211 }
212
213 @Override
214 public Animation getAttackAnimation(Npc attacker, Mob defender) {
215 return ANIMATION;
216 }
217
218 @Override
219 public CombatHit[] getHits(Npc attacker, Mob defender) {
220 return new CombatHit[]{nextMeleeHit(attacker, defender)};
221 }
222 }
223}
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
abstract Combat<? extends Mob > getCombat()
Position transform(int diffX, int diffY, int diffZ)