# HG changeset patch # User Thibaut Girka # Date 1315177663 -7200 # Node ID 7899942759685a37894d778094532225f64473d6 # Parent ad9297e0fbf293f94240b8f584d181cd1e1feed8 Fix boss callback, handle a few more callbacks diff --git a/pytouhou/game/enemy.py b/pytouhou/game/enemy.py --- a/pytouhou/game/enemy.py +++ b/pytouhou/game/enemy.py @@ -48,6 +48,7 @@ class Enemy(object): self.bullet_attributes = None self.bullet_launch_offset = (0, 0) self.death_callback = None + self.boss_callback = None self.low_life_callback = None self.low_life_trigger = None self.timeout = None diff --git a/pytouhou/vm/eclrunner.py b/pytouhou/vm/eclrunner.py --- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -106,16 +106,28 @@ class ECLRunner(object): def handle_callbacks(self): - #TODO + #TODO: implement missing callbacks and clean up! enm = self._enemy - if enm.timeout and enm.frame == enm.timeout: + if enm.boss_callback is not None: #XXX: MSG's job! + self.frame = 0 + self.sub = enm.boss_callback + self.instruction_pointer = 0 + enm.boss_callback = None + if enm.life == 0 and enm.death_callback is not None: + self.frame = 0 + self.sub = enm.death_callback + self.instruction_pointer = 0 + #TODO: various things, like deleting the character + enm.death_callback = None #XXX + elif enm.timeout and enm.frame == enm.timeout: enm.frame = 0 - if enm.timeout_callback: + if enm.timeout_callback is not None: self.frame = 0 self.sub = enm.timeout_callback self.instruction_pointer = 0 + enm.timeout_callback = None else: - pass #TODO + enm.life = 0 #TODO: other callbacks (low life, etc.) @@ -695,9 +707,9 @@ class ECLRunner(object): #TODO #XXX: this is a hack to display bosses although we don't handle MSG :) if index == 0: - self.sub = value - self.frame = 0 - self.instruction_pointer = 0 + self._enemy.boss_callback = value + else: + raise Exception #TODO @instruction(111)