# HG changeset patch # User Thibaut Girka # Date 1315256683 -7200 # Node ID 5d9052b9a4e80b5ff9346611b5144076f6d68f7a # Parent c7847bfed427f3aec1d04fb9b15a66993c269f98 (almost) implement Cirno's freezing spellcard diff --git a/pytouhou/formats/ecl.py b/pytouhou/formats/ecl.py --- a/pytouhou/formats/ecl.py +++ b/pytouhou/formats/ecl.py @@ -117,7 +117,7 @@ class ECL(object): 118: ('iihh', None), 119: ('i', 'drop_bonus'), 120: ('i', 'set_automatic_orientation'), - 121: ('ii', None), + 121: ('ii', 'call_special_function'), 122: ('i', None), 123: ('i', 'skip_frames'), 124: ('i', 'drop_specific_bonus'), diff --git a/pytouhou/game/bullet.py b/pytouhou/game/bullet.py --- a/pytouhou/game/bullet.py +++ b/pytouhou/game/bullet.py @@ -110,13 +110,23 @@ class Bullet(object): rec[2].extend(sprite._colors) + def set_anim(self, anim_idx=None, sprite_idx_offset=None): + if anim_idx is not None: + self.anim_idx = anim_idx + + if sprite_idx_offset is not None: + self.sprite_idx_offset = sprite_idx_offset + + self._sprite = Sprite() + anm_wrapper = self._game_state.resource_loader.get_anm_wrapper(('etama3.anm',)) #TODO + self._anmrunner = ANMRunner(anm_wrapper, self.anim_idx, + self._sprite, self.sprite_idx_offset) + + def update(self): if not self._sprite or self._sprite._removed: self._launched = True - self._sprite = Sprite() - anm_wrapper = self._game_state.resource_loader.get_anm_wrapper(('etama3.anm',)) #TODO - self._anmrunner = ANMRunner(anm_wrapper, self.anim_idx, - self._sprite, self.sprite_idx_offset) + self.set_anim() self._anmrunner.run_frame() self._sprite.update(angle_base=self.angle) diff --git a/pytouhou/vm/eclrunner.py b/pytouhou/vm/eclrunner.py --- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -13,7 +13,7 @@ ## -from math import atan2, cos, sin +from math import atan2, cos, sin, pi from pytouhou.utils.helpers import get_logger @@ -763,6 +763,21 @@ class ECLRunner(object): self._enemy.automatic_orientation = bool(flags & 1) + @instruction(121) + def call_special_function(self, function, arg): + if function == 0: # Cirno + if arg == 0: + for bullet in self._game_state.bullets: + bullet.speed = bullet.angle = 0. + bullet.set_anim(sprite_idx_offset=0) #TODO: check + else: + for bullet in self._game_state.bullets: + bullet.speed = 2.0 #TODO + bullet.angle = self._game_state.prng.rand_double() * pi #TODO + else: + logger.warn("Unimplemented special function %d!", function) + + @instruction(123) def skip_frames(self, frames): #TODO: is that all?