RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
MetalicDragon.java
1package com.osroyale.game.world.entity.combat.attack.listener.npc.dragon;
2
3import com.osroyale.game.world.entity.combat.CombatType;
4import com.osroyale.game.world.entity.combat.CombatUtil;
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.hit.Hit;
10import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
11import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
12import com.osroyale.game.world.entity.combat.strategy.npc.impl.DragonfireStrategy;
13import com.osroyale.game.world.entity.mob.Mob;
14import com.osroyale.game.world.entity.mob.npc.Npc;
15
16import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
17import static com.osroyale.game.world.entity.combat.CombatUtil.getHitDelay;
18import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
19import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
20
25 /* Bronze */ 270, 271,
26 /* Iron */ 272, 273,
27 /* Steel */ 139, 274, 275,
28 /* Mithril */ 2919
29})
58
59public class MetalicDragon extends SimplifiedListener<Npc> {
60
61 private static Dragonfire DRAGONFIRE;
62 private static CombatStrategy<Npc>[] STRATEGIES;
63
64 static {
65 try {
66 DRAGONFIRE = new Dragonfire();
67 STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), 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 start(Npc attacker, Mob defender, Hit[] hits) {
83 if(!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
84 attacker.setStrategy(DRAGONFIRE);
85 } else {
86 attacker.setStrategy(randomStrategy(STRATEGIES));
87 }
88 }
89
90 private static class Dragonfire extends DragonfireStrategy {
91 private Dragonfire() {
92 super(getDefinition("Metalic dragonfire"));
93 }
94
95 @Override
96 public int getAttackDistance(Npc attacker, FightType fightType) {
97 return 10;
98 }
99
100 @Override
101 public CombatHit[] getHits(Npc attacker, Mob defender) {
102 return new CombatHit[] { CombatUtil.generateDragonfire(attacker, defender, 60, false) };
103 }
104 }
105
106}
CombatStrategy< Npc > getStrategy()
Definition Npc.java:198