RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
SkeletalWyvern.java
1package com.osroyale.game.world.entity.combat.attack.listener.npc.dragon;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.UpdatePriority;
5import com.osroyale.game.world.entity.combat.attack.FightType;
6import com.osroyale.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
7import com.osroyale.game.world.entity.combat.attack.listener.SimplifiedListener;
8import com.osroyale.game.world.entity.combat.hit.CombatHit;
9import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
10import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
11import com.osroyale.game.world.entity.combat.strategy.npc.impl.DragonfireStrategy;
12import com.osroyale.game.world.entity.mob.Mob;
13import com.osroyale.game.world.entity.mob.npc.Npc;
14
15import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
16import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
17import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
18
20@NpcCombatListenerSignature(npcs = {467})
50
51public class SkeletalWyvern extends SimplifiedListener<Npc> {
52 private static DragonfireStrategy DRAGONFIRE;
53 private static CombatStrategy<Npc>[] STRATEGIES;
54
55 static {
56 try {
57 DRAGONFIRE = new DragonfireStrategy(getDefinition("Skeletal wyvern breathe"));
58 STRATEGIES = createStrategyArray(new Melee(), DRAGONFIRE);
59 } catch (Exception e) {
60 e.printStackTrace();
61 }
62 }
63
64 @Override
65 public boolean canAttack(Npc attacker, Mob defender) {
66 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
67 attacker.setStrategy(DRAGONFIRE);
68 }
69 return attacker.getStrategy().canAttack(attacker, defender);
70 }
71
72 @Override
73 public void finishOutgoing(Npc attacker, Mob defender) {
74 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
75 attacker.setStrategy(DRAGONFIRE);
76 } else {
77 attacker.setStrategy(randomStrategy(STRATEGIES));
78 }
79 }
80
81 private static final class Melee extends NpcMeleeStrategy {
82 private static final Animation ANIMATION = new Animation(422, UpdatePriority.HIGH);
83
84 @Override
85 public int getAttackDistance(Npc attacker, FightType fightType) {
86 return 1;
87 }
88
89 @Override
90 public Animation getAttackAnimation(Npc attacker, Mob defender) {
91 return ANIMATION;
92 }
93
94 @Override
95 public CombatHit[] getHits(Npc attacker, Mob defender) {
96 return new CombatHit[]{nextMeleeHit(attacker, defender)};
97 }
98 }
99}
CombatStrategy< Npc > getStrategy()
Definition Npc.java:198