Mercurial > touhou
changeset 67:e2cb9d434dc2
Add support for a few opcodes.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Fri, 26 Aug 2011 22:43:10 +0200 |
parents | a701a89192a9 |
children | a2459defd4b6 |
files | pytouhou/formats/ecl.py pytouhou/game/eclrunner.py pytouhou/game/enemymanager.py |
diffstat | 3 files changed, 34 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/formats/ecl.py +++ b/pytouhou/formats/ecl.py @@ -91,7 +91,7 @@ class ECL(object): 90: ('iiii', None), 92: ('i', None), #93: set_spellcard, a string is there - 94: ('', None), + 94: ('', 'end_spellcard'), 95: ('ifffhhi', None), 96: ('', None), 97: ('i', 'set_anim'), @@ -102,18 +102,18 @@ class ECL(object): 102: ('iffff', None), 103: ('fff', 'set_enemy_hitbox'), 104: ('i', None), - 105: ('i', 'set_vulnerable'), + 105: ('i', 'set_damageable'), 106: ('i', 'play_sound'), 107: ('i', None), 108: ('i', 'set_death_callback?'), 109: ('ii', 'memory_write_int'), 111: ('i', 'set_life'), - 112: ('i', None), + 112: ('i', 'set_ellapsed_time'), 113: ('i', 'set_low_life_trigger'), 114: ('i', 'set_low_life_callback'), 115: ('i', 'set_timeout'), - 116: ('i', None), - 117: ('i', None), + 116: ('i', 'set_timeout_callback'), + 117: ('i', 'set_touchable'), 118: ('iihh', None), 119: ('i', 'drop_bonus'), 120: ('i', None),
--- a/pytouhou/game/eclrunner.py +++ b/pytouhou/game/eclrunner.py @@ -478,8 +478,8 @@ class ECLRunner(object): @instruction(105) - def set_vulnerable(self, vulnerable): - self._enemy.vulnerable = bool(vulnerable & 1) + def set_damageable(self, vulnerable): + self._enemy.damageable = bool(vulnerable & 1) @instruction(108) @@ -502,6 +502,15 @@ class ECLRunner(object): self._enemy.life = value + @instruction(112) + def set_ellapsed_time(self, value): + """Sets the enemy's frame counter. + This is used for timeouts, where the framecounter is compared to the + timeout value (what's displayed is (enemy.timeout - enemy.frame) // 60). + """ + self._enemy.frame = value + + @instruction(113) def set_low_life_trigger(self, value): self._enemy.low_life_trigger = value @@ -517,6 +526,20 @@ class ECLRunner(object): self._enemy.timeout = timeout + @instruction(116) + def set_timeout_callback(self, sub): + self._enemy.timeout_callback = sub + + + @instruction(117) + def set_touchable(self, value): + """Defines whether the enemy is “touchable”. + Bullets only collide with an enemy if it is “touchable”. + Likewise, ReimuA's homing attacks only target “touchable” enemies. + """ + self._enemy.touchable = bool(value) + + @instruction(126) def set_remaining_lives(self, lives): self._enemy.remaining_lives = lives
--- a/pytouhou/game/enemymanager.py +++ b/pytouhou/game/enemymanager.py @@ -37,14 +37,17 @@ class Enemy(object): self.x, self.y = pos self.life = life self.max_life = life + self.touchable = True + self.damageable = True + self.death_flags = 0 self.pending_bullets = [] self.bullet_attributes = None self.bullet_launch_offset = (0, 0) - self.vulnerable = True self.death_callback = None self.low_life_callback = None self.low_life_trigger = None self.timeout = None + self.timeout_callback = None self.remaining_lives = -1 self.bullet_launch_interval = 0