PyAI uses basically the same format as all other programs in
PyMS. The only difference is that when decompiling you need 2
input files, and when compiling you need 2 output files. So
for decompiling it is:
python PyAI.py [options] -d <aiscript.bin> <bwscript.bin> [out]
Like the other programs, if you leave [out] blank it will
make up the filename, so it will take the aiscript.bin's
filename but with the .txt extension. To compile its:
python PyAI.py [options] -c <inp> [aiscript.bin [bwscript.bin]]
If you dont supply the files for [aiscript.bin] and/or
[bwscript.bin], it will take the filename of <inp> and use
the .bin extension ([bwscript.bin] will get 'bw' added to the
front in this situation).
The coding in PyMS is not too much different then SCAIEdit
III's .asc3 format. The differences (:
- For comments, instead of using semi-colons (';'), PyAI uses
hash's ('#')
- Commands use perenthesis ('(' and ')') to encapsulate the
parameters, and commas (',') to seperate them
- Strings (used in the debug command, which works with PyMS,
BUT NOT SCAIEdit!!!!) use TBL formatting (so use <40> for
an open parenthesis '(', <41> for a close parenthesis
')', and <44> for a comma ',')
- Block labels are in the format '--Name--' instead of ':Name'
- Jumping now supports external script jumps. To use them, the
format is 'AIID:Label', where AIID is the ID of the script,
and Label is the name of the block in that AI (used like a
normal label in any jumping command)
- PyMS has the option to use "Descriptive" command names when
decompiling. You can also interchange the origional commands
with the descriptive ones anywhere in your code.
- Instead of using script_name and script_id, there is one
header used to start an AI Script
- Variables can now be defined. They have overflowing types, so
if you define a 'building' variable, it will also work for a
'unit' variable because... buildings are units. But if you
define a 'military' variable, it will not work as a 'building'
because it isn't a building.
- Information Comments can be used to save descriptions of things
in your AI in its compiled form. They are any text within a
pair of braces ('{' and '}')
- External Definition files can be supplied either with the -f
(--deffile) option, or with the 'extdef' keyword
External Definition files are files that list common variables which
can be included in any aiscript. To use them in code all you do is
place an 'extdef' line anywhere in your code like so:
extdef <file>
You can either supply the name of a file in the same folder as the
aiscript, or a full path to a file.
Information Comments come on the same line, or directly after a
variable declaration, block label, or AI Script header. They are
completely optionally. If its on the same line it must be at the
end (but still before normal comments), and can only my a single
line information comment. Single line information comments are in
the form {<comment>}, and multi-line information comments are in
the form (The braces must be on their own lines):
{
<comment>
}
Note: Variables are saved to aiscript.bin, so if you dont keep
your aiscript.bin with your bwscript.bin when you try to
decompile the bwscript.bin, you will not get your variables.
You can set variables anywhere in your file, inside or outside
of your ai's, it doesn't matter. The syntax for a variable is:
<type> <name> = <value>
Type is a paramater type like 'byte', 'building', etc. You can
view the different types in the reference (Note: Labels can NOT
but set to variables).
Every AI Script in your file must start with the declaration
header, formatted like so:
<ID>(<String>, <Flags>, <Script>):
<ID> is the 4 letter ID for your script, or one of the keywords
Protoss, BWProtoss, Terran, BWTerran, Zerg, and BWZerg, which
represents PMCu, PMCx, TMCu, TMCx, ZMCu, and ZMCx respectivly.
<String> is the id number of the string in your stat_tbl.txt.
<Flags> is 3 ones or zeros (for example 000, 111, 101, 001, etc),
a 0 means a flag is unset, a 1 means a flag is set.
If the first flag is set, the AI script requires a location.
If the second flag is set, the AI script will not show up in
StarEdit. If the third flag is set, its a BW AI Script (DOES
NOT MEAN GOES IN bwscript.bin!). <Script> is either the keyword
aiscript, or the keyword bwscript and defines which bin file
it is compiled to. Under that you have your commands and blocks.
Here is an example of Terran 5 - Harvest Town (Te5H):
# stat_txt.tbl entry 1054: Terran 5 - Terran Harvest Town<0>
Te5H(1054, 011, aiscript):
start_campaign()
start_areatown()
defaultbuild_off()
default_min(0)
wait(1)
build(1, Terran Command Center, 150)
build(4, Terran SCV, 130)
--Te5H 0000--
wait(1500)
goto(Te5H 0000)
|