-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPestControl2.java
132 lines (115 loc) · 5.51 KB
/
PestControl2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import org.rspeer.runetek.adapter.component.InterfaceComponent;
import org.rspeer.runetek.adapter.scene.Npc;
import org.rspeer.runetek.adapter.scene.Player;
import org.rspeer.runetek.adapter.scene.SceneObject;
import org.rspeer.runetek.api.commons.Time;
import org.rspeer.runetek.api.commons.math.Random;
import org.rspeer.runetek.api.component.Interfaces;
import org.rspeer.runetek.api.input.menu.tree.WalkAction;
import org.rspeer.runetek.api.movement.Movement;
import org.rspeer.runetek.api.movement.position.Area;
import org.rspeer.runetek.api.movement.position.Position;
import org.rspeer.runetek.api.scene.Npcs;
import org.rspeer.runetek.api.scene.Players;
import org.rspeer.runetek.api.scene.SceneObjects;
import org.rspeer.script.Script;
import org.rspeer.script.ScriptMeta;
import org.rspeer.ui.Log;
@ScriptMeta(developer = "Sri", name = "Pest Control2", desc = "PC2")
public class PestControl2 extends Script {
Player local;
private static final Area BOAT_DOCK = Area.rectangular(new Position(2638, 2655), new Position(2640, 2652));
private static final Area BOAT_AREA = Area.rectangular(new Position(2632, 2654), new Position(2635, 2649));
private Area pestControlIslandCenter;
//12257, 7028
private Position landingPoint;
private static final Position BOAT_POSITION = new Position(2638, 2654);
private String state = "start";
int gameCount = 0;
int winCount = 0;
public int getRand(int low, int high) {
low = low - 100;
high = high + 100;
int highRand = org.rspeer.runetek.api.commons.math.Random.high(low, high);
int lowRand = org.rspeer.runetek.api.commons.math.Random.low(low, high);
int rand;
if (org.rspeer.runetek.api.commons.math.Random.nextInt(0, 100) < 50) {
rand = lowRand;
}
else {
rand = highRand;
}
return rand;
}
@Override
public int loop() {
local = Players.getLocal();
if (state.equals("start")) {
// Log.fine("State is " + state);
if (BOAT_DOCK.contains(local.getPosition())) {
Time.sleep(getRand(1000, 2000));
SceneObjects.getNearest("Gangplank").interact("Cross");
Time.sleepUntil(() -> BOAT_AREA.contains(Players.getLocal().getPosition()), getRand(4500, 6000));
}
if (BOAT_AREA.contains(local.getPosition())) {
state = "onBoat";
// Log.fine("State set to " + state);
}
}
if (state.equals("onBoat")) {
// Log.fine("State is " + state);
// Time.sleepUntil(() -> !BOAT_AREA.contains(Players.getLocal().getPosition()), 60000);
if (!BOAT_AREA.contains(local.getPosition()) && local.getX() > 3000) {
state = "landed";
// Log.fine("State set to " + state);
}
}
if (state.equals("landed")) {
// Log.fine("State is " + state);
Position walkSouth = new Position(Players.getLocal().getPosition().getX() + Random.nextInt(-1, 1), Players.getLocal().getPosition().getY() - Random.nextInt(14, 18));
Log.fine(walkSouth.toString());
Time.sleep(getRand(500, 1500));
Movement.walkTo(walkSouth);
Time.sleepUntil(() -> Players.getLocal().getPosition().distance(walkSouth) < 5, getRand(25000, 35000));
Npc voidKnight = Npcs.getNearest("Void Knight"); //
Position voidKnightBottomLeft = new Position(voidKnight.getPosition().getX() - 3, voidKnight.getPosition().getY() - 3);
Position voidKnightTopRight = new Position(voidKnight.getPosition().getX() + 3, voidKnight.getPosition().getY() + 3);
pestControlIslandCenter = Area.rectangular(voidKnightBottomLeft, voidKnightTopRight);
Movement.walkTo(Random.nextElement(pestControlIslandCenter.getTiles()));
Time.sleepUntil(() -> pestControlIslandCenter.contains(local.getPosition()), getRand(7500, 13000));
if (pestControlIslandCenter.contains(local.getPosition())) {
state = "inCenter";
// Log.fine("State set to " + state);
}
}
if (state.equals("inCenter")) {
// Log.fine("State is " + state);
Npc monster = Npcs.getNearest(n -> (!(n.getName().equals("Void Knight")) && !(n.getName().equals("Squire")) && !(n.getName().equals("")) && pestControlIslandCenter.contains(n.getPosition())));
if (monster != null) {
Time.sleep(getRand(600, 1200));
monster.interact("Attack");
// Log.fine("Attack " + monster.getName());
Time.sleepUntil(() -> Players.getLocal().getTarget() == null, 4500);
//Time.sleepUntil(() -> monster.getHealthPercent() == 0, 15000);
// Log.fine(monster.getName() + " Killed");
Time.sleep(getRand(600, 1200));
}
}
if (state.equals("inCenter") && BOAT_DOCK.contains(local.getPosition())) {
// Log.fine("State is InBoat and " + state);
state = "start";
gameCount++;
Time.sleepUntil(() -> Interfaces.isOpen(231), getRand(3500, 5000));
if (Interfaces.isOpen(231)) {
winCount++;
}
else if (Interfaces.isOpen(229)) {
//Loss
}
Log.severe("GameCount: " + gameCount);
Log.severe("WinCount: " + winCount);
// Log.fine("State set to " + state);
}
return getRand(200, 600);
}
}