3 # GemRB - Infinity Engine Emulator
4 # Copyright (C) 2009 The GemRB Project
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This generates a formatio.2da file for GemRB, because it was becoming
21 # far too tedious to do this by hand. The output files have pairs of
22 # coordinates in the order of the party members.
24 # Run it as 'make_formation.py bg2 > override/bg2/formatio.2da' or similar.
26 # written (badly, sorry!) by fuzzie, feb 2nd 2009
28 # TODO: older games have focus points in different positions and different
29 # spacing (ie, coordinates have different offsets)
30 # eg, pst seems to usually have the focus point always on the lead char
34 def generate_header():
37 print "# generated by make_formation.py, do not edit"
40 for i
in range(num_coords
):
41 print "X" + str(i
+ 1),
42 print "Y" + str(i
+ 1),
45 # A simple spaced line formation.
46 def generate_line(name
):
49 for i
in range(num_coords
):
55 # A 'T' shape formation, with 3 actors at the front.
58 for i
in range(num_coords
):
69 # first line member (48 deeper)
72 # line member (36 deeper)
74 print 48 + ((i
- 3) * 36),
77 # A 'gathered' formation around a centre point.
78 def generate_gather():
80 for i
in range(num_coords
):
106 # A block formation which places 4 on a row - first two in the
107 # middle (left then right), then two on the outside (left then right).
108 # With a party size of 6 this results in 4 on the first row and 2 on the
109 # second, hence the name.
110 def generate_4and2():
112 for i
in range(num_coords
):
126 # A wavy-line formation.
127 def generate_s(bg2style
):
129 for i
in range(num_coords
):
130 # x coordinate: +/- 15 for bg2, 0/64 otherwise
132 if bg2style
: print 15, # on right
133 else: print 0, # on left
135 if bg2style
: print -15, # on left
136 else: print 64, # on right
138 # y coordinate: 24 each
142 # Returns the position in a formation of party member 'actorno',
143 # if the lead character must be in position 'leadpos'.
144 def corrected_position_for_actor(actorno
, leadpos
):
145 if actorno
== 0: # lead
147 elif actorno
< leadpos
+ 1: # in front of lead
149 else: # behind lead (normal position)
152 # A wavy-line formation, with the lead character in the 4th position and
153 # the other characters in order (even if this leaves spaces!).
154 def generate_wavyline():
156 for i
in range(num_coords
):
157 pos
= corrected_position_for_actor(i
, 3)
159 # x coordinate: +/- 15
165 # y coordinate: 24 each
169 # A formation surrounding the main character. The next character goes
170 # at the front, then one left, then one right, then the next left/right
171 # at the back, then other characters trail behind the main one (it goes
172 # completely chaotic in real BG2, apparently).
173 def generate_protect():
175 for i
in range(num_coords
):
177 print "0 0", # centre
179 print "0 -36", # front
181 print "-64 0", # left
183 print "64 0", # right
185 print "-32 48", # back left
187 print "32 48", # back right
193 # A simple 3-across block formation.
196 for i
in range(num_coords
):
209 # A simple 2-across block formation.
212 # left first, then right
215 for i
in range(num_coords
):
222 # first step back is 48, then 36
227 left_side
= not left_side
230 # A horizontal line formation, with each character being placed
231 # alternately on right and left of the previous characters.
234 for i
in range(num_coords
):
235 # lead character placed at focal point -32, spacing is 64
237 print -32 - ((i
/ 2) * 64),
239 print -32 + (((i
+ 1) / 2) * 64),
245 for i
in range(num_coords
):
249 xpos
= 64 + (i
/ 2) * -15
255 # A triangle with the lead character at the back. Focal point is at the
256 # front. Other characters are placed row-by-row starting at the front row,
257 # middle then left then right, with the maximum width being 3.
258 def generate_triangle():
260 for i
in range(num_coords
):
261 pos
= corrected_position_for_actor(i
, 3)
265 print "-32 36", # middle left
267 print "32 36", # middle right
270 # start 72 back, then move back 36 per row
271 ypos
= 72 + ((pos
/ 3) * 36)
273 if pos
% 3 == 0: # middle
275 elif pos
% 3 == 1: # left
284 # A wide triangle with the lead character at the front. Characters are placed
285 # row-by-row. Second row: right then left. Third row: left then right then
286 # middle. Other rows: Middle first, left, right.
287 # TODO: the older games seem to have the third row ordered the same as the other ones
288 def generate_wedge():
290 for i
in range(num_coords
):
294 print "64 36", # second row: right
296 print "-64 36", # second row: left
298 print "-124 72", # third row: left
300 print "124 72", # third row: right
302 print "0 72", # third row: middle
311 ypos
= 72 + (i
/ 3) * 36
315 from sys
import argv
,exit
318 print "pass a game name on the command line"
323 if argv
[1] == "bg1" or argv
[1] == "iwd" or argv
[1] == "iwd2" or argv
[1] == "how":
324 generate_line("FOLLOW") # TODO: should be hard-coded game logic
329 generate_protect() # TODO: wrong formation for bg1 or others?
335 generate_line("LINE")
338 generate_line("FOLLOW") # TODO: should be hard-coded game logic
349 generate_line("LINE")
351 for i
in range(num_coords
):
356 generate_line("FOLLOW") # TODO: should be hard-coded game logic
367 generate_line("LINE")
369 if argv
[1] == "test1":
370 generate_line("LINE")