Mercurial > touhou
annotate pytouhou/game/eclrunner.py @ 55:de358a7684c8
Fix a few bugs
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 23 Aug 2011 00:10:35 +0200 |
parents | e72166f73e30 |
children | 694f25881d0f |
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 |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
16 from math import atan2, cos, sin |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
17 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
18 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
19 class MetaRegistry(type): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
20 def __new__(mcs, name, bases, classdict): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
21 instruction_handlers = {} |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
22 for item in classdict.itervalues(): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
23 try: |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
24 instruction_ids = item._instruction_ids |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
25 except AttributeError: |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
26 pass |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
27 else: |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
28 for id_ in instruction_ids: |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
29 instruction_handlers[id_] = item |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
30 classdict['_handlers'] = instruction_handlers |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
31 return type.__new__(mcs, name, bases, classdict) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
32 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
33 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
34 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
35 def instruction(instruction_id): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
36 def _decorator(func): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
37 if not hasattr(func, '_instruction_ids'): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
38 func._instruction_ids = set() |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
39 func._instruction_ids.add(instruction_id) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
40 return func |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
41 return _decorator |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
42 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
43 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
44 |
23
444ac7bca7bc
Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
45 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
|
46 __metaclass__ = MetaRegistry |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
47 __slots__ = ('_ecl', '_enemy', '_game_state', 'variables', 'sub', 'frame', |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
48 '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
|
49 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
50 def __init__(self, ecl, sub, enemy, game_state): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
51 # 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
|
52 self._ecl = ecl |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
53 self._enemy = enemy |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
54 self._game_state = game_state |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
55 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
56 # 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
|
57 self.variables = [0, 0, 0, 0, |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
58 0., 0., 0., 0., |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
59 0, 0, 0, 0] |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
60 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
|
61 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
|
62 self.frame = 0 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
63 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
|
64 |
47
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
65 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
|
66 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
67 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
68 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
|
69 # 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
|
70 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
|
71 return False |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
72 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
73 # Then, check for callbacks |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
74 #TODO |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
75 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
76 # Now, process script |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
77 frame = self.frame |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
78 while True: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
79 try: |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
80 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
|
81 except IndexError: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
82 return False |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
83 |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
84 #TODO: skip bad ranks |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
85 |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
86 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
|
87 break |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
88 else: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
89 self.instruction_pointer += 1 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
90 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
|
91 try: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
92 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
|
93 except KeyError: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
94 print('Warning: unhandled opcode %d!' % instr_type) #TODO |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
95 else: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
96 callback(self, *args) |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
97 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
98 self.frame += 1 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
99 return True |
47
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
100 |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
101 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
102 def _getval(self, value): |
48
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
103 if -10012 <= value <= -10001: |
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
104 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
|
105 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
|
106 if value == -10013: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
107 return self._game_state.rank |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
108 elif value == -10014: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
109 return self._game_state.difficulty |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
110 elif value == -10015: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
111 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
|
112 elif value == -10016: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
113 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
|
114 elif value == -10017: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
115 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
|
116 elif value == -10018: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
117 player = self._enemy.select_player(self._game_state.players) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
118 return player.x |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
119 elif value == -10019: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
120 player = self._enemy.select_player(self._game_state.players) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
121 return player.y |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
122 elif value == -10021: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
123 player = self._enemy.select_player(self._game_state.players) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
124 return self._enemy.get_player_angle(player) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
125 elif value == -10022: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
126 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
|
127 elif value == -10024: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
128 return self._enemy.life |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
129 raise NotImplementedError #TODO |
48
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
130 else: |
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
131 return value |
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
132 |
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
133 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 elif -10025 <= variable_id <= -10013: |
55 | 138 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
|
139 self._enemy.x = value |
55 | 140 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
|
141 self._enemy.y = value |
55 | 142 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
|
143 self._enemy.z = value |
55 | 144 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
|
145 self._enemy.frame = value |
55 | 146 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
|
147 self._enemy.life = value |
55 | 148 else: |
149 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
|
150 else: |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
151 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
|
152 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
153 |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
154 @instruction(0) |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
155 def noop(self): |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
156 pass #TODO: Really? |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
157 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
158 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
159 @instruction(1) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
160 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
|
161 #TODO: arg? |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
162 self._enemy._removed = True |
48
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
163 |
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
164 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
165 @instruction(2) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
166 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
|
167 """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
|
168 |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
51
diff
changeset
|
169 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
|
170 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
|
171 """ |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
172 self.frame, self.instruction_pointer = frame, instruction_pointer |
48
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
173 |
8353c33d53d4
Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents:
47
diff
changeset
|
174 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
175 @instruction(3) |
53 | 176 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
|
177 """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
|
178 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
|
179 |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
51
diff
changeset
|
180 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
|
181 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
|
182 """ |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
183 counter_value = self._getval(variable_id) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
184 if counter_value: |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
185 self._setval(variable_id, counter_value - 1) |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
186 self.frame, self.instruction_pointer = frame, instruction_pointer |
47
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
187 |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
188 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
189 @instruction(4) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
190 @instruction(5) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
191 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
|
192 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
|
193 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
194 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
195 @instruction(6) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
196 def set_random_int(self, variable_id, maxval): |
52
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
51
diff
changeset
|
197 """Set the specified variable to a random int in the [[0, maxval)) range. |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
51
diff
changeset
|
198 """ |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
199 self._setval(variable_id, int(self._getval(maxval) * self._game_state.prng.rand_double())) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
200 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
201 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
202 @instruction(8) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
203 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
|
204 """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
|
205 """ |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
206 self._setval(variable_id, self._getval(maxval) * self._game_state.prng.rand_double()) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
207 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
208 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
209 @instruction(20) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
210 def add(self, variable_id, a, b): |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
211 #TODO: int vs float thing |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
212 self._setval(variable_id, 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
|
213 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
214 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
215 @instruction(21) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
216 def substract(self, variable_id, a, b): |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
217 #TODO: int vs float thing |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
218 self._setval(variable_id, self._getval(a) - self._getval(b)) |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
219 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
220 |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
221 @instruction(27) |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
222 def compare_ints(self, a, b): |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
223 a, b = self._getval(a), self._getval(b) |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
224 if a < b: |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
225 self.comparison_reg = -1 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
226 elif a == b: |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
227 self.comparison_reg = 0 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
228 else: |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
229 self.comparison_reg = 1 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
230 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
231 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
232 @instruction(31) |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
233 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
|
234 if self.comparison_reg == 0: |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
235 self.relative_jump(frame, instruction_pointer) |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
236 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
237 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
238 @instruction(35) |
47
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
239 def call(self, sub, param1, param2): |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
240 self.stack.append((self.sub, self.frame, self.instruction_pointer, |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
241 self.variables, self.comparison_reg)) |
47
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
242 self.sub = sub |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
243 self.frame = 0 |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
244 self.instruction_pointer = 0 |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
245 self.variables = [param1, 0, 0, 0, |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
246 param2, 0., 0., 0., |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
247 0, 0, 0, 0] |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
248 |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
249 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
250 @instruction(36) |
47
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
251 def ret(self): |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
252 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
|
253 |
1f1793e7ec8e
Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents:
43
diff
changeset
|
254 |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
255 @instruction(39) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
256 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
|
257 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
|
258 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
|
259 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
260 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
261 @instruction(43) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
262 def set_pos(self, x, y, z): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
263 self._enemy.set_pos(x, y, z) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
264 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
265 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
266 @instruction(45) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
267 def set_angle_speed(self, angle, speed): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
268 self._enemy.angle, self._enemy.speed = angle, speed |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
269 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
270 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
271 @instruction(46) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
272 def set_rotation_speed(self, speed): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
273 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
|
274 |
444ac7bca7bc
Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
275 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
276 @instruction(47) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
277 def set_speed(self, speed): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
278 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
|
279 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
280 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
281 @instruction(48) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
282 def set_acceleration(self, acceleration): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
283 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
|
284 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
285 |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
286 @instruction(50) |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
287 def set_random_angle(self, min_angle, max_angle): |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
288 #TODO: This thing is really odd, check, double check, triple check, disassemble... |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
289 angle = self._game_state.prng.rand_double() * (max_angle - min_angle) + min_angle |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
290 self._enemy.angle = atan2(-abs(sin(angle)), -abs(cos(angle))) |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
291 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
292 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
293 @instruction(51) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
294 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
|
295 #TODO: unknown |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
296 self._enemy.speed = speed |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
297 self._enemy.angle = self._enemy.get_player_angle(self._enemy.select_player(self._game_state.players)) |
43
7195aaf95f6e
Fix set_counter, and relative_jump(_ex)
Thibaut Girka <thib@sitedethib.com>
parents:
42
diff
changeset
|
298 |
7195aaf95f6e
Fix set_counter, and relative_jump(_ex)
Thibaut Girka <thib@sitedethib.com>
parents:
42
diff
changeset
|
299 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
300 @instruction(57) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
301 def move_to(self, duration, x, y, z): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
302 self._enemy.move_to(duration, x, y, z) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
303 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
304 |
50
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
305 @instruction(65) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
306 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
|
307 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
|
308 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
309 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
310 @instruction(66) |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
311 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
|
312 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
|
313 |
811cefefb5c8
Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
49
diff
changeset
|
314 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
315 @instruction(77) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
316 def set_bullet_interval(self, value): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
317 self._enemy.bullet_launch_interval = value |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
318 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
319 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
320 @instruction(78) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
321 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
|
322 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
|
323 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
324 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
325 @instruction(79) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
326 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
|
327 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
|
328 |
444ac7bca7bc
Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
329 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
330 @instruction(81) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
331 def set_bullet_launch_offset(self, x, y, z): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
332 self._enemy.bullet_launch_offset = (x, y) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
333 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
334 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
335 @instruction(97) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
336 def set_anim(self, sprite_index): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
337 self._enemy.set_anim(sprite_index) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
338 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
339 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
340 @instruction(98) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
345 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
346 @instruction(100) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
347 def set_death_anim(self, sprite_index): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
348 self._enemy.death_anim = sprite_index % 256 #TODO |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
349 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
350 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
351 @instruction(103) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
352 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
|
353 self._enemy.hitbox = (width, height) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
354 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
355 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
356 @instruction(105) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
357 def set_vulnerable(self, vulnerable): |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
358 self._enemy.vulnerable = bool(vulnerable & 1) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
359 |
23
444ac7bca7bc
Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
360 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
361 @instruction(108) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
362 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
|
363 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
|
364 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
365 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
366 @instruction(109) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
367 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
|
368 #TODO |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
369 #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
|
370 if index == 0: |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
371 self.sub = value |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
372 self.frame = 0 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
373 self.instruction_pointer = 0 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
374 |
23
444ac7bca7bc
Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
375 |
51
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
376 @instruction(111) |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
377 def set_life(self, value): |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
378 self._enemy.life = value |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
379 |
0707ff53e7b5
Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
380 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
381 @instruction(113) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
382 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
|
383 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
|
384 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
385 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
386 @instruction(114) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
387 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
|
388 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
|
389 |
23
444ac7bca7bc
Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
390 |
49
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
391 @instruction(115) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
392 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
|
393 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
|
394 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
395 |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
396 @instruction(126) |
cbe1cb50f2fd
Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents:
48
diff
changeset
|
397 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
|
398 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
|
399 |