comparison pytouhou/vm/eclrunner.py @ 79:ffe2c2b9912c

Handle a few more ECL instructions. Prepare for bullet handling \o/
author Thibaut Girka <thib@sitedethib.com>
date Sat, 03 Sep 2011 18:17:39 +0200
parents bcf965ede96c
children de48213a02bf
comparison
equal deleted inserted replaced
78:bcf965ede96c 79:ffe2c2b9912c
97 elif value == -10016: 97 elif value == -10016:
98 return self._enemy.y 98 return self._enemy.y
99 elif value == -10017: 99 elif value == -10017:
100 return self._enemy.z 100 return self._enemy.z
101 elif value == -10018: 101 elif value == -10018:
102 player = self._enemy.select_player(self._game_state.players) 102 player = self._enemy.select_player()
103 return player.x 103 return player.x
104 elif value == -10019: 104 elif value == -10019:
105 player = self._enemy.select_player(self._game_state.players) 105 player = self._enemy.select_player()
106 return player.y 106 return player.y
107 elif value == -10021: 107 elif value == -10021:
108 player = self._enemy.select_player(self._game_state.players) 108 return self._enemy.get_player_angle()
109 return self._enemy.get_player_angle(player)
110 elif value == -10022: 109 elif value == -10022:
111 return self._enemy.frame 110 return self._enemy.frame
112 elif value == -10024: 111 elif value == -10024:
113 return self._enemy.life 112 return self._enemy.life
114 elif value == -10025: 113 elif value == -10025:
115 return self._enemy.select_player(self._game_state.players).character 114 return self._enemy.select_player().character
116 raise NotImplementedError(value) #TODO 115 raise NotImplementedError(value) #TODO
117 else: 116 else:
118 return value 117 return value
119 118
120 119
381 380
382 @instruction(51) 381 @instruction(51)
383 def target_player(self, unknown, speed): 382 def target_player(self, unknown, speed):
384 #TODO: unknown 383 #TODO: unknown
385 self._enemy.speed = speed 384 self._enemy.speed = speed
386 self._enemy.angle = self._enemy.get_player_angle(self._enemy.select_player(self._game_state.players)) 385 self._enemy.angle = self._enemy.get_player_angle()
387 386
388 387
389 @instruction(56) 388 @instruction(56)
390 def move_to_linear(self, duration, x, y, z): 389 def move_to_linear(self, duration, x, y, z):
391 self._enemy.move_to(duration, x, y, z, lambda x: x) 390 self._enemy.move_to(duration, x, y, z, lambda x: x)
421 self._enemy.screen_box = None 420 self._enemy.screen_box = None
422 421
423 422
424 @instruction(67) 423 @instruction(67)
425 def set_bullet_attributes1(self, bullet_anim, launch_anim, bullets_per_shot, 424 def set_bullet_attributes1(self, bullet_anim, launch_anim, bullets_per_shot,
426 number_of_shots, speed, unknown, launch_angle, 425 number_of_shots, speed, speed2, launch_angle,
427 angle, flags): 426 angle, flags):
428 self._enemy.set_bullet_attributes(1, bullet_anim, launch_anim, 427 self._enemy.set_bullet_attributes(67, bullet_anim, launch_anim,
429 bullets_per_shot, number_of_shots, 428 self._getval(bullets_per_shot),
430 speed, unknown, launch_angle, angle, 429 self._getval(number_of_shots),
431 flags) 430 self._getval(speed),
431 self._getval(speed2),
432 self._getval(launch_angle),
433 self._getval(angle),
434 flags)
435
436
437 @instruction(68)
438 def set_bullet_attributes2(self, bullet_anim, launch_anim, bullets_per_shot,
439 number_of_shots, speed, speed2, launch_angle,
440 angle, flags):
441 self._enemy.set_bullet_attributes(68, bullet_anim, launch_anim,
442 self._getval(bullets_per_shot),
443 self._getval(number_of_shots),
444 self._getval(speed),
445 self._getval(speed2),
446 self._getval(launch_angle),
447 self._getval(angle),
448 flags)
449
450
451 @instruction(69)
452 def set_bullet_attributes3(self, bullet_anim, launch_anim, bullets_per_shot,
453 number_of_shots, speed, speed2, launch_angle,
454 angle, flags):
455 self._enemy.set_bullet_attributes(69, bullet_anim, launch_anim,
456 self._getval(bullets_per_shot),
457 self._getval(number_of_shots),
458 self._getval(speed),
459 self._getval(speed2),
460 self._getval(launch_angle),
461 self._getval(angle),
462 flags)
463
464
465 @instruction(70)
466 def set_bullet_attributes4(self, bullet_anim, launch_anim, bullets_per_shot,
467 number_of_shots, speed, speed2, launch_angle,
468 angle, flags):
469 self._enemy.set_bullet_attributes(67, bullet_anim, launch_anim,
470 self._getval(bullets_per_shot),
471 self._getval(number_of_shots),
472 self._getval(speed),
473 self._getval(speed2),
474 self._getval(launch_angle),
475 self._getval(angle),
476 flags)
477
478
479 @instruction(71)
480 def set_bullet_attributes5(self, bullet_anim, launch_anim, bullets_per_shot,
481 number_of_shots, speed, speed2, launch_angle,
482 angle, flags):
483 self._enemy.set_bullet_attributes(71, bullet_anim, launch_anim,
484 self._getval(bullets_per_shot),
485 self._getval(number_of_shots),
486 self._getval(speed),
487 self._getval(speed2),
488 self._getval(launch_angle),
489 self._getval(angle),
490 flags)
491
432 492
433 493
434 @instruction(76) 494 @instruction(76)
435 def set_bullet_interval(self, value): 495 def set_bullet_interval(self, value):
436 self._enemy.bullet_launch_interval = value 496 self._enemy.bullet_launch_interval = value
455 @instruction(81) 515 @instruction(81)
456 def set_bullet_launch_offset(self, x, y, z): 516 def set_bullet_launch_offset(self, x, y, z):
457 self._enemy.bullet_launch_offset = (x, y) 517 self._enemy.bullet_launch_offset = (x, y)
458 518
459 519
520 @instruction(82)
521 def set_extended_bullet_attributes(self, *attributes):
522 self._enemy.extended_bullet_attributes = attributes
523
524
460 @instruction(97) 525 @instruction(97)
461 def set_anim(self, sprite_index): 526 def set_anim(self, sprite_index):
462 self._enemy.set_anim(sprite_index) 527 self._enemy.set_anim(sprite_index)
463 528
464 529
480 545
481 546
482 @instruction(103) 547 @instruction(103)
483 def set_hitbox(self, width, height, depth): 548 def set_hitbox(self, width, height, depth):
484 self._enemy.hitbox = (width, height) 549 self._enemy.hitbox = (width, height)
550
551
552 @instruction(104)
553 def set_collidable(self, collidable):
554 """Defines whether the enemy is “collidable”.
555 A collision between a collidable enemy and the player will kill the player.
556 """
557 self._enemy.collidable = bool(collidable & 1)
485 558
486 559
487 @instruction(105) 560 @instruction(105)
488 def set_damageable(self, damageable): 561 def set_damageable(self, damageable):
489 self._enemy.damageable = bool(damageable & 1) 562 self._enemy.damageable = bool(damageable & 1)