-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathEVEWatcher.iss
265 lines (241 loc) · 8.71 KB
/
EVEWatcher.iss
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/* EveBots.iss - The purpose of this script is to automatically launch all accounts
in an ISBoxer character set.
WHAT YOU NEED TO DO:
1) Set up the launcher for your characters.
2) Make an ISBoxer character set for any characters you want started or regenerated.
3) Configure the characters in the ISBoxer set to automatically start the launcher
with that slot's character.
4) Set the variables appropriately in the main function under the line saying "Adjust these"
/* This will automatically close all sessions 5 minutes after downtime and start them back up ,
as well as regenerating any that crash. */
variable(global) obj_EveWatcher EVEWatcher
#define FIVE_MINUTES_MS 1000 * 60 * 5
#define ONE_MINUTE_MS 1000 * 60
#define DEBUG TRUE
/* main() - script entry point. */
function main()
{
/* Make sure we're run in the uplink */
if ${Session} != NULL
{
echo "EveBots.iss: This script may only be run from the uplink. Use \"uplink run EveBots\" or"
echo "open the uplink console and run it from there."
return
}
/* Adjust these */
/* REMEMBER TO ADJUST THESE FOR DAYLIGHT SAVINGS TIME */
variable int DowntimeHour = 6
variable int UptimeHour = 7
variable string CharacterSet = "SomeSet" /* Name of the ISBoxer Character Set goes here */
variable int CharactersInSet = 0 /* Number of characters in the ISBoxer Set */
/* Don't touch below this line */
/* LS.RT uses time in ms */
variable int Timer = ${LavishScript.RunningTime}
variable int CrashedSessions = 0
variable int TimesReportedLow = 0
variable iterator CalledBackIterator
variable iterator SessionIterator
variable iterator LastUpdateIterator
/* Loop every minute. */
while 1==1
{
/* Broadcast callback and check for crashes every minute. Only regenerate sessions every five minutes. */
/* Wait until a bit after the last launcher says it's in-game */
if DEBUG
echo "EveBots.iss: LS.RT: ${LavishScript.RunningTime}, EW.LauncherTimer: ${EVEWatcher.LauncherTimer}"
if ${LavishScript.RunningTime} >= ${EVEWatcher.LauncherTimer}
{
/* Broadcast for our callback */
if DEBUG
echo "EveBots.iss: Broadcasting callback request to all other sessions then waiting 5 seconds."
relay "all other" EVECallback:DoCallback
wait 50
}
/* Get our iterators. */
EVEWatcher.Characters_CalledBack:GetIterator[CalledBackIterator]
EVEWatcher.Characters_Session:GetIterator[SessionIterator]
EVEWatcher.Characters_LastUpdate:GetIterator[LastUpdateIterator]
/* Close any crashed sessions. If we do have to close any, wait a few seconds after closing to
give our system a bit of a break between closing sessions and immediately restarting them. */
if ${CalledBackIterator:First(exists)} && ${SessionIterator:First(exists)} && ${LastUpdateIterator:First(exists)}
{
do
{
/* If a session hasn't called back for over 60 seconds it's probably crashed. */
if (${LavishScript.RunningTime} - ${LastUpdateIterator.Value}) > FIVE_MINUTES_MS && ${LastUpdateIterator.Value} != NULL
{
if DEBUG
echo "EveBots.iss: Haven't heard from ${CalledBackIterator.Key} in over five minutes. Killing ${SessionIterator.Value}."
kill ${SessionIterator.Value}
CrashedSessions:Inc
wait 10
}
}
while ${CalledBackIterator:Next(exists)} && ${SessionIterator:Next(exists)} && ${LastUpdateIterator:Next(exists)}
}
/* The regeneration check will only run every five mintues. */
if ${LavishScript.RunningTime} >= ${Timer}
{
if DEBUG
echo "EveBots.iss: Regeneration check."
/* Update the timer */
Timer:Set[${Math.Calc[${LavishScript.RunningTime} + FIVE_MINUTES_MS]}]
/* If we're between downtime and uptime and there are running sessions, kill them. */
if ${Time.Hour} >= ${DowntimeHour} && ${Time.Hour} < ${UptimeHour} && ${EVEWatcher.Characters_Session.Used} > 0
{
if DEBUG
echo "EveBots.iss: Downtime started, killing all Watched sessions."
EVEWatcher:CloseSessions[]
EVEWatcher:ResetCalledBack[]
EVEWatcher.Characters_CalledBack:Clear
EVEWatcher.Characters_Session:Clear
}
/* If we're after uptime, make sure we have our sessions up. */
/* Just use isboxer to launch the char set. Each char will have a different profile and therefore a different evebot,
allowing for autologin to work. */
if (${CrashedSessions} > 0 || ${EVEWatcher.Characters_CalledBack.Used} < ${CharactersInSet}) && (${Time.Hour} >= ${UptimeHour} || ${Time.Hour} < ${DowntimeHour})
{
/* We need to account for fuckups, i.e. bad login, account expired, account *shudder* closed. Lower CharactersInSet if we repeatedly
have CalledBack report less than we're expecting so we don't spam launch. */
if ${EVEWatcher.Characters_CalledBack.Used} < ${CharactersInSet}
{
if DEBUG
echo "EveBots.iss: CallBacks reporting low, incrementing counter..."
TimesReportedLow:Inc
if ${TimesReportedLow} > 5
{
if DEBUG
echo "EveBots.iss: Characters reported low five times, problems? Lowering CharactersInSet just in case."
CharactersInSet:Set[${EVEWatcher.Characters_CalledBack.Used}]
TimesReportedLow:Set[0]
}
}
if DEBUG
echo "EveBots.iss: Downtime passed and ${CrashedSessions} crashed sessions detected or no sessions running; regenerating bots."
run isboxer -launch "${CharacterSet}"
/* If this is our first run give at least five minutes for everything to start up. */
if ${EVEWatcher.Characters_CalledBack.Used} == 0
{
if DEBUG
echo "EveBots.iss: First launch, giving sessions some time to start so that Me.Name isn't null for callback..."
TimesReportedLow:Dec
/* Must change this wait into a real timer, maybe? */
wait ${Math.Calc[10 * 60 * 4]}
/* Wait 4 minutes here and the other minute down there. */
}
}
}
/* Sleep for 1 minute. */
/* 10 deciseconds per second, 60 seconds per minute */
if DEBUG
echo "EveBots.iss: Sleeping 1 minute."
wait ${Math.Calc[10 * 60]}
}
}
/* The object for the eve callbacks. */
objectdef obj_EveWatcher
{
/* Parallel collections to hold our characters paired with a bool designating
whether or not we got the callback and a string to hold the session. We will
use this to kill a crashed session so we can regenerate them. */
variable collection:bool Characters_CalledBack
variable collection:string Characters_Session
variable collection:int Characters_LastUpdate
/* Timer Launcher will update. */
variable int LauncherTimer = ${Math.Calc[${LavishScript.RunningTime} + 60 * 1000]}
/* Another emtpy initialize function. */
method Initialize()
{
/* This code did not work because of a UTF-8 vs ASCII conflict.
Had to make some hackish modifications to insert names based on callbacks. */
}
/* Reset the CalledBack collection to false. */
method ResetCalledBack()
{
variable iterator itrCalledBack
Characters_CalledBack:GetIterator[itrCalledBack]
if DEBUG
echo "EveBots.iss: Resetting CalledBack list."
if ${itrCalledBack:First(exists)}
{
do
{
itrCalledBack:SetValue[FALSE]
}
while ${itrCalledBack:Next(exists)}
}
}
/* Set the variables from callbacks.
session: The session that's calling back.
characterName: The name of the character in the session calling back. */
method Update(string newSession, string characterName)
{
if !${characterName.Equal[NULL]}
{
Characters_CalledBack:Set[${characterName},TRUE]
Characters_LastUpdate:Set[${characterName},${LavishScript.RunningTime}]
Characters_Session:Set[${characterName},${newSession}]
}
}
/* Close all of our saved sessions. */
method CloseSessions()
{
variable iterator itrSession
Characters_Session:GetIterator[itrSession]
if ${itrSession:First(exists)}
{
do
{
if DEBUG
{
echo "EveBots.iss: Closing session ${itrSession.Value}"
}
kill ${itrSession.Value}
}
while ${itrSession:Next(exists)}
}
}
/* Debug methods to dump the collections */
method DumpSession()
{
echo "EveBots: Dumping sessions:"
variable iterator itrSession
Characters_Session:GetIterator[itrSession]
if ${itrSession:First(exists)}
{
do
{
echo "EveBots: ${itrSession.Key} ${itrSession.Value}"
}
while ${itrSession:Next(exists)}
}
}
method DumpCalledBack()
{
echo "EveBots: Dumping CalledBack:"
variable iterator itrCalledBack
Characters_CalledBack:GetIterator[itrCalledBack]
if ${itrCalledBack:First(exists)}
{
do
{
echo "EveBots: ${itrCalledBack.Key} ${itrCalledBack.Value}"
}
while ${itrCalledBack:Next(exists)}
}
}
method DumpLastUpdate()
{
echo "EveBots: Dumping LastUpdate:"
variable iterator itrLastUpdate
Characters_LastUpdate:GetIterator[itrLastUpdate]
if ${itrLastUpdate:First(exists)}
{
do
{
echo "EveBots: ${itrLastUpdate.Key} ${itrLastUpdate.Value}"
}
while ${itrLastUpdate:Next(exists)}
}
}
}