-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProbeHelperSE.py
431 lines (366 loc) · 12.9 KB
/
ProbeHelperSE.py
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
try:
import uix
import uiutil
import mathUtil
import xtriui
import uthread
import form
import blue
import util
import trinity
import service
import listentry
import base
import math
import sys
import geo2
import maputils
import copy
from math import pi, cos, sin, sqrt
from foo import Vector3
from mapcommon import SYSTEMMAP_SCALE
from traceback import format_exception
import functools
import uiconst
import uicls
import listentry
import state
try:
Scanner_old_apply_attributes
except NameError:
Scanner_old_apply_attributes = form.Scanner.ApplyAttributes
def safetycheck(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except:
try:
print "exception in " + func.__name__
(exc, e, tb,) = sys.exc_info()
result2 = (''.join(format_exception(exc, e, tb)) + '\n').replace('\n', '<br>')
sm.GetService('gameui').MessageBox(result2, "ProbeHelper Exception")
except:
print "exception in safetycheck"
return wrapper
@safetycheck
def MyAddTab(self):
ret = uix.NamePopup(mls.UI_CMD_ADD_TAB, mls.UI_INFLIGHT_TYPELABEL, maxLength=15)
if not ret:
return
numTabs = 8
tabsettings = settings.user.overview.Get('tabsettings', {})
if (len(tabsettings) >= numTabs):
eve.Message('TooManyTabs', {'numTabs': numTabs})
return
if (len(tabsettings) == 0):
newKey = 0
else:
newKey = (max(tabsettings.keys()) + 1)
oldtabsettings = tabsettings
tabsettings[newKey] = {'name': ret['name'],
'overview': None,
'bracket': None}
if self.destroyed:
return
self.OnOverviewTabChanged(tabsettings, oldtabsettings)
form.OverView.AddTab = MyAddTab
@safetycheck
def ContractProbes(self, *args):
scanSvc = sm.GetService("scanSvc")
probeData = [(k,v) for (k,v) in scanSvc.GetProbeData().iteritems() if v.state == const.probeStateIdle]
if len(probeData) == 0:
return
avg = sum( (v.destination for (k,v) in probeData), Vector3() ) / len(probeData)
min_range = min( v.rangeStep for (k,v) in probeData )
if (min_range <= 1):
return
for (k,v) in probeData:
destination = (v.destination + avg)/2
scanSvc.SetProbeDestination(k, destination)
scanSvc.SetProbeRangeStep(k, v.rangeStep - 1)
self.UpdateProbeSpheres()
form.Scanner.ContractProbes = ContractProbes
@safetycheck
def ExpandProbes(self, *args):
scanSvc = sm.GetService("scanSvc")
probeData = [(k,v) for (k,v) in scanSvc.GetProbeData().iteritems() if v.state == const.probeStateIdle]
if len(probeData) == 0:
return
avg = sum( (v.destination for (k,v) in probeData), Vector3() ) / len(probeData)
max_range = max( v.rangeStep for (k,v) in probeData )
if (max_range >= const.scanProbeNumberOfRangeSteps):
return
for (k,v) in probeData:
destination = (2 * v.destination) - avg
scanSvc.SetProbeDestination(k, destination)
scanSvc.SetProbeRangeStep(k, v.rangeStep + 1)
self.UpdateProbeSpheres()
form.Scanner.ExpandProbes = ExpandProbes
@safetycheck
def SendProbes(self, *args):
selected = self.sr.resultscroll.GetSelected()
points = []
target = Vector3(0,0,0)
target2 = Vector3(0,0,0)
try:
itemid = eve.LocalSvc("window").GetWindow("selecteditemview").itemIDs[0]
ball= eve.LocalSvc("michelle").GetBallpark().GetBall(itemid)
target2= Vector3(ball.x,ball.y, ball.z)
except:
sm.GetService('gameui').Say("No active item, going to scan results")
if selected:
for sel in selected:
data = sel.result.data
if isinstance(data, float):
data = sel.result.pos
if not isinstance(data, Vector3):
data = data.point
points.append(data)
csum = 0
for p in points:
target += p
target /= len(points)
if uicore.uilib.Key(uiconst.VK_SHIFT) or (not selected):
target = target2
scanSvc = sm.GetService("scanSvc")
probeData = [(k,v) for (k,v) in scanSvc.GetProbeData().iteritems() if v.state == const.probeStateIdle]
if len(probeData) == 0:
return
avg = sum( (v.destination for (k,v) in probeData), Vector3() ) / len(probeData)
for (k,v) in probeData:
destination = target + v.destination - avg
scanSvc.SetProbeDestination(k, destination)
self.UpdateProbeSpheres()
form.Scanner.SendProbes = SendProbes
@safetycheck
def SaveLoadProbePositions(self, *args):
scanSvc = sm.GetService("scanSvc")
probeData = [(k,v) for (k,v) in scanSvc.GetProbeData().iteritems() if v.state == const.probeStateIdle]
if len(probeData) == 0:
return
settingsName = 'ProbePositons2' if uicore.uilib.Key(uiconst.VK_CONTROL) else 'ProbePositions'
if uicore.uilib.Key(uiconst.VK_SHIFT):
settings.public.ui.Set(settingsName, [(v.destination, v.rangeStep) for (k,v) in probeData])
return
pos = settings.public.ui.Get(settingsName, [])
if( pos == [] ):
return
for ((probekey, probevalue), (dest,rstep)) in zip(probeData, pos):
scanSvc.SetProbeDestination(probekey, dest)
scanSvc.SetProbeRangeStep(probekey, rstep)
self.UpdateProbeSpheres()
form.Scanner.SaveLoadProbePositions = SaveLoadProbePositions
@safetycheck
def GoToLocations(self, *args):
selected = self.sr.resultscroll.GetSelected()
scanSvc = sm.GetService("scanSvc")
probeData = [(k,v) for (k,v) in scanSvc.GetProbeData().iteritems() if v.state == const.probeStateIdle]
avg = sum( (v.destination for (k,v) in probeData), Vector3() ) / len(probeData)
if len(probeData) == 0:
return
points = []
try:
for sel in selected:
data = sel.result.data
if isinstance(data, float):
data = sel.result.pos
if not isinstance(data, Vector3):
data = data.point
points.append(data)
target = Vector3(0,0,0)
csum = 0
for p in points:
target += p
target /= len(points)
except:
stub = "stubmsg"
if uicore.uilib.Key(uiconst.VK_SHIFT):
settings.public.ui.Set("Locations%d"%(args[0]), target)
return
elif uicore.uilib.Key(uiconst.VK_CONTROL):
settings.public.ui.Set("Locations%d"%(args[0]), avg)
return
else:
target = settings.public.ui.Get("Locations%d"%(args[0]))
for (k,v) in probeData:
destination = target + v.destination - avg
scanSvc.SetProbeDestination(k, destination)
self.UpdateProbeSpheres()
form.Scanner.GoToLocations = GoToLocations
@safetycheck
def GoToLocations1(self, *args):
GoToLocations(self, 1, args)
form.Scanner.GoToLocations1 = GoToLocations1
@safetycheck
def GoToLocations2(self, *args):
GoToLocations(self, 2, args)
form.Scanner.GoToLocations2 = GoToLocations2
@safetycheck
def GoToLocations3(self, *args):
GoToLocations(self, 3, args)
form.Scanner.GoToLocations3 = GoToLocations3
@safetycheck
def MyLoadResultList(self):
if ((self is None) or self.destroyed):
return
scanSvc = sm.GetService('scanSvc')
currentScan = scanSvc.GetCurrentScan()
scanningProbes = scanSvc.GetScanningProbes()
results = scanSvc.GetScanResults()
if self.destroyed:
return
self.CleanupResultShapes()
resultlist = []
if (currentScan and (blue.os.TimeDiffInMs(currentScan.startTime) < currentScan.duration)):
data = util.KeyVal()
data.header = mls.UI_GENERIC_ANALYZING
data.startTime = currentScan.startTime
data.duration = currentScan.duration
resultlist.append(listentry.Get('Progress', data=data))
elif (scanningProbes and (session.shipid not in scanningProbes)):
data = util.KeyVal()
data.label = mls.UI_GENERIC_SCAN_WAITING_FOR_PROBES
data.hideLines = 1
resultlist.append(listentry.Get('Generic', data=data))
elif results:
bp = sm.GetService('michelle').GetBallpark(doWait=True)
if (bp is None):
return
ego = bp.balls[bp.ego]
myPos = Vector3(ego.x, ego.y, ego.z)
for result in results:
if (result.id in scanSvc.resultsIgnored):
continue
if ((self.currentFilter is not None) and (len(self.currentFilter) > 0)):
if (result.certainty >= const.probeResultGood):
if (result.groupID not in self.currentFilter):
continue
else:
if (result.scanGroupID not in self.activeScanGroupInFilter):
continue
id = result.id
probeID = result.probeID
certainty = result.certainty
typeID = result.Get('typeID', None)
result.typeName = None
result.groupName = None
result.scanGroupName = self.scanGroups[result.scanGroupID]
if (certainty >= const.probeResultGood):
explorationSite = (result.groupID in (const.groupCosmicAnomaly, const.groupCosmicSignature))
if explorationSite:
result.groupName = self.GetExplorationSiteType(result.strengthAttributeID)
else:
result.groupName = cfg.invgroups.Get(result.groupID).name
if (certainty >= const.probeResultInformative):
if explorationSite:
result.typeName = result.dungeonName
else:
result.typeName = cfg.invtypes.Get(typeID).name
if isinstance(result.data, Vector3):
dist = (result.data - myPos).Length()
if result.groupName == None:
result.groupName = cfg.invgroups.Get(result.groupID).name
elif isinstance(result.data, float):
dist = result.data
certainty = min(0.9999, certainty)
else:
dist = (result.data.point - myPos).Length()
certainty = min(0.9999, certainty)
if result.groupName == None:
result.groupName = cfg.invgroups.Get(result.groupID).name
texts = [result.id,
result.scanGroupName,
(result.groupName or ''),
(result.typeName or ''),
(('%1.2f' % (min(1.0, certainty) * 100)) + '%'),
util.FmtDist(dist)]
sortdata = [result.id,
result.scanGroupName,
(result.groupName or ''),
(result.typeName or ''),
(min(1.0, certainty) * 100),
dist]
data = util.KeyVal()
data.texts = texts
data.sortData = sortdata
data.columnID = 'probeResultGroupColumn'
data.result = result
data.GetMenu = self.ResultMenu
resultlist.append(listentry.Get('ColumnLine', data=data))
resultlist = listentry.SortColumnEntries(resultlist, 'probeResultGroupColumn')
data = util.KeyVal()
data.texts = [mls.UI_GENERIC_ID,
mls.UI_GENERIC_SCAN_GROUP,
mls.UI_GENERIC_GROUP,
mls.UI_GENERIC_TYPE,
mls.UI_GENERIC_SIGNALSTRENGTH,
mls.UI_GENERIC_DISTANCE]
data.columnID = 'probeResultGroupColumn'
data.editable = True
data.showBottomLine = True
data.selectable = False
data.hilightable = False
resultlist.insert(0, listentry.Get('ColumnLine', data=data))
listentry.InitCustomTabstops(data.columnID, resultlist)
if not resultlist:
data = util.KeyVal()
data.label = mls.UI_GENERIC_NO_SCAN_RESULT
data.hideLines = 1
resultlist.append(listentry.Get('Generic', data=data))
resultlist.append(listentry.Get('Line', data=util.KeyVal(height=1)))
self.sr.resultscroll.Load(contentList=resultlist)
self.sr.resultscroll.ShowHint('')
self.HighlightGoodResults()
form.Scanner.LoadResultList = MyLoadResultList
@safetycheck
def Nuke(self, *args):
self.SendProbes (*args)
self.Analyze(*args)
form.Scanner.Nuke = Nuke
@safetycheck
def MyApplyAttributes(self, attributes):
Scanner_old_apply_attributes(self, attributes)
self.sr.destroyBtn.Close()
btn = uix.GetBigButton(32, self.sr.systemTopParent, left=108)
btn.OnClick = self.SaveLoadProbePositions
btn.hint = "SHIFT-CLICK TO SAVE PROBES, CLICK TO LOAD PROBES"
btn.sr.icon.LoadIcon('44_03')
self.sr.saveloadBtn = btn
btn = uix.GetBigButton(32, self.sr.systemTopParent, left=152)
btn.OnClick = self.ContractProbes
btn.hint = "CONTRACT PROBES"
btn.sr.icon.LoadIcon('44_43')
self.sr.contractBtn = btn
btn = uix.GetBigButton(32, self.sr.systemTopParent, left=184)
btn.OnClick = self.ExpandProbes
btn.hint = "EXPAND PROBES"
btn.sr.icon.LoadIcon('44_44')
self.sr.expandBtn = btn
btn = uix.GetBigButton(32, self.sr.systemTopParent, left=228)
btn.OnClick = self.SendProbes
btn.hint = "SEND PROBES TO SELECTED RESULT"
btn.sr.icon.LoadIcon('44_59')
self.sr.sendBtn = btn
btn = uix.GetBigButton(32, self.sr.systemTopParent, left=270)
btn.OnClick = self.GoToLocations1
btn.hint = "SAVE/SEND TO LOCATION1"
btn.sr.icon.LoadIcon('77_21')
self.sr.GoToBtn = btn
btn = uix.GetBigButton(32, self.sr.systemTopParent, left=302)
btn.OnClick = self.GoToLocations2
btn.hint = "SAVE/SEND TO LOCATION2"
btn.sr.icon.LoadIcon('77_21')
self.sr.GoToBtn = btn
btn = uix.GetBigButton(32, self.sr.systemTopParent, left=334)
btn.OnClick = self.GoToLocations3
btn.hint = "SAVE/SEND TO LOCATION3"
btn.sr.icon.LoadIcon('77_21')
self.sr.GoToBtn = btn
btn = uix.GetBigButton(40, self.sr.systemTopParent, left=400)
btn.OnClick = self.Nuke
btn.hint = "DECLOAK THE BITCH"
btn.sr.icon.LoadIcon('44_59')
self.sr.TwoInOneBtn = btn
form.Scanner.ApplyAttributes = MyApplyAttributes
except:
print "ProbeHelper broken."