RuneHive-Game
Loading...
Searching...
No Matches
CommanderZilyana.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.attack.listener.npc;
2
3import com.runehive.game.Animation;
4import com.runehive.game.UpdatePriority;
5import com.runehive.game.world.entity.combat.CombatType;
6import com.runehive.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
7import com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener;
8import com.runehive.game.world.entity.combat.hit.CombatHit;
9import com.runehive.game.world.entity.combat.hit.Hit;
10import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
11import com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
12import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
13import com.runehive.game.world.entity.mob.Mob;
14import com.runehive.game.world.entity.mob.npc.Npc;
15import com.runehive.util.Utility;
16
17import static com.runehive.game.world.entity.combat.CombatUtil.createStrategyArray;
18import static com.runehive.game.world.entity.combat.CombatUtil.randomStrategy;
19import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
20
21/**
22 * @author Daniel
23 */
24@NpcCombatListenerSignature(npcs = {2205})
26
27 private static MagicAttack MAGIC;
29
30 private static final String[] SHOUTS = {
31 "Death to the enemies of the light!",
32 "Slay the evil ones!",
33 "Saradomin lend me strength!",
34 "By the power of Saradomin!",
35 "May Saradomin be my sword!",
36 "Good will always triumph!",
37 "Forward! Our allies are with us!",
38 "Saradomin is with us!",
39 "In the name of Saradomin!",
40 "All praise Saradomin!",
41 "Attack! Find the Godsword!"
42 };
43
44 static {
45 try {
46 MAGIC = new MagicAttack();
47 STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), MAGIC);
48 } catch (Exception e) {
49 e.printStackTrace();
50 }
51 }
52
53 @Override
54 public boolean canAttack(Npc attacker, Mob defender) {
55 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
56 attacker.setStrategy(MAGIC);
57 }
58 return attacker.getStrategy().canAttack(attacker, defender);
59 }
60
61 @Override
62 public void start(Npc attacker, Mob defender, Hit[] hits) {
63 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
64 attacker.setStrategy(MAGIC);
65 } else {
66 attacker.setStrategy(randomStrategy(STRATEGIES));
67 }
68 if (Utility.random(3) == 0) {
70 }
71 }
72 @Override
73 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
74 attacker.getStrategy().block(attacker, defender, hit, combatType);
75 defender.getCombat().attack(attacker);
76 }
77
78 private static class MagicAttack extends NpcMagicStrategy {
79 private MagicAttack() {
80 super(getDefinition("EMPTY"));
81 }
82
83 @Override
84 public void start(Npc attacker, Mob defender, Hit[] hits) {
85 attacker.animate(new Animation(6970, UpdatePriority.VERY_HIGH));
86 }
87
88 @Override
89 public void hit(Npc attacker, Mob defender, Hit hit) {
90 }
91
92 @Override
93 public CombatHit[] getHits(Npc attacker, Mob defender) {
94 CombatHit hit = nextMagicHit(attacker, defender, 31);
95 hit.setAccurate(true);
96 return new CombatHit[]{hit};
97 }
98 }
99}
Class that models a single animation used by an entity.
void block(Mob attacker, Npc defender, Hit hit, CombatType combatType)
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
final CombatHit nextMagicHit(T attacker, Mob defender)
Handles the mob class.
Definition Mob.java:66
abstract< T extends Mob > CombatStrategy<? super T > getStrategy()
The combat strategy of the mob.
void speak(String forceChat)
Sets the mob's forced chat.
Definition Mob.java:127
Represents a non-player character in the in-game world.
Definition Npc.java:29
void setStrategy(CombatStrategy< Npc > strategy)
Definition Npc.java:212
CombatStrategy< Npc > getStrategy()
The combat strategy of the mob.
Definition Npc.java:161
Combat< Npc > getCombat()
The combat of the mob.
Definition Npc.java:156
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
Represents different priorities for updating.