1package com.osroyale.game.world.entity.combat.attack.listener.npc;
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;
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;
61 private static MagicAttack MAGIC;
62 private static CombatStrategy<Npc>[] STRATEGIES;
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!"
80 MAGIC =
new MagicAttack();
81 STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), MAGIC);
82 }
catch (Exception e) {
88 public boolean canAttack(
Npc attacker,
Mob defender) {
89 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
90 attacker.setStrategy(MAGIC);
92 return attacker.
getStrategy().canAttack(attacker, defender);
96 public void start(
Npc attacker,
Mob defender,
Hit[] hits) {
97 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
98 attacker.setStrategy(MAGIC);
100 attacker.setStrategy(randomStrategy(STRATEGIES));
108 attacker.
getStrategy().block(attacker, defender, hit, combatType);
112 private static class MagicAttack
extends NpcMagicStrategy {
113 private MagicAttack() {
114 super(getDefinition(
"EMPTY"));
118 public void start(
Npc attacker,
Mob defender,
Hit[] hits) {
123 public void hit(
Npc attacker,
Mob defender,
Hit hit) {
128 CombatHit hit = nextMagicHit(attacker, defender, 31);
129 hit.setAccurate(
true);
void speak(String forceChat)
abstract Combat<? extends Mob > getCombat()
CombatStrategy< Npc > getStrategy()
static< T > T randomElement(Collection< T > collection)