RuneHive-Game
Loading...
Searching...
No Matches
DarkBeast.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.attack.listener.NpcCombatListenerSignature;
6import com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener;
7import com.runehive.game.world.entity.combat.hit.CombatHit;
8import com.runehive.game.world.entity.combat.hit.Hit;
9import com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
10import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
11import com.runehive.game.world.entity.mob.Mob;
12import com.runehive.game.world.entity.mob.npc.Npc;
13import com.runehive.util.RandomUtils;
14
15import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
16
17@NpcCombatListenerSignature(npcs = {4005})
18public class DarkBeast extends SimplifiedListener<Npc> {
19 private static MagicAttack MAGIC = new MagicAttack();
20
21 @Override
22 public void start(Npc attacker, Mob defender, Hit[] hits) {
23 if (RandomUtils.success(.85)) {
25 } else {
26 attacker.setStrategy(MAGIC);
27 }
28 }
29
30
31 private static class MagicAttack extends NpcMagicStrategy {
32 private MagicAttack() {
33 super(getDefinition("Fire Bolt"));
34 }
35
36 @Override
37 public void start(Npc attacker, Mob defender, Hit[] hits) {
38 attacker.animate(new Animation(2731, UpdatePriority.VERY_HIGH));
39 combatProjectile.sendProjectile(attacker, defender);
40
41 }
42
43 @Override
44 public void hit(Npc attacker, Mob defender, Hit hit) {
45 }
46
47 @Override
48 public CombatHit[] getHits(Npc attacker, Mob defender) {
49 CombatHit hit = nextMagicHit(attacker, defender, 8, 2, 1);
50 hit.setAccurate(true);
51 return new CombatHit[]{hit};
52 }
53 }
54}
Class that models a single animation used by an entity.
void start(Npc attacker, Mob defender, Hit[] hits)
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
Represents a non-player character in the in-game world.
Definition Npc.java:29
void setStrategy(CombatStrategy< Npc > strategy)
Definition Npc.java:212
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...
Represents different priorities for updating.