RuneHive-Game
Loading...
Searching...
No Matches
Zulrah.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.npc.boss;
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.hit.CombatHit;
8import com.runehive.game.world.entity.combat.hit.Hit;
9import com.runehive.game.world.entity.combat.strategy.npc.MultiStrategy;
10import com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
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.pathfinding.path.SimplePathChecker;
16import com.runehive.game.world.position.Position;
17import com.runehive.util.Utility;
18
19import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
20
21/** @author Daniel */
22public class Zulrah extends MultiStrategy {
23 private final MeleeAttack MELEE = new MeleeAttack();
24 private static final MagicAttack MAGIC = new MagicAttack();
25 private static final RangedAttack RANGED = new RangedAttack();
26
27 public Zulrah() {
28 setRanged();
29 }
30
31 public void setMelee() {
33 }
34
35 public void setMagic() {
37 }
38
39 public void setRanged() {
41 }
42
43 private class MeleeAttack extends NpcMeleeStrategy {
44 private Position end;
45
46 @Override
47 public boolean withinDistance(Npc attacker, Mob defender) {
48 return Utility.within(attacker, defender, getAttackDistance(attacker, attacker.getCombat().getFightType()))
49 && (SimplePathChecker.checkProjectile(attacker, defender) || SimplePathChecker.checkProjectile(defender, attacker));
50 }
51
52 @Override
53 public void start(Npc attacker, Mob defender, Hit[] hits) {
54 attacker.blockInteract = true;
55 attacker.resetFace();
56 attacker.face(end = defender.getPosition());
57 }
58
59 @Override
60 public void hit(Npc attacker, Mob defender, Hit hit) {
61 attacker.blockInteract = false;
62 attacker.animate(new Animation(5806, UpdatePriority.HIGH));
63
64 if (!defender.getPosition().equals(end)) {
65 /* not in same position, remove hit */
66 hit.setDamage(-1);
67 hit.setAccurate(false);
68 } else {
69 /* re-roll the hit */
70 attacker.getCombat().addModifier(this);
71 hit.setAs(nextMeleeHit(attacker, defender, 41));
72 attacker.getCombat().removeModifier(this);
73 defender.animate(CombatUtil.getBlockAnimation(defender));
74 }
75 }
76
77 @Override
78 public CombatHit[] getHits(Npc attacker, Mob defender) {
79 return new CombatHit[] { nextMeleeHit(attacker, defender, -1, 4, 0, false) };
80 }
81
82 @Override
83 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
84 return 6;
85 }
86
87 @Override
88 public int getAttackDistance(Npc attacker, FightType fightType) {
89 return 4;
90 }
91
92 @Override
93 public Animation getAttackAnimation(Npc attacker, Mob defender) {
94 return new Animation(5807, UpdatePriority.HIGH);
95 }
96
97 @Override
98 public int modifyAttackLevel(Npc attacker, Mob defender, int level) {
99 /* level 300 attack */
100 return 300;
101 }
102
103 }
104
105 private static class RangedAttack extends NpcRangedStrategy {
106 private RangedAttack() {
107 super(getDefinition("Zulrah Ranged"));
108 }
109
110 @Override
111 public CombatHit[] getHits(Npc attacker, Mob defender) {
112 return new CombatHit[]{nextRangedHit(attacker, defender, 41)};
113 }
114
115 @Override
116 public int getAttackDistance(Npc attacker, FightType fightType) {
117 return 10;
118 }
119
120 }
121
122 private static class MagicAttack extends NpcMagicStrategy {
123 private MagicAttack() {
124 super(getDefinition("Zulrah Magic"));
125 }
126
127 @Override
128 public CombatHit[] getHits(Npc attacker, Mob defender) {
129 CombatHit combatHit = nextMagicHit(attacker, defender, 41);
130 combatHit.setAccurate(true);
131 return new CombatHit[]{combatHit};
132 }
133
134 @Override
135 public int getAttackDistance(Npc attacker, FightType fightType) {
136 return 10;
137 }
138
139 }
140
141}
Class that models a single animation used by an entity.
A collection of util methods and constants related to combat.
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)
final CombatHit nextMagicHit(T attacker, Mob defender)
int modifyAttackLevel(Npc attacker, Mob defender, int level)
Definition Zulrah.java:98
int getAttackDelay(Npc attacker, Mob defender, FightType fightType)
Definition Zulrah.java:83
Handles the mob class.
Definition Mob.java:66
void face(GameObject object)
Sets the client update flag to face a certain direction.
Definition Mob.java:289
void resetFace()
Resets the mob's face location.
Definition Mob.java:330
Represents a non-player character in the in-game world.
Definition Npc.java:29
Combat< Npc > getCombat()
The combat of the mob.
Definition Npc.java:156
Represents a PathFinder which is meant to be used to check projectiles passage in a straight line.
static boolean checkProjectile(Interactable source, Interactable target)
Represents a single tile on the game world.
Definition Position.java:14
Handles miscellaneous methods.
Definition Utility.java:27
static boolean within(Position source, Position target, int distance)
Definition Utility.java:676
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.