changeset 171:2f3665a77f11

Add support for the last unknown value of the enemy spawning.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 20 Oct 2011 06:34:35 -0700
parents e7902309305c
children ea2ad94c33a0
files pytouhou/formats/ecl.py pytouhou/game/enemy.py pytouhou/game/game.py pytouhou/vm/eclrunner.py
diffstat 4 files changed, 14 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/formats/ecl.py
+++ b/pytouhou/formats/ecl.py
@@ -132,10 +132,10 @@ class ECL(object):
                      134: ('', None),
                      135: ('i', None)} #TODO
 
-    _main_instructions = {0: ('fffhhHH', 'spawn_enemy'),
-                          2: ('fffhhHH', 'spawn_enemy_mirrored'),
-                          4: ('fffhhHH', 'spawn_enemy_random'),
-                          6: ('fffhhHH', 'spawn_enemy_mirrored_random'),
+    _main_instructions = {0: ('fffhhI', 'spawn_enemy'),
+                          2: ('fffhhI', 'spawn_enemy_mirrored'),
+                          4: ('fffhhI', 'spawn_enemy_random'),
+                          6: ('fffhhI', 'spawn_enemy_mirrored_random'),
                           8: ('', None),
                           9: ('', None),
                           10: ('II', None),
--- a/pytouhou/game/enemy.py
+++ b/pytouhou/game/enemy.py
@@ -40,7 +40,7 @@ class Effect(object):
 
 
 class Enemy(object):
-    def __init__(self, pos, life, _type, bonus_dropped, anm_wrapper, game):
+    def __init__(self, pos, life, _type, bonus_dropped, die_score, anm_wrapper, game):
         self._game = game
         self._anm_wrapper = anm_wrapper
         self._sprite = None
@@ -48,6 +48,7 @@ class Enemy(object):
         self._removed = False
         self._type = _type
         self._bonus_dropped = bonus_dropped
+        self._die_score = die_score #TODO: use it
         self._was_visible = False
 
         self.frame = 0
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -70,8 +70,8 @@ class Game(object):
         self.bullets = []
 
 
-    def new_enemy(self, pos, life, instr_type, bonus_dropped):
-        enemy = Enemy(pos, life, instr_type, bonus_dropped, self.enm_anm_wrapper, self)
+    def new_enemy(self, pos, life, instr_type, bonus_dropped, die_score):
+        enemy = Enemy(pos, life, instr_type, bonus_dropped, die_score, self.enm_anm_wrapper, self)
         self.enemies.append(enemy)
         return enemy
 
--- a/pytouhou/vm/eclrunner.py
+++ b/pytouhou/vm/eclrunner.py
@@ -61,7 +61,7 @@ class ECLMainRunner(object):
                                                 if process.run_iteration())
 
 
-    def _pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, unknown2, unknown3):
+    def _pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, die_score):
         if instr_type & 4:
             if x < -990: #102h.exe@0x411820
                 x = self._game.prng.rand_double() * 368
@@ -69,7 +69,7 @@ class ECLMainRunner(object):
                 y = self._game.prng.rand_double() * 416
             if z < -990: #102h.exe@0x411881
                 y = self._game.prng.rand_double() * 800
-        enemy = self._game.new_enemy((x, y), life, instr_type, bonus_dropped)
+        enemy = self._game.new_enemy((x, y), life, instr_type, bonus_dropped, die_score)
         process = ECLRunner(self._ecl, sub, enemy, self._game)
         self.processes.append(process)
         process.run_iteration()
@@ -79,10 +79,10 @@ class ECLMainRunner(object):
     @instruction(2)
     @instruction(4)
     @instruction(6)
-    def pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, unknown2, unknown3):
+    def pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, die_score):
         if self._game.boss:
             return
-        self._pop_enemy(sub, instr_type, x, y, z, life, bonus_dropped, unknown2, unknown3)
+        self._pop_enemy(sub, instr_type, x, y, z, life, bonus_dropped, die_score)
 
 
 
@@ -712,8 +712,8 @@ class ECLRunner(object):
 
 
     @instruction(95)
-    def pop_enemy(self, sub, x, y, z, life, bonus_dropped, unknown2):
-        self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, unknown2, 0) # TODO: check about unknown values
+    def pop_enemy(self, sub, x, y, z, life, bonus_dropped, die_score):
+        self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x), self._getval(y), 0, life, bonus_dropped, die_score)
 
 
     @instruction(96)