Getting WML to do tricks

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
Circon
Posts: 1200
Joined: November 17th, 2003, 4:26 am
Location: Right behind Gwiti, coding

Getting WML to do tricks

Post by Circon »

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.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

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:

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]
Hope that all makes sense!

Btw I am thinking of making a WML extension that allows you to instead of saying,

Code: Select all

x=X1
y=Y1
go,

Code: Select all

x,y=X1,Y1
This would allow a little more compactness in defining things like co-ordinates.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Circon
Posts: 1200
Joined: November 17th, 2003, 4:26 am
Location: Right behind Gwiti, coding

Post by Circon »

Dave wrote:

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]
Hope that all makes sense!
David
Yes, it does. To make it a specific unit (the Magic Sphere) on the tiles, it it just to edit the bits reading

Code: Select all

        [have_unit]
        side=1
        x=X3
        y=Y3
        [/have_unit]
into

Code: Select all

        [have_unit]
        [filter]
        [name="Magic Sphere"]
        [/filter]
        side=1
        x=X3
        y=Y3
        [/have_unit]
?
Circon
Posts: 1200
Joined: November 17th, 2003, 4:26 am
Location: Right behind Gwiti, coding

Post by Circon »

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.
fmunoz
Founding Artist
Posts: 1469
Joined: August 17th, 2003, 10:04 am
Location: Spain
Contact:

Post by fmunoz »

There is a map in the multiplayer section with some kinds of teleporters... (1 use) the map is named across the river... just check its config file.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

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
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Post Reply