Scripting format for KQ2Tool Import/Export

Overview

Please note that, at the moment, the script import/export facility is highly experimental and largely untested.

The file format is based on the in-built capabilities of the development tools, since speed of development was the overwhelming priority, hence it is simple and fairly inflexible.

Each command has to be on its own line. It cannot stretch over multiple lines, and there cannot be more than one command per line. Anything that is not recognised is skipped, so comments can be added as long as they don't begin with a command (I'd suggest starting with one of the common comment indicators: // ' ; or # ). Anything after the end of a command is also ignored, so in-line comments should also be okay.

The command elements should be separated by spaces. Leading spaces and multiple spaces are ignored. Using double-quotes around the whole item will enable a space to be embedded within a name (eg. "Flag 11"). I do not recommend that you use double-quotes or commas in any names.

Where appropriate, items are specified by name. The names are case-sensitive, and must match the name you have given the item in KQ2ED precisely. If you have duplicate names (eg. two tiles named "grass"), then the first will be matched (and it's a bad idea anyway, so don't do it).

Keywords are also case-sensitive and should all be in lower-case.

Use the export scripts facility in KQ2Tool to see some examples.

The following conventions are used in this document: bold items are literal keywords, italic items are names (eg. TownMap), and plain items are numeric values.

General Format

script
objectscript
globalscript
deathscript
startscript
script-name
conditions:
condition
.
.
.
commands:
command
.
.
.
end script

Note: script is a synonym for objectscript.


Reference tables

Conditions
ConditionDescription
alwaysAlways fire
flagFlag value
locationLocation
attributeAttribute
itemItem
charsetCharacter graphic
palettePalette
incombatCombat status
timeTime
colorColor support
registeredRegistered
tileexistsTile Exists
spellSpell
equippedEquipped
Commands
CommandDescription
nothingDo nothing
changeflagChange flag value
warpWarp
changeattributeChange attribute
givetakeGive/take item
changecharsetChange character graphic
showgraphicDisplay graphic
showtextDisplay text
[ex-command]Obsolete - do not use
playPlay song
waitWait
learnLearn spell
moveobjPlace/remove object
changetilesChange map tiles
runRun script
gameoverEnd game
changepaletteChange palette
changeobjpicChange object graphic
shopDisplay shop
combatStart/end combat
redrawmapRedraw map
changescreenChange custom screen
clearClear screen
stopscriptsStop execution of scripts
advshowgraphicAdvanced display graphic
advchangetilesAdvanced tile change
advmoveobjAdvanced place/remove object
redoglobalsRedo global scripts
returntomapReturn to map screen
showlistDislpay list
unlearnRemove spell
customtapGet custom screen tap
walkWalk player
equipEquip/unequip
deletelayerDelete tile layer
Comparisons
>=
<=
==
<>
>
<
Target Types
valvalue
attattribute
randrand-max
flagflag-name
Attributes
str
agl
int
hp
sp
level
maxhp
maxsp
money
exp
map
x
y
dir
obj.map
obj.x
obj.y
monster.str
monster.agl
monster.int
monster.hp
monster.sp
monster.level
monster.maxhp
monster.maxsp
monster.money
monster.exp
Operations
inc
dec
set
mult
div
mod

Conditions syntax

always
flag flag-value >=
<=
==
<>
>
<
Compare to
valvalue
attattribute
randrand-max
flagflag-name
location not
at
Map
valmap-name
attattribute
randrand-max
flagflag-name
X
valvalue
attattribute
randrand-max
flagflag-name
Y
valvalue
attattribute
randrand-max
flagflag-name
attribute attribute >=
<=
==
<>
>
<
Compare to
valvalue
attattribute
randrand-max
flagflag-name
item has
missing
item-name
charset is
not
charset-name
palette is
not
palette-name
incombat true
false
time minute
hour
day
month
year
>=
<=
==
<>
>
<
Compare to
valvalue
attattribute
randrand-max
flagflag-name
color true
false
registered true
false
tileexists
X
valvalue
attattribute
randrand-max
flagflag-name
Y
valvalue
attattribute
randrand-max
flagflag-name
bottom
middle
top
exists
missing
spell known
unknown
spell-name
equipped item-name equipped
unequipped

Commands Syntax

nothing
changeflag inc
dec
set
mult
div
mod
flag-name
Change to
valvalue
attattribute
randrand-max
flagflag-name
warp
Map
valmap-name
attattribute
randrand-max
flagflag-name
X
valvalue
attattribute
randrand-max
flagflag-name
Y
valvalue
attattribute
randrand-max
flagflag-name
changeattribute attribute inc
dec
set
mult
div
mod
Change to
valvalue
attattribute
randrand-max
flagflag-name
givetake give
take
item-name
changecharset charset-name
showgraphic graphic-name -1
x-val y-val
showtext text-name color-number -1 nowait
wait
topleft-x topleft-y bottomright-x bottomright-y
[ex-command]
play song-name
wait -1
milliseconds
learn spell-name
moveobj place
remove
object-name map-name x-coord y-coord
changetiles from-tile-name to-tile-name -1
on-map-name -1
x-coord y-coord
run script-name process
ignore
Number of times
valvalue
attattribute
randrand-max
flagflag-name
gameover
changepalette palette-name
changeobjpic object-name graphic-name -1
on-map-name -1
x-coord y-coord
shop shop-name
combat start monster-name
stop
redrawmap
changescreen background
inventory
combat
graphic-name
clear color-number
stopscripts
advshowgraphic graphic-name
X
valx-value
attattribute
randrand-max
flagflag-name
Y
valy-value
attattribute
randrand-max
flagflag-name
advchangetiles tile-name
Map
valmap-name
attattribute
randrand-max
flagflag-name
X
valx-value
attattribute
randrand-max
flagflag-name
Y
valvalue
attattribute
randrand-max
flagflag-name
advmoveobj place
remove
object-name
Map
valmap-name
attattribute
randrand-max
flagflag-name
X
valx-value
attattribute
randrand-max
flagflag-name
Y
valvalue
attattribute
randrand-max
flagflag-name
redoglobals
returntomap
showlist list-name color-number -1
topleft-x topleft-y bottomright-x bottomright-y
unlearn spell-name
customtap x-flag-name y-flag-name
walk up
down
left
right
equip add
remove
item-name
deletelayer
Map
valmap-name
attattribute
randrand-max
flagflag-name
X
valx-value
attattribute
randrand-max
flagflag-name
Y
valy-value
attattribute
randrand-max
flagflag-name
bottom
middle
top