comparison pytouhou/vm/eclrunner.py @ 165:c8c60291c56f

Implement item dropping by enemies.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 18 Oct 2011 07:35:02 -0700
parents 606468ab4f7b
children dcf32488a2c9
comparison
equal deleted inserted replaced
164:5271789c067d 165:c8c60291c56f
116 if enm.boss_callback is not None: #XXX: MSG's job! 116 if enm.boss_callback is not None: #XXX: MSG's job!
117 self.frame = 0 117 self.frame = 0
118 self.sub = enm.boss_callback 118 self.sub = enm.boss_callback
119 self.instruction_pointer = 0 119 self.instruction_pointer = 0
120 enm.boss_callback = None 120 enm.boss_callback = None
121 if enm.life == 0 and enm.death_callback is not None: 121 if enm.life <= 0:
122 death_flags = enm.death_flags & 7
123
124 if death_flags < 4:
125 if enm._bonus_dropped >= 0:
126 self._game.drop_bonus(enm.x, enm.y, enm._bonus_dropped)
127 elif enm._bonus_dropped == -1:
128 self._game.drop_bonus(enm.x, enm.y, self._game.prng.rand_uint16() % 2) #TODO: find the formula in the binary. Can be big power sometimes.
129
130 if enm.death_callback is not None:
131 self.frame = 0
132 self.sub = enm.death_callback
133 self.instruction_pointer = 0
134 enm.death_callback = None
135 elif enm.life <= enm.low_life_trigger and enm.low_life_callback is not None:
122 self.frame = 0 136 self.frame = 0
123 self.sub = enm.death_callback 137 self.sub = enm.low_life_callback
124 self.instruction_pointer = 0 138 self.instruction_pointer = 0
125 #TODO: various things, like deleting the character 139 enm.low_life_callback = None
126 enm.death_callback = None #XXX
127 elif enm.timeout and enm.frame == enm.timeout: 140 elif enm.timeout and enm.frame == enm.timeout:
128 enm.frame = 0 141 enm.frame = 0
129 if enm.timeout_callback is not None: 142 if enm.timeout_callback is not None:
130 self.frame = 0 143 self.frame = 0
131 self.sub = enm.timeout_callback 144 self.sub = enm.timeout_callback
796 self._enemy.touchable = bool(value) 809 self._enemy.touchable = bool(value)
797 810
798 811
799 @instruction(119) 812 @instruction(119)
800 def drop_some_bonus(self, number): 813 def drop_some_bonus(self, number):
814 bonus = 0 if self._enemy.select_player().state.power < 128 else 1
801 for i in range(number): 815 for i in range(number):
802 #TODO: find the formula in the binary. 816 #TODO: find the formula in the binary.
803 self._game.drop_bonus(self._enemy.x - 64 + self._game.prng.rand_uint16() % 128, 817 self._game.drop_bonus(self._enemy.x - 64 + self._game.prng.rand_uint16() % 128,
804 self._enemy.y - 64 + self._game.prng.rand_uint16() % 128, 0) 818 self._enemy.y - 64 + self._game.prng.rand_uint16() % 128,
819 bonus)
805 820
806 821
807 @instruction(120) 822 @instruction(120)
808 def set_automatic_orientation(self, flags): 823 def set_automatic_orientation(self, flags):
809 #TODO: does it change anything else than the sprite's rotation? 824 #TODO: does it change anything else than the sprite's rotation?
833 self.frame += self._getval(frames) 848 self.frame += self._getval(frames)
834 849
835 850
836 @instruction(124) 851 @instruction(124)
837 def drop_specific_bonus(self, _type): 852 def drop_specific_bonus(self, _type):
853 #TODO: if _type < 0, “drop” an bullet animation instead of a bonus (never used).
838 self._game.drop_bonus(self._enemy.x, self._enemy.y, _type) 854 self._game.drop_bonus(self._enemy.x, self._enemy.y, _type)
839 855
840 856
841 @instruction(126) 857 @instruction(126)
842 def set_remaining_lives(self, lives): 858 def set_remaining_lives(self, lives):