comparison pytouhou/vm/eclrunner.py @ 140:a9d46c4b5764

Fix move_to (handle variables) and spawn_enemy
author Thibaut Girka <thib@sitedethib.com>
date Sun, 25 Sep 2011 20:16:13 +0200
parents e9ac3640280b
children cadfc5e5ad7a
comparison
equal deleted inserted replaced
139:3af65541dfd3 140:a9d46c4b5764
60 60
61 self.processes[:] = (process for process in self.processes 61 self.processes[:] = (process for process in self.processes
62 if process.run_iteration()) 62 if process.run_iteration())
63 63
64 64
65 def _pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, unknown2, unknown3):
66 if instr_type & 4:
67 if x < -990: #102h.exe@0x411820
68 x = self._game_state.prng.rand_double() * 368
69 if y < -990: #102h.exe@0x41184b
70 y = self._game_state.prng.rand_double() * 416
71 if z < -990: #102h.exe@0x411881
72 y = self._game_state.prng.rand_double() * 800
73 enemy = self._new_enemy_func((x, y), life, instr_type, self._pop_enemy)
74 process = ECLRunner(self._ecl, sub, enemy, self._game_state)
75 self.processes.append(process)
76 process.run_iteration()
77
78
65 @instruction(0) 79 @instruction(0)
66 @instruction(2) 80 @instruction(2)
67 @instruction(4) 81 @instruction(4)
68 @instruction(6) 82 @instruction(6)
69 def pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, unknown2, unknown3): 83 def pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, unknown2, unknown3):
70 if self._game_state.boss: 84 if self._game_state.boss:
71 return 85 return
72 if instr_type & 4: 86 self._pop_enemy(sub, instr_type, x, y, z, life, bonus_dropped, unknown2, unknown3)
73 if x < -990: #102h.exe@0x411820
74 x = self._game_state.prng.rand_double() * 368
75 if y < -990: #102h.exe@0x41184b
76 y = self._game_state.prng.rand_double() * 416
77 if z < -990: #102h.exe@0x411881
78 y = self._game_state.prng.rand_double() * 800
79 enemy = self._new_enemy_func((x, y), life, instr_type, self.pop_enemy)
80 process = ECLRunner(self._ecl, sub, enemy, self._game_state)
81 self.processes.append(process)
82 process.run_iteration()
83 87
84 88
85 89
86 90
87 class ECLRunner(object): 91 class ECLRunner(object):
475 self._enemy.angle = self._enemy.get_player_angle() 479 self._enemy.angle = self._enemy.get_player_angle()
476 480
477 481
478 @instruction(56) 482 @instruction(56)
479 def move_to_linear(self, duration, x, y, z): 483 def move_to_linear(self, duration, x, y, z):
480 self._enemy.move_to(duration, x, y, z, lambda x: x) 484 self._enemy.move_to(duration,
485 self._getval(x), self._getval(y), self._getval(z),
486 lambda x: x)
481 487
482 488
483 @instruction(57) 489 @instruction(57)
484 def move_to_decel(self, duration, x, y, z): 490 def move_to_decel(self, duration, x, y, z):
485 self._enemy.move_to(duration, x, y, z, lambda x: 2. * x - x ** 2) 491 self._enemy.move_to(duration,
492 self._getval(x), self._getval(y), self._getval(z),
493 lambda x: 2. * x - x ** 2)
486 494
487 495
488 @instruction(59) 496 @instruction(59)
489 def move_to_accel(self, duration, x, y, z): 497 def move_to_accel(self, duration, x, y, z):
490 self._enemy.move_to(duration, x, y, z, lambda x: x ** 2) 498 self._enemy.move_to(duration,
499 self._getval(x), self._getval(y), self._getval(z),
500 lambda x: x ** 2)
491 501
492 502
493 @instruction(61) 503 @instruction(61)
494 def stop_in(self, duration): 504 def stop_in(self, duration):
495 self._enemy.stop_in(duration, lambda x: x) 505 self._enemy.stop_in(duration, lambda x: x)