RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
TrapExecution.java
1package com.osroyale.content.skill.impl.hunter.trap;
2
3import com.osroyale.game.world.entity.mob.npc.Npc;
4import com.osroyale.game.world.entity.skill.Skill;
5import com.osroyale.util.Utility;
6
27
28public class TrapExecution {
29
30 public static void setTrapProcess(Trap trap) {
31 for (final Npc npc : TrapManager.HUNTER_NPC_LIST) {
32 if (npc == null || !npc.isVisible()) {
33 continue;
34 }
35 if (trap instanceof BoxTrap && npc.id != 5079 && npc.id != 5080)
36 continue;
37 if (trap instanceof SnareTrap && (npc.id == 5079 || npc.id == 5080))
38 continue;
39 if (npc.getPosition().isWithinDistance(trap.getGameObject().getPosition(), 1)) {
40 if (Utility.random(100) < successFormula(trap)) {
41 TrapManager.catchNPC(trap, npc);
42 return;
43 }
44 }
45 }
46 }
47
48 public static int successFormula(Trap trap) {
49 if (trap.getOwner() == null)
50 return 0;
51 int chance = 70;
52
53 if (TrapManager.hasLarupia(trap.getOwner())) {
54 chance = chance + 10;
55 }
56
57 chance = chance + (int) (trap.getOwner().skills.getLevel(Skill.HUNTER) / 1.5) + 10;
58
59 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 25)
60 chance = (int) (chance * 1.5) + 8;
61 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 40)
62 chance = (int) (chance * 1.4) + 3;
63 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 50)
64 chance = (int) (chance * 1.3) + 1;
65 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 55)
66 chance = (int) (chance * 1.2);
67 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 60)
68 chance = (int) (chance * 1.1);
69 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 65)
70 chance = (int) (chance * 1.05) + 3;
71
72 return chance;
73 }
74
75 public static boolean trapTimerManagement(Trap trap) {
76 if (trap.getTicks() > 0)
77 trap.setTicks(trap.getTicks() - 1);
78 if (trap.getTicks() <= 0) {
79 TrapManager.deregister(trap);
80 if (trap.getOwner() != null)
81 trap.getOwner().message("You left your trap for too long, and it collapsed.");
82 }
83 return true;
84 }
85}
boolean isWithinDistance(Position other, int radius)