comparison pytouhou/vm/eclrunner.py @ 268:dd621ad72beb

Fix callback handling and damage dealing.
author Thibaut Girka <thib@sitedethib.com>
date Mon, 23 Jan 2012 23:00:42 +0100
parents 3a86c4e070dc
children 729382f57ad0
comparison
equal deleted inserted replaced
267:35644a67ba4c 268:dd621ad72beb
149 if death_flags == 1: 149 if death_flags == 1:
150 enm.touchable = False 150 enm.touchable = False
151 elif death_flags == 2: 151 elif death_flags == 2:
152 pass # Just that? 152 pass # Just that?
153 elif death_flags == 3: 153 elif death_flags == 3:
154 #TODO: disable boss mode
154 enm.damageable = False 155 enm.damageable = False
155 enm.life = 1 156 enm.life = 1
156 enm.death_flags = 0 157 enm.death_flags = 0
157 else: 158
158 pass #TODO: sparks 159 if death_flags != 0 and enm.death_callback >= 0:
159
160 if death_flags != 0 and enm.death_callback is not None:
161 self.frame = 0 160 self.frame = 0
162 self.sub = enm.death_callback 161 self.sub = enm.death_callback
163 self.instruction_pointer = 0 162 self.instruction_pointer = 0
164 enm.death_callback = None 163 enm.death_callback = -1
165 elif enm.life <= enm.low_life_trigger and enm.low_life_callback is not None: 164 elif enm.life <= enm.low_life_trigger and enm.low_life_callback >= 0:
166 self.frame = 0 165 self.frame = 0
167 self.sub = enm.low_life_callback 166 self.sub = enm.low_life_callback
168 self.instruction_pointer = 0 167 self.instruction_pointer = 0
169 enm.low_life_callback = None 168 enm.low_life_callback = -1
170 elif enm.timeout and enm.frame == enm.timeout: 169 elif enm.timeout and enm.frame == enm.timeout:
171 enm.frame = 0 170 enm.frame = 0
172 if enm.timeout_callback is not None: 171 if enm.timeout_callback >= 0:
173 self.frame = 0 172 self.frame = 0
174 self.sub = enm.timeout_callback 173 self.sub = enm.timeout_callback
175 self.instruction_pointer = 0 174 self.instruction_pointer = 0
176 enm.timeout_callback = None 175 enm.timeout_callback = -1
177 else: 176 else:
178 enm.life = 0 177 enm.life = 0
179 #TODO: other callbacks (low life, etc.) 178 #TODO: other callbacks (low life, etc.)
180 179
181 180
741 self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, die_score) 740 self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, die_score)
742 741
743 742
744 @instruction(96) 743 @instruction(96)
745 def kill_enemies(self): 744 def kill_enemies(self):
746 for enemy in self._game.enemies: 745 for proc in self._game.ecl_runner.processes:
747 if enemy.touchable and not enemy.boss: 746 if proc._enemy.boss:
748 enemy.life = 0 747 pass # Bosses are immune to 96
748 elif proc._enemy.touchable:
749 proc._enemy.life = 0
750 elif proc._enemy.death_callback > 0:
751 #TODO: check
752 #TODO: refactor
753 proc.frame = 0
754 proc.instruction_pointer = 0
755 proc.sub = proc._enemy.death_callback
756 proc._enemy.death_callback = -1
749 757
750 758
751 @instruction(97) 759 @instruction(97)
752 def set_anim(self, script): 760 def set_anim(self, script):
753 self._enemy.set_anim(script) 761 self._enemy.set_anim(script)