Getting WML to do tricks
Moderator: Forum Moderators
Getting WML to do tricks
How, if at all, do I code the following condition:
When 3 units are on special tiles, do event.
I've seen scenarios onvolving that units must have been moved to specific tiles, but is there any way to force it to happen on the same turn?
Of course, I could just copy the code and add condition turn=# for every one, but that would be utterly graceless and near on hard-coded, which is bad.
When 3 units are on special tiles, do event.
I've seen scenarios onvolving that units must have been moved to specific tiles, but is there any way to force it to happen on the same turn?
Of course, I could just copy the code and add condition turn=# for every one, but that would be utterly graceless and near on hard-coded, which is bad.
Okay, let's say your three special tiles are (X1,Y1), (X2,Y2), and (X3,Y3), and you want side 1 to have a unit on each of the three tiles.
You do the check every time a unit from side 1 moves onto any of the tiles. Like this:
Hope that all makes sense!
Btw I am thinking of making a WML extension that allows you to instead of saying,
go,
This would allow a little more compactness in defining things like co-ordinates.
David
You do the check every time a unit from side 1 moves onto any of the tiles. Like this:
Code: Select all
[event]
name=moveto
#make the event trigger every time a unit from side 1
#moves onto any of the three tiles
[filter]
side=1
x=X1,X2,X3
y=X1,X2,X3
[/filter]
[if]
#check if there is a unit on each of the three tiles
[have_unit]
side=1
x=X1
y=Y1
[/have_unit]
[have_unit]
side=1
x=X2
y=Y2
[/have_unit]
[have_unit]
side=1
x=X3
y=Y3
[/have_unit]
[then]
#trigger whatever stuff you want to happen in here.
[/then]
[/if]
[/event]
Btw I am thinking of making a WML extension that allows you to instead of saying,
Code: Select all
x=X1
y=Y1
Code: Select all
x,y=X1,Y1
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Yes, it does. To make it a specific unit (the Magic Sphere) on the tiles, it it just to edit the bits readingDave wrote:Hope that all makes sense!Code: Select all
[event] name=moveto #make the event trigger every time a unit from side 1 #moves onto any of the three tiles [filter] side=1 x=X1,X2,X3 y=X1,X2,X3 [/filter] [if] #check if there is a unit on each of the three tiles [have_unit] side=1 x=X1 y=Y1 [/have_unit] [have_unit] side=1 x=X2 y=Y2 [/have_unit] [have_unit] side=1 x=X3 y=Y3 [/have_unit] [then] #trigger whatever stuff you want to happen in here. [/then] [/if] [/event]
David
Code: Select all
[have_unit]
side=1
x=X3
y=Y3
[/have_unit]
Code: Select all
[have_unit]
[filter]
[name="Magic Sphere"]
[/filter]
side=1
x=X3
y=Y3
[/have_unit]
New question: Is there a "teleport function" or something of the sort that can move a unit from one area to another? I'm thinking of a slide, trapdoor, one-way thingy, etc. Also, how do I prevent units appearing on top of each other? I know there must be a function for this so that the orcs in Crossroads cannot appear on top of (and delete) Konrad.
The [teleport] tag can teleport units.
Teleported units will automatically be placed in the nearest vacant tile to where you specify they should be teleported -- they will never land on top of an existing unit. You could also check if a unit is already at the destination before teleporting, if you don't want the teleport to go ahead unless the destination is clear.
David
Teleported units will automatically be placed in the nearest vacant tile to where you specify they should be teleported -- they will never land on top of an existing unit. You could also check if a unit is already at the destination before teleporting, if you don't want the teleport to go ahead unless the destination is clear.
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming