RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ChromaticDragon.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
21 /* Lava */ 6593,
22 /* Green */ 260, 261, 262, 263, 264, 7868, 7869, 7870,
23 /* Red */ 247, 248, 249, 250, 251,
24 /* Blue */ 265, 4385, 5878, 5879, 5880, 5881, 5882, 267,
25 /* Black */ 252, 253, 254, 255, 256, 257, 258, 259, 2642, 6500, 6501, 6502, 6636, 6652
26})
59
60public class ChromaticDragon extends SimplifiedListener<Npc> {
61 private static DragonfireStrategy DRAGONFIRE;
62 private static CombatStrategy<Npc>[] STRATEGIES;
63
64 static {
65 try {
66 DRAGONFIRE = new DragonfireStrategy(getDefinition("Chromatic dragonfire"));
67 STRATEGIES = createStrategyArray(new CrushMelee(), new StabMelee(), DRAGONFIRE);
68 } catch (Exception e) {
69 e.printStackTrace();
70 }
71 }
72
73 @Override
74 public boolean canAttack(Npc attacker, Mob defender) {
75 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
76 attacker.setStrategy(DRAGONFIRE);
77 }
78 return attacker.getStrategy().canAttack(attacker, defender);
79 }
80
81 @Override
82 public void finishOutgoing(Npc attacker, Mob defender) {
83 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
84 attacker.setStrategy(DRAGONFIRE);
85 } else {
86 attacker.setStrategy(randomStrategy(STRATEGIES));
87 }
88 }
89
90 private static final class CrushMelee extends NpcMeleeStrategy {
91 private static final Animation ANIMATION = new Animation(80, UpdatePriority.HIGH);
92
93 @Override
94 public int getAttackDistance(Npc attacker, FightType fightType) {
95 return 1;
96 }
97
98 @Override
99 public Animation getAttackAnimation(Npc attacker, Mob defender) {
100 return ANIMATION;
101 }
102
103 @Override
104 public CombatHit[] getHits(Npc attacker, Mob defender) {
105 return new CombatHit[]{nextMeleeHit(attacker, defender)};
106 }
107 }
108
109 private static final class StabMelee extends NpcMeleeStrategy {
110 private static final Animation ANIMATION = new Animation(91, UpdatePriority.HIGH);
111
112 @Override
113 public int getAttackDistance(Npc attacker, FightType fightType) {
114 return 1;
115 }
116
117 @Override
118 public Animation getAttackAnimation(Npc attacker, Mob defender) {
119 return ANIMATION;
120 }
121
122 @Override
123 public CombatHit[] getHits(Npc attacker, Mob defender) {
124 return new CombatHit[]{nextMeleeHit(attacker, defender)};
125 }
126 }
127
128}
CombatStrategy< Npc > getStrategy()
Definition Npc.java:198