RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
CommanderZilyana.java
1package com.osroyale.game.world.entity.combat.attack.listener.npc;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.UpdatePriority;
5import com.osroyale.game.world.entity.combat.CombatType;
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.NpcMagicStrategy;
12import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
13import com.osroyale.game.world.entity.mob.Mob;
14import com.osroyale.game.world.entity.mob.npc.Npc;
15import com.osroyale.util.Utility;
16
17import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
18import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
19import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
20
24@NpcCombatListenerSignature(npcs = {2205})
58
59public class CommanderZilyana extends SimplifiedListener<Npc> {
60
61 private static MagicAttack MAGIC;
62 private static CombatStrategy<Npc>[] STRATEGIES;
63
64 private static final String[] SHOUTS = {
65 "Death to the enemies of the light!",
66 "Slay the evil ones!",
67 "Saradomin lend me strength!",
68 "By the power of Saradomin!",
69 "May Saradomin be my sword!",
70 "Good will always triumph!",
71 "Forward! Our allies are with us!",
72 "Saradomin is with us!",
73 "In the name of Saradomin!",
74 "All praise Saradomin!",
75 "Attack! Find the Godsword!"
76 };
77
78 static {
79 try {
80 MAGIC = new MagicAttack();
81 STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), MAGIC);
82 } catch (Exception e) {
83 e.printStackTrace();
84 }
85 }
86
87 @Override
88 public boolean canAttack(Npc attacker, Mob defender) {
89 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
90 attacker.setStrategy(MAGIC);
91 }
92 return attacker.getStrategy().canAttack(attacker, defender);
93 }
94
95 @Override
96 public void start(Npc attacker, Mob defender, Hit[] hits) {
97 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
98 attacker.setStrategy(MAGIC);
99 } else {
100 attacker.setStrategy(randomStrategy(STRATEGIES));
101 }
102 if (Utility.random(3) == 0) {
103 attacker.speak(Utility.randomElement(SHOUTS));
104 }
105 }
106 @Override
107 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
108 attacker.getStrategy().block(attacker, defender, hit, combatType);
109 defender.getCombat().attack(attacker);
110 }
111
112 private static class MagicAttack extends NpcMagicStrategy {
113 private MagicAttack() {
114 super(getDefinition("EMPTY"));
115 }
116
117 @Override
118 public void start(Npc attacker, Mob defender, Hit[] hits) {
119 attacker.animate(new Animation(6970, UpdatePriority.VERY_HIGH));
120 }
121
122 @Override
123 public void hit(Npc attacker, Mob defender, Hit hit) {
124 }
125
126 @Override
127 public CombatHit[] getHits(Npc attacker, Mob defender) {
128 CombatHit hit = nextMagicHit(attacker, defender, 31);
129 hit.setAccurate(true);
130 return new CombatHit[]{hit};
131 }
132 }
133}
void speak(String forceChat)
Definition Mob.java:164
abstract Combat<? extends Mob > getCombat()
CombatStrategy< Npc > getStrategy()
Definition Npc.java:198
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285