annotate pytouhou/vm/eclrunner.py @ 283:b6c068c8f7f2

Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
author Thibaut Girka <thib@sitedethib.com>
date Sun, 12 Feb 2012 02:09:16 +0100
parents 3539520fff93
children 91eb0afcb1e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
1 # -*- encoding: utf-8 -*-
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
2 ##
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
3 ## Copyright (C) 2011 Thibaut Girka <thib@sitedethib.com>
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
4 ##
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
5 ## This program is free software; you can redistribute it and/or modify
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
6 ## it under the terms of the GNU General Public License as published
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
7 ## by the Free Software Foundation; version 3 only.
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
8 ##
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
9 ## This program is distributed in the hope that it will be useful,
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
12 ## GNU General Public License for more details.
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
13 ##
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
14
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
15
107
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
16 from math import atan2, cos, sin, pi
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
17
58
3da4de9decd0 Use logging module
Thibaut Girka <thib@sitedethib.com>
parents: 57
diff changeset
18 from pytouhou.utils.helpers import get_logger
3da4de9decd0 Use logging module
Thibaut Girka <thib@sitedethib.com>
parents: 57
diff changeset
19
69
a142e57218a0 Refactor. Move VMs to pytouhou.vm.
Thibaut Girka <thib@sitedethib.com>
parents: 67
diff changeset
20 from pytouhou.vm.common import MetaRegistry, instruction
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
21
69
a142e57218a0 Refactor. Move VMs to pytouhou.vm.
Thibaut Girka <thib@sitedethib.com>
parents: 67
diff changeset
22 logger = get_logger(__name__)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
23
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
24
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
25
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
26 class ECLMainRunner(object):
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
27 __metaclass__ = MetaRegistry
180
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
28 __slots__ = ('_ecl', '_game', 'processes', 'frame',
283
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
29 'instruction_pointer',
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
30 'time_stopped')
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
31
157
ca6f8b3f739d Remove half of the new_enemy/pop_enemy mess.
Thibaut Girka <thib@sitedethib.com>
parents: 155
diff changeset
32 def __init__(self, ecl, game):
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
33 self._ecl = ecl
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
34 self._game = game
180
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
35 self.frame = 0
283
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
36 self.time_stopped = False
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
37
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
38 self.processes = []
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
39
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
40 self.instruction_pointer = 0
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
41
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
42
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
43 def run_iter(self):
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
44 while True:
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
45 try:
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
46 frame, sub, instr_type, args = self._ecl.main[self.instruction_pointer]
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
47 except IndexError:
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
48 break
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
49
180
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
50 if frame > self.frame:
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
51 break
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
52 else:
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
53 self.instruction_pointer += 1
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
54
180
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
55 if frame == self.frame:
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
56 try:
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
57 callback = self._handlers[instr_type]
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
58 except KeyError:
99
68aa8bf00c88 Change a debug string to avoid confusion
Thibaut Girka <thib@sitedethib.com>
parents: 97
diff changeset
59 logger.warn('unhandled main opcode %d (args: %r)', instr_type, args)
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
60 else:
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
61 callback(self, sub, instr_type, *args)
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
62
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
63 self.processes[:] = (process for process in self.processes
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
64 if process.run_iteration())
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
65
283
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
66 if not self._game.boss:
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
67 self.time_stopped = False
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
68
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
69 if not self.time_stopped:
180
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
70 self.frame += 1
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
71
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
72
171
2f3665a77f11 Add support for the last unknown value of the enemy spawning.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 169
diff changeset
73 def _pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, die_score):
140
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
74 if instr_type & 4:
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
75 if x < -990: #102h.exe@0x411820
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
76 x = self._game.prng.rand_double() * 368
140
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
77 if y < -990: #102h.exe@0x41184b
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
78 y = self._game.prng.rand_double() * 416
140
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
79 if z < -990: #102h.exe@0x411881
270
7a9135b88853 Partially fix some of Flandre's spellcards.
Thibaut Girka <thib@sitedethib.com>
parents: 269
diff changeset
80 z = self._game.prng.rand_double() * 800
7a9135b88853 Partially fix some of Flandre's spellcards.
Thibaut Girka <thib@sitedethib.com>
parents: 269
diff changeset
81 enemy = self._game.new_enemy((x, y, z), life, instr_type, bonus_dropped, die_score)
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
82 process = ECLRunner(self._ecl, sub, enemy, self._game)
140
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
83 self.processes.append(process)
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
84 process.run_iteration()
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
85
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
86
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
87 @instruction(0)
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
88 @instruction(2)
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
89 @instruction(4)
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
90 @instruction(6)
171
2f3665a77f11 Add support for the last unknown value of the enemy spawning.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 169
diff changeset
91 def pop_enemy(self, sub, instr_type, x, y, z, life, bonus_dropped, die_score):
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
92 if self._game.boss:
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
93 return
171
2f3665a77f11 Add support for the last unknown value of the enemy spawning.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 169
diff changeset
94 self._pop_enemy(sub, instr_type, x, y, z, life, bonus_dropped, die_score)
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
95
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
96
283
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
97 @instruction(12)
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
98 def stop_time(self, sub, instr_type):
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
99 self.time_stopped = True
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
100
b6c068c8f7f2 Fix ECL time flow. Spellcard do not stop time. Instruction 0xc does.
Thibaut Girka <thib@sitedethib.com>
parents: 279
diff changeset
101
97
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
102
ac2e5e1c2c3c Refactor \o/
Thibaut Girka <thib@sitedethib.com>
parents: 96
diff changeset
103
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
104 class ECLRunner(object):
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
105 __metaclass__ = MetaRegistry
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
106 __slots__ = ('_ecl', '_enemy', '_game', 'variables', 'sub', 'frame',
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
107 'instruction_pointer', 'comparison_reg', 'stack')
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
108
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
109 def __init__(self, ecl, sub, enemy, game):
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
110 # Things not supposed to change
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
111 self._ecl = ecl
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
112 self._enemy = enemy
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
113 self._game = game
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
114
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
115 # Things supposed to change (and be put in the stack)
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
116 self.variables = [0, 0, 0, 0,
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
117 0., 0., 0., 0.,
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
118 0, 0, 0, 0]
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
119 self.comparison_reg = 0
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
120 self.sub = sub
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
121 self.frame = 0
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
122 self.instruction_pointer = 0
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
123
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
124 self.stack = []
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
125
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
126
93
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
127 def handle_callbacks(self):
103
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
128 #TODO: implement missing callbacks and clean up!
93
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
129 enm = self._enemy
103
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
130 if enm.boss_callback is not None: #XXX: MSG's job!
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
131 self.frame = 0
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
132 self.sub = enm.boss_callback
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
133 self.instruction_pointer = 0
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
134 enm.boss_callback = None
166
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
135 if enm.life <= 0 and enm.touchable:
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
136 death_flags = enm.death_flags & 7
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
137
166
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
138 enm.die_anim()
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
139
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
140 if death_flags < 4:
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
141 if enm._bonus_dropped >= 0:
190
dbe6b7b2d3fc Fix a few things about particles.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 185
diff changeset
142 enm.drop_particles(7, 0)
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
143 self._game.drop_bonus(enm.x, enm.y, enm._bonus_dropped)
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
144 elif enm._bonus_dropped == -1:
193
9f58e2a6e950 Fix particles, fix "random" item popping, change update order to match the original game's more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 192
diff changeset
145 if self._game.deaths_count % 3 == 0:
192
5e84dfd153ab Use the right “random” item drop function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 190
diff changeset
146 enm.drop_particles(10, 0)
5e84dfd153ab Use the right “random” item drop function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 190
diff changeset
147 self._game.drop_bonus(enm.x, enm.y, self._game.bonus_list[self._game.next_bonus])
5e84dfd153ab Use the right “random” item drop function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 190
diff changeset
148 self._game.next_bonus = (self._game.next_bonus + 1) % 32
5e84dfd153ab Use the right “random” item drop function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 190
diff changeset
149 else:
5e84dfd153ab Use the right “random” item drop function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 190
diff changeset
150 enm.drop_particles(4, 0)
5e84dfd153ab Use the right “random” item drop function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 190
diff changeset
151 self._game.deaths_count += 1
190
dbe6b7b2d3fc Fix a few things about particles.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 185
diff changeset
152 else:
dbe6b7b2d3fc Fix a few things about particles.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 185
diff changeset
153 enm.drop_particles(4, 0)
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
154
166
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
155 if death_flags == 0:
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
156 enm._removed = True
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
157 return
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
158
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
159 if death_flags == 1:
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
160 enm.touchable = False
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
161 elif death_flags == 2:
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
162 pass # Just that?
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
163 elif death_flags == 3:
268
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
164 #TODO: disable boss mode
166
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
165 enm.damageable = False
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
166 enm.life = 1
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
167 enm.death_flags = 0
dcf32488a2c9 Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 165
diff changeset
168
268
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
169 if death_flags != 0 and enm.death_callback >= 0:
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
170 self.frame = 0
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
171 self.sub = enm.death_callback
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
172 self.instruction_pointer = 0
268
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
173 enm.death_callback = -1
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
174 elif enm.life <= enm.low_life_trigger and enm.low_life_callback >= 0:
103
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
175 self.frame = 0
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
176 self.sub = enm.low_life_callback
103
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
177 self.instruction_pointer = 0
268
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
178 enm.low_life_callback = -1
103
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
179 elif enm.timeout and enm.frame == enm.timeout:
93
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
180 enm.frame = 0
268
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
181 if enm.timeout_callback >= 0:
93
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
182 self.frame = 0
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
183 self.sub = enm.timeout_callback
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
184 self.instruction_pointer = 0
268
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
185 enm.timeout_callback = -1
272
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
186 elif enm.touchable:
103
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
187 enm.life = 0
272
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
188 elif enm.death_callback >= 0:
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
189 self.frame = 0
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
190 self.sub = enm.death_callback
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
191 self.instruction_pointer = 0
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
192 enm.death_callback = -1
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
193 enm.timeout = -1 #TODO: check
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
194 else:
b21acb12bed1 Fix timeout handling
Thibaut Girka <thib@sitedethib.com>
parents: 271
diff changeset
195 raise Exception('What the hell, man!')
93
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
196
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
197
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
198 def run_iteration(self):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
199 # First, if enemy is dead, return
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
200 if self._enemy._removed:
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
201 return False
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
202
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
203 # Then, check for callbacks
93
d167280a82fc Handle timeout callbacks, and clean up unneeded things
Thibaut Girka <thib@sitedethib.com>
parents: 91
diff changeset
204 self.handle_callbacks()
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
205
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
206 # Now, process script
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
207 while True:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
208 try:
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
209 frame, instr_type, rank_mask, param_mask, args = self._ecl.subs[self.sub][self.instruction_pointer]
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
210 except IndexError:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
211 return False
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
212
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
213 if frame > self.frame:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
214 break
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
215 else:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
216 self.instruction_pointer += 1
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
217
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
218
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
219 #TODO: skip bad ranks
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
220 if not rank_mask & (0x100 << self._game.rank):
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
221 continue
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
222
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
223
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
224 if frame == self.frame:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
225 try:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
226 callback = self._handlers[instr_type]
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
227 except KeyError:
58
3da4de9decd0 Use logging module
Thibaut Girka <thib@sitedethib.com>
parents: 57
diff changeset
228 logger.warn('unhandled opcode %d (args: %r)', instr_type, args)
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
229 else:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
230 callback(self, *args)
100
5c40cc1b8019 Use game's frame for interpolation. No more time manipulation interfering with interpolators!
Thibaut Girka <thib@sitedethib.com>
parents: 99
diff changeset
231 logger.debug('executed opcode %d (args: %r)', instr_type, args)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
232
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
233 self.frame += 1
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
234 return True
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
235
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
236
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
237 def _getval(self, value):
48
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
238 if -10012 <= value <= -10001:
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
239 return self.variables[int(-10001-value)]
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
240 elif -10025 <= value <= -10013:
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
241 if value == -10013:
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
242 return self._game.rank
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
243 elif value == -10014:
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
244 return self._game.difficulty
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
245 elif value == -10015:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
246 return self._enemy.x
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
247 elif value == -10016:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
248 return self._enemy.y
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
249 elif value == -10017:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
250 return self._enemy.z
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
251 elif value == -10018:
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
252 player = self._enemy.select_player()
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
253 return player.x
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
254 elif value == -10019:
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
255 player = self._enemy.select_player()
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
256 return player.y
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
257 elif value == -10021:
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
258 return self._enemy.get_player_angle()
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
259 elif value == -10022:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
260 return self._enemy.frame
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
261 elif value == -10024:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
262 return self._enemy.life
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
263 elif value == -10025:
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
264 return self._enemy.select_player().state.character #TODO
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
265 raise NotImplementedError(value) #TODO
48
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
266 else:
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
267 return value
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
268
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
269
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
270 def _setval(self, variable_id, value):
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
271 if -10012 <= variable_id <= -10001:
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
272 self.variables[int(-10001-variable_id)] = value
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
273 elif -10025 <= variable_id <= -10013:
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
274 if variable_id == -10015:
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
275 self._enemy.x = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
276 elif variable_id == -10016:
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
277 self._enemy.y = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
278 elif variable_id == -10017:
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
279 self._enemy.z = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
280 elif variable_id == -10022:
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
281 self._enemy.frame = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
282 elif variable_id == -10024:
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
283 self._enemy.life = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
284 else:
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
285 raise IndexError #TODO: proper exception
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
286 else:
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
287 raise IndexError #TODO: proper exception
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
288
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
289
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
290 @instruction(0)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
291 def noop(self):
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
292 pass #TODO: Really?
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
293
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
294
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
295 @instruction(1)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
296 def destroy(self, arg):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
297 #TODO: arg?
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
298 self._enemy._removed = True
48
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
299
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
300
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
301 @instruction(2)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
302 def relative_jump(self, frame, instruction_pointer):
52
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
303 """Jumps to a relative offset in the same subroutine.
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
304
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
305 Warning: the relative offset has been translated to an instruction pointer
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
306 by the ECL parsing code (see pytouhou.formats.ecl).
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
307 """
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
308 self.frame, self.instruction_pointer = frame, instruction_pointer
48
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
309
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
310
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
311 @instruction(3)
53
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
312 def relative_jump_ex(self, frame, instruction_pointer, variable_id):
52
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
313 """If the given variable is non-zero, decrease it by 1 and jump to a
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
314 relative offset in the same subroutine.
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
315
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
316 Warning: the relative offset has been translated to an instruction pointer
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
317 by the ECL parsing code (see pytouhou.formats.ecl).
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
318 """
91
f7525fa66bb0 Fix ECL instruction 3
Thibaut Girka <thib@sitedethib.com>
parents: 87
diff changeset
319 counter_value = self._getval(variable_id) - 1
f7525fa66bb0 Fix ECL instruction 3
Thibaut Girka <thib@sitedethib.com>
parents: 87
diff changeset
320 if counter_value > 0:
f7525fa66bb0 Fix ECL instruction 3
Thibaut Girka <thib@sitedethib.com>
parents: 87
diff changeset
321 self._setval(variable_id, counter_value)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
322 self.frame, self.instruction_pointer = frame, instruction_pointer
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
323
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
324
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
325 @instruction(4)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
326 @instruction(5)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
327 def set_variable(self, variable_id, value):
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
328 self._setval(variable_id, self._getval(value))
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
329
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
330
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
331 @instruction(6)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
332 def set_random_int(self, variable_id, maxval):
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
333 """Set the specified variable to a random int in the [0, maxval) range.
52
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
334 """
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
335 self._setval(variable_id, int(self._getval(maxval) * self._game.prng.rand_double()))
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
336
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
337
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
338 @instruction(8)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
339 def set_random_float(self, variable_id, maxval):
52
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
340 """Set the specified variable to a random float in [0, maxval) range.
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
341 """
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
342 self._setval(variable_id, self._getval(maxval) * self._game.prng.rand_double())
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
343
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
344
59
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
345 @instruction(9)
144
cadfc5e5ad7a Fix a stupid inversion of properties.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 140
diff changeset
346 def set_random_float2(self, variable_id, amp, minval):
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
347 self._setval(variable_id, self._getval(minval) + self._getval(amp) * self._game.prng.rand_double())
59
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
348
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
349
75
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
350 @instruction(10)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
351 def store_x(self, variable_id):
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
352 self._setval(variable_id, self._enemy.x)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
353
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
354
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
355 @instruction(14)
65
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
356 @instruction(21)
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
357 def substract(self, variable_id, a, b):
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
358 #TODO: 14 takes only ints and 21 only floats.
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
359 # The original engine dereferences the variables in the type it waits for, so this isn't exactly the correct implementation, but the data don't contain such case.
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
360 self._setval(variable_id, self._getval(a) - self._getval(b))
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
361
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
362
87
fda176f07d6d Fix add_int
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
363 @instruction(13)
fda176f07d6d Fix add_int
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
364 @instruction(20)
fda176f07d6d Fix add_int
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
365 def add(self, variable_id, a, b):
fda176f07d6d Fix add_int
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
366 #TODO: 13 takes only ints and 20 only floats.
fda176f07d6d Fix add_int
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
367 # The original engine dereferences the variables in the type it waits for, so this isn't exactly the correct implementation, but the data don't contain such case.
fda176f07d6d Fix add_int
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
368 self._setval(variable_id, self._getval(a) + self._getval(b))
fda176f07d6d Fix add_int
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
369
fda176f07d6d Fix add_int
Thibaut Girka <thib@sitedethib.com>
parents: 83
diff changeset
370
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
371 @instruction(15)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
372 def multiply_int(self, variable_id, a, b):
65
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
373 #TODO: takes only ints.
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
374 self._setval(variable_id, self._getval(a) * self._getval(b))
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
375
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
376
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
377 @instruction(16)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
378 def divide_int(self, variable_id, a, b):
65
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
379 #TODO: takes only ints.
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
380 self._setval(variable_id, self._getval(a) // self._getval(b))
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
381
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
382
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
383 @instruction(17)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
384 def modulo(self, variable_id, a, b):
65
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
385 self._setval(variable_id, self._getval(a) % self._getval(b))
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
386
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
387
96
54929d495654 Handle ECL instruction 18
Thibaut Girka <thib@sitedethib.com>
parents: 95
diff changeset
388 @instruction(18)
54929d495654 Handle ECL instruction 18
Thibaut Girka <thib@sitedethib.com>
parents: 95
diff changeset
389 def increment(self, variable_id):
54929d495654 Handle ECL instruction 18
Thibaut Girka <thib@sitedethib.com>
parents: 95
diff changeset
390 self._setval(variable_id, self._getval(variable_id) + 1)
54929d495654 Handle ECL instruction 18
Thibaut Girka <thib@sitedethib.com>
parents: 95
diff changeset
391
54929d495654 Handle ECL instruction 18
Thibaut Girka <thib@sitedethib.com>
parents: 95
diff changeset
392
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
393 @instruction(23)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
394 def divide_float(self, variable_id, a, b):
65
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
395 #TODO: takes only floats.
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
396 self._setval(variable_id, self._getval(a) / self._getval(b))
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
397
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
398
77
6fa6d74a049a Handle a new ECL instruction, and add some names.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 76
diff changeset
399 @instruction(25)
6fa6d74a049a Handle a new ECL instruction, and add some names.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 76
diff changeset
400 def get_direction(self, variable_id, x1, y1, x2, y2):
6fa6d74a049a Handle a new ECL instruction, and add some names.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 76
diff changeset
401 #TODO: takes only floats.
147
a61c96265779 Fix a crash with ECL instruction 25
Thibaut Girka <thib@sitedethib.com>
parents: 144
diff changeset
402 self._setval(variable_id, atan2(self._getval(y2) - self._getval(y1), self._getval(x2) - self._getval(x1)))
77
6fa6d74a049a Handle a new ECL instruction, and add some names.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 76
diff changeset
403
6fa6d74a049a Handle a new ECL instruction, and add some names.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 76
diff changeset
404
155
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
405 @instruction(26)
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
406 def float_to_unit_circle(self, variable_id):
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
407 #TODO: takes only floats.
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
408 self._setval(variable_id, (self._getval(variable_id) + pi) % (2*pi) - pi)
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
409
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
410
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
411 @instruction(27)
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
412 @instruction(28)
65
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
413 def compare(self, a, b):
0efec109f798 Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 64
diff changeset
414 #TODO: 27 takes only ints and 28 only floats.
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
415 a, b = self._getval(a), self._getval(b)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
416 if a < b:
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
417 self.comparison_reg = -1
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
418 elif a == b:
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
419 self.comparison_reg = 0
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
420 else:
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
421 self.comparison_reg = 1
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
422
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
423
64
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
424 @instruction(29)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
425 def relative_jump_if_lower_than(self, frame, instruction_pointer):
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
426 if self.comparison_reg == -1:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
427 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
428
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
429
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
430 @instruction(30)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
431 def relative_jump_if_lower_or_equal(self, frame, instruction_pointer):
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
432 if self.comparison_reg != 1:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
433 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
434
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
435
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
436 @instruction(31)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
437 def relative_jump_if_equal(self, frame, instruction_pointer):
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
438 if self.comparison_reg == 0:
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
439 self.relative_jump(frame, instruction_pointer)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
440
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
441
64
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
442 @instruction(32)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
443 def relative_jump_if_greater_than(self, frame, instruction_pointer):
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
444 if self.comparison_reg == 1:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
445 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
446
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
447
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
448 @instruction(33)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
449 def relative_jump_if_greater_or_equal(self, frame, instruction_pointer):
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
450 if self.comparison_reg != -1:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
451 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
452
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
453
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
454 @instruction(34)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
455 def relative_jump_if_not_equal(self, frame, instruction_pointer):
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
456 if self.comparison_reg != 0:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
457 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
458
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
459
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
460 @instruction(35)
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
461 def call(self, sub, param1, param2):
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
462 self.stack.append((self.sub, self.frame, self.instruction_pointer,
195
52c0b9399413 Fix ECL function calls... again
Thibaut Girka <thib@sitedethib.com>
parents: 194
diff changeset
463 list(self.variables), self.comparison_reg))
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
464 self.sub = sub
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
465 self.frame = 0
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
466 self.instruction_pointer = 0
185
68e6d3faeee6 Don’t reinitialize variables when another sub is called.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 183
diff changeset
467 self.variables[0] = param1
194
efa847ee8b3c Fix ECL function calls
Thibaut Girka <thib@sitedethib.com>
parents: 193
diff changeset
468 self.variables[4] = param2
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
469
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
470
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
471 @instruction(36)
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
472 def ret(self):
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
473 self.sub, self.frame, self.instruction_pointer, self.variables, self.comparison_reg = self.stack.pop()
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
474
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
475
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
476 @instruction(39)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
477 def call_if_equal(self, sub, param1, param2, a, b):
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
478 if self._getval(a) == self._getval(b):
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
479 self.call(sub, param1, param2)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
480
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
481
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
482 @instruction(43)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
483 def set_pos(self, x, y, z):
74
adac26098408 Handle variables in set_pos instruction (Daiyousei...)
Thibaut Girka <thib@sitedethib.com>
parents: 70
diff changeset
484 self._enemy.set_pos(self._getval(x), self._getval(y), self._getval(z))
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
485
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
486
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
487 @instruction(45)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
488 def set_angle_speed(self, angle, speed):
251
4b549894ef6b Change position/speed interpoletor handling to match the original game more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 250
diff changeset
489 self._enemy.update_mode = 0
270
7a9135b88853 Partially fix some of Flandre's spellcards.
Thibaut Girka <thib@sitedethib.com>
parents: 269
diff changeset
490 self._enemy.angle, self._enemy.speed = self._getval(angle), self._getval(speed)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
491
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
492
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
493 @instruction(46)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
494 def set_rotation_speed(self, speed):
251
4b549894ef6b Change position/speed interpoletor handling to match the original game more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 250
diff changeset
495 self._enemy.update_mode = 0
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
496 self._enemy.rotation_speed = speed
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
497
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
498
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
499 @instruction(47)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
500 def set_speed(self, speed):
251
4b549894ef6b Change position/speed interpoletor handling to match the original game more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 250
diff changeset
501 self._enemy.update_mode = 0
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
502 self._enemy.speed = speed
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
503
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
504
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
505 @instruction(48)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
506 def set_acceleration(self, acceleration):
251
4b549894ef6b Change position/speed interpoletor handling to match the original game more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 250
diff changeset
507 self._enemy.update_mode = 0
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
508 self._enemy.acceleration = acceleration
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
509
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
510
70
7c1f20407b3e Add set_random_angle support
Thibaut Girka <thib@sitedethib.com>
parents: 69
diff changeset
511 @instruction(49)
7c1f20407b3e Add set_random_angle support
Thibaut Girka <thib@sitedethib.com>
parents: 69
diff changeset
512 def set_random_angle(self, min_angle, max_angle):
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
513 angle = self._game.prng.rand_double() * (max_angle - min_angle) + min_angle
70
7c1f20407b3e Add set_random_angle support
Thibaut Girka <thib@sitedethib.com>
parents: 69
diff changeset
514 self._enemy.angle = angle
7c1f20407b3e Add set_random_angle support
Thibaut Girka <thib@sitedethib.com>
parents: 69
diff changeset
515
7c1f20407b3e Add set_random_angle support
Thibaut Girka <thib@sitedethib.com>
parents: 69
diff changeset
516
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
517 @instruction(50)
70
7c1f20407b3e Add set_random_angle support
Thibaut Girka <thib@sitedethib.com>
parents: 69
diff changeset
518 def set_random_angle_ex(self, min_angle, max_angle):
59
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
519 if self._enemy.screen_box:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
520 minx, miny, maxx, maxy = self._enemy.screen_box
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
521 else:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
522 minx, miny, maxx, maxy = (0., 0., 0., 0.)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
523
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
524 angle = self._game.prng.rand_double() * (max_angle - min_angle) + min_angle
59
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
525 sa, ca = sin(angle), cos(angle)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
526
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
527 if self._enemy.x > maxx - 96.0:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
528 ca = -abs(ca)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
529 elif self._enemy.x < minx + 96.0:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
530 ca = abs(ca)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
531
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
532 if self._enemy.y > maxy - 48.0:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
533 sa = -abs(sa)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
534 elif self._enemy.y < miny + 48.0:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
535 sa = abs(sa)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
536 self._enemy.angle = atan2(sa, ca)
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
537
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
538
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
539 @instruction(51)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
540 def target_player(self, unknown, speed):
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
541 #TODO: unknown
251
4b549894ef6b Change position/speed interpoletor handling to match the original game more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 250
diff changeset
542 self._enemy.update_mode = 0
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
543 self._enemy.speed = speed
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
544 self._enemy.angle = self._enemy.get_player_angle()
43
7195aaf95f6e Fix set_counter, and relative_jump(_ex)
Thibaut Girka <thib@sitedethib.com>
parents: 42
diff changeset
545
7195aaf95f6e Fix set_counter, and relative_jump(_ex)
Thibaut Girka <thib@sitedethib.com>
parents: 42
diff changeset
546
183
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
547 @instruction(52)
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
548 def move_in_decel(self, duration, angle, speed):
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
549 self._enemy.angle, self._enemy.speed = angle, speed
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
550 self._enemy.stop_in(duration, lambda x: 2. * x - x ** 2)
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
551
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
552
76
f305c0e406d6 Handle all move_to_* ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 75
diff changeset
553 @instruction(56)
f305c0e406d6 Handle all move_to_* ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 75
diff changeset
554 def move_to_linear(self, duration, x, y, z):
140
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
555 self._enemy.move_to(duration,
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
556 self._getval(x), self._getval(y), self._getval(z),
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
557 lambda x: x)
76
f305c0e406d6 Handle all move_to_* ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 75
diff changeset
558
f305c0e406d6 Handle all move_to_* ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 75
diff changeset
559
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
560 @instruction(57)
76
f305c0e406d6 Handle all move_to_* ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 75
diff changeset
561 def move_to_decel(self, duration, x, y, z):
140
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
562 self._enemy.move_to(duration,
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
563 self._getval(x), self._getval(y), self._getval(z),
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
564 lambda x: 2. * x - x ** 2)
62
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
565
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
566
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
567 @instruction(59)
76
f305c0e406d6 Handle all move_to_* ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 75
diff changeset
568 def move_to_accel(self, duration, x, y, z):
140
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
569 self._enemy.move_to(duration,
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
570 self._getval(x), self._getval(y), self._getval(z),
a9d46c4b5764 Fix move_to (handle variables) and spawn_enemy
Thibaut Girka <thib@sitedethib.com>
parents: 134
diff changeset
571 lambda x: x ** 2)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
572
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
573
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
574 @instruction(61)
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
575 def stop_in(self, duration):
75
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
576 self._enemy.stop_in(duration, lambda x: x)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
577
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
578
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
579 @instruction(63)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
580 def stop_in_accel(self, duration):
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
581 self._enemy.stop_in(duration, lambda x: 1. - x)
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
582
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
583
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
584 @instruction(65)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
585 def set_screen_box(self, xmin, ymin, xmax, ymax):
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
586 self._enemy.screen_box = xmin, ymin, xmax, ymax
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
587
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
588
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
589 @instruction(66)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
590 def clear_screen_box(self):
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
591 self._enemy.screen_box = None
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
592
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
593
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
594 @instruction(67)
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
595 def set_bullet_attributes1(self, anim, sprite_idx_offset, bullets_per_shot,
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
596 number_of_shots, speed, speed2, launch_angle,
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
597 angle, flags):
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
598 self._enemy.set_bullet_attributes(67, anim,
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
599 self._getval(sprite_idx_offset),
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
600 self._getval(bullets_per_shot),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
601 self._getval(number_of_shots),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
602 self._getval(speed),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
603 self._getval(speed2),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
604 self._getval(launch_angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
605 self._getval(angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
606 flags)
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
607
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
608
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
609 @instruction(68)
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
610 def set_bullet_attributes2(self, anim, sprite_idx_offset, bullets_per_shot,
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
611 number_of_shots, speed, speed2, launch_angle,
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
612 angle, flags):
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
613 self._enemy.set_bullet_attributes(68, anim,
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
614 self._getval(sprite_idx_offset),
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
615 self._getval(bullets_per_shot),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
616 self._getval(number_of_shots),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
617 self._getval(speed),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
618 self._getval(speed2),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
619 self._getval(launch_angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
620 self._getval(angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
621 flags)
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
622
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
623
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
624 @instruction(69)
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
625 def set_bullet_attributes3(self, anim, sprite_idx_offset, bullets_per_shot,
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
626 number_of_shots, speed, speed2, launch_angle,
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
627 angle, flags):
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
628 self._enemy.set_bullet_attributes(69, anim,
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
629 self._getval(sprite_idx_offset),
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
630 self._getval(bullets_per_shot),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
631 self._getval(number_of_shots),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
632 self._getval(speed),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
633 self._getval(speed2),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
634 self._getval(launch_angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
635 self._getval(angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
636 flags)
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
637
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
638
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
639 @instruction(70)
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
640 def set_bullet_attributes4(self, anim, sprite_idx_offset, bullets_per_shot,
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
641 number_of_shots, speed, speed2, launch_angle,
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
642 angle, flags):
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
643 self._enemy.set_bullet_attributes(70, anim,
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
644 self._getval(sprite_idx_offset),
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
645 self._getval(bullets_per_shot),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
646 self._getval(number_of_shots),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
647 self._getval(speed),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
648 self._getval(speed2),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
649 self._getval(launch_angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
650 self._getval(angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
651 flags)
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
652
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
653
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
654 @instruction(71)
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
655 def set_bullet_attributes5(self, anim, sprite_idx_offset, bullets_per_shot,
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
656 number_of_shots, speed, speed2, launch_angle,
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
657 angle, flags):
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
658 self._enemy.set_bullet_attributes(71, anim,
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
659 self._getval(sprite_idx_offset),
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
660 self._getval(bullets_per_shot),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
661 self._getval(number_of_shots),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
662 self._getval(speed),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
663 self._getval(speed2),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
664 self._getval(launch_angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
665 self._getval(angle),
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
666 flags)
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
667
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
668
83
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
669 @instruction(74)
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
670 def set_bullet_attributes6(self, anim, sprite_idx_offset, bullets_per_shot,
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
671 number_of_shots, speed, speed2, launch_angle,
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
672 angle, flags):
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
673 #TODO
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
674 self._enemy.set_bullet_attributes(74, anim,
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
675 self._getval(sprite_idx_offset),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
676 self._getval(bullets_per_shot),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
677 self._getval(number_of_shots),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
678 self._getval(speed),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
679 self._getval(speed2),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
680 self._getval(launch_angle),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
681 self._getval(angle),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
682 flags)
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
683
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
684
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
685 @instruction(75)
106
c7847bfed427 Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 105
diff changeset
686 def set_bullet_attributes7(self, anim, sprite_idx_offset, bullets_per_shot,
83
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
687 number_of_shots, speed, speed2, launch_angle,
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
688 angle, flags):
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
689 #TODO
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
690 self._enemy.set_bullet_attributes(75, anim,
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
691 self._getval(sprite_idx_offset),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
692 self._getval(bullets_per_shot),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
693 self._getval(number_of_shots),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
694 self._getval(speed),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
695 self._getval(speed2),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
696 self._getval(launch_angle),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
697 self._getval(angle),
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
698 flags)
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
699
fc0294c745b6 Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents: 82
diff changeset
700
78
bcf965ede96c Fix/rename/comment a few things
Thibaut Girka <thib@sitedethib.com>
parents: 77
diff changeset
701 @instruction(76)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
702 def set_bullet_interval(self, value):
182
20843875ad8f (Hopefully) use difficulty as it should.
Thibaut Girka <thib@sitedethib.com>
parents: 181
diff changeset
703 self._enemy.set_bullet_launch_interval(value)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
704
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
705
78
bcf965ede96c Fix/rename/comment a few things
Thibaut Girka <thib@sitedethib.com>
parents: 77
diff changeset
706 @instruction(77)
bcf965ede96c Fix/rename/comment a few things
Thibaut Girka <thib@sitedethib.com>
parents: 77
diff changeset
707 def set_bullet_interval_ex(self, value):
182
20843875ad8f (Hopefully) use difficulty as it should.
Thibaut Girka <thib@sitedethib.com>
parents: 181
diff changeset
708 self._enemy.set_bullet_launch_interval(value, self._game.prng.rand_double()) #TODO: check
78
bcf965ede96c Fix/rename/comment a few things
Thibaut Girka <thib@sitedethib.com>
parents: 77
diff changeset
709
bcf965ede96c Fix/rename/comment a few things
Thibaut Girka <thib@sitedethib.com>
parents: 77
diff changeset
710
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
711 @instruction(78)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
712 def set_delay_attack(self):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
713 self._enemy.delay_attack = True
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
714
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
715
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
716 @instruction(79)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
717 def set_no_delay_attack(self):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
718 self._enemy.delay_attack = False
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
719
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
720
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
721 @instruction(81)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
722 def set_bullet_launch_offset(self, x, y, z):
134
e9ac3640280b Add support for enemy spawnling enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 128
diff changeset
723 self._enemy.bullet_launch_offset = (self._getval(x), self._getval(y))
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
724
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
725
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
726 @instruction(82)
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
727 def set_extended_bullet_attributes(self, *attributes):
102
ad9297e0fbf2 Handle variables in ECL instruction 82
Thibaut Girka <thib@sitedethib.com>
parents: 100
diff changeset
728 self._enemy.extended_bullet_attributes = tuple(self._getval(attr) for attr in attributes)
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
729
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
730
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 147
diff changeset
731 @instruction(83)
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 147
diff changeset
732 def change_bullets_into_star_items(self):
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
733 self._game.change_bullets_into_star_items()
150
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 147
diff changeset
734
4f46717390aa Introduce items, implement ECL instruction 83
Thibaut Girka <thib@sitedethib.com>
parents: 147
diff changeset
735
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
736 @instruction(85)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
737 def new_laser(self, laser_type, sprite_idx_offset, angle, speed,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
738 start_offset, end_offset, max_length, width,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
739 start_duration, duration, end_duration,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
740 grazing_delay, grazing_extra_duration, unknown):
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
741 self._enemy.new_laser(85, laser_type, sprite_idx_offset, self._getval(angle), speed,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
742 start_offset, end_offset, max_length, width,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
743 start_duration, duration, end_duration,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
744 grazing_delay, grazing_extra_duration, unknown)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
745
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
746
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
747 @instruction(86)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
748 def new_laser_towards_player(self, laser_type, sprite_idx_offset, angle, speed,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
749 start_offset, end_offset, max_length, width,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
750 start_duration, duration, end_duration,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
751 grazing_delay, grazing_extra_duration, unknown):
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
752 self._enemy.new_laser(86, laser_type, sprite_idx_offset, self._getval(angle), speed,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
753 start_offset, end_offset, max_length, width,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
754 start_duration, duration, end_duration,
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
755 grazing_delay, grazing_extra_duration, unknown)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
756
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
757
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
758 @instruction(87)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
759 def set_upcoming_laser_id(self, laser_id):
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
760 self._enemy.current_laser_id = laser_id
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
761
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
762
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
763 @instruction(88)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
764 def alter_laser_angle(self, laser_id, delta):
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
765 try:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
766 laser = self._enemy.laser_by_id[laser_id]
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
767 except KeyError:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
768 pass #TODO
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
769 else:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
770 laser.angle += self._getval(delta)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
771
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
772
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
773 @instruction(90)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
774 def reposition_laser(self, laser_id, ox, oy, oz):
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
775 try:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
776 laser = self._enemy.laser_by_id[laser_id]
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
777 except KeyError:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
778 pass #TODO
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
779 else:
279
3539520fff93 Fix sprite rotation/translation.
Thibaut Girka <thib@sitedethib.com>
parents: 276
diff changeset
780 laser.base_pos = self._enemy.x + ox, self._enemy.y + oy
274
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
781
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
782
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
783 @instruction(92)
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
784 def cancel_laser(self, laser_id):
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
785 try:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
786 laser = self._enemy.laser_by_id[laser_id]
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
787 except KeyError:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
788 pass #TODO
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
789 else:
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
790 laser.cancel()
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
791
f037bca24f2d Partially implement lasers.
Thibaut Girka <thib@sitedethib.com>
parents: 273
diff changeset
792
95
e2d8f2a56ea4 Handle ECL opcodes with string.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 93
diff changeset
793 @instruction(93)
276
754ff6452d7e Fix spellcard number 0.
Thibaut Girka <thib@sitedethib.com>
parents: 275
diff changeset
794 def set_spellcard(self, face, number, name):
95
e2d8f2a56ea4 Handle ECL opcodes with string.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 93
diff changeset
795 #TODO: display it on the game.
155
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
796 #TODO: make the enemies more resistants (and find how).
160
606468ab4f7b Clean up bullets when starting a spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 159
diff changeset
797 self._game.change_bullets_into_star_items()
276
754ff6452d7e Fix spellcard number 0.
Thibaut Girka <thib@sitedethib.com>
parents: 275
diff changeset
798 self._game.spellcard = (number, name)
217
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 207
diff changeset
799 self._game.enable_effect()
155
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
800
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
801
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
802 @instruction(94)
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
803 def end_spellcard(self):
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
804 #TODO: return everything back to normal
ed86bec43b93 Implement two new instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 154
diff changeset
805 #TODO: give the spellcard bonus.
180
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
806 if self._game.spellcard:
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
807 self._game.change_bullets_into_star_items()
5a1533677a9a Freeze time during spellcards
Thibaut Girka <thib@sitedethib.com>
parents: 178
diff changeset
808 self._game.spellcard = None
217
577f45454402 Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 207
diff changeset
809 self._game.disable_effect()
95
e2d8f2a56ea4 Handle ECL opcodes with string.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 93
diff changeset
810
e2d8f2a56ea4 Handle ECL opcodes with string.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 93
diff changeset
811
134
e9ac3640280b Add support for enemy spawnling enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 128
diff changeset
812 @instruction(95)
171
2f3665a77f11 Add support for the last unknown value of the enemy spawning.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 169
diff changeset
813 def pop_enemy(self, sub, x, y, z, life, bonus_dropped, die_score):
270
7a9135b88853 Partially fix some of Flandre's spellcards.
Thibaut Girka <thib@sitedethib.com>
parents: 269
diff changeset
814 self._game.ecl_runner._pop_enemy(sub, 0, self._getval(x),
7a9135b88853 Partially fix some of Flandre's spellcards.
Thibaut Girka <thib@sitedethib.com>
parents: 269
diff changeset
815 self._getval(y),
7a9135b88853 Partially fix some of Flandre's spellcards.
Thibaut Girka <thib@sitedethib.com>
parents: 269
diff changeset
816 self._getval(z),
7a9135b88853 Partially fix some of Flandre's spellcards.
Thibaut Girka <thib@sitedethib.com>
parents: 269
diff changeset
817 life, bonus_dropped, die_score)
134
e9ac3640280b Add support for enemy spawnling enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 128
diff changeset
818
e9ac3640280b Add support for enemy spawnling enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 128
diff changeset
819
154
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
820 @instruction(96)
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
821 def kill_enemies(self):
268
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
822 for proc in self._game.ecl_runner.processes:
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
823 if proc._enemy.boss:
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
824 pass # Bosses are immune to 96
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
825 elif proc._enemy.touchable:
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
826 proc._enemy.life = 0
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
827 elif proc._enemy.death_callback > 0:
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
828 #TODO: check
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
829 #TODO: refactor
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
830 proc.frame = 0
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
831 proc.instruction_pointer = 0
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
832 proc.sub = proc._enemy.death_callback
dd621ad72beb Fix callback handling and damage dealing.
Thibaut Girka <thib@sitedethib.com>
parents: 266
diff changeset
833 proc._enemy.death_callback = -1
154
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
834
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
835
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
836 @instruction(97)
242
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
837 def set_anim(self, script):
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
838 self._enemy.set_anim(script)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
839
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
840
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
841 @instruction(98)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
842 def set_multiple_anims(self, default, end_left, end_right, left, right):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
843 self._enemy.movement_dependant_sprites = end_left, end_right, left, right
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
844 self._enemy.set_anim(default)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
845
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
846
242
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
847 @instruction(99)
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
848 def set_aux_anm(self, number, script):
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
849 self._enemy.set_aux_anm(number, script)
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
850
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
851
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
852 @instruction(100)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
853 def set_death_anim(self, sprite_index):
181
184196480f59 Don’t use the useless eff00.anm and implement particles (grazing, death, and more).
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 180
diff changeset
854 self._enemy.death_anim = sprite_index
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
855
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
856
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
857 @instruction(101)
177
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
858 def set_boss_mode(self, value):
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
859 #TODO: if there are multiple boss, spawned by a 95,
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
860 # only the last one has her life displayed,
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
861 # but standard enemies are blocked only until any of them is killed.
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
862 if value == 0:
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
863 self._enemy.boss = True
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
864 self._game.boss = self._enemy
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
865 elif value == -1:
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
866 self._enemy.boss = False
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
867 self._game.boss = None
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
868 else:
6e8653ff2b23 Fix boss mode and don’t suicide the boss when she just want to kill the other enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 171
diff changeset
869 raise Exception #TODO
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
870
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
871
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
872 @instruction(103)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
873 def set_hitbox(self, width, height, depth):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
874 self._enemy.hitbox = (width, height)
152
86807b8a63bd Add collisions with enemies and items.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 151
diff changeset
875 self._enemy.hitbox_half_size = (width / 2., height / 2.)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
876
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
877
79
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
878 @instruction(104)
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
879 def set_collidable(self, collidable):
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
880 """Defines whether the enemy is “collidable”.
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
881 A collision between a collidable enemy and the player will kill the player.
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
882 """
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
883 self._enemy.collidable = bool(collidable & 1)
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
884
ffe2c2b9912c Handle a few more ECL instructions. Prepare for bullet handling \o/
Thibaut Girka <thib@sitedethib.com>
parents: 78
diff changeset
885
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
886 @instruction(105)
75
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
887 def set_damageable(self, damageable):
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
888 self._enemy.damageable = bool(damageable & 1)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
889
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
890
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
891 @instruction(107)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
892 def set_death_flags(self, death_flags):
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
893 self._enemy.death_flags = death_flags
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
894
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
895
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
896 @instruction(108)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
897 def set_death_callback(self, sub):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
898 self._enemy.death_callback = sub
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
899
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
900
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
901 @instruction(109)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
902 def memory_write(self, value, index):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
903 #TODO
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
904 #XXX: this is a hack to display bosses although we don't handle MSG :)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
905 if index == 0:
103
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
906 self._enemy.boss_callback = value
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
907 else:
789994275968 Fix boss callback, handle a few more callbacks
Thibaut Girka <thib@sitedethib.com>
parents: 102
diff changeset
908 raise Exception #TODO
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
909
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
910
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
911 @instruction(111)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
912 def set_life(self, value):
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
913 self._enemy.life = value
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
914
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
915
67
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
916 @instruction(112)
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
917 def set_ellapsed_time(self, value):
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
918 """Sets the enemy's frame counter.
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
919 This is used for timeouts, where the framecounter is compared to the
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
920 timeout value (what's displayed is (enemy.timeout - enemy.frame) // 60).
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
921 """
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
922 self._enemy.frame = value
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
923
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
924
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
925 @instruction(113)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
926 def set_low_life_trigger(self, value):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
927 self._enemy.low_life_trigger = value
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
928
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
929
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
930 @instruction(114)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
931 def set_low_life_callback(self, sub):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
932 self._enemy.low_life_callback = sub
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
933
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
934
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
935 @instruction(115)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
936 def set_timeout(self, timeout):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
937 self._enemy.timeout = timeout
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
938
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
939
67
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
940 @instruction(116)
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
941 def set_timeout_callback(self, sub):
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
942 self._enemy.timeout_callback = sub
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
943
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
944
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
945 @instruction(117)
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
946 def set_touchable(self, value):
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
947 """Defines whether the enemy is “touchable”.
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
948 Bullets only collide with an enemy if it is “touchable”.
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
949 Likewise, ReimuA's homing attacks only target “touchable” enemies.
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
950 """
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
951 self._enemy.touchable = bool(value)
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
952
e2cb9d434dc2 Add support for a few opcodes.
Thibaut Girka <thib@sitedethib.com>
parents: 65
diff changeset
953
154
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
954 @instruction(119)
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
955 def drop_some_bonus(self, number):
244
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
956 if self._enemy.select_player().state.power < 128:
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
957 if number > 0:
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
958 #TODO: find the real formula in the binary.
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
959 self._game.drop_bonus(self._enemy.x - 64 + self._game.prng.rand_uint16() % 128,
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
960 self._enemy.y - 64 + self._game.prng.rand_uint16() % 128,
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
961 2)
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
962 for i in xrange(number - 1):
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
963 self._game.drop_bonus(self._enemy.x - 64 + self._game.prng.rand_uint16() % 128,
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
964 self._enemy.y - 64 + self._game.prng.rand_uint16() % 128,
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
965 0)
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
966 else:
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
967 for i in xrange(number):
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
968 self._game.drop_bonus(self._enemy.x - 64 + self._game.prng.rand_uint16() % 128,
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
969 self._enemy.y - 64 + self._game.prng.rand_uint16() % 128,
2b7f69ad9ccd Drop the correct amount of power with 119.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 242
diff changeset
970 1)
154
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
971
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
972
75
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
973 @instruction(120)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
974 def set_automatic_orientation(self, flags):
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
975 #TODO: does it change anything else than the sprite's rotation?
82
de48213a02bf Fix a few things
Thibaut Girka <thib@sitedethib.com>
parents: 79
diff changeset
976 self._enemy.automatic_orientation = bool(flags & 1)
75
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
977
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
978
107
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
979 @instruction(121)
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
980 def call_special_function(self, function, arg):
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
981 if function == 0: # Cirno
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
982 if arg == 0:
249
2ef8f4e181e3 Change ECL special function 0 in order to match the game more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 244
diff changeset
983 self._game.new_effect((self._enemy.x, self._enemy.y), 17)
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
984 for bullet in self._game.bullets:
107
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
985 bullet.speed = bullet.angle = 0.
256
507dfd6efe0c Refactor pytouhou.game.bullet.
Thibaut Girka <thib@sitedethib.com>
parents: 251
diff changeset
986 bullet.dx, bullet.dy = 0., 0.
128
8ba018617829 Fix Cirno's freezing bullets
Thibaut Girka <thib@sitedethib.com>
parents: 107
diff changeset
987 bullet.set_anim(sprite_idx_offset=15) #TODO: check
107
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
988 else:
249
2ef8f4e181e3 Change ECL special function 0 in order to match the game more closely.
Thibaut Girka <thib@sitedethib.com>
parents: 244
diff changeset
989 self._game.new_effect((self._enemy.x, self._enemy.y), 17)
151
5cf927cbd9c5 Merge GameState into Game. TODO: Merge PlayerState into Player
Thibaut Girka <thib@sitedethib.com>
parents: 150
diff changeset
990 for bullet in self._game.bullets:
256
507dfd6efe0c Refactor pytouhou.game.bullet.
Thibaut Girka <thib@sitedethib.com>
parents: 251
diff changeset
991 bullet.flags = 16 #TODO: check
250
cd4800154c9b Change ECL special function 0 in order to match the game more closely (again)
Thibaut Girka <thib@sitedethib.com>
parents: 249
diff changeset
992 angle = pi + self._game.prng.rand_double() * 2. * pi
256
507dfd6efe0c Refactor pytouhou.game.bullet.
Thibaut Girka <thib@sitedethib.com>
parents: 251
diff changeset
993 bullet.attributes[4:6] = [0.01, angle] #TODO: check
507dfd6efe0c Refactor pytouhou.game.bullet.
Thibaut Girka <thib@sitedethib.com>
parents: 251
diff changeset
994 bullet.attributes[0] = -1 #TODO: check
250
cd4800154c9b Change ECL special function 0 in order to match the game more closely (again)
Thibaut Girka <thib@sitedethib.com>
parents: 249
diff changeset
995 bullet.set_anim(sprite_idx_offset=15) #TODO: check
168
b96d835c0807 Implement Cirno’s 雪符「ダイアモンドブリザード」 spellcard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 166
diff changeset
996 elif function == 1: # Cirno
207
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
997 offset = (self._game.prng.rand_uint16() % arg - arg / 2,
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
998 self._game.prng.rand_uint16() % arg - arg / 2)
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
999 self._enemy.fire(offset=offset)
266
3a86c4e070dc Implement ECL’s 3rd hardcoded function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 256
diff changeset
1000 elif function == 3: # Patchouli’s dual sign spellcards
3a86c4e070dc Implement ECL’s 3rd hardcoded function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 256
diff changeset
1001 values = [[0, 3, 1],
3a86c4e070dc Implement ECL’s 3rd hardcoded function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 256
diff changeset
1002 [2, 3, 4],
3a86c4e070dc Implement ECL’s 3rd hardcoded function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 256
diff changeset
1003 [1, 4, 0],
3a86c4e070dc Implement ECL’s 3rd hardcoded function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 256
diff changeset
1004 [4, 2, 3]]
3a86c4e070dc Implement ECL’s 3rd hardcoded function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 256
diff changeset
1005 character = self._enemy.select_player().state.character
3a86c4e070dc Implement ECL’s 3rd hardcoded function.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 256
diff changeset
1006 self.variables[1:4] = values[character]
169
c4b4f7c068f2 Fix Cirno’s last spellcard and implement something for Patchy in extra stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 168
diff changeset
1007 elif function == 13:
c4b4f7c068f2 Fix Cirno’s last spellcard and implement something for Patchy in extra stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 168
diff changeset
1008 if self._enemy.bullet_attributes is None:
c4b4f7c068f2 Fix Cirno’s last spellcard and implement something for Patchy in extra stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 168
diff changeset
1009 return
c4b4f7c068f2 Fix Cirno’s last spellcard and implement something for Patchy in extra stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 168
diff changeset
1010
178
0bd5e5f19a73 Fix Patchouli’s 日符「ロイヤルフレア」 spellcard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 177
diff changeset
1011 if self._enemy.frame % 6:
0bd5e5f19a73 Fix Patchouli’s 日符「ロイヤルフレア」 spellcard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 177
diff changeset
1012 return
0bd5e5f19a73 Fix Patchouli’s 日符「ロイヤルフレア」 spellcard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 177
diff changeset
1013
207
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1014 (type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots,
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1015 speed, speed2, launch_angle, angle, flags) = self._enemy.bullet_attributes
178
0bd5e5f19a73 Fix Patchouli’s 日符「ロイヤルフレア」 spellcard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 177
diff changeset
1016 for i in range(arg):
0bd5e5f19a73 Fix Patchouli’s 日符「ロイヤルフレア」 spellcard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 177
diff changeset
1017 _angle = i*2*pi/arg
0bd5e5f19a73 Fix Patchouli’s 日符「ロイヤルフレア」 spellcard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 177
diff changeset
1018 _angle2 = _angle + self._getval(-10007)
0bd5e5f19a73 Fix Patchouli’s 日符「ロイヤルフレア」 spellcard.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 177
diff changeset
1019 _distance = self._getval(-10008)
207
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1020 launch_pos = (192 + cos(_angle2) * _distance,
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1021 224 + sin(_angle2) * _distance)
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1022 bullet_attributes = (type_, anim, sprite_idx_offset,
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1023 bullets_per_shot, number_of_shots,
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1024 speed, speed2,
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1025 self._getval(-10006) + _angle, angle, flags)
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1026 self._enemy.fire(launch_pos=launch_pos,
709f42eaa55e Minor refactoring
Thibaut Girka <thib@sitedethib.com>
parents: 195
diff changeset
1027 bullet_attributes=bullet_attributes)
275
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1028 elif function == 14: # Laevateinn
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1029 if arg == 0:
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1030 self.variables[4] = 0
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1031 for laser in self._enemy.laser_by_id.values():
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1032 self.variables[4] += 1
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1033 for pos in laser.get_bullets_pos():
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1034 self._enemy.fire(launch_pos=pos)
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1035 else:
4b0570bf5847 Implement hardcoded function 14 used by spellcard “Lævateinn”.
Thibaut Girka <thib@sitedethib.com>
parents: 274
diff changeset
1036 pass #TODO: check
273
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1037 elif function == 16: # QED: Ripples of 495 years
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1038 #TODO: the rythm seems to be really wrong
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1039 # Indeed, Flandre is supposed to start slowly, and those values
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1040 # match the craziest parts of the spellcard
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1041 if arg == 0:
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1042 self.variables[9] = 40 #TODO: is that all?
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1043 self.variables[7] = 2. #TODO: check value. is that all?
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1044 else:
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1045 #TODO: check
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1046 self.variables[6] = self._game.prng.rand_double() * (self._game.width - 64.) + 32.
595b227886b1 Partially implement hardcoded function 16, used for QED: ripples of 495 years
Thibaut Girka <thib@sitedethib.com>
parents: 272
diff changeset
1047 self.variables[7] = self._game.prng.rand_double() * (self._game.width / 2. - 64.) + 32.
107
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
1048 else:
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
1049 logger.warn("Unimplemented special function %d!", function)
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
1050
5d9052b9a4e8 (almost) implement Cirno's freezing spellcard
Thibaut Girka <thib@sitedethib.com>
parents: 106
diff changeset
1051
75
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
1052 @instruction(123)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
1053 def skip_frames(self, frames):
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
1054 #TODO: is that all?
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
1055 self.frame += self._getval(frames)
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
1056
b3bd421bb895 Handle a few more ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 74
diff changeset
1057
154
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
1058 @instruction(124)
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
1059 def drop_specific_bonus(self, _type):
165
c8c60291c56f Implement item dropping by enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 160
diff changeset
1060 #TODO: if _type < 0, “drop” an bullet animation instead of a bonus (never used).
154
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
1061 self._game.drop_bonus(self._enemy.x, self._enemy.y, _type)
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
1062
364935f6e313 Implement enemy killing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 152
diff changeset
1063
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
1064 @instruction(126)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
1065 def set_remaining_lives(self, lives):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
1066 self._enemy.remaining_lives = lives
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
1067
182
20843875ad8f (Hopefully) use difficulty as it should.
Thibaut Girka <thib@sitedethib.com>
parents: 181
diff changeset
1068
242
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1069 @instruction(128)
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1070 def interrupt(self, event):
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1071 self._enemy._anmrunner.interrupt(event)
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1072
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1073
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1074 @instruction(129)
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1075 def interrupt_aux(self, number, event):
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1076 self._enemy.aux_anm[number]._anmrunner.interrupt(event)
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1077
1d3c8c7473a2 Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 224
diff changeset
1078
183
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
1079 @instruction(132)
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
1080 def set_visible(self, value):
269
729382f57ad0 Fix set_visible.
Thibaut Girka <thib@sitedethib.com>
parents: 268
diff changeset
1081 self._enemy._visible = not bool(value)
183
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
1082
b6d7ce644f34 Implement two new ECL instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 182
diff changeset
1083
182
20843875ad8f (Hopefully) use difficulty as it should.
Thibaut Girka <thib@sitedethib.com>
parents: 181
diff changeset
1084 @instruction(131)
20843875ad8f (Hopefully) use difficulty as it should.
Thibaut Girka <thib@sitedethib.com>
parents: 181
diff changeset
1085 def set_difficulty_coeffs(self, speed_a, speed_b, nb_a, nb_b, shots_a, shots_b):
20843875ad8f (Hopefully) use difficulty as it should.
Thibaut Girka <thib@sitedethib.com>
parents: 181
diff changeset
1086 self._enemy.difficulty_coeffs = (speed_a, speed_b, nb_a, nb_b, shots_a, shots_b)
20843875ad8f (Hopefully) use difficulty as it should.
Thibaut Girka <thib@sitedethib.com>
parents: 181
diff changeset
1087