RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Prayer.java
1package com.osroyale.game.world.entity.mob.prayer;
2
3import com.google.common.collect.ImmutableList;
4import com.google.common.collect.ImmutableSet;
5import com.osroyale.game.world.entity.combat.attack.listener.CombatListener;
6import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.AuguryListener;
7import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.ChivalryListener;
8import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.PietyListener;
9import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.RigourListener;
10import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.attack.ClarityOfThoughtListener;
11import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.attack.ImprovedReflexesListener;
12import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.attack.IncredibleReflexesListener;
13import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.defence.RockSkinListener;
14import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.defence.SteelSkinListener;
15import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.defence.ThickSkinListener;
16import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.magic.MysticLoreListener;
17import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.magic.MysticMightListener;
18import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.magic.MysticWillListener;
19import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.ranged.EagleEyeListener;
20import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.ranged.HawkEyeListener;
21import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.ranged.SharpListener;
22import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.strength.BurstOfStrengthListener;
23import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.strength.SuperhumanStrengthListener;
24import com.osroyale.game.world.entity.combat.attack.listener.other.prayer.strength.UltimateStrengthListener;
25import com.osroyale.game.world.entity.mob.Mob;
26import com.osroyale.game.world.entity.mob.player.Player;
27import com.osroyale.game.world.entity.mob.player.PlayerRight;
28import com.osroyale.game.world.entity.skill.Skill;
29import com.osroyale.net.packet.out.SendConfig;
30import com.osroyale.net.packet.out.SendMessage;
31
32import java.util.*;
33
93
94public enum Prayer {
95 THICK_SKIN("Thick Skin", 1, 3, 83, 630, 5609, new ThickSkinListener(), Type.DEFENSIVE),
96 BURST_OF_STRENGTH("Burst of Strength", 4, 3, 84, 631, 5610, new BurstOfStrengthListener(), Type.AGGRESSIVE),
97 CLARITY_OF_THOUGHT("Clarity of Thought", 7, 3, 85, 632, 5611, new ClarityOfThoughtListener(), Type.OFFENSIVE),
98 SHARP_EYE("Sharp Eye", 8, 3, 700, 633, 19812, new SharpListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
99 MYSTIC_WILL("Mystic Will", 9, 3, 701, 634, 19814, new MysticWillListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
100 ROCK_SKIN("Rock Skin", 10, 6, 86, 635, 5612, new RockSkinListener(), Type.DEFENSIVE),
101 SUPERHUMAN_STRENGTH("Superhuman Strength", 13, 6, 87, 636, 5613, new SuperhumanStrengthListener(), Type.AGGRESSIVE),
102 IMPROVED_REFLEXES("Improved Reflexes", 16, 6, 88, 637, 5614, new ImprovedReflexesListener(), Type.OFFENSIVE),
103 RAPID_RESTORE("Rapid Restore", 19, 1, 89, 638, 5615, Type.NORMAL),
104 RAPID_HEAL("Rapid Heal", 22, 2, 90, 639, 5616, Type.NORMAL),
105 PROTECT_ITEM("Protect Item", 25, 2, 91, 640, 5617, Type.NORMAL),
106 HAWK_EYE("Hawk Eye", 26, 6, 702, 641, 19816, new HawkEyeListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
107 MYSTIC_LORE("Mystic Lore", 27, 6, 703, 642, 19818, new MysticLoreListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
108 STEEL_SKIN("Steel Skin", 28, 12, 92, 643, 5618, new SteelSkinListener(), Type.DEFENSIVE),
109 ULTIMATE_STRENGTH("Ultimate Strength", 31, 12, 93, 644, 5619, new UltimateStrengthListener(), Type.AGGRESSIVE),
110 INCREDIBLE_REFLEXES("Incredible Reflexes", 34, 12, 94, 645, 5620, new IncredibleReflexesListener(), Type.OFFENSIVE),
111 PROTECT_FROM_MAGIC("Protect from Magic", 37, 12, 95, 646, 5621, Type.OVERHEAD),
112 PROTECT_FROM_RANGE("Protect from Range", 40, 12, 96, 647, 5622, Type.OVERHEAD),
113 PROTECT_FROM_MELEE("Protect from Melee", 43, 12, 97, 648, 5623, Type.OVERHEAD),
114 EAGLE_EYE("Eagle Eye", 44, 12, 704, 649, 19821, new EagleEyeListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
115 MYSTIC_MIGHT("Mystic Might", 45, 12, 705, 650, 19823, new MysticMightListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
116 RETRIBUTION("Retribution", 46, 3, 98, 651, 683, Type.OVERHEAD),
117 REDEMPTION("Redemption", 49, 6, 99, 652, 684, Type.OVERHEAD),
118 SMITE("Smite", 52, 18, 100, 653, 685, Type.OVERHEAD),
119 PRESERVE("Preserve", 55, 3, 708, 654, 28001, Type.NORMAL),
120 CHIVALRY("Chivalry", 60, 24, 706, 655, 19825, new ChivalryListener(), Type.OFFENSIVE, Type.AGGRESSIVE, Type.DEFENSIVE),
121 PIETY("Piety", 70, 24, 707, 656, 19827, new PietyListener(), Type.OFFENSIVE, Type.AGGRESSIVE, Type.DEFENSIVE),
122 RIGOUR("Rigour", 74, 24, 710, 657, 28004, new RigourListener(), Type.OFFENSIVE, Type.DEFENSIVE, Type.AGGRESSIVE),
123 AUGURY("Augury", 77, 24, 712, 658, 28007, new AuguryListener(), Type.OFFENSIVE, Type.DEFENSIVE, Type.AGGRESSIVE);
124
126 public final String name;
127
129 public final int level;
130
132 private final int drainRate;
133
135 private final int config;
136
138 private final int qConfig;
139
141 private final int button;
142
144 private final CombatListener<Mob> listener;
145
147 private final Type[] types;
148
158 Prayer(String name, int level, int drainRate, int config, int qConfig, int button, Type... types) {
159 this.name = name;
160 this.level = level;
161 this.drainRate = drainRate;
162 this.config = config;
163 this.qConfig = qConfig;
164 this.button = button;
165 this.listener = null;
166 this.types = types;
167 }
168
178 Prayer(String name, int level, int drainRate, int config, int qConfig, int button, CombatListener<Mob> listener, Type... types) {
179 this.name = name;
180 this.level = level;
181 this.drainRate = drainRate;
182 this.config = config;
183 this.qConfig = qConfig;
184 this.button = button;
185 this.listener = listener;
186 this.types = types;
187 }
188
190 public static Optional<Prayer> forButton(int button) {
191 return Arrays.stream(values()).filter(p -> p.getButton() == button).findAny();
192 }
193
194 public String getName() {
195 return name;
196 }
197
198 public int getLevel() {
199 return level;
200 }
201
202 public int getDrainRate() {
203 return drainRate;
204 }
205
206 public int getConfig() {
207 return config;
208 }
209
210 public int getQConfig() {
211 return qConfig;
212 }
213
214 public int getButton() {
215 return button;
216 }
217
218 public Prayer.Type[] getTypes() {
219 return types;
220 }
221
222 private static final Collection<Prayer> OFFENSIVE = ImmutableList.of(
223 CLARITY_OF_THOUGHT, IMPROVED_REFLEXES, INCREDIBLE_REFLEXES,
224 SHARP_EYE, HAWK_EYE, EAGLE_EYE,
225 MYSTIC_WILL, MYSTIC_LORE, MYSTIC_MIGHT,
226 CHIVALRY, PIETY, RIGOUR, AUGURY
227 );
228
229 private static final Collection<Prayer> AGGRESSIVE = ImmutableList.of(
230 BURST_OF_STRENGTH, SUPERHUMAN_STRENGTH, ULTIMATE_STRENGTH,
231 SHARP_EYE, HAWK_EYE, EAGLE_EYE,
232 MYSTIC_WILL, MYSTIC_LORE, MYSTIC_MIGHT,
233 CHIVALRY, PIETY, RIGOUR
234 );
235
236 private static final Collection<Prayer> DEFENSIVE = ImmutableList.of(
237 THICK_SKIN, ROCK_SKIN, STEEL_SKIN,
238 CHIVALRY, PIETY, RIGOUR, AUGURY
239 );
240
241 public static final Collection<Prayer> OVERHEAD = ImmutableList.of(
242 PROTECT_FROM_MAGIC, PROTECT_FROM_RANGE, PROTECT_FROM_MELEE,
243 RETRIBUTION, REDEMPTION, SMITE
244 );
245
252 boolean is(Type type) {
253 return Arrays.stream(getTypes()).anyMatch(other -> type == other);
254 }
255
261 Set<Prayer> toDeactivate() {
262 Type[] types = getTypes();
263 if (types.length == 0) return EMPTY;
264 Set<Prayer> deactivate = new HashSet<>();
265 for (Type type : types) {
266 deactivate.addAll(forType(type));
267 }
268 return deactivate;
269
270 }
271 public static double getBonus(Player player) {
272 double bonus = 0;
273 if(player.equipment.getId(0) == 25438)
274 bonus += 0.4;
275 if(player.equipment.getId(4) == 25434)
276 bonus += 0.8;
277 if(player.equipment.getId(7) == 25436)
278 bonus += 0.6;
279 if(player.equipment.getId(10) == 25440)
280 bonus += 0.2;
281
282 if(player.equipment.containsAll(25438, 25434, 25436, 25440))
283 bonus = 2.5;
284
285 return bonus;
286 }
287
288
289 public boolean canToggle(Player player) {
290 if (player.skills.getLevel(Skill.PRAYER) == 0) {
291 return false;
292 }
293 if (level > player.skills.getMaxLevel(Skill.PRAYER)) {
294 return false;
295 }
296 if (this == CHIVALRY && player.skills.getMaxLevel(Skill.DEFENCE) < 60) {
297 return false;
298 }
299 if ((this == PIETY || this == RIGOUR || this == AUGURY) && player.skills.getMaxLevel(Skill.DEFENCE) < 70) {
300 return false;
301 }
302 if (this == PROTECT_ITEM && player.right.equals(PlayerRight.ULTIMATE_IRONMAN)) {
303 return false;
304 }
305 /* if ((this == PROTECT_FROM_MAGIC || this == PROTECT_FROM_MELEE || this == PROTECT_FROM_RANGE) && Area.inEventArena(player)) {
306 return false;
307 }*/
308 return PlayerRight.isAdministrator(player) || (this != RIGOUR && this != AUGURY && this != PRESERVE) || player.unlockedPrayers.contains(this);
309 }
310
311 public void reset(Player player) {
312 reset(player, null);
313 }
314
322 public void reset(Player player, String message) {
323 player.prayer.reset();
324 player.send(new SendConfig(config, 0));
325 if (message != null) {
326 player.send(new SendMessage(message));
327 }
328 }
329
330 public Optional<CombatListener<Mob>> getListener() {
331 return Optional.ofNullable(listener);
332 }
333
334 public int getHeadIcon() {
335 switch (this) {
336 case PROTECT_FROM_MAGIC:
337 return 2;
338 case PROTECT_FROM_RANGE:
339 return 1;
340 case PROTECT_FROM_MELEE:
341 return 0;
342 case RETRIBUTION:
343 return 3;
344 case REDEMPTION:
345 return 5;
346 case SMITE:
347 return 4;
348 default:
349 return -1;
350 }
351 }
352
353 Collection<Prayer> forType(Type type) {
354 switch (type) {
355 case OFFENSIVE:
356 return OFFENSIVE;
357 case DEFENSIVE:
358 return DEFENSIVE;
359 case AGGRESSIVE:
360 return AGGRESSIVE;
361 case OVERHEAD:
362 return OVERHEAD;
363 default:
364 return EMPTY;
365 }
366 }
367
368 static final Set<Prayer> EMPTY = ImmutableSet.of();
369
370 enum Type {
371 OFFENSIVE,
372 DEFENSIVE,
373 AGGRESSIVE,
374 OVERHEAD,
375 NORMAL
376 }
377}
Prayer(String name, int level, int drainRate, int config, int qConfig, int button, Type... types)
Definition Prayer.java:158
Prayer(String name, int level, int drainRate, int config, int qConfig, int button, CombatListener< Mob > listener, Type... types)
Definition Prayer.java:178
void reset(Player player, String message)
Definition Prayer.java:322
static Optional< Prayer > forButton(int button)
Definition Prayer.java:190