filtering a unit by controller

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
musketaquid
Art Contributor
Posts: 117
Joined: July 18th, 2006, 12:23 am

filtering a unit by controller

Post by musketaquid »

Hello!

Can anybody tell me how i can filter a unit by controller. That means, the event should be executed when the unit is controlled by ai. It couldn't be done by side, because the map is in multiplayer mode and i don't know wich side is controlled by whom before playing.
Have to be something like this.

Code: Select all

[event]
    name=moveto
    first_time_only=no
    [filter]
        x,y={X},{Y}
        controller=ai   # something like that?
    [/filter]
    ... (some code) ...
[/event]
User avatar
DEATH_is_undead
Posts: 960
Joined: March 4th, 2007, 3:00 pm
Location: Northern United States

Re: filtering a unit by controller

Post by DEATH_is_undead »

Should work...
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: filtering a unit by controller

Post by zookeeper »

Code: Select all

[event]
    name=moveto
    first_time_only=no
    
    [store_side]
        side=$side_number
        variable=temp
    [/store_side]
    
    [if]
        [variable]
            name=temp.controller
            equals=ai
        [/variable]
        
        [then]
            ...
        [/then]
        
        [else]
            [allow_undo]
            [/allow_undo]
        [/else]
    [/if]
    
    {CLEAR_VARIABLE temp}
[/event]
I'm not sure if clients across the network will know whether the AI sides are controlled by the AI. At least the other clients won't know if someone droids himself, and thus you must be careful that doing stuff like this won't cause OOS (since the above check will pass on the client of whoever droided himself, but not on the other clients).
musketaquid
Art Contributor
Posts: 117
Joined: July 18th, 2006, 12:23 am

Re: filtering a unit by controller

Post by musketaquid »

@zookeeper
Thanks a lot! It works fine :)

Concerning the danger of OOS errors, i use this check only to skip a dialog for ai turns. That means only human players will see the dialog. I think it shouldn't throw some OOS even if someone droids. But it has to be tested.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: filtering a unit by controller

Post by zookeeper »

musketaquid wrote:@zookeeper
Thanks a lot! It works fine :)

Concerning the danger of OOS errors, i use this check only to skip a dialog for ai turns. That means only human players will see the dialog. I think it shouldn't throw some OOS even if someone droids. But it has to be tested.
Yeah, there's no problem if you don't actually change anything in the event (or use random, since random in MP requires that each client executes the same number of calls to prevent them from going off-sync).
Post Reply