RuneHive-Game
Loading...
Searching...
No Matches
SkeletalWyvern.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.attack.listener.npc.dragon;
2
3import com.runehive.game.Animation;
4import com.runehive.game.UpdatePriority;
5import com.runehive.game.world.entity.combat.attack.FightType;
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.strategy.CombatStrategy;
10import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
11import com.runehive.game.world.entity.combat.strategy.npc.impl.DragonfireStrategy;
12import com.runehive.game.world.entity.mob.Mob;
13import com.runehive.game.world.entity.mob.npc.Npc;
14
15import static com.runehive.game.world.entity.combat.CombatUtil.createStrategyArray;
16import static com.runehive.game.world.entity.combat.CombatUtil.randomStrategy;
17import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
18
19/** @author Daniel */
20@NpcCombatListenerSignature(npcs = {467})
24
25 static {
26 try {
27 DRAGONFIRE = new DragonfireStrategy(getDefinition("Skeletal wyvern breathe"));
28 STRATEGIES = createStrategyArray(new Melee(), DRAGONFIRE);
29 } catch (Exception e) {
30 e.printStackTrace();
31 }
32 }
33
34 @Override
35 public boolean canAttack(Npc attacker, Mob defender) {
36 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
37 attacker.setStrategy(DRAGONFIRE);
38 }
39 return attacker.getStrategy().canAttack(attacker, defender);
40 }
41
42 @Override
43 public void finishOutgoing(Npc attacker, Mob defender) {
44 if (!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
45 attacker.setStrategy(DRAGONFIRE);
46 } else {
47 attacker.setStrategy(randomStrategy(STRATEGIES));
48 }
49 }
50
51 private static final class Melee extends NpcMeleeStrategy {
52 private static final Animation ANIMATION = new Animation(422, UpdatePriority.HIGH);
53
54 @Override
55 public int getAttackDistance(Npc attacker, FightType fightType) {
56 return 1;
57 }
58
59 @Override
60 public Animation getAttackAnimation(Npc attacker, Mob defender) {
61 return ANIMATION;
62 }
63
64 @Override
65 public CombatHit[] getHits(Npc attacker, Mob defender) {
66 return new CombatHit[]{nextMeleeHit(attacker, defender)};
67 }
68 }
69}
Class that models a single animation used by an entity.
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
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
CombatStrategy< Npc > getStrategy()
The combat strategy of the mob.
Definition Npc.java:161
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.