-
Notifications
You must be signed in to change notification settings - Fork 0
/
Joker.java
143 lines (114 loc) · 3.64 KB
/
Joker.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
133
134
135
136
137
138
139
140
141
142
package scripts;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.powerbot.script.*;
import org.powerbot.script.rt4.*;
import org.powerbot.script.rt4.ClientContext;
import scripts.tasks.*;
import scripts.tasks.Bank;
import java.util.concurrent.Callable;
@Script.Manifest(name="Joker", description = "I tell jokes around GE for donations", properties = "author=Tortidip; topic=999; client=4;")
public class Joker extends PollingScript<ClientContext> implements MessageListener {
public boolean in_business = false;
public boolean joking = false;
public int n_sale_talks=0;
public int counter = 0;
public Task shout;
public Task walk;
public Task bank;
public TellJoke tellJoke;
public Trade trade;
public CheckInventory checkInventory;
public int inventoryCount;
public int coinCount;
public String possibleCustomer;
public Random rand = new Random();
@Override
public void start(){
System.out.println("Starting script");
shout = new Shout(ctx);
walk = new Walk(ctx);
tellJoke = new TellJoke(ctx);
checkInventory = new CheckInventory(ctx);
bank = new Bank(ctx);
}
@Override
public void stop(){
System.out.println("Stopping script");
}
@Override
public void poll() {
//main loop
if(!joking && !in_business && bank.activate()){
bank.execute();
}
else if(joking){
ctx.input.sendln("kk coming up");
if(possibleCustomer!=null) {
tellJoke.tell();
possibleCustomer = null;
joking = false;
in_business = false;
}
}
else if(in_business && !joking) {
if (!trade.opened()) {
if (checkInventory.getAmount() > inventoryCount || checkInventory.getCoin() > coinCount) {
// System.out.println("joke time");
joking = true;
} else {
ctx.input.sendln("No freebies m8 :/ i've got to feed my family.");
in_business = false;
possibleCustomer = null;
}
}
}
else if(trade != null && trade.isTrading() && !in_business){
if(trade.firstOpened() && trade.hasPlayerAccepted()){
trade.accept();
System.out.println(coinCount);
}
else if(trade.secondOpened() && trade.hasPlayerAccepted()){
trade.accept();
in_business = true;
}
}
else {
counter++;
inventoryCount = checkInventory.getAmount();
coinCount = checkInventory.getCoin();
//System.out.println(counter);
if (!in_business && counter > rand.nextInt(200,300)) {
shout();
}
if (!in_business && n_sale_talks == 5) {
walk();
}
}
}
public void shout(){
if(shout.activate()){
n_sale_talks++;
shout.execute();
counter = 0;
}
}
public void walk(){
if(walk.activate()){
walk.execute();
n_sale_talks = 0;
}
}
@Override
public void messaged(MessageEvent messageEvent) {
//System.out.println(messageEvent.text());
if(messageEvent.type() == 101 && !in_business) {
String tradePlayer = messageEvent.source();
trade = new Trade(ctx, tradePlayer);
trade.initTrade();
possibleCustomer = tradePlayer;
}
else if (messageEvent.source() == possibleCustomer){
tellJoke.answered = true;
}
}
}