1#textdomain wesnoth
2# Conditionals for MP scenarios.
3
4# These don't depend on any other macros.  Please don't change this.
5# ! in comments is used in generating HTML documentation, ignore it otherwise.
6
7#define OWN_VILLAGE X Y SIDE
8    # Test if a given side owns the village at the specified location
9    [have_location]
10        owner_side={SIDE}
11        x={X}
12        y={Y}
13    [/have_location]
14#enddef
15
16#define IF_VAR VAR OP_NAME VALUE CONTENTS_WML
17    # Shortcut for IF statements testing the value of a variable.
18    # Need to write [then] and [else] tags manually.
19    # Use like this:
20    #! {IF_VAR some_variable equals yes (
21    #!     [then]
22    #!         ...
23    #!     [/then]
24    #! )}
25    [if]
26        [variable]
27            name={VAR}
28            {OP_NAME}={VALUE}
29        [/variable]
30
31        {CONTENTS_WML}
32    [/if]
33#enddef
34
35#define IF_ALIVE SIDE ACTION_WML
36    # Condition triggering of ACTION_WML on whether SIDE has at least one unit left.
37    # For example, if the player 2 is still alive, kill all his units.
38    #! {IF_ALIVE 2 (
39    #!   [kill]
40    #!       side=2
41    #!   [/kill]
42    #! )}
43    [if]
44        [have_unit]
45            side={SIDE}
46        [/have_unit]
47        [then]
48            {ACTION_WML}
49        [/then]
50    [/if]
51#enddef
52
53#define IF_DEAD SIDE ACTION_WML
54    # Condition triggering of ACTION_WML on whether SIDE has no units left.
55    # For example, give player 2 gold if player 1 is dead
56    #! {IF_DEAD 1 (
57    #!   [gold]
58    #!       side=2
59    #!       amount=25
60    #!   [/gold]
61    #! )}
62    [if]
63        [not]
64            [have_unit]
65                side={SIDE}
66            [/have_unit]
67        [/not]
68        [then]
69            {ACTION_WML}
70        [/then]
71    [/if]
72#enddef
73
74#define IF_ALLIED PLAYER1_SIDE PLAYER2_SIDE ACTION_WML
75    # Condition that triggers if PLAYER1_SIDE and PLAYER2_SIDE belong
76    # to the same team.
77    # NOTE: only works if leaders are alive, are the same leader as the game
78    # started and haven't changed teams.
79    # For example, if player 3 and 4 is allied, steal 10 gold from each:
80    #! {IF_ALLIED 3 4 (
81    #!   [gold]
82    #!       side=3
83    #!       amount=-10
84    #!   [/gold]
85    #!   [gold]
86    #!       side=4
87    #!       amount=-10
88    #!   [/gold]
89    #! )}
90    [store_side]
91        side={PLAYER1_SIDE}
92        variable=player1_side
93    [/store_side]
94    [store_side]
95        side={PLAYER2_SIDE}
96        variable=player2_side
97    [/store_side]
98    [if]
99        [variable]
100            name=player1_side.team_name
101            not_equals=$empty
102        [/variable]
103        [variable]
104            name=player1_side.team_name
105            equals=$player2_side.team_name
106        [/variable]
107        [then]
108            {ACTION_WML}
109        [/then]
110    [/if]
111    [clear_variable]
112        name=player1_side,player2_side
113    [/clear_variable]
114#enddef
115