Mercurial > touhou
comparison pytouhou/vm/eclrunner.py @ 497:3da7395f39e3
Make enemy callbacks programmables.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 14 Oct 2013 12:20:55 +0200 |
parents | 6be9c99a3a24 |
children | bcff39c920ab |
comparison
equal
deleted
inserted
replaced
496:104c737ce8b3 | 497:3da7395f39e3 |
---|---|
101 self._game.msg_wait = True | 101 self._game.msg_wait = True |
102 | 102 |
103 | 103 |
104 @instruction(10) | 104 @instruction(10) |
105 def resume_ecl(self, sub, instr_type, unk1, unk2): | 105 def resume_ecl(self, sub, instr_type, unk1, unk2): |
106 boss = self._game.boss | 106 boss = self._game.boss._enemy |
107 self._game.msg_wait = False | 107 self._game.msg_wait = False |
108 if boss._enemy.boss_callback > -1: | 108 if not boss.boss_callback: |
109 boss.switch_to_sub(boss._enemy.boss_callback) | |
110 boss._enemy.boss_callback = -1 | |
111 else: | |
112 raise Exception #TODO | 109 raise Exception #TODO |
110 boss.boss_callback.fire() | |
113 | 111 |
114 | 112 |
115 @instruction(12) | 113 @instruction(12) |
116 def wait_for_boss_death(self, sub, instr_type): | 114 def wait_for_boss_death(self, sub, instr_type): |
117 self.boss_wait = True | 115 self.boss_wait = True |
841 self._enemy.death_flags = death_flags | 839 self._enemy.death_flags = death_flags |
842 | 840 |
843 | 841 |
844 @instruction(108) | 842 @instruction(108) |
845 def set_death_callback(self, sub): | 843 def set_death_callback(self, sub): |
846 self._enemy.death_callback = sub | 844 self._enemy.death_callback.enable(self.switch_to_sub, (sub,)) |
847 | 845 |
848 | 846 |
849 @instruction(109) | 847 @instruction(109) |
850 def memory_write(self, value, index): | 848 def memory_write(self, value, index): |
851 if index == 0: | 849 if index == 0: |
852 self._enemy.boss_callback = value | 850 self._enemy.boss_callback.enable(self.switch_to_sub, (value,)) |
853 else: | 851 else: |
854 raise Exception #TODO | 852 raise Exception #TODO |
855 | 853 |
856 | 854 |
857 @instruction(111) | 855 @instruction(111) |
878 self._game.interface.set_spell_life() | 876 self._game.interface.set_spell_life() |
879 | 877 |
880 | 878 |
881 @instruction(114) | 879 @instruction(114) |
882 def set_low_life_callback(self, sub): | 880 def set_low_life_callback(self, sub): |
883 self._enemy.low_life_callback = sub | 881 self._enemy.low_life_callback.enable(self.switch_to_sub, (sub,)) |
884 | 882 |
885 | 883 |
886 @instruction(115) | 884 @instruction(115) |
887 def set_timeout(self, timeout): | 885 def set_timeout(self, timeout): |
888 self._enemy.frame = 0 | 886 self._enemy.frame = 0 |
889 self._enemy.timeout = timeout | 887 self._enemy.timeout = timeout |
890 | 888 |
891 | 889 |
892 @instruction(116) | 890 @instruction(116) |
893 def set_timeout_callback(self, sub): | 891 def set_timeout_callback(self, sub): |
894 self._enemy.timeout_callback = sub | 892 self._enemy.timeout_callback.enable(self.switch_to_sub, (sub,)) |
895 | 893 |
896 | 894 |
897 @instruction(117) | 895 @instruction(117) |
898 def set_touchable(self, value): | 896 def set_touchable(self, value): |
899 """Defines whether the enemy is “touchable”. | 897 """Defines whether the enemy is “touchable”. |
1142 self._enemy.visible = not bool(value) | 1140 self._enemy.visible = not bool(value) |
1143 | 1141 |
1144 | 1142 |
1145 @instruction(133) | 1143 @instruction(133) |
1146 def copy_callbacks(self): | 1144 def copy_callbacks(self): |
1147 self._enemy.timeout_callback = self._enemy.death_callback | 1145 self._enemy.timeout_callback.enable(self.switch_to_sub, (self._enemy.death_callback.args[0],)) |
1148 | 1146 |