· 8 years ago · Dec 08, 2017, 07:42 PM
1#### COMBOS WORK MOSTLY
2#### X2 x3 x4 ect not working
3#### NEED TO CREATE VARIABLE FOR TRICKS WITH PASS TRIGGERS
4#### TRIGGERS AND TRICKS LOAD AND SAVE, YUO CAN ADD TRIGGERS IN GAME NOW EZ PZ
5#### STILL NEED TO FIX TRICKPASS VARIABLE
6
7
8import es, traceback, gamethread, effectlib, vecmath, usermsg, cPickle, playerlib, popuplib
9from math import sqrt
10import datetime as dt
11from time import strftime
12from time import time
13from math import *
14
15useridlist = []
16uid = []
17people = {}
18settings = {}
19savetrig={
20 'loc1':(0),
21 'loc2':(0),
22 'name':''
23}
24tricks = {}
25triggers = {}
26fstricks = {}
27linetriggers = {}
28linetriggerpoints = {}
29testtime = []
30trickpass={}
31rotated = {}
32
33'''trickpass = {
34 'dog gap':['deagle platform'],
35 't1000':['deagle platform']
36}'''
37
38speedexception = {
39 'chrome fs':{
40 'a':14.000
41 },
42 'dog gap from strafe':{
43 'a':14.000
44 },
45 'main to sign from strafe':{
46 'a':14.000
47 },
48 'awp to awp from strafe':{
49 'a':14.000
50 },
51 'deagle to chrome fs':{
52 'a':14.000
53 }
54}
55
56#####################################
57########## LOAD AND UNLOAD ##########
58#####################################
59
60def load():
61 global people
62 global settings
63 global tricks
64 global triggers
65 global savetrig
66 global iud
67 global speedexception
68 global linetriggers
69 global trickpass
70 global linetriggerpoints
71 global rotated
72 main = None
73 sub = None
74 trickmain = None
75 tricksub = None
76 tricksub2 = None
77 rotatedmain = None
78 rotatedsub = None
79 rotatedsub2 = None
80
81
82 try:
83 rotated = loadrotated()
84 triggers = loadtriggers()
85 linetriggers = loadlinetriggers()
86 tricks = loadtricks()
87 except:
88 print_exception()
89
90 try:
91 num = str(len(tricks))
92 #usermsg.saytext2('#all', -1, '\x04[tricks]\x03 TRICKS: \x01'+num)
93 tell_server("There are "+num+" tricks")
94 except:
95 print_exception()
96 try:
97 a = str(len(triggers) + len(linetriggers))
98 #usermsg.saytext2('#all', -1, '\x04[tricks]\x03 there are \x01'+a+'\x03 triggers.')
99 tell_server("There are "+a+" triggers")
100 except:
101 print_exception()
102 loadsettings()
103 refresh()
104 es.regsaycmd('!draw', 'sky/draw')
105 es.regsaycmd('!debug', 'sky/debug')
106 es.regsaycmd('!box', 'sky/box')
107 es.regsaycmd('!addtrigger', 'sky/addtrigger')
108 es.regsaycmd('!addline', 'sky/addline')
109 es.regsaycmd('!asd', 'sky/asd')
110 es.regsaycmd('!save', 'sky/save')
111 es.regsaycmd('!noclip', 'sky/noclip')
112 es.regsaycmd('!tele', 'sky/tele')
113 es.regsaycmd('!test', 'sky/test')
114 es.regsaycmd('!tricks', 'sky/showtricks')
115 es.regsaycmd('!addtrick', 'sky/addtrick')
116 es.regsaycmd('!edittrick', 'sky/edittrick')
117 es.regsaycmd('!addrotated', 'sky/addrotated')
118 es.regsaycmd('!editrotated', 'sky/editrotated')
119
120
121 calculatepoints()
122 #timer()
123 try:
124 savehtml()
125 es.server.queuecmd('motdfile tricks.html')
126 except:
127 print_exception()
128 tell_server("loaded.")
129 tell_server("type !tricks to view tricklist.")
130
131def unload():
132 es.unregsaycmd('!draw')
133 es.unregsaycmd('!box')
134 es.unregsaycmd('!debug')
135 es.unregsaycmd('!tricks')
136 es.unregsaycmd('!addtrigger')
137 es.unregsaycmd('!addline')
138 es.unregsaycmd('!asd')
139 es.unregsaycmd('!save')
140 es.unregsaycmd('!noclip')
141 es.unregsaycmd('!tele')
142 es.unregsaycmd('!test')
143 es.unregsaycmd('!tricks')
144 es.unregsaycmd('!addtrick')
145 es.unregsaycmd('!edittrick')
146 es.unregsaycmd('!addrotated')
147 es.unregsaycmd('!editrotated')
148 #es.unregsaycmd('!addtricks')
149 gamethread.cancelDelayed('check')
150 gamethread.cancelDelayed('speedtimer')
151 #save()
152 try:
153 savetriggers()
154 saverotated()
155 savelinetriggers()
156 savetricks()
157 #savefstricks()
158 except:
159 print_exception()
160 tell_server('unloaded.')
161
162
163
164#####################################
165########## SAVES TRICKS TO HTML FILE ##########
166#####################################
167def savehtml():
168 try:
169 savetxt = "<html><body><table width='90%' align='center'><tr><td align='center'><h1>Trick List</h1><br \><br \><table cellpadding='10px' width='75%'>"
170 for i in tricks:
171 savetxt += "<tr><td align=right>"+i+"</td><td align=right>"
172 ln = (len(tricks[i]['s'])-1)
173 count = 0
174 for trigs in tricks[i]['s']:
175 if count == ln:
176 savetxt += ("<font color=blue>"+trigs+"</font>")
177 else:
178 savetxt += ("<font color=blue>"+trigs+"</font> to ")
179 count += 1
180 savetxt += "</td></tr>"
181 savetxt += "</table></td></tr></table></body></html>"
182 filepath = '/home/switchb/css/cstrike/tricks.html'
183 f = open(filepath,'w')
184 f.write(savetxt)
185 f.close()
186 tell_server("tricks saved to motd")
187 except:
188 print_exception()
189
190
191
192 ###########################################################
193### LOADS ALL OF THE POINTS FOR LINE TRIGGERS FOR FASTER TICKER ###
194 ###########################################################
195def calculatepoints():
196 try:
197 for trigs in linetriggers:
198 count = 0
199 coord1 = ()
200 coord2 = ()
201 for locs in linetriggers[trigs]:
202 if count == 0:
203 coord1 = linetriggers[trigs][locs]
204 count +=1
205 pass
206 elif count == 1:
207 coord2 = linetriggers[trigs][locs]
208 count = 0
209 coord3 = difference(coord1, coord2)
210 coord4 = difference(coord1, coord3)
211 coord5 = difference(coord2, coord3)
212 if trigs not in linetriggerpoints:
213 linetriggerpoints[trigs] = []
214 linetriggerpoints[trigs].append(coord1)
215 linetriggerpoints[trigs].append(coord2)
216 linetriggerpoints[trigs].append(coord3)
217 linetriggerpoints[trigs].append(coord4)
218 linetriggerpoints[trigs].append(coord5)
219 else:
220 linetriggerpoints[trigs].append(coord1)
221 linetriggerpoints[trigs].append(coord2)
222 linetriggerpoints[trigs].append(coord3)
223 linetriggerpoints[trigs].append(coord4)
224 linetriggerpoints[trigs].append(coord5)
225 timer()
226 except:
227 print_exception()
228
229#####################################
230########## MENUS ##########
231#####################################
232
233def showtricks():
234 global main
235 main = None
236 userid = es.getcmduserid()
237 steamid = es.getplayersteamid(userid)
238 tricklist = []
239 if steamid == 'STEAM_0:0:7825017':
240 try:
241 main = popuplib.easymenu('main', None, clienthandler)
242 main.settitle("Tricks:")
243 for i in tricks:
244 tricklist.append(i)
245 for b in sorted(tricklist):
246 main.addoption(b, b)
247 main.send(userid)
248 except:
249 print_exception()
250
251def clienthandler(userid, choice, popupname):
252 tell_user(userid, choice)
253 if popupname == "main":
254 global sub
255 sub = None
256 sub = popuplib.easymenu('sub', None, clienthandler)
257 sub.settitle("Trick Path:")
258
259 if choice in tricks:
260 for trigs in tricks[choice]['s']:
261 sub.addoption(trigs, trigs)
262 main.unsend(userid)
263 main.delete()
264 sub.send(userid)
265 if popupname == "sub":
266 #tricks['dog gap']['s'].remove('deagle platform')
267 sub.unsend()
268 sub.delete()
269
270
271
272
273
274def adminhandler(userid, choice, popupname):
275 tell_user(userid, choice)
276 if popupname == "trickmain":
277 global tricksub
278 tricksub = None
279 tricksub = popuplib.easymenu('tricksub', None, adminhandler)
280 tricksub.settitle("Edit Trick Path:")
281 if choice in tricks:
282 if len(tricks[choice]['s']) != 0:
283 for trigs in tricks[choice]['s']:
284 tricksub.addoption(choice+"-"+trigs, trigs)
285 tricksub.addoption(choice+"-addtrigger", "->Add Trigger")
286 trickmain.unsend(userid)
287 trickmain.delete()
288 tricksub.send(userid)
289
290 if popupname == "tricksub":
291 try:
292 a = choice.split("-")
293 trick = a[0]
294 option = a[1]
295 if option == "addtrigger":
296 global tricksub2
297 tricksub2 = None
298 tricksub2 = popuplib.easymenu('tricksub2', None, adminhandler)
299 tricksub2.settitle("Select Trigger:")
300 triggerlist = []
301 for i in triggers:
302 #tricksub2.addoption(choice+"-"+i, i)
303 triggerlist.append(i)
304 for z in linetriggers:
305 #tricksub2.addoption(choice+"-"+z, z)
306 triggerlist.append(z)
307 for b in sorted(triggerlist):
308 tricksub2.addoption(choice+"-"+b, b)
309 tricksub.unsend(userid)
310 tricksub.delete()
311 tricksub2.send(userid)
312 else:
313 if trick in tricks:
314 if option in tricks[trick]['s']:
315 tricks[trick]['s'].remove(option)
316 tricksub.unsend(userid)
317 if tricksub.exists():
318 tricksub.delete()
319 global tricksub
320 tricksub = None
321 tricksub = popuplib.easymenu('tricksub', None, adminhandler)
322 tricksub.settitle("Edit Trick Path:")
323 if trick in tricks:
324 if len(tricks[trick]['s']) != 0:
325 for trigs in tricks[trick]['s']:
326 tricksub.addoption(choice+"-"+trigs, trigs)
327 tricksub.addoption(choice+"-addtrigger", "->Add Trigger")
328 tricksub.send(userid)
329 except:
330 print_exception()
331
332 if popupname == "tricksub2":
333 try:
334 a = choice.split("-")
335 trick = a[0]
336 option = a[1]
337 trigger = a[2]
338 if trick in tricks:
339 tricks[trick]['s'].append(trigger)
340 tell_user(userid, trigger+"added to "+trick)
341 tricksub2.unsend(userid)
342 tricksub2.delete()
343 global tricksub
344 tricksub = None
345 tricksub = popuplib.easymenu('tricksub', None, adminhandler)
346 tricksub.settitle("Edit Trick Path:")
347 if trick in tricks:
348 if len(tricks[trick]['s']) != 0:
349 for trigs in tricks[trick]['s']:
350 tricksub.addoption(trick+"-"+trigs, trigs)
351 else:
352 tricksub.addoption(trick+"-addtrigger", "->Add Trigger")
353 tricksub.addoption(trick+"-addtrigger", "->Add Trigger")
354 tricksub.send(userid)
355 except:
356 print_exception()
357
358
359
360def edittrick():
361 global trickmain
362 trickmain = None
363 userid = es.getcmduserid()
364 steamid = es.getplayersteamid(userid)
365 tricklist = []
366 if steamid == 'STEAM_0:0:7825017':
367 try:
368 trickmain = popuplib.easymenu('trickmain', None, adminhandler)
369 trickmain.settitle("Edit Tricks:")
370 for i in tricks:
371 tricklist.append(i)
372 for b in sorted(tricklist):
373 trickmain.addoption(b, b)
374 trickmain.send(userid)
375 except:
376 print_exception()
377
378
379def addtrick():
380 userid = es.getcmduserid()
381 steamid = es.getplayersteamid(userid)
382 if steamid == 'STEAM_0:0:7825017':
383 try:
384 message = es.getargs()
385 if message not in tricks:
386 tricks[message] = {}
387 tricks[message]['s'] = []
388 tell_user(userid, message+" \x01added.")
389 else:
390 tell_user(userid, message+" \x01already exists.")
391 except:
392 print_exception()
393
394def addrotated():
395 userid = es.getcmduserid()
396 steamid = es.getplayersteamid(userid)
397 if steamid == 'STEAM_0:0:7825017':
398 try:
399 message = es.getargs()
400 if message not in rotated:
401 rotated[message] = {}
402 rotated[message]['enabled'] = False
403 rotated[message]['corner1'] = (0, 0)
404 rotated[message]['corner2'] = (0, 0)
405 rotated[message]['corner3'] = (0, 0)
406 rotated[message]['corner4'] = (0, 0)
407 rotated[message]['maxz'] = 0.0
408 rotated[message]['minz'] = 0.0
409 rotated[message]['has2'] = False
410 tell_user(userid, message+" \x01added.")
411 else:
412 tell_user(userid, message+" \x01already exists.")
413 except:
414 print_exception()
415
416def editrotated():
417 global rotatedmain
418 rotatedmain = None
419 userid = es.getcmduserid()
420 steamid = es.getplayersteamid(userid)
421 rotatedlist = []
422 if steamid == 'STEAM_0:0:7825017':
423 try:
424 rotatedmain = popuplib.easymenu('rotatedmain', None, rotatedhandler)
425 rotatedmain.settitle("Edit Rotated Boxes:")
426 for i in rotated:
427 rotatedlist.append(i)
428 for b in sorted(rotatedlist):
429 rotatedmain.addoption(b, b)
430 rotatedmain.send(userid)
431 except:
432 print_exception()
433
434def rotatedhandler(userid, choice, popupname):
435 tell_user(userid, choice)
436 if popupname == "rotatedmain":
437 try:
438 global rotatedsub
439 rotatedsub = None
440 rotatedsub = popuplib.easymenu('rotatedsub', None, rotatedhandler)
441 rotatedsub.settitle("Edit "+choice+" Options:")
442 if choice in rotated:
443 if rotated[choice]['enabled'] == False:
444 rotatedsub.addoption(choice+"-"+'enable', "Enabled: False")
445 else:
446 rotatedsub.addoption(choice+"-"+'enable', "Enabled: True")
447 if rotated[choice]['has2'] == False:
448 rotatedsub.addoption(choice+"-"+'has2', "Has 2: False")
449 else:
450 rotatedsub.addoption(choice+"-"+'enable', "Has 2: True")
451 x, y = rotated[choice]['corner1']
452 x = str(x)
453 y = str(y)
454 out = "("+x+", "+y+")"
455 rotatedsub.addoption(choice+"-"+'corner1', out)
456 x, y = rotated[choice]['corner2']
457 x = str(x)
458 y = str(y)
459 out = "("+x+", "+y+")"
460 rotatedsub.addoption(choice+"-"+'corner2', out)
461 x, y = rotated[choice]['corner3']
462 x = str(x)
463 y = str(y)
464 out = "("+x+", "+y+")"
465 rotatedsub.addoption(choice+"-"+'corner3', out)
466 x, y = rotated[choice]['corner4']
467 x = str(x)
468 y = str(y)
469 out = "("+x+", "+y+")"
470 rotatedsub.addoption(choice+"-"+'corner4', out)
471 if rotated[choice]['has2'] == True:
472 x, y = rotated[choice]['corner5']
473 x = str(x)
474 y = str(y)
475 out = "("+x+", "+y+")"
476 rotatedsub.addoption(choice+"-"+'corner5', out)
477 x, y = rotated[choice]['corner6']
478 x = str(x)
479 y = str(y)
480 out = "("+x+", "+y+")"
481 rotatedsub.addoption(choice+"-"+'corner6', out)
482 x, y = rotated[choice]['corner7']
483 x = str(x)
484 y = str(y)
485 out = "("+x+", "+y+")"
486 rotatedsub.addoption(choice+"-"+'corner7', out)
487 x, y = rotated[choice]['corner8']
488 x = str(x)
489 y = str(y)
490 out = "("+x+", "+y+")"
491 rotatedsub.addoption(choice+"-"+'corner8', out)
492 maxz = str(rotated[choice]['maxz'])
493 minz = str(rotated[choice]['minz'])
494 rotatedsub.addoption(choice+"-maxz", "maxz value: "+maxz)
495 rotatedsub.addoption(choice+"-minz", "minz value: "+minz)
496 #rotatedmain.unsend(userid)
497 rotatedsub.send(userid)
498 except:
499 print_exception()
500
501 if popupname == "rotatedsub":
502 try:
503 a = choice.split("-")
504 trigger = a[0]
505 option = a[1]
506 if option == "enable":
507 if rotated[trigger]['enabled'] == False:
508 rotated[trigger]['enabled'] = True
509 rotatedsub.setoption(choice, "Enabled: True", state=1)
510 else:
511 rotated[trigger]['enabled'] = False
512 rotatedsub.setoption(choice, "Enabled: False", state=1)
513 elif option == "corner1":
514 loc = es.getplayerlocation(userid)
515 loc1 = (loc[0], loc[1])
516 x = str(loc[0])
517 y = str(loc[1])
518 out = "("+x+", "+y+")"
519 rotated[trigger]['corner1'] = loc1
520 rotatedsub.setoption(choice, out, state=1)
521 elif option == "corner2":
522 loc = es.getplayerlocation(userid)
523 loc1 = (loc[0], loc[1])
524 x = str(loc[0])
525 y = str(loc[1])
526 out = "("+x+", "+y+")"
527 rotated[trigger]['corner2'] = loc1
528 rotatedsub.setoption(choice, out, state=1)
529 elif option == "corner3":
530 loc = es.getplayerlocation(userid)
531 loc1 = (loc[0], loc[1])
532 x = str(loc[0])
533 y = str(loc[1])
534 out = "("+x+", "+y+")"
535 rotated[trigger]['corner3'] = loc1
536 rotatedsub.setoption(choice, out, state=1)
537 elif option == "corner4":
538 loc = es.getplayerlocation(userid)
539 loc1 = (loc[0], loc[1])
540 x = str(loc[0])
541 y = str(loc[1])
542 out = "("+x+", "+y+")"
543 rotated[trigger]['corner4'] = loc1
544 rotatedsub.setoption(choice, out, state=1)
545 elif option == "maxz":
546 loc = es.getplayerlocation(userid)
547 max = loc[2]
548 rotated[trigger]['maxz'] = max
549 max = str(max)
550 rotatedsub.setoption(choice, "maxz value: "+max, state=1)
551 elif option == "minz":
552 loc = es.getplayerlocation(userid)
553 min = loc[2]
554 rotated[trigger]['minz'] = min
555 min = str(min)
556 rotatedsub.setoption(choice, "minz value: "+min, state=1)
557 elif option == "has2":
558 if rotated[trigger]['has2'] == False:
559 rotated[trigger]['has2'] = True
560 rotatedsub.setoption(choice, "has 2: True")
561 rotated[trigger]['corner5'] = (0.0, 0.0)
562 rotated[trigger]['corner6'] = (0.0, 0.0)
563 rotated[trigger]['corner7'] = (0.0, 0.0)
564 rotated[trigger]['corner8'] = (0.0, 0.0)
565 else:
566 rotated[trigger]['has2'] = False
567 rotatedsub.setoption(choice, "has 2: False")
568 rotatedsub.update(userid)
569 rotatedsub.unsend(userid)
570 rotatedsub.send(userid)
571 #rotatedsub.update(userid)
572 '''rotatedsub.unsend(userid)
573 global rotatedsub
574 rotatedsub = None
575 rotatedsub = popuplib.easymenu('rotatedsub', None, rotatedhandler)
576 rotatedsub.settitle("Edit "+trigger+" Options:")
577 if trigger in rotated:
578 if rotated[trigger]['enabled'] == False:
579 rotatedsub.addoption(trigger+"-"+'enable', "Enabled: False")
580 else:
581 rotatedsub.addoption(trigger+"-"+'disable', "Enabled: True")
582 x = str(rotated[trigger]['corner1'][0])
583 y = str(rotated[trigger]['corner1'][1])
584 out = "("+x+", "+y+")"
585 rotatedsub.addoption(trigger+"-"+'corner1', out)
586 x = str(rotated[trigger]['corner2'][0])
587 y = str(rotated[trigger]['corner2'][1])
588 out = "("+x+", "+y+")"
589 rotatedsub.addoption(trigger+"-"+'corner2', out)
590 x = str(rotated[trigger]['corner3'][0])
591 y = str(rotated[trigger]['corner3'][1])
592 out = "("+x+", "+y+")"
593 rotatedsub.addoption(trigger+"-"+'corner3', out)
594 x = str(rotated[trigger]['corner4'][0])
595 y = str(rotated[trigger]['corner4'][1])
596 out = "("+x+", "+y+")"
597 rotatedsub.addoption(trigger+"-"+'corner4', out)
598
599
600 maxz = str(rotated[trigger]['maxz'])
601 minz = str(rotated[trigger]['minz'])
602 rotatedsub.addoption(trigger+"-maxz", "maxz value: "+maxz)
603 rotatedsub.addoption(trigger+"-minz", "minz value: "+minz)
604 rotatedsub.send(userid)'''
605 except:
606 print_exception()
607
608
609#####################################
610########## Save and Load ##########
611#####################################
612def savetriggers():
613 try:
614 date = strftime("%m-%d-%Y")
615 logfiledate = date+'.txt'
616 filepath = es.getAddonPath("sky")+'/triggers/'+logfiledate
617 FILE = open(filepath, "w")
618 cPickle.dump(triggers, FILE)
619 FILE.close()
620 except:
621 print_exception()
622
623def saverotated():
624 try:
625 date = strftime("%m-%d-%Y")
626 logfiledate = date+'.txt'
627 filepath = es.getAddonPath("sky")+'/rotated/'+logfiledate
628 FILE = open(filepath, "w")
629 cPickle.dump(rotated, FILE)
630 FILE.close()
631 except:
632 print_exception()
633
634def savelinetriggers():
635 try:
636 date = strftime("%m-%d-%Y")
637 logfiledate = date+'.txt'
638 filepath = es.getAddonPath("sky")+'/linetriggers/'+logfiledate
639 FILE = open(filepath, "w")
640 cPickle.dump(linetriggers, FILE)
641 FILE.close()
642 except:
643 print_exception()
644
645def savetricks():
646 global tricks
647 try:
648 date = strftime("%m-%d-%Y")
649 logfiledate = date+'.txt'
650 filepath = es.getAddonPath("sky")+'/tricks/'+logfiledate
651 FILE = open(filepath, "w")
652 cPickle.dump(tricks, FILE)
653 FILE.close()
654 except:
655 print_exception()
656
657def savefstricks():
658 try:
659 date = strftime("%m-%d-%Y")
660 logfiledate = date+'.txt'
661 filepath = es.getAddonPath("sky")+'/fstricks/'+logfiledate
662 FILE = open(filepath, "w")
663 cPickle.dump(fstricks, FILE)
664 FILE.close()
665 except:
666 print_exception()
667
668def loadrotated():
669 try:
670 date = strftime("%m-%d-%Y")
671 logfiledate = date+'.txt'
672 filepath = es.getAddonPath("sky")+'/rotated/'+logfiledate
673 FILE = open(filepath, "r")
674 rotated = cPickle.load(FILE)
675 FILE.close()
676 return rotated
677 except:
678 print_exception()
679
680def loadtriggers():
681 try:
682 date = strftime("%m-%d-%Y")
683 logfiledate = date+'.txt'
684 filepath = es.getAddonPath("sky")+'/triggers/'+logfiledate
685 FILE = open(filepath, "r")
686 triggers = cPickle.load(FILE)
687 FILE.close()
688 return triggers
689 except:
690 print_exception()
691
692def loadlinetriggers():
693 try:
694 date = strftime("%m-%d-%Y")
695 logfiledate = date+'.txt'
696 filepath = es.getAddonPath("sky")+'/linetriggers/'+logfiledate
697 FILE = open(filepath, "r")
698 linetriggers = cPickle.load(FILE)
699 FILE.close()
700 return linetriggers
701 except:
702 print_exception()
703
704def loadtricks():
705 global tricks
706 try:
707 date = strftime("%m-%d-%Y")
708 logfiledate = date+'.txt'
709 filepath = es.getAddonPath("sky")+'/tricks/'+logfiledate
710 FILE = open(filepath, "r")
711 tricks = cPickle.load(FILE)
712 FILE.close()
713 return tricks
714 except:
715 print_exception()
716
717def loadfstricks():
718 try:
719 date = strftime("%m-%d-%Y")
720 logfiledate = date+'.txt'
721 filepath = es.getAddonPath("sky")+'/fstricks/'+logfiledate
722 FILE = open(filepath, "r")
723 fstricks = cPickle.load(FILE)
724 FILE.close()
725 return fstricks
726 except:
727 print_exception()
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744#####################################
745########## ADD LINE TRIGGERS AND LINES
746#####################################
747def addline():
748 global linetriggers
749 userid = es.getcmduserid()
750 steamid = es.getplayersteamid(userid)
751 loc = es.getplayerlocation(userid)
752 if steamid == 'STEAM_0:0:7825017':
753 try:
754 message = es.getargs()
755 if message in linetriggers:
756 if linetriggers[message] == {}:
757 linetriggers[message]['0'] = loc
758 x, y, z = loc
759 x = str(x)
760 y = str(y)
761 z = str(z)
762 tell_user(userid, x+" "+y+" "+z+" added")
763 else:
764 ln = str(len(linetriggers[message]))
765 linetriggers[message][ln] = loc
766 x, y, z = loc
767 x = str(x)
768 y = str(y)
769 z = str(z)
770 tell_user(userid, x+" "+y+" "+z+" added")
771
772 except:
773 print_exception()
774
775def addtrigger():
776 global linetriggers
777 userid = es.getcmduserid()
778 steamid = es.getplayersteamid(userid)
779 if steamid == 'STEAM_0:0:7825017':
780 try:
781 message = es.getargs()
782 if message not in linetriggers:
783 linetriggers[message] = {}
784 tell_user(userid, "trigger ["+message+"] created")
785 except:
786 print_exception()
787
788
789
790
791
792
793#####################################
794########## SAVES TRICKS TO HTML FILE ##########
795#####################################
796'''def savetricks():
797 try:
798 savetxt = "<html><body><table width='600' align='center'><tr><td align='center'><h1>Trick List</h1><br \><br \><table>"
799 for i in tricks:
800 savetxt += "<tr><td>"+i+"</td><td></tr>"
801 #for amount in tricks[i]:
802 #for trigs in amount[0]:
803 #savetxt += (translate[amount[0][trigs]]+" ")
804 #savetxt += "</td></tr>"
805 savetxt += "</table></td></tr></table></body></html>"
806 filepath = '/home/switchb/css/cstrike/tricks.html'
807 f = open(filepath,'w')
808 f.write(savetxt)
809 f.close()
810 tell_server("tricks saved")
811 except:
812 print_exception()'''
813
814
815
816#####################################
817########## NOCLIP / TESTING ##########
818#####################################
819def noclip():
820 userid = es.getcmduserid()
821 steamid = es.getplayersteamid(userid)
822 if steamid == 'STEAM_0:0:7825017':
823 try:
824 me = playerlib.getPlayer(userid)
825 nc = me.noclip
826 if nc == 0:
827 me.noclip = 1
828 tell_user(userid, "noclip enabled.")
829 else:
830 me.noclip = 0
831 tell_user(userid, "noclip disabled.")
832 except:
833 print_exception()
834
835def cross(a, b, c):
836 return (((b[0] - a[0])*(c[1] - a[1])) - ((b[1] - a[1])*(c[0] - a[0])))
837
838def test():
839 userid = es.getcmduserid()
840 try:
841 #A function to check whether point P(x, y) lies inside the triangle formed
842 #by A(x1, y1), B(x2, y2) and D(x3, y3)
843 #by C(x1, y1), D(x2, y2) and B(x3, y3)
844
845 '''wedge5 west GOOD
846 (-4796.903809, 2135.776123, -1191.837158)
847 (-4414.416504, 1765.388916, -1225.174194)
848 (-4788.012695, 1392.025146, -1226.973877)
849 (-5154.923340, 1780.625122, -1197.654297)
850 '''
851 '''wedge 4 wst GOOD
852 (-4502.458984, 2811.379639, -813.852844)
853 [tricks] (-4132.039551, 2438.511963, -851.719116)
854 [tricks] (-4480.808105, 2066.248535, -834.004028)
855 [tricks] (-4862.180176, 2447.129150, -298.442566)
856 '''
857 '''wedge 5 east GOOD
858 (-4778.200195, -1397.818726, -631.043518)
859 [tricks] (-4416.620605, -1759.829834, -593.947632)
860 [tricks] (-4800.916992, -2143.006592, -1187.756836)
861 [tricks] (-5160.668457, -1780.948608, -1135.378784)
862 '''
863 '''4thdeagleeast WORKS
864 (4538.910156, -4272.215820, 3275.698242)
865 [tricks] (5421.883301, -3765.129150, 3322.720459)
866 [tricks] (5694.761719, -4231.598145, 2715.654297)
867 [tricks] (4809.183105, -4742.844727, 2730.021729)
868 '''
869 ''' main ramp test (one positive one negative)
870 (988.863525, 233.451935, 4408.530273)
871 [tricks] (1488.718628, 249.632919, 4383.617188)
872 [tricks] (1490.898926, -239.130692, 4383.698730)
873 [tricks] (1051.781982, -239.813797, 4384.056641)
874
875 '''
876
877 a = (988.863525, 233.451935)
878 b = (1488.718628, 249.632919)
879 c = (1490.898926, -239.130692)
880 d = (1051.781982, -239.813797)
881
882 loc = es.getplayerlocation(userid)
883 e = (loc[0], loc[1])
884 test = cross(a, b, e)
885 test2 = cross(b, c, e)
886 test3 = cross(c, d, e)
887 test4 = cross(d, a, e)
888 if (test4 < 0) and (test3 < 0) and (test2 < 0) and (test < 0):
889 tell_user(userid, "inside?")
890 else:
891 tell_user(userid, "outside?")
892
893 '''loc = es.getplayerlocation(userid)
894 e = (fabs(loc[0]), fabs(loc[1]))
895
896
897 A = getarea(a[0],a[1],b[0],b[1],d[0],d[1])
898 A1 = getarea(e[0], e[1], b[0], b[1], d[0], d[1])
899 A2 = getarea(a[0], a[1], e[0], e[1], d[0], d[1])
900 A3 = getarea(a[0], a[1], b[0], b[1], e[0], e[1])
901
902 B = getarea(c[0],c[1],d[0],d[1],b[0],b[1])
903 B1 = getarea(e[0], e[1], d[0], d[1], b[0], b[1])
904 B2 = getarea(c[0], c[1], e[0], e[1], b[0], b[1])
905 B3 = getarea(c[0], c[1], d[0], d[1], e[0], e[1])
906
907 if (A == (A1 + A2 + A3)):
908 tell_user(userid, "inside box")
909 else:
910 tell_user(userid, "not inside box")'''
911 except:
912 print_exception()
913
914def asd():
915 #m_hGroundEntity
916 # m_fFlags in air
917 #m_flFallVelocity
918 #gr = str(es.getplayerprop(userid, "CBaseEntity.m_fFlags"))
919 userid = es.getcmduserid()
920 steamid = es.getplayersteamid(userid)
921 if steamid == 'STEAM_0:0:7825017':
922 try:
923 #2013-12-30 23:59:59
924 #a = datetime.now()
925 a = "1"
926 except:
927 print_exception()
928
929
930
931
932
933#####################################
934########## TELEPORT ##########
935#####################################
936def tele():
937 global people
938 userid = es.getcmduserid()
939 try:
940 es.setplayerprop(userid, "CBasePlayer.localdata.m_vecBaseVelocity", es.createvectorstring(-es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[0]"), -es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[1]"), -es.getplayerprop(userid, "CBasePlayer.localdata.m_vecVelocity[2]")))
941 es.setplayerprop(userid, "CBasePlayer.m_iHealth", 100)
942 es.setang(userid, 0.0,0.0,0.0)
943 for z in people[userid]['total']:
944 people[userid]['total'].remove(z)
945 es.server.queuecmd('es_xsetpos %s %f %f %f' % (userid, -1838.519531, 23.961834, 7208.031250))
946 trickstr = ""
947 if people[userid]['seq'] != []:
948 ccount = len(people[userid]['seq'])
949 ccoun2 = 1
950 if ccount != 1:
951 for trick in people[userid]['seq']:
952 trickstr += (trick + " to ")
953 ccoun2 +=1
954 name = es.getplayername(userid)
955 usermsg.saytext2('#all', 2, '\x07ff33ff#\x01'+name+' \x07ff33ff'+trickstr)
956 people[userid]['seq'] = []
957 people[userid]['time'] = {}
958 except:
959 print_exception()
960
961
962
963def tell_server(message):
964 message = str(message)
965 usermsg.saytext2('#all', 2, '\x01[\x07ff33fftricks\x01]\x0733ffff '+message)
966
967def tell_user(userid, message):
968 message = str(message)
969 usermsg.saytext2(userid, -1, '\x01[\x07ff33fftricks\x01]\x0733ffff '+message)
970
971def round_start(ev):
972 try:
973 gamethread.cancelDelayed('check')
974 refresh()
975 timer()
976 except:
977 print_exception()
978
979
980def player_spawn(ev):
981 try:
982 userid = ev['userid']
983 refresh_player(userid)
984 except:
985 print_exception()
986
987def loadsettings():
988 settings['debug'] = 0
989
990def debug():
991 try:
992 userid = es.getcmduserid()
993 steam = es.getplayersteamid(userid)
994 if steam == 'STEAM_0:0:7825017':
995 a = settings['debug']
996 if a == 0:
997 settings['debug'] = 1
998 #es.server.cmd('es_unload spec')
999 tell_user(userid, 'debug on')
1000 else:
1001 settings['debug'] = 0
1002 #es.server.cmd('es_load spec')
1003 tell_user(userid, 'debug off')
1004 except:
1005 print_exception()
1006
1007def player_activate(ev):
1008 userid = ev['userid']
1009 refresh_player(userid)
1010
1011def refresh():
1012 try:
1013 list = []
1014 list = es.getUseridList()
1015 for i in list:
1016 people[i]={}
1017 people[i]['last']=''
1018 people[i]['total'] = []
1019 people[i]['speed']=0.00
1020 people[i]['seq'] = []
1021 people[i]['lasttrick'] = ""
1022 people[i]['time'] = {}
1023 except:
1024 print_exception()
1025
1026def refresh_player(userid):
1027 try:
1028 if userid in people:
1029 del people[userid]
1030 people[userid]={}
1031 people[userid]['last']=''
1032 if 'total' in people[userid]:
1033 for z in people[userid]['total']:
1034 people[userid]['total'].remove(z)
1035 else:
1036 people[userid]['total'] = []
1037 people[userid]['speed']=0.00
1038 people[userid]['seq'] = []
1039 people[userid]['lasttrick'] = ""
1040 people[userid]['time'] = {}
1041 except:
1042 print_exception()
1043
1044def speedtimer():
1045 global uid
1046 try:
1047 tellspeed(uid.pop())
1048 except:
1049 uid = es.getUseridList()
1050
1051 gamethread.delayedname(0, 'speedtimer', speedtimer)
1052
1053def getspeed(userid):
1054 #CBasePlayer.localdata.m_hGroundEntity
1055 x = es.getplayerprop(userid,'CBasePlayer.localdata.m_vecVelocity[0]')
1056 y = es.getplayerprop(userid,'CBasePlayer.localdata.m_vecVelocity[1]')
1057 z = es.getplayerprop(userid,'CBasePlayer.localdata.m_vecVelocity[2]')
1058 #km/h
1059 speed = int(round((x*x + y*y + z*z)**0.5, 2) / float(37) * 1.6)
1060 speed = float(speed) * 0.621371192
1061 #speed = sqrt(x*x + y*y + z*z)
1062 #speed = speed / 30.0000
1063 speed = str(speed)
1064 speed = speed[:7]
1065 return speed
1066
1067def tellspeed(userid):
1068 try:
1069 speed = getspeed(userid)
1070 #tell_user(userid, "speed: "+speed+" m/h")
1071 text = "speed\n"+speed[:5]+" m/h"
1072 es.usermsg('create', 'saytext2', 'KeyHintText')
1073 es.usermsg('write', 'byte', 'saytext2', 1)
1074 es.usermsg('write', 'string', 'saytext2', text)
1075 es.usermsg('send', 'saytext2', userid)
1076 es.usermsg('delete', 'saytext2')
1077 except:
1078 print_exception()
1079
1080def timer():
1081 global useridlist
1082 try:
1083 check(useridlist.pop())
1084 except:
1085 useridlist = es.getUseridList()
1086
1087 gamethread.delayedname(0, 'check', timer)
1088
1089
1090
1091def check(userid):
1092 steamid = es.getplayersteamid(userid)
1093 if not es.exists("userid", userid):
1094 #not connected anymore
1095 return
1096 if es.getplayerprop(userid, "CBasePlayer.pl.deadflag") != 0:
1097 #dead
1098 return
1099 if es.getplayerteam(userid) < 2:
1100 #spec
1101 return
1102 where = es.getplayerlocation(userid)
1103 out = []
1104 good = 0
1105 trigger = ''
1106 speed = float(getspeed(userid))
1107
1108 '''
1109 try:
1110 if len(linetriggerpoints) != 0:
1111 for trigs in linetriggerpoints:
1112 for points in linetriggerpoints[trigs]:
1113 dist = vecmath.distance(points, where)
1114 if dist < 140:
1115 trigger = trigs
1116 if settings['debug'] == 1:
1117 good = 1
1118 except:
1119 print_exception()'''
1120
1121 try:
1122 for trigs in rotated:
1123 if rotated[trigs]['enabled'] == True:
1124 if rotated[trigs]['has2'] == False:
1125 a = rotated[trigs]['corner1']
1126 b = rotated[trigs]['corner2']
1127 c = rotated[trigs]['corner3']
1128 d = rotated[trigs]['corner4']
1129
1130 e = (where[0], where[1])
1131 z = where[2]
1132 minz = rotated[trigs]['minz']
1133 maxz = rotated[trigs]['maxz']
1134 test = cross(a, b, e)
1135 test2 = cross(b, c, e)
1136 test3 = cross(c, d, e)
1137 test4 = cross(d, a, e)
1138 if (test4 < 0) and (test3 < 0) and (test2 < 0) and (test < 0):
1139 if z > minz:
1140 if z < maxz:
1141 trigger = trigs
1142 if settings['debug'] == 1:
1143 good = 1
1144 except:
1145 print_exception()
1146
1147 for trigs in triggers:
1148 #numb_locs = len(triggers[trigs])
1149 count = 0
1150 loc1 = ()
1151 loc2 = ()
1152 ####SEES IF USER IS IN A TRIGGER#########
1153 for locs in triggers[trigs]:
1154 try:
1155 if count == 0:
1156 loc1 = triggers[trigs][locs]
1157 count +=1
1158 pass
1159 elif count == 1:
1160 loc2 = triggers[trigs][locs]
1161 count = 0
1162 if vecmath.isbetweenRect(where, loc1, loc2):
1163 trigger = trigs
1164 #t = time()
1165 #people[userid]['time'][trigs] = t
1166 if settings['debug'] == 1:
1167 good = 1
1168 except:
1169 print_exception()
1170
1171
1172
1173 #### IF USER GOES THROUGH BOTTOM TELE, IT resets
1174 if trigger != '':
1175 if trigger == 'top':
1176 if people[userid]['last'] == 'pool teleporter':
1177 try:
1178 for z in people[userid]['total']:
1179 people[userid]['total'].remove(z)
1180 trickstr = ""
1181 if people[userid]['seq'] != []:
1182 ccount = len(people[userid]['seq'])
1183 ccoun2 = 1
1184 if ccount != 1:
1185 for trick in people[userid]['seq']:
1186 trickstr += (trick + " to ")
1187 ccoun2 +=1
1188 name = es.getplayername(userid)
1189 usermsg.saytext2('#all', 2, '\x07ff33ff#\x01'+name+' \x07ff33ff'+trickstr)
1190 people[userid]['seq'] = []
1191 people[userid]['time'] = {}
1192 except:
1193 print_exception()
1194 if trigger != people[userid]['last']:
1195 if settings['debug'] == 1:
1196 steam = es.getplayersteamid(userid)
1197 if steam == 'STEAM_0:0:7825017' or steam == 'STEAM_0:0:16706001':
1198 try:
1199 tell_user(userid, 'on point '+trigger)
1200 except:
1201 pass
1202 else:
1203 if trigger == 'a':
1204 people[userid]['speed'] = speed
1205
1206 #OLD REPETATIVE CODE
1207 if trigger != '':
1208 if trigger != people[userid]['last']:
1209 people[userid]['total'].append(trigger)
1210 people[userid]['last'] = trigger
1211 if good == 1:
1212 if steamid == 'STEAM_0:0:7825017':
1213 seq = ""
1214 for i in people[userid]['total']:
1215 seq += i
1216 tell_user(userid, seq)
1217 try:
1218 checktrick(userid, speed, trigger)
1219 except:
1220 print_exception()
1221
1222
1223def checktrick(userid, speed, trigger):
1224 name = ""
1225 speed = str(speed)
1226 #people[userid]['seq']
1227 try:
1228 #UPDATE: THIS NOW CHECKS TRICKS, FSTRICKS DELETED
1229 for i in tricks:
1230 #GETS EACH TRIG IN TRICK SEQUENCE
1231 fseq = ""
1232 totalseq = ""
1233 temp = people[userid]['total']
1234 if i in trickpass:
1235 for d in trickpass[i]:
1236 if d in temp:
1237 temp.remove(d)
1238 #tell_user(userid, "removing pass: "+d)
1239 for c in temp:
1240 totalseq += c
1241 for seq in tricks[i]['s']:
1242 #GETS SEQUENCE FOR TRICK AND COMPARES TO TOTALSEQ
1243 fseq += seq
1244 ###IF SEQUENCE IS IN TOTAL THEN WE HAVE A TRICK
1245 if fseq in totalseq:
1246 #tell_user(userid, fseq)
1247 #tell_user(userid, "found in ")
1248 #tell_user(userid, totalseq)
1249 #SEEIS IF TRICK HAS A SPEED EXCEPTION
1250 if i in speedexception:
1251 for trig in speedexception[i]:
1252 ### IF A TRICK HAS A SPEED EXCEPTION IT CHECKS IT HERE
1253 if speedexception[i][trig] > people[userid]['speed']:
1254 #speed = str(speedexception[i][trig])+">" + str(people[userid]['speed'])
1255 #tell_user(userid, speed)
1256 name = es.getplayername(userid)
1257 trik = i
1258 #tell_user(userid, trik+" found")
1259 sequence = seq
1260 else:
1261 tell_user(userid, "going to fast")
1262 else:
1263 name = es.getplayername(userid)
1264 trik = i
1265 #tell_user(userid, trik+" found")
1266 sequence = seq
1267 else:
1268 #tell_user(userid, fseq)
1269 #tell_user(userid, "NOT IN")
1270 #tell_user(userid, totalseq)
1271 poop = "lol"
1272
1273 #IF IT FINDS IT IN TRICKS IT WILL TELL YOU AND RESET TOTAL / RETURN
1274 if name != "":
1275 '''if trik in tricks:
1276 l = (len(tricks[trik]['s']) - 1)
1277 trig2 = tricks[trik]['s'][l]
1278 trig1 = tricks[trik]['s'][0]
1279 trig2 = people[userid]['time'][trig2]
1280 trig1 = people[userid]['time'][trig1]
1281 t = (trig2 - trig1)
1282 t = str(t)'''
1283 for z in people[userid]['total']:
1284 people[userid]['total'].remove(z)
1285 people[userid]['seq'].append(trik)
1286 '''if people[userid]['lasttrick'] != "":
1287 if trik == "deagle wrap":
1288 if people[userid]['lasttrick'] == "deagle wrap":
1289 trik = "deagle wrap x2"
1290 else:
1291 trick = people[userid]['lasttrick']
1292 l = (len(trick) - 1)
1293 u = str(int(trick[l]) + 1)
1294 trik = trick[:l] + u'''
1295 people[userid]['total'].append(trigger)
1296 people[userid]['lasttrick'] = trik
1297 usermsg.saytext2('#all', 2, '\x07ff33ff#\x01'+name+'\x07ff33ff '+trik+"\x01 going \x0733ffff"+speed+"\x01mph")
1298 #+" m/h\x05 in \x03"+t+"\x05 seconds"
1299 except:
1300 print_exception()
1301
1302def box():
1303 userid = es.getcmduserid()
1304 x, y, z = es.getplayerlocation(userid)
1305 me = (x, y, z)
1306 tell_user(userid, '(%f, %f, %f)'%me)
1307
1308
1309def draw_really(loc1, loc2):
1310 effectlib.drawBox(loc1, loc2,
1311 model="materials/sprites/laser.vmt",
1312 halo="materials/sprites/halo01.vmt",
1313 seconds=10,
1314 width=5,
1315 endwidth=10,
1316 red=255,
1317 green=255,
1318 blue=255,
1319 brightness=255,
1320 speed=10,
1321 fadelength=0,
1322 noise=0,
1323 framestart=0,
1324 framerate=0)
1325
1326def draw():
1327 userid = es.getcmduserid()
1328 steamid = es.getplayersteamid(userid)
1329 message = es.getargs()
1330 if steamid == 'STEAM_0:0:7825017':
1331 try:
1332 if message in triggers:
1333 count = 0
1334 loc1 = ()
1335 loc2 = ()
1336 for trigs in triggers[message]:
1337 if count == 0:
1338 loc1 = triggers[message][trigs]
1339 if count == 1:
1340 loc2 = triggers[message][trigs]
1341 gamethread.delayed(1.0, draw_really, (loc1, loc2))
1342 count += 1
1343 if count == 2:
1344 count = 0
1345 elif message in linetriggers:
1346 count = 0
1347 loc1 = ()
1348 loc2 = ()
1349 for trigs in linetriggers[message]:
1350 if count == 0:
1351 loc1 = linetriggers[message][trigs]
1352 if count == 1:
1353 loc2 = linetriggers[message][trigs]
1354 effectlib.drawLine(loc1, loc2, seconds=5)
1355 count += 1
1356 if count == 2:
1357 count = 0
1358 elif message == 'all':
1359 for i in triggers:
1360 count = 0
1361 loc1 = ()
1362 loc2 = ()
1363 for trigs in triggers[i]:
1364 if count == 0:
1365 loc1 = triggers[i][trigs]
1366 if count == 1:
1367 loc2 = triggers[i][trigs]
1368 gamethread.delayed(1.0, draw_really, (loc1, loc2))
1369 count += 1
1370 if count == 2:
1371 count = 0
1372 except:
1373 print_exception()
1374
1375
1376def print_exception():
1377 formatted_lines = traceback.format_exc().splitlines()
1378 userid = es.getuserid('switchb')
1379 for line in formatted_lines:
1380 es.tell(userid, '#multi', '#green :::#default %s'%line)
1381
1382 ####################################################
1383 ###THIS FUNCTION CALCULATES A POINT BETWHEEN TWO POINTS###
1384 ####################################################
1385def difference(tup1, tup2):
1386 x1, y1, z1 = tup1
1387 x2, y2, z2 = tup2
1388 ########################
1389 ####CALCULATES X #######
1390 ########################
1391 if x1 < 0:
1392 # x negative and x2 positive
1393 if x2 > 0:
1394 ##removes negative and makes positive, then adds together and finds difference / 2
1395 x1 = str(x1)
1396 x1 = float(x1[1:])
1397 dif = ((x1+x2) / 2)
1398
1399 #new x =
1400 x3 = (x2-dif)
1401 #tell_user(userid, "difference between (-1300 and 900) / 2 is: "+new)
1402
1403 #x negative and x2 negative
1404 else:
1405 dif = (x1 - x2) / 2
1406 if x1 < x2:
1407 x3 = x1 - dif
1408 else:
1409 x3 = x2 - dif
1410 #x1 >0
1411 else:
1412
1413 #x postive and x2 negative
1414 if x2 < 0:
1415 x2 = str(x2)
1416 x2 = float(x2[1:])
1417 dif = (x1+x2) / 2
1418 x3 = (x1-dif)
1419
1420 #x positive and x2 positive
1421 else:
1422 if x1 < x2:
1423 dif = (x2 - x1) / 2
1424 x3 = x2 - dif
1425 else:
1426 dif = (x1 - x2) / 2
1427 x3 = x2 + dif
1428
1429 ########################
1430 ####CALCULATES Y #######
1431 ########################
1432 if y1 < 0:
1433 # y negative and y2 positive
1434 if y2 > 0:
1435 ##removes negative and makes positive, then adds together and finds difference / 2
1436 y1 = str(y1)
1437 y1 = float(y1[1:])
1438 dif = ((y1+y2) / 2)
1439
1440 #new y =
1441 y3 = (y2-dif)
1442 #tell_user(userid, "difference between (-1300 and 900) / 2 is: "+new)
1443
1444 #y negative and y2 negative
1445 else:
1446 dif = y1 + y2
1447 if y1 < y2:
1448 y3 = y1 - dif
1449 else:
1450 y3 = y2 - dif
1451 #y1 >0
1452 else:
1453 #y postive and y2 negative
1454 if y2 < 0:
1455 y2 = str(y2)
1456 y2 = float(y2[1:])
1457 dif = (y1+y2) / 2
1458 y3 = (y1-dif)
1459
1460 #y positive and y2 positive
1461 else:
1462 if y1 < y2:
1463 dif = (y2 - y1) / 2
1464 y3 = y2 - dif
1465 else:
1466 dif = (y1 - y2) / 2
1467 y3 = y2 + dif
1468
1469 ########################
1470 ####CALCULATES Z #######
1471 ########################
1472 if z1 < 0:
1473 # z negative and z2 positive
1474 if z2 > 0:
1475 ##removes negative and makes positive, then adds together and finds difference / 2
1476 z1 = str(z1)
1477 z1 = float(z1[1:])
1478 dif = ((z1+z2) / 2)
1479
1480 #new z =
1481 z3 = (z2-dif)
1482 #tell_user(userid, "difference between (-1300 and 900) / 2 is: "+new)
1483
1484 #z negative and z2 negative
1485 else:
1486 dif = z1 + z2
1487 if z1 < z2:
1488 z3 = z1 - dif
1489 else:
1490 dif = (z1-z2) /2
1491 z3 = z2 - dif
1492 #z1 >0
1493 else:
1494
1495 #z postive and z2 negative
1496 if z2 < 0:
1497 z2 = str(z2)
1498 z2 = float(z2[1:])
1499 dif = (z1+z2) / 2
1500 x3 = (z1-dif)
1501
1502 #z positive and z2 positive
1503 else:
1504 if z1 < z2:
1505 dif = (z2 - z1) / 2
1506 z3 = z2 - dif
1507 else:
1508 dif = (z1 - z2) / 2
1509 z3 = z2 + dif
1510
1511 #############################
1512 ##RETURN THE NEW COORDINATE##
1513 #############################
1514 newtup = (x3, y3, z3)
1515 return newtup