1package com.osroyale.game.world.entity.combat.attack.listener.npc.dragon;
3import com.osroyale.game.Animation;
4import com.osroyale.game.Graphic;
5import com.osroyale.game.Projectile;
6import com.osroyale.game.UpdatePriority;
7import com.osroyale.game.world.World;
8import com.osroyale.game.world.entity.combat.attack.FightType;
9import com.osroyale.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
10import com.osroyale.game.world.entity.combat.attack.listener.SimplifiedListener;
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.NpcMagicStrategy;
16import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
17import com.osroyale.game.world.entity.combat.strategy.npc.impl.BrutalDragonfireStrategy;
18import com.osroyale.game.world.entity.combat.strategy.npc.impl.DragonfireStrategy;
19import com.osroyale.game.world.entity.mob.Mob;
20import com.osroyale.game.world.entity.mob.npc.Npc;
21import com.osroyale.util.Utility;
23import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
24import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
25import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
292918, 7273, 7274, 7275, 8081, 8087, 8092
67 private static CombatStrategy<Npc>[] STRATEGIES;
72 STRATEGIES = createStrategyArray(
new CrushMelee(),
new StabMelee());
73 }
catch (Exception e) {
79 public boolean canAttack(
Npc attacker,
Mob defender) {
80 final var style =
Utility.random(NpcMeleeStrategy.get().withinDistance(attacker, defender) ? 1 : 2);
82 attacker.setStrategy(DRAGONFIRE);
83 }
else if (style == 1) {
84 attacker.setStrategy(
new MagicAttack());
86 attacker.setStrategy(randomStrategy(STRATEGIES));
88 return attacker.
getStrategy().canAttack(attacker, defender);
92 public void finishOutgoing(
Npc attacker,
Mob defender) {
93 final var style =
Utility.random(NpcMeleeStrategy.get().withinDistance(attacker, defender) ? 1 : 2);
95 attacker.setStrategy(DRAGONFIRE);
96 }
else if (style == 1) {
97 attacker.setStrategy(
new MagicAttack());
99 attacker.setStrategy(randomStrategy(STRATEGIES));
103 private static final class CrushMelee
extends NpcMeleeStrategy {
107 public int getAttackDistance(
Npc attacker,
FightType fightType) {
118 return new CombatHit[]{nextMeleeHit(attacker, defender)};
122 private static final class StabMelee
extends NpcMeleeStrategy {
126 public int getAttackDistance(
Npc attacker,
FightType fightType) {
137 return new CombatHit[]{nextMeleeHit(attacker, defender)};
141 private static class MagicAttack
extends NpcMagicStrategy {
142 private MagicAttack() {
143 super(getDefinition(
"EMPTY"));
154 CombatHit combatHit = nextMagicHit(attacker, defender, getMaxHit(attacker.getId()));
155 combatHit.setAccurate(
true);
160 private static int getMaxHit(
int npcId) {
161 return switch (npcId) {
162 case 2918, 8081 -> 18;
164 case 7274, 8087 -> 22;
165 case 7275, 8092 -> 29;
170 private static Projectile getMagicProjectile(
int npcId) {
171 return switch (npcId) {
172 case 2918, 8081 ->
new Projectile(136, 40, 90, 27, 30, 5);
173 case 7273 ->
new Projectile(133, 40, 90, 27, 30, 5);
174 case 7274, 8087 ->
new Projectile(130, 40, 90, 27, 30, 5);
175 case 7275, 8092 ->
new Projectile(88, 40, 90, 27, 30, 5);
static void sendProjectile(Projectile projectile, Position position, int instance, int lock, byte offsetX, byte offsetY)
CombatStrategy< Npc > getStrategy()