2017-10-07 23:37:53 +00:00
|
|
|
import sys
|
|
|
|
import Scrap
|
|
|
|
import quickconsole
|
2017-10-09 18:53:18 +00:00
|
|
|
import MissionsFuncs
|
2018-12-22 03:25:18 +00:00
|
|
|
import SScorer
|
|
|
|
import Menu
|
|
|
|
QC = quickconsole
|
|
|
|
MF = MissionsFuncs
|
|
|
|
last_frame = None
|
|
|
|
|
|
|
|
|
|
|
|
def reload():
|
|
|
|
sys.settrace(None)
|
|
|
|
sys.modules['__builtin__'].reload(sys.modules['dbg'])
|
|
|
|
|
|
|
|
|
|
|
|
def dgb_info():
|
|
|
|
txt =`last_frame`
|
|
|
|
SScorer.SetLabelText(txt, Scrap.GetTime()+0.1)
|
|
|
|
Scrap.AddScheduledFunc(Scrap.GetTime()+0.1, dgb_info, (), "dbg_info")
|
|
|
|
|
|
|
|
|
|
|
|
def crazy():
|
|
|
|
E = Scrap.GetFirst()
|
|
|
|
me = Scrap.UsrEntity(0)
|
|
|
|
while E:
|
|
|
|
if E.Name == me.Name:
|
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
try:
|
|
|
|
E.Action = "CrazyInit"
|
|
|
|
E.CanPhoto = 1
|
|
|
|
E.DefLoop = "Crazy"
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
|
|
|
|
|
|
|
|
def decrazy():
|
|
|
|
E = Scrap.GetFirst()
|
|
|
|
me = Scrap.UsrEntity(0)
|
|
|
|
while E:
|
|
|
|
if E.Name == me.Name:
|
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
try:
|
|
|
|
E.Action = "CrazyEnd"
|
|
|
|
E.CanPhoto = 0
|
|
|
|
E.ForceDefLoop = "Relax"
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
|
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
def p_s(*args):
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = ""
|
2017-10-07 23:37:53 +00:00
|
|
|
for obj in args:
|
|
|
|
if msg:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+" "+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
else:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
Scrap.Print(msg)
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
def p_e(*args):
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = ""
|
2017-10-07 23:37:53 +00:00
|
|
|
for obj in args:
|
|
|
|
if msg:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+" "+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
else:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
Scrap.ConsoleError(msg)
|
2018-12-22 03:25:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
sys.stdout.write = p_s
|
|
|
|
sys.stderr.write = p_e
|
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
|
|
|
|
def p(*args):
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = ""
|
2017-10-07 23:37:53 +00:00
|
|
|
for obj in args:
|
|
|
|
if msg:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+" "+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
else:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
Scrap.Print(msg+"\n")
|
2018-12-22 03:25:18 +00:00
|
|
|
|
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
def e(*args):
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = ""
|
2017-10-07 23:37:53 +00:00
|
|
|
for obj in args:
|
|
|
|
if msg:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+" "+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
else:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
Scrap.ConsoleError(msg+"\n")
|
2018-12-22 03:25:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
# sys.modules['__builtin__'].__dict__['print']=e
|
|
|
|
sys.modules['__builtin__'].__dict__['s_write'] = p
|
|
|
|
sys.modules['__builtin__'].__dict__['e_write'] = e
|
|
|
|
|
|
|
|
|
|
|
|
def modhelp(Module="Scrap"):
|
|
|
|
print "======== [ " + Module + " ] ========"
|
|
|
|
exec("import "+Module)
|
|
|
|
for v in dir(eval(Module)):
|
|
|
|
if v in ("__doc__", "__name__"):
|
|
|
|
continue
|
|
|
|
print v + ":"
|
|
|
|
try:
|
|
|
|
print " " + eval(Module + "." + v + ".__doc__")
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def helpfunc(func):
|
|
|
|
print func.__name__+":"
|
|
|
|
print " "+func.__doc__
|
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
|
|
|
|
for module in sys.builtin_module_names:
|
2018-12-22 03:25:18 +00:00
|
|
|
if module[0] == "S":
|
2017-10-07 23:37:53 +00:00
|
|
|
print "Loading "+module
|
2018-12-22 03:25:18 +00:00
|
|
|
exec("import " + module)
|
2017-10-07 23:37:53 +00:00
|
|
|
|
|
|
|
sys.settrace(None)
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
|
|
|
def trace(frame, event, arg):
|
|
|
|
global last_frame
|
|
|
|
if event != "call":
|
|
|
|
return
|
|
|
|
g = frame.f_globals
|
|
|
|
l = frame.f_locals
|
|
|
|
if frame.f_code.co_name == "godcall":
|
2017-10-07 23:37:53 +00:00
|
|
|
return
|
2018-12-22 03:25:18 +00:00
|
|
|
if frame.f_code.co_filename == ".\\lib\\dbg.py":
|
|
|
|
return
|
|
|
|
R = frame.f_code.co_filename+": "+frame.f_code.co_name+"("
|
2017-10-07 23:37:53 +00:00
|
|
|
for i in range(frame.f_code.co_argcount):
|
|
|
|
name = frame.f_code.co_varnames[i]
|
2018-12-22 03:25:18 +00:00
|
|
|
R = R+name+"="+repr(frame.f_locals[name])+","
|
|
|
|
R = R+") Consts: ["
|
2017-10-07 23:37:53 +00:00
|
|
|
for const in frame.f_code.co_consts:
|
2018-12-22 03:25:18 +00:00
|
|
|
R = R+repr(const)+","
|
|
|
|
R = R+"]"
|
|
|
|
print R, "Locals:", l, "Globals:", g
|
|
|
|
last_frame = R
|
2017-10-07 23:37:53 +00:00
|
|
|
return trace
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
def menu():
|
|
|
|
import Menu
|
2018-12-22 03:25:18 +00:00
|
|
|
Menu.DebugMenu(1, '')
|
|
|
|
Menu.InitMenuSys(1)
|
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
|
|
|
|
def settrace():
|
|
|
|
sys.settrace(trace)
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
|
|
|
def notrace():
|
|
|
|
sys.settrace(None)
|
|
|
|
|
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
def log(*args):
|
|
|
|
if not args:
|
2018-12-22 03:25:18 +00:00
|
|
|
open(logfile_name, "w").close()
|
2017-10-07 23:37:53 +00:00
|
|
|
return
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = ""
|
2017-10-07 23:37:53 +00:00
|
|
|
for obj in args:
|
|
|
|
if msg:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+" "+str(obj)
|
2017-10-07 23:37:53 +00:00
|
|
|
else:
|
2018-12-22 03:25:18 +00:00
|
|
|
msg = msg+str(obj)
|
|
|
|
open(logfile_name, "a").write(msg+"\n")
|
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
|
|
|
|
def helplib():
|
2018-12-22 03:25:18 +00:00
|
|
|
global logfile_name
|
2017-10-07 23:37:53 +00:00
|
|
|
print "Generating helplib.txt"
|
2018-12-22 03:25:18 +00:00
|
|
|
logfile_name = "helplib.txt"
|
2017-10-07 23:37:53 +00:00
|
|
|
log()
|
2018-12-22 03:25:18 +00:00
|
|
|
for modname, mod in sys.modules.items():
|
|
|
|
if hasattr(mod, '__file__'):
|
|
|
|
continue
|
2017-10-07 23:37:53 +00:00
|
|
|
log("======== [ "+modname+" ] ========")
|
2018-12-22 03:25:18 +00:00
|
|
|
for name, value in vars(mod).items():
|
|
|
|
if name in ("__doc__", "__name__"):
|
2017-10-07 23:37:53 +00:00
|
|
|
continue
|
2018-12-22 03:25:18 +00:00
|
|
|
if hasattr(value, "__doc__"):
|
2017-10-07 23:37:53 +00:00
|
|
|
if value.__doc__:
|
|
|
|
log("- "+name+":")
|
|
|
|
log(" "+value.__doc__)
|
|
|
|
else:
|
|
|
|
log("- "+name+": ???")
|
|
|
|
else:
|
|
|
|
log("- "+name+": "+repr(value))
|
|
|
|
log("\n")
|
2018-12-22 03:25:18 +00:00
|
|
|
logfile_name = None
|
2017-10-07 23:37:53 +00:00
|
|
|
print "Done!"
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
def enable_all_conv():
|
2018-12-22 03:25:18 +00:00
|
|
|
try:
|
|
|
|
import CharConversor
|
|
|
|
except ImportError:
|
|
|
|
print("CharConversor not available")
|
|
|
|
return
|
|
|
|
CharConversor.ConversionChars = list(CharConversor.ConversionChars)
|
|
|
|
E = Scrap.GetFirst()
|
2017-10-07 23:37:53 +00:00
|
|
|
while E:
|
|
|
|
try:
|
|
|
|
if E.ActCtrl not in CharConversor.ConversionChars:
|
|
|
|
CharConversor.ConversionChars.append(E.ActCtrl)
|
|
|
|
except:
|
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
continue
|
2018-12-22 03:25:18 +00:00
|
|
|
E.Invulnerable = 0
|
|
|
|
E.Life = 100
|
2017-10-07 23:37:53 +00:00
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
print(len(CharConversor.ConversionChars))
|
|
|
|
print "Done!"
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
2017-10-09 18:53:18 +00:00
|
|
|
def goto(name=None):
|
2018-12-22 03:25:18 +00:00
|
|
|
if name == None:
|
|
|
|
name = MF.currentTarget
|
|
|
|
Scrap.UsrEntity(0).Pos = Scrap.GetEntity(name).Pos
|
|
|
|
|
2017-10-09 18:53:18 +00:00
|
|
|
|
|
|
|
def bring(name=None):
|
2018-12-22 03:25:18 +00:00
|
|
|
if name == None:
|
|
|
|
name = MF.currentTarget
|
|
|
|
Scrap.GetEntity(name).Pos = Scrap.UsrEntity(0).Pos
|
|
|
|
|
2017-10-09 18:53:18 +00:00
|
|
|
|
2017-10-08 01:06:33 +00:00
|
|
|
def nuke():
|
2018-12-22 03:25:18 +00:00
|
|
|
E = Scrap.GetFirst()
|
2017-10-08 01:06:33 +00:00
|
|
|
me = Scrap.UsrEntity(0)
|
|
|
|
while E:
|
2018-12-22 03:25:18 +00:00
|
|
|
if E.Name == me.Name:
|
2017-10-08 01:06:33 +00:00
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
try:
|
2018-12-22 03:25:18 +00:00
|
|
|
E.Life = 0
|
|
|
|
E.Invulnerable = 0
|
2017-10-08 01:06:33 +00:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
def become(name):
|
|
|
|
enable_all_conv()
|
|
|
|
import CharConversor
|
|
|
|
me = Scrap.UsrEntity(0)
|
|
|
|
ent = Scrap.GetEntity(name)
|
|
|
|
if ent:
|
2018-12-22 03:25:18 +00:00
|
|
|
CharConversor.Possession(me.Name, name)
|
2017-10-07 23:37:53 +00:00
|
|
|
else:
|
|
|
|
print "Entity not found"
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
StopMovie = 0
|
|
|
|
|
2018-12-22 03:25:18 +00:00
|
|
|
|
2017-10-07 23:37:53 +00:00
|
|
|
def movie(MovieName="Movie/Movie"):
|
2018-12-22 03:25:18 +00:00
|
|
|
global StopMovie
|
|
|
|
if LastTime == None:
|
|
|
|
Scrap.Set("PhysicalAspectRatio", 16.0/9.0)
|
|
|
|
LastTime = Scrap.GetTime()
|
|
|
|
StopMovie = 0
|
|
|
|
if StopMovie == 1:
|
|
|
|
return
|
|
|
|
Scrap.Set("DisableSkipSlot", 1)
|
|
|
|
Scrap.ProcessDVF(MovieName+".dvf", 0)
|
|
|
|
Scrap.ScreenShot(MovieName+"*")
|
|
|
|
NextTime = LastTime+1.0/25.0
|
|
|
|
Scrap.AddScheduledFunc(NextTime, movie, (Speed, MovieName, NextTime))
|
|
|
|
|
|
|
|
|
|
|
|
def park():
|
|
|
|
me = Scrap.UsrEntity(0)
|
|
|
|
|
|
|
|
|
|
|
|
def find(filt="*"):
|
|
|
|
Scrap.StartDummySearch(filt, 1)
|
|
|
|
dummy = 1
|
|
|
|
while dummy:
|
|
|
|
dummy = Scrap.NextDummySearch()
|
|
|
|
print dummy
|
|
|
|
|
|
|
|
|
|
|
|
def getall():
|
|
|
|
E = Scrap.GetFirst()
|
|
|
|
me = Scrap.UsrEntity(0)
|
|
|
|
while E:
|
|
|
|
try:
|
|
|
|
E.Pos = me.Pos
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
E = Scrap.GetEntity(E.NextInSlot)
|
|
|
|
|
|
|
|
|
|
|
|
def god():
|
|
|
|
e = Scrap.UsrEntity(0)
|
|
|
|
QC.godcall(None, (1, 1, 1, 1, 1, 1))
|
|
|
|
Scrap.AddScheduledFunc(Scrap.GetTime()+0.1, god, (), 'dbg.god')
|
|
|
|
|
|
|
|
|
|
|
|
notrace()
|
2017-10-07 23:37:53 +00:00
|
|
|
helplib()
|
2018-12-22 03:25:18 +00:00
|
|
|
# settrace()
|
|
|
|
dgb_info()
|
|
|
|
enable_all_conv()
|
|
|
|
god()
|
|
|
|
Scrap.Set("debug", 3)
|
|
|
|
Scrap.Set("ShowConsoleLog", 1)
|
|
|
|
|
|
|
|
print "Debug Module loaded"
|