diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-06-22 22:38:35 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-06-22 22:38:35 -0300 |
commit | 7b0e97da3413c0ff04ce8741b968c85b3dc4568e (patch) | |
tree | 4e95a56a68ba8e577d651ec13f266bfad6aa1538 | |
parent | 711e8efeca69bbb4d00b2d87b152343a1178e425 (diff) | |
download | tools-7b0e97da3413c0ff04ce8741b968c85b3dc4568e.tar.gz tools-7b0e97da3413c0ff04ce8741b968c85b3dc4568e.tar.bz2 tools-7b0e97da3413c0ff04ce8741b968c85b3dc4568e.tar.xz tools-7b0e97da3413c0ff04ce8741b968c85b3dc4568e.zip |
The last object of my Dungeon Building System:
Traps. Classic.
-rwxr-xr-x | hercules/tmx_converter.py | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/hercules/tmx_converter.py b/hercules/tmx_converter.py index 5b21961..e84b6d5 100755 --- a/hercules/tmx_converter.py +++ b/hercules/tmx_converter.py @@ -157,10 +157,12 @@ class FunctionTrigger(Object): __slots__ = ( 'callfunc', 'doevent', + 'args', ) def __init__(self): self.callfunc = '' self.doevent = '' + self.args = '' class Trap(Object): __slots__ = ( @@ -173,7 +175,7 @@ class Trap(Object): self.disarmtime = 15 self.stuntime = 3 self.damage = 80 - self.target = 2 + self.target = 3 #################################### class ContentHandler(xml.sax.ContentHandler): @@ -408,6 +410,7 @@ class ContentHandler(xml.sax.ContentHandler): obj_name = "%s_%s_%s" % (self.base, obj.x, obj.y) self.confs.write( SEPARATOR.join([ + '', '%s,%d,%d,0\tscript\t#save_%s\tNPC_SAVE_POINT,{\n' % (self.base, obj.x, obj.y, obj_name), ' savepointparticle .map$, .x, .y, %s;\n close;\n\nOnInit:\n .distance = 2;\n .sex = G_OTHER;\n end;\n}\n' % (obj.inn), ]) @@ -460,9 +463,10 @@ class ContentHandler(xml.sax.ContentHandler): obj_name = "%s_%s_%s" % (self.base, obj.x, obj.y) self.confs.write( SEPARATOR.join([ + '\n', '%s,%d,%d,0\t' % (self.base, obj.x, (obj.y)), 'script\t', - '%s\tNPC_HIDDEN,{\n\tend;\nOnDisable:\n\tdelcells "%s"; end;\n' % (obj_name, obj_name), + '#%s\tNPC_HIDDEN,{\n\tend;\nOnDisable:\n\tdelcells "%s"; end;\n' % (obj_name, obj_name), 'OnEnable:\nOnInit:\n\tsetcells "%s", %d, %d, %d, %d, %d, "%s";\n}\n' % (self.base, obj.x, obj.y, obj.x+obj.w, obj.y+obj.h, obj.colid, obj_name), ]) ) @@ -471,13 +475,47 @@ class ContentHandler(xml.sax.ContentHandler): obj_name = "%s_%s_%s" % (self.base, obj.x, obj.y) self.confs.write( SEPARATOR.join([ + '\n', + '// FIXME: Either let flip/unflip, or only run once.\n', + '// This could be done with a new attribute ', + 'and checking NPC display when only run once.\n', '%s,%d,%d,0\t' % (self.base, obj.x, (obj.y)), 'script\t', - '%s\tNPC_SWITCH_%s,{\n\tcallfunc "%s"%s;\n' % (obj_name, ifte(obj.enabled, "OFFLINE", "ONLINE"), obj.callfunc, ifte(obj.args != '', ", %s" % obj.args, "")), + '#%s\tNPC_SWITCH_%s,{\n\tcallfunc "%s"%s;\n' % (obj_name, ifte(obj.enabled, "OFFLINE", "ONLINE"), obj.callfunc, ifte(obj.args != '', ", %s" % obj.args, "")), '\tsetnpcdisplay %s, NPC_SWITCH_%s;\n\tend;\nOnInit:\n\t.distance=%d;\n}\n' % (obj_name, ifte(obj.enabled, "ONLINE", "OFFLINE"), obj.distance), ]) ) self.save_cnt = True + elif isinstance(obj, FunctionTrigger): + obj_name = "%s_%s_%s" % (self.base, obj.x, obj.y) + func_name = ifte(obj.callfunc != "", "\tcallfunc \"%s\"%s;\n" % (obj.callfunc, + ifte(obj.args != "", ", %s" % obj.args, "")), "") + scrp_name = ifte(obj.doevent != "", "\tdoevent \"%s\";\n" % (obj.doevent), "") + self.confs.write( + SEPARATOR.join([ + '\n', + '%s,%d,%d,0\t' % (self.base, obj.x, (obj.y)), + 'script\t', + '#%s\tNPC_HIDDEN,%d,%d,{\n\tend;\n' % (obj_name, obj.w, obj.h), + 'OnTouch:\n%s%s\tend;\n}\n' % (func_name, scrp_name), + ]) + ) + self.save_cnt = True + elif isinstance(obj, Trap): + obj_name = "%s_%s_%s" % (self.base, obj.x, obj.y) + npcid = ifte(obj.disarmtime, "NPC_TRAP", "NPC_TRAP_ONLINE") + timer = ifte(obj.disarmtime, "OnTimer%d:\n\tstopnpctimer; setnpctimer 0; setnpcdisplay %s, NPC_TRAP; end;\n" % (obj.disarmtime*1000, obj_name), "") + self.confs.write( + SEPARATOR.join([ + '\n', + '%s,%d,%d,0\t' % (self.base, obj.x, (obj.y)), + 'script\t', + '#%s\t%s,%d,%d,{\n\tmesn strcharinfo(0);\n\tmesq l("Something seems off with that!");\n\tclose;\n' % (obj_name, npcid, obj.w, obj.h), + '%s%s' % (ifte(obj.target & 1, "OnTouch:\n", ""), ifte(obj.target & 2, "OnTouchNPC:\n", "")), + '\tIronTrap(%d, %d, %d);\n\tend;\n%s}\n' % (obj.damage, obj.disarmtime, obj.stuntime, timer), + ]) + ) + self.save_cnt = True ############################################################## |