RuneHive-Game
Loading...
Searching...
No Matches
MetalicDragon.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.attack.listener.npc.dragon;
2
3import com.runehive.game.world.entity.combat.CombatType;
4import com.runehive.game.world.entity.combat.CombatUtil;
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.hit.Hit;
10import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
11import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
12import com.runehive.game.world.entity.combat.strategy.npc.impl.DragonfireStrategy;
13import com.runehive.game.world.entity.mob.Mob;
14import com.runehive.game.world.entity.mob.npc.Npc;
15
16import static com.runehive.game.world.entity.combat.CombatUtil.createStrategyArray;
17import static com.runehive.game.world.entity.combat.CombatUtil.getHitDelay;
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 Michael | Chex
23 */
25 /* Bronze */ 270, 271,
26 /* Iron */ 272, 273,
27 /* Steel */ 139, 274, 275,
28 /* Mithril */ 2919
29})
31
32 private static Dragonfire DRAGONFIRE;
34
35 static {
36 try {
37 DRAGONFIRE = new Dragonfire();
38 STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), DRAGONFIRE);
39 } catch(Exception e) {
40 e.printStackTrace();
41 }
42 }
43
44 @Override
45 public boolean canAttack(Npc attacker, Mob defender) {
46 if(!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
47 attacker.setStrategy(DRAGONFIRE);
48 }
49 return attacker.getStrategy().canAttack(attacker, defender);
50 }
51
52 @Override
53 public void start(Npc attacker, Mob defender, Hit[] hits) {
54 if(!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
55 attacker.setStrategy(DRAGONFIRE);
56 } else {
57 attacker.setStrategy(randomStrategy(STRATEGIES));
58 }
59 }
60
61 private static class Dragonfire extends DragonfireStrategy {
62 private Dragonfire() {
63 super(getDefinition("Metalic dragonfire"));
64 }
65
66 @Override
67 public int getAttackDistance(Npc attacker, FightType fightType) {
68 return 10;
69 }
70
71 @Override
72 public CombatHit[] getHits(Npc attacker, Mob defender) {
73 return new CombatHit[] { CombatUtil.generateDragonfire(attacker, defender, 60, false) };
74 }
75 }
76
77}
A collection of util methods and constants related to combat.
static CombatHit generateDragonfire(Mob attacker, Mob defender, int max, boolean prayer)
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
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
The enumerated type whose elements represent the fighting types.