RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
TzTokJad.java
1package com.osroyale.game.world.entity.combat.strategy.npc.boss;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.Graphic;
5import com.osroyale.game.Projectile;
6import com.osroyale.game.UpdatePriority;
7import com.osroyale.game.world.World;
8import com.osroyale.game.world.entity.combat.CombatType;
9import com.osroyale.game.world.entity.combat.attack.FightType;
10import com.osroyale.game.world.entity.combat.hit.CombatHit;
11import com.osroyale.game.world.entity.combat.hit.Hit;
12import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
13import com.osroyale.game.world.entity.combat.strategy.npc.MultiStrategy;
14import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
15import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
16import com.osroyale.game.world.entity.combat.strategy.npc.NpcRangedStrategy;
17import com.osroyale.game.world.entity.mob.Mob;
18import com.osroyale.game.world.entity.mob.npc.Npc;
19import com.osroyale.game.world.entity.mob.prayer.Prayer;
20
21import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
22import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
23import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
24
59
60public class TzTokJad extends MultiStrategy {
61 private static MeleeAttack MELEE = new MeleeAttack();
62 private static RangedAttack RANGED = new RangedAttack();
63 private static MagicAttack MAGIC = new MagicAttack();
64 private static final CombatStrategy<Npc>[] FULL_STRATEGIES = createStrategyArray(MELEE, RANGED, MAGIC);
65 private static final CombatStrategy<Npc>[] NON_MELEE = createStrategyArray(RANGED, MAGIC);
66
67 public TzTokJad() {
68 currentStrategy = randomStrategy(NON_MELEE);
69 }
70
71 @Override
72 public boolean withinDistance(Npc attacker, Mob defender) {
73 if (!currentStrategy.withinDistance(attacker, defender)) {
74 currentStrategy = randomStrategy(NON_MELEE);
75 }
76 return currentStrategy.withinDistance(attacker, defender);
77 }
78
79 @Override
80 public boolean canAttack(Npc attacker, Mob defender) {
81 if (!currentStrategy.canAttack(attacker, defender)) {
82 currentStrategy = randomStrategy(NON_MELEE);
83 }
84 return currentStrategy.canAttack(attacker, defender);
85 }
86
87 @Override
88 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
89 currentStrategy.block(attacker, defender, hit, combatType);
90 defender.getCombat().attack(attacker);
91 }
92
93 @Override
94 public void finishOutgoing(Npc attacker, Mob defender) {
95 currentStrategy.finishOutgoing(attacker, defender);
96 if (MELEE.withinDistance(attacker, defender)) {
97 currentStrategy = randomStrategy(FULL_STRATEGIES);
98 } else {
99 currentStrategy = randomStrategy(NON_MELEE);
100 }
101 }
102
103 @Override
104 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
105 return attacker.definition.getAttackDelay();
106 }
107
108 private static class MeleeAttack extends NpcMeleeStrategy {
109
110 @Override
111 public Animation getAttackAnimation(Npc attacker, Mob defender) {
112 return new Animation(2655, UpdatePriority.HIGH);
113 }
114
115 @Override
116 public void hit(Npc attacker, Mob defender, Hit hit) {
117 if (defender.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
118 hit.modifyDamage(damage -> 0);
119 }
120 }
121
122 @Override
123 public CombatHit[] getHits(Npc attacker, Mob defender) {
124 return new CombatHit[]{nextMeleeHit(attacker, defender, 97, 0, 0, false)};
125 }
126 }
127
128 private static class RangedAttack extends NpcRangedStrategy {
129
130 RangedAttack() {
131 super(getDefinition("EMPTY"));
132 }
133
134 @Override
135 public Animation getAttackAnimation(Npc attacker, Mob defender) {
136 return new Animation(2652, UpdatePriority.HIGH);
137 }
138
139 @Override
140 public void attack(Npc attacker, Mob defender, Hit hit) {
141 }
142
143 @Override
144 public void hit(Npc attacker, Mob defender, Hit hit) {
145 World.sendGraphic(new Graphic(451, 30, UpdatePriority.HIGH), defender.getPosition());
146 defender.graphic(new Graphic(157, 90, true, UpdatePriority.HIGH));
147
148 if (defender.prayer.isActive(Prayer.PROTECT_FROM_RANGE)) {
149 hit.modifyDamage(damage -> 0);
150 }
151 }
152
153 @Override
154 public void hitsplat(Npc attacker, Mob defender, Hit hit) {
155 if (defender.prayer.isActive(Prayer.PROTECT_FROM_RANGE)) {
156 hit.modifyDamage(damage -> 0);
157 }
158 }
159
160 @Override
161 public CombatHit[] getHits(Npc attacker, Mob defender) {
162 return new CombatHit[]{nextRangedHit(attacker, defender, 97, 0, 4)};
163 }
164 }
165
166 private static class MagicAttack extends NpcMagicStrategy {
167
168 public MagicAttack() {
169 super(getDefinition("EMPTY"));
170 }
171
172 @Override
173 public Animation getAttackAnimation(Npc attacker, Mob defender) {
174 return new Animation(2656, UpdatePriority.HIGH);
175 }
176
177 @Override
178 public void attack(Npc attacker, Mob defender, Hit hit) {
179 }
180
181 @Override
182 public void hit(Npc attacker, Mob defender, Hit hit) {
183 attacker.graphic(new Graphic(447, 0, 0x1F40000, UpdatePriority.HIGH));
184 World.sendProjectile(attacker, defender, new Projectile(448, 70, 100, 140, 20));
185 World.sendProjectile(attacker, defender, new Projectile(449, 75, 100, 140, 20));
186 World.sendProjectile(attacker, defender, new Projectile(450, 80, 100, 140, 20));
187 defender.graphic(new Graphic(157, 100, true, UpdatePriority.HIGH));
188 }
189
190 @Override
191 public void hitsplat(Npc attacker, Mob defender, Hit hit) {
192 if (defender.prayer.isActive(Prayer.PROTECT_FROM_MAGIC)) {
193 hit.modifyDamage(damage -> 0);
194 }
195 }
196
197 @Override
198 public CombatHit[] getHits(Npc attacker, Mob defender) {
199 CombatHit hit = nextMagicHit(attacker, defender, 97, 0, 4);
200 hit.setAccurate(true);
201 return new CombatHit[]{hit};
202 }
203 }
204
205}
static void sendGraphic(Graphic graphic, Position position, int instance)
Definition World.java:305
static void sendProjectile(Projectile projectile, Position position, int instance, int lock, byte offsetX, byte offsetY)
Definition World.java:332
abstract Combat<? extends Mob > getCombat()