RuneHive-Game
Loading...
Searching...
No Matches
TrapExecution.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.hunter.trap;
2
3import com.runehive.game.world.entity.mob.npc.Npc;
4import com.runehive.game.world.entity.skill.Skill;
5import com.runehive.util.Utility;
6
7public class TrapExecution {
8
9 public static void setTrapProcess(Trap trap) {
10 for (final Npc npc : TrapManager.HUNTER_NPC_LIST) {
11 if (npc == null || !npc.isVisible()) {
12 continue;
13 }
14 if (trap instanceof BoxTrap && npc.id != 5079 && npc.id != 5080)
15 continue;
16 if (trap instanceof SnareTrap && (npc.id == 5079 || npc.id == 5080))
17 continue;
18 if (npc.getPosition().isWithinDistance(trap.getGameObject().getPosition(), 1)) {
19 if (Utility.random(100) < successFormula(trap)) {
21 return;
22 }
23 }
24 }
25 }
26
27 public static int successFormula(Trap trap) {
28 if (trap.getOwner() == null)
29 return 0;
30 int chance = 70;
31
32 if (TrapManager.hasLarupia(trap.getOwner())) {
33 chance = chance + 10;
34 }
35
36 chance = chance + (int) (trap.getOwner().skills.getLevel(Skill.HUNTER) / 1.5) + 10;
37
38 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 25)
39 chance = (int) (chance * 1.5) + 8;
40 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 40)
41 chance = (int) (chance * 1.4) + 3;
42 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 50)
43 chance = (int) (chance * 1.3) + 1;
44 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 55)
45 chance = (int) (chance * 1.2);
46 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 60)
47 chance = (int) (chance * 1.1);
48 if (trap.getOwner().skills.getLevel(Skill.HUNTER) < 65)
49 chance = (int) (chance * 1.05) + 3;
50
51 return chance;
52 }
53
54 public static boolean trapTimerManagement(Trap trap) {
55 if (trap.getTicks() > 0)
56 trap.setTicks(trap.getTicks() - 1);
57 if (trap.getTicks() <= 0) {
59 if (trap.getOwner() != null)
60 trap.getOwner().message("You left your trap for too long, and it collapsed.");
61 }
62 return true;
63 }
64}
Represents a non-player character in the in-game world.
Definition Npc.java:29
Represents a trainable and usable skill.
Definition Skill.java:18
static final int HUNTER
The hunter skill id.
Definition Skill.java:87
boolean isWithinDistance(Position other, int radius)
Checks if this location is within range of another.
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239