RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Zulrah.java
1package com.osroyale.game.world.entity.combat.strategy.npc.boss;
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.hit.CombatHit;
8import com.osroyale.game.world.entity.combat.hit.Hit;
9import com.osroyale.game.world.entity.combat.strategy.npc.MultiStrategy;
10import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
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.pathfinding.path.SimplePathChecker;
16import com.osroyale.game.world.position.Position;
17import com.osroyale.util.Utility;
18
19import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
20
55
56public class Zulrah extends MultiStrategy {
57 private final MeleeAttack MELEE = new MeleeAttack();
58 private static final MagicAttack MAGIC = new MagicAttack();
59 private static final RangedAttack RANGED = new RangedAttack();
60
61 public Zulrah() {
62 setRanged();
63 }
64
65 public void setMelee() {
66 currentStrategy = MELEE;
67 }
68
69 public void setMagic() {
70 currentStrategy = MAGIC;
71 }
72
73 public void setRanged() {
74 currentStrategy = RANGED;
75 }
76
77 private class MeleeAttack extends NpcMeleeStrategy {
78 private Position end;
79
80 @Override
81 public boolean withinDistance(Npc attacker, Mob defender) {
82 return Utility.within(attacker, defender, getAttackDistance(attacker, attacker.getCombat().getFightType()))
83 && (SimplePathChecker.checkProjectile(attacker, defender) || SimplePathChecker.checkProjectile(defender, attacker));
84 }
85
86 @Override
87 public void start(Npc attacker, Mob defender, Hit[] hits) {
88 attacker.blockInteract = true;
89 attacker.resetFace();
90 attacker.face(end = defender.getPosition());
91 }
92
93 @Override
94 public void hit(Npc attacker, Mob defender, Hit hit) {
95 attacker.blockInteract = false;
96 attacker.animate(new Animation(5806, UpdatePriority.HIGH));
97
98 if (!defender.getPosition().equals(end)) {
99 /* not in same position, remove hit */
100 hit.setDamage(-1);
101 hit.setAccurate(false);
102 } else {
103 /* re-roll the hit */
104 attacker.getCombat().addModifier(this);
105 hit.setAs(nextMeleeHit(attacker, defender, 41));
106 attacker.getCombat().removeModifier(this);
107 defender.animate(CombatUtil.getBlockAnimation(defender));
108 }
109 }
110
111 @Override
112 public CombatHit[] getHits(Npc attacker, Mob defender) {
113 return new CombatHit[] { nextMeleeHit(attacker, defender, -1, 4, 0, false) };
114 }
115
116 @Override
117 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
118 return 6;
119 }
120
121 @Override
122 public int getAttackDistance(Npc attacker, FightType fightType) {
123 return 4;
124 }
125
126 @Override
127 public Animation getAttackAnimation(Npc attacker, Mob defender) {
128 return new Animation(5807, UpdatePriority.HIGH);
129 }
130
131 @Override
132 public int modifyAttackLevel(Npc attacker, Mob defender, int level) {
133 /* level 300 attack */
134 return 300;
135 }
136
137 }
138
139 private static class RangedAttack extends NpcRangedStrategy {
140 private RangedAttack() {
141 super(getDefinition("Zulrah Ranged"));
142 }
143
144 @Override
145 public CombatHit[] getHits(Npc attacker, Mob defender) {
146 return new CombatHit[]{nextRangedHit(attacker, defender, 41)};
147 }
148
149 @Override
150 public int getAttackDistance(Npc attacker, FightType fightType) {
151 return 10;
152 }
153
154 }
155
156 private static class MagicAttack extends NpcMagicStrategy {
157 private MagicAttack() {
158 super(getDefinition("Zulrah Magic"));
159 }
160
161 @Override
162 public CombatHit[] getHits(Npc attacker, Mob defender) {
163 CombatHit combatHit = nextMagicHit(attacker, defender, 41);
164 combatHit.setAccurate(true);
165 return new CombatHit[]{combatHit};
166 }
167
168 @Override
169 public int getAttackDistance(Npc attacker, FightType fightType) {
170 return 10;
171 }
172
173 }
174
175}
void face(GameObject object)
Definition Mob.java:326