RuneHive-Game
Loading...
Searching...
No Matches
GeneralGraardor.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.CombatUtil;
6import com.runehive.game.world.entity.combat.attack.FightType;
7import com.runehive.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
8import com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener;
9import com.runehive.game.world.entity.combat.hit.CombatHit;
10import com.runehive.game.world.entity.combat.hit.Hit;
11import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
12import com.runehive.game.world.entity.combat.strategy.npc.NpcRangedStrategy;
13import com.runehive.game.world.entity.mob.Mob;
14import com.runehive.game.world.entity.mob.npc.Npc;
15import com.runehive.game.world.position.Area;
16import com.runehive.util.RandomUtils;
17import com.runehive.util.Utility;
18
19import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
20
21/**
22 * @author Daniel
23 */
24@NpcCombatListenerSignature(npcs = {2215})
26 private static MeleeAttack MELEE;
27 private static RangedAttack RANGED;
28
29 private static final String[] SHOUTS = {
30 "Brargh!",
31 "Split their skulls!",
32 "All glory to Bandos!",
33 "GRRRAAAAAR!",
34 "CHAAARGE!",
35 "Crush them underfoot!",
36 "Death to our enemies!",
37 "Break their bones!",
38 "For the glory of the Big High War God!",
39 "We feast on the bones of our enemies tonight!"
40 };
41
42 static {
43 try {
44 MELEE = new MeleeAttack();
45 RANGED = new RangedAttack();
46 } catch (Exception e) {
47 e.printStackTrace();
48 }
49 }
50
51 @Override
52 public void start(Npc attacker, Mob defender, Hit[] hits) {
53 if (attacker.getStrategy().equals(NpcMeleeStrategy.get())) {
54 attacker.setStrategy(MELEE);
55 }
56
57 if (RandomUtils.success(0.35)) {
59 }
60 }
61
62 private static class MeleeAttack extends NpcMeleeStrategy {
63 @Override
64 public Animation getAttackAnimation(Npc attacker, Mob defender) {
65 return new Animation(7018, UpdatePriority.HIGH);
66 }
67
68 @Override
69 public void finishOutgoing(Npc attacker, Mob defender) {
70 if (RandomUtils.success(0.40)) {
71 attacker.setStrategy(RANGED);
72 }
73 }
74 }
75
76 private static class RangedAttack extends NpcRangedStrategy {
78 super(getDefinition("Graardor Ranged"));
79 }
80
81 @Override
82 public Animation getAttackAnimation(Npc attacker, Mob defender) {
83 return new Animation(7021, UpdatePriority.HIGH);
84 }
85
86 @Override
87 public CombatHit[] getHits(Npc attacker, Mob defender) {
88 return new CombatHit[]{nextRangedHit(attacker, defender, 35)};
89 }
90
91 @Override
92 public void hitsplat(Npc attacker, Mob defender, Hit hit) {
93 super.hitsplat(attacker, defender, hit);
94
95 CombatUtil.areaAction(attacker, 64, 18, mob -> {
96 if (mob.isPlayer() && Area.inBandos(mob)) {
97 mob.damage(nextRangedHit(attacker, defender, 35));
98 }
99 });
100 }
101
102 @Override
103 public void finishOutgoing(Npc attacker, Mob defender) {
104 if (attacker.getStrategy() != MELEE) {
105 attacker.setStrategy(MELEE);
106 }
107 }
108
109 @Override
110 public int getAttackDistance(Npc attacker, FightType fightType) {
111 return 32;
112 }
113
114 }
115
116}
Class that models a single animation used by an entity.
A collection of util methods and constants related to combat.
static void areaAction(Mob mob, Consumer< Mob > action)
Executes an action for mobs within a 3x3 square, including the source mob.
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 nextRangedHit(T attacker, Mob defender)
Handles the mob class.
Definition Mob.java:66
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
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inBandos(Mob mob)
Definition Area.java:366
A static-util class that provides additional functionality for generating pseudo-random numbers.
static boolean success(double value)
Determines if a pseudorandomly generated double rounded to two decimal places is below or equal to va...
Handles miscellaneous methods.
Definition Utility.java:27
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.
The enumerated type whose elements represent the fighting types.