RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
GeneralGraardor.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.CombatUtil;
6import com.osroyale.game.world.entity.combat.attack.FightType;
7import com.osroyale.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
8import com.osroyale.game.world.entity.combat.attack.listener.SimplifiedListener;
9import com.osroyale.game.world.entity.combat.hit.CombatHit;
10import com.osroyale.game.world.entity.combat.hit.Hit;
11import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
12import com.osroyale.game.world.entity.combat.strategy.npc.NpcRangedStrategy;
13import com.osroyale.game.world.entity.mob.Mob;
14import com.osroyale.game.world.entity.mob.npc.Npc;
15import com.osroyale.game.world.position.Area;
16import com.osroyale.util.RandomUtils;
17import com.osroyale.util.Utility;
18
19import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
20
24@NpcCombatListenerSignature(npcs = {2215})
61
62public class GeneralGraardor extends SimplifiedListener<Npc> {
63 private static MeleeAttack MELEE;
64 private static RangedAttack RANGED;
65
66 private static final String[] SHOUTS = {
67 "Brargh!",
68 "Split their skulls!",
69 "All glory to Bandos!",
70 "GRRRAAAAAR!",
71 "CHAAARGE!",
72 "Crush them underfoot!",
73 "Death to our enemies!",
74 "Break their bones!",
75 "For the glory of the Big High War God!",
76 "We feast on the bones of our enemies tonight!"
77 };
78
79 static {
80 try {
81 MELEE = new MeleeAttack();
82 RANGED = new RangedAttack();
83 } catch (Exception e) {
84 e.printStackTrace();
85 }
86 }
87
88 @Override
89 public void start(Npc attacker, Mob defender, Hit[] hits) {
90 if (attacker.getStrategy().equals(NpcMeleeStrategy.get())) {
91 attacker.setStrategy(MELEE);
92 }
93
94 if (RandomUtils.success(0.35)) {
95 attacker.speak(Utility.randomElement(SHOUTS));
96 }
97 }
98
99 private static class MeleeAttack extends NpcMeleeStrategy {
100 @Override
101 public Animation getAttackAnimation(Npc attacker, Mob defender) {
102 return new Animation(7018, UpdatePriority.HIGH);
103 }
104
105 @Override
106 public void finishOutgoing(Npc attacker, Mob defender) {
107 if (RandomUtils.success(0.40)) {
108 attacker.setStrategy(RANGED);
109 }
110 }
111 }
112
113 private static class RangedAttack extends NpcRangedStrategy {
114 RangedAttack() {
115 super(getDefinition("Graardor Ranged"));
116 }
117
118 @Override
119 public Animation getAttackAnimation(Npc attacker, Mob defender) {
120 return new Animation(7021, UpdatePriority.HIGH);
121 }
122
123 @Override
124 public CombatHit[] getHits(Npc attacker, Mob defender) {
125 return new CombatHit[]{nextRangedHit(attacker, defender, 35)};
126 }
127
128 @Override
129 public void hitsplat(Npc attacker, Mob defender, Hit hit) {
130 super.hitsplat(attacker, defender, hit);
131
132 CombatUtil.areaAction(attacker, 64, 18, mob -> {
133 if (mob.isPlayer() && Area.inBandos(mob)) {
134 mob.damage(nextRangedHit(attacker, defender, 35));
135 }
136 });
137 }
138
139 @Override
140 public void finishOutgoing(Npc attacker, Mob defender) {
141 if (attacker.getStrategy() != MELEE) {
142 attacker.setStrategy(MELEE);
143 }
144 }
145
146 @Override
147 public int getAttackDistance(Npc attacker, FightType fightType) {
148 return 32;
149 }
150
151 }
152
153}
static void areaAction(Mob mob, Consumer< Mob > action)
void speak(String forceChat)
Definition Mob.java:164
CombatStrategy< Npc > getStrategy()
Definition Npc.java:198
static< T > T randomElement(Collection< T > collection)
Definition Utility.java:285