annotate pytouhou/game/eclrunner.py @ 65:0efec109f798

Merge compare and substract functions, remove dangerous casts and add comments about differences with the original engine.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 25 Aug 2011 20:19:25 +0200
parents d469012368b3
children e2cb9d434dc2
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
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
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
3da4de9decd0 Use logging module
Thibaut Girka <thib@sitedethib.com>
parents: 57
diff changeset
20 logger = get_logger(__name__)
3da4de9decd0 Use logging module
Thibaut Girka <thib@sitedethib.com>
parents: 57
diff changeset
21
3da4de9decd0 Use logging module
Thibaut Girka <thib@sitedethib.com>
parents: 57
diff changeset
22
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
23
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
24 class MetaRegistry(type):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
25 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
26 instruction_handlers = {}
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
27 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
28 try:
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
29 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
30 except AttributeError:
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
31 pass
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
32 else:
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
33 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
34 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
35 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
36 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
37
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
38
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
39
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
40 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
41 def _decorator(func):
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
42 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
43 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
44 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
45 return func
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
46 return _decorator
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
47
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
48
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
49
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
50 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
51 __metaclass__ = MetaRegistry
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
52 __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
53 '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
54
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
55 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
56 # 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
57 self._ecl = ecl
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
58 self._enemy = enemy
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
59 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
60
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
61 # 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
62 self.variables = [0, 0, 0, 0,
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
63 0., 0., 0., 0.,
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
64 0, 0, 0, 0]
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
65 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
66 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
67 self.frame = 0
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
68 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
69
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
70 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
71
49
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 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
74 # 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
75 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
76 return False
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
77
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
78 # 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
79 #TODO
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
80
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
81 # Now, process script
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
82 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
83 while True:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
84 try:
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
85 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
86 except IndexError:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
87 return False
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
88
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
89 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
90 break
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
91 else:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
92 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
93
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
94
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
95 #TODO: skip bad ranks
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
96 if not rank_mask & (0x100 << self._game_state.rank):
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
97 continue
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
98
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
99
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
100 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
101 try:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
102 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
103 except KeyError:
58
3da4de9decd0 Use logging module
Thibaut Girka <thib@sitedethib.com>
parents: 57
diff changeset
104 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
105 else:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
106 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
107
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
108 self.frame += 1
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
109 return True
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
110
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
111
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
112 def _getval(self, value):
48
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
113 if -10012 <= value <= -10001:
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
114 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
115 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
116 if value == -10013:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
117 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
118 elif value == -10014:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
119 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
120 elif value == -10015:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
121 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
122 elif value == -10016:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
123 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
124 elif value == -10017:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
125 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
126 elif value == -10018:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
127 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
128 return player.x
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
129 elif value == -10019:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
130 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
131 return player.y
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
132 elif value == -10021:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
133 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
134 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
135 elif value == -10022:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
136 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
137 elif value == -10024:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
138 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
139 elif value == -10025:
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
140 return self._enemy.select_player(self._game_state.players).character
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
141 raise NotImplementedError(value) #TODO
48
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
142 else:
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
143 return value
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
144
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
145
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
146 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
147 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
148 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
149 elif -10025 <= variable_id <= -10013:
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
150 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
151 self._enemy.x = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
152 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
153 self._enemy.y = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
154 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
155 self._enemy.z = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
156 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
157 self._enemy.frame = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
158 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
159 self._enemy.life = value
55
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
160 else:
de358a7684c8 Fix a few bugs
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
161 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
162 else:
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
163 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
164
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
165
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
166 @instruction(0)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
167 def noop(self):
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
168 pass #TODO: Really?
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
169
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
170
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
171 @instruction(1)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
172 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
173 #TODO: arg?
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
174 self._enemy._removed = True
48
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
175
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
176
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
177 @instruction(2)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
178 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
179 """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
180
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
181 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
182 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
183 """
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
184 self.frame, self.instruction_pointer = frame, instruction_pointer
48
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
185
8353c33d53d4 Support a few more instructions
Thibaut Girka <thib@sitedethib.com>
parents: 47
diff changeset
186
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
187 @instruction(3)
53
Thibaut Girka <thib@sitedethib.com>
parents: 52
diff changeset
188 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
189 """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
190 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
191
ab826bc29aa2 Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents: 51
diff changeset
192 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
193 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
194 """
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
195 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
196 if counter_value:
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
197 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
198 self.frame, self.instruction_pointer = frame, instruction_pointer
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
199
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
200
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
201 @instruction(4)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
202 @instruction(5)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
203 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
204 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
205
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
206
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
207 @instruction(6)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
208 def set_random_int(self, variable_id, maxval):
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
209 """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
210 """
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
211 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
212
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 @instruction(8)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
215 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
216 """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
217 """
50
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(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
219
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
220
59
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
221 @instruction(9)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
222 def set_random_float2(self, variable_id, minval, amp):
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
223 self._setval(variable_id, self._getval(minval) + self._getval(amp) * self._game_state.prng.rand_double())
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
224
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
225
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
226 @instruction(13)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
227 def set_random_int2(self, variable_id, minval, amp):
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
228 self._setval(variable_id, int(self._getval(minval)) + int(self._getval(amp)) * self._game_state.prng.rand_double())
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
229
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
230
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
231 @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
232 @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
233 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
234 #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
235 # 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
236 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
237
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
238
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
239 @instruction(15)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
240 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
241 #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
242 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
243
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
244
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
245 @instruction(16)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
246 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
247 #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
248 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
249
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
250
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
251 @instruction(17)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
252 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
253 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
254
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
255
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
256 @instruction(20)
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
257 def add_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
258 #TODO: takes only floats.
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
259 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
260
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
261
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
262 @instruction(23)
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
263 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
264 #TODO: takes only floats.
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
265 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
266
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
267
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
268 @instruction(27)
63
8527fe640844 Implement simple arithmetic instructions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 62
diff changeset
269 @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
270 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
271 #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
272 a, b = self._getval(a), self._getval(b)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
273 if a < b:
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
274 self.comparison_reg = -1
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
275 elif a == b:
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
276 self.comparison_reg = 0
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
277 else:
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
278 self.comparison_reg = 1
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
279
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
280
64
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
281 @instruction(29)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
282 def relative_jump_if_lower_than(self, frame, instruction_pointer):
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
283 if self.comparison_reg == -1:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
284 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
285
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
286
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
287 @instruction(30)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
288 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
289 if self.comparison_reg != 1:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
290 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
291
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
292
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
293 @instruction(31)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
294 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
295 if self.comparison_reg == 0:
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
296 self.relative_jump(frame, instruction_pointer)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
297
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
298
64
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
299 @instruction(32)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
300 def relative_jump_if_greater_than(self, frame, instruction_pointer):
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
301 if self.comparison_reg == 1:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
302 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
303
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
304
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
305 @instruction(33)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
306 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
307 if self.comparison_reg != -1:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
308 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
309
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
310
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
311 @instruction(34)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
312 def relative_jump_if_not_equal(self, frame, instruction_pointer):
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
313 if self.comparison_reg != 0:
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
314 self.relative_jump(frame, instruction_pointer)
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
315
d469012368b3 Implement conditional jumps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 63
diff changeset
316
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
317 @instruction(35)
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
318 def call(self, sub, param1, param2):
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
319 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
320 self.variables, self.comparison_reg))
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
321 self.sub = sub
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
322 self.frame = 0
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
323 self.instruction_pointer = 0
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
324 self.variables = [param1, 0, 0, 0,
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
325 param2, 0., 0., 0.,
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
326 0, 0, 0, 0]
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
327
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
328
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
329 @instruction(36)
47
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
330 def ret(self):
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
331 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
332
1f1793e7ec8e Handle a few more opcodes
Thibaut Girka <thib@sitedethib.com>
parents: 43
diff changeset
333
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
334 @instruction(39)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
335 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
336 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
337 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
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(43)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
341 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
342 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
343
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 @instruction(45)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
346 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
347 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
348
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 @instruction(46)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
351 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
352 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
353
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
354
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
355 @instruction(47)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
356 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
357 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
358
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
359
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
360 @instruction(48)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
361 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
362 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
363
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
364
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
365 @instruction(50)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
366 def set_random_angle(self, min_angle, max_angle):
59
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
367 if self._enemy.screen_box:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
368 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
369 else:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
370 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
371
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
372 angle = self._game_state.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
373 sa, ca = sin(angle), cos(angle)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
374
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
375 distx = min(96.0, (maxx - minx) / 2.)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
376 disty = min(96.0, (maxy - miny) / 2.)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
377
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
378 if self._enemy.x > maxx - 96.0:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
379 ca = -abs(ca)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
380 elif self._enemy.x < minx + 96.0:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
381 ca = abs(ca)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
382
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
383 if self._enemy.y > maxy - 48.0:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
384 sa = -abs(sa)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
385 elif self._enemy.y < miny + 48.0:
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
386 sa = abs(sa)
4fe37a620b22 Handle set_random_angle properly! At last!
Thibaut Girka <thib@sitedethib.com>
parents: 58
diff changeset
387 self._enemy.angle = atan2(sa, ca)
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
388
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
389
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
390 @instruction(51)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
391 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
392 #TODO: unknown
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
393 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
394 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
395
7195aaf95f6e Fix set_counter, and relative_jump(_ex)
Thibaut Girka <thib@sitedethib.com>
parents: 42
diff changeset
396
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
397 @instruction(57)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
398 def move_to(self, duration, x, y, z):
62
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
399 self._enemy.move_to(duration, x, y, z, lambda x: 2. * x - x ** 2)
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
400
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
401
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
402 @instruction(59)
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
403 def move_to2(self, duration, x, y, z):
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
404 #TODO: not accurate
1f591adcea04 Fix animation determination (ins_98 stuff) and some interpolation functions
Thibaut Girka <thib@sitedethib.com>
parents: 59
diff changeset
405 self._enemy.move_to(duration, x, y, z, lambda x: 1.0014 * x ** 2 - 0.0012 * x)
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
406
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
407
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
408 @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
409 def stop_in(self, duration):
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
410 self._enemy.stop_in(duration)
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
411
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
412
50
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
413 @instruction(65)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
414 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
415 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
416
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
417
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
418 @instruction(66)
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
419 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
420 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
421
811cefefb5c8 Fix a few bugs and add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 49
diff changeset
422
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
423 @instruction(67)
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
424 def set_bullet_attributes1(self, bullet_anim, launch_anim, bullets_per_shot,
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
425 number_of_shots, speed, unknown, launch_angle,
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
426 angle, flags):
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
427 self._enemy.set_bullet_attributes(1, bullet_anim, launch_anim,
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
428 bullets_per_shot, number_of_shots,
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
429 speed, unknown, launch_angle, angle,
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
430 flags)
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
431
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
432
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
433 @instruction(77)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
434 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
435 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
436
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
437
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
438 @instruction(78)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
439 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
440 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
441
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
442
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
443 @instruction(79)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
444 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
445 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
446
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
447
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
448 @instruction(81)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
449 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
450 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
451
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
452
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
453 @instruction(97)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
454 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
455 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
456
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
457
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
458 @instruction(98)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
459 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
460 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
461 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
462
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
463
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
464 @instruction(100)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
465 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
466 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
467
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
468
57
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
469 @instruction(101)
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
470 def set_boss_mode(self, unknown):
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
471 #TODO: unknown
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
472 self._game_state.boss = self._enemy
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
473
694f25881d0f Fix move_to interpolation, add support for a few ANM and ECL instructions
Thibaut Girka <thib@sitedethib.com>
parents: 55
diff changeset
474
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
475 @instruction(103)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
476 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
477 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
478
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
479
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
480 @instruction(105)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
481 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
482 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
483
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
484
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
485 @instruction(108)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
486 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
487 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
488
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
489
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
490 @instruction(109)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
491 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
492 #TODO
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
493 #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
494 if index == 0:
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
495 self.sub = value
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
496 self.frame = 0
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
497 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
498
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
499
51
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
500 @instruction(111)
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
501 def set_life(self, value):
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
502 self._enemy.life = value
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
503
0707ff53e7b5 Add support for a few instructions
Thibaut Girka <thib@sitedethib.com>
parents: 50
diff changeset
504
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
505 @instruction(113)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
506 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
507 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
508
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 @instruction(114)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
511 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
512 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
513
23
444ac7bca7bc Refacto ECL stuff, add support for a few instructions, and add some culling
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
514
49
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
515 @instruction(115)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
516 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
517 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
518
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
519
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
520 @instruction(126)
cbe1cb50f2fd Refactor ECLRunner/EnemyManager so that all VM stuff goes to ECLRunner
Thibaut Girka <thib@sitedethib.com>
parents: 48
diff changeset
521 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
522 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
523