1#textdomain wesnoth-ai
2
3[test]
4    id=swarm
5    name= _ "Swarm"
6    next_scenario=micro_ai_test
7
8    map_data="{ai/micro_ais/maps/animals.map}"
9
10    {DEFAULT_SCHEDULE}
11    turns=unlimited
12    victory_when_enemies_defeated=no
13
14    [side]
15        side=1
16        controller=human
17        suppress_end_turn_confirmation=yes
18        hidden=no
19        name= _ "Kraa"
20        id=Kraa
21        type=Gryphon
22        max_moves=99
23        side=1
24        persistent=no
25
26        team_name=gryphons
27        user_team_name= _ "Gryphons"
28
29        canrecruit=yes
30        recruit=Ruffian,Footpad,Thug,Poacher
31        gold=0
32    [/side]
33
34    [side]
35        side=2
36        controller=ai
37        no_leader=yes
38        persistent=no
39
40        team_name=bats
41        user_team_name= _ "Bats"
42
43        gold=0
44        income=-2
45    [/side]
46
47    [side]  # This side is only here because we need one persistent side for the game to go on
48        side=3
49        controller=null
50        persistent=yes
51        save_id=Grnk
52        hidden=yes
53    [/side]
54
55    # Put all the units and markers out there
56    [event]
57        name=prestart
58
59        {VARIABLE scenario_name swarm}
60
61        {REPEAT 12 {GENERIC_UNIT 2 "Vampire Bat" 37 26}}
62
63        # The right-click menu items
64        [set_menu_item]
65            id=m01_end_swarm
66            description= _ "End Scenario"
67            image=items/ring-red.png~CROP(26,26,20,20)
68            [show_if]
69                {VARIABLE_CONDITIONAL scenario_name equals swarm}
70            [/show_if]
71            [command]
72                [message]
73                    speaker=narrator
74                    image=wesnoth-icon.png
75                    message= _ "Well, that was that."
76                [/message]
77
78                # So that game goes on to next scenario
79                [modify_side]
80                    side=4
81                    controller=human
82                [/modify_side]
83
84                [endlevel]
85                    result=victory
86                    bonus=no
87                    carryover_percentage=0
88                    carryover_report=no
89                    linger_mode=no
90                [/endlevel]
91            [/command]
92        [/set_menu_item]
93        [set_menu_item]
94            id=m02_new_gryphon
95            description= _ "Place Side 1 Gryphon"
96            image=units/monsters/gryphon.png~CROP(38,36,24,24)
97            [show_if]
98                {VARIABLE_CONDITIONAL scenario_name equals swarm}
99            [/show_if]
100            [command]
101                {UNIT 1 Gryphon $x1 $y1 (max_moves=99)}
102            [/command]
103        [/set_menu_item]
104        [set_menu_item]
105            id=m03_new_bat
106            description= _ "Place Side 2 Bat"
107            image=units/undead/bat-se-4.png~CROP(24,16,24,24)
108            [show_if]
109                {VARIABLE_CONDITIONAL scenario_name equals swarm}
110            [/show_if]
111            [command]
112                {GENERIC_UNIT 2 (Vampire Bat) $x1 $y1}
113            [/command]
114        [/set_menu_item]
115        [set_menu_item]
116            id=m05_kill_unit
117            description= _ "Kill Unit under Cursor"
118            image=items/potion-poison.png~CROP(24,29,24,24)
119            [show_if]
120                {VARIABLE_CONDITIONAL scenario_name equals swarm}
121            [/show_if]
122            [command]
123                [kill]
124                    x,y=$x1,$y1
125                [/kill]
126            [/command]
127        [/set_menu_item]
128
129        # Set up the swarm micro AI
130        [micro_ai]
131            side=2
132            ai_type=swarm
133            action=add
134        [/micro_ai]
135    [/event]
136
137    [event]
138        name=start
139
140        # wmllint: unbalanced-on
141        [message]
142            speaker=narrator
143            image=wesnoth-icon.png
144            message= _ "This scenario features bats moving around in a swarm. Without adjacent enemies, they simply try to stay together and at a certain distance from enemies. However, if an enemy unit is close to any bat, the swarm scatters. This is particular fun to watch when one places an enemy unit in the middle of the swarm. After being scattered, the swarm members slowly rejoin, but not in a very organized way. Sub-swarms or individual bats might roam around for quite some time before they find their way back. It is also possible that individual bats (or small groups) split off from the larger swarm at times.
145
146The player controls a side of gryphons, each of which is given 99 moves so that the reaction of the swarm to enemies can be tested easily. There are also several right-click options, for example for adding bats or gryphons or for taking units off the map.
147
148Note: The Swarm AI is coded as a Micro AI. A Micro AI can be added and adapted to the need of a scenario easily using only WML and the [micro_ai] tag. Check out the <span color='#00A000'>Micro AI wiki page</span> at https://wiki.wesnoth.org/Micro_AIs for more information."
149        [/message]
150        # wmllint: unbalanced-off
151
152        [objectives]
153            side=1
154            summary= _ "Watch the bats move around and fight them if you want"
155            [objective]
156                description= _ "Defeat all bats"
157                condition=win
158            [/objective]
159            [objective]
160                description= _ "Use right-click option"
161                condition=win
162            [/objective]
163            [objective]
164                description= _ "Death of all gryphons"
165                condition=lose
166            [/objective]
167            [note]
168                description= _ "Check out the right-click menu options for additional actions"
169            [/note]
170        [/objectives]
171    [/event]
172
173    # Stop if this was the last death on this side
174    [event]
175        name=die
176        first_time_only=no
177
178        [if]
179            [not]
180                [have_unit]
181                    side=$unit.side
182                [/have_unit]
183            [/not]
184            [then]
185                [message]
186                    speaker=narrator
187                    image=wesnoth-icon.png
188                    message= _ "Well, that was that."
189                [/message]
190
191                # So that game goes on to next scenario
192                [modify_side]
193                    side=3
194                    controller=human
195                [/modify_side]
196
197                [endlevel]
198                    result=victory
199                    bonus=no
200                    carryover_percentage=0
201                    carryover_report=no
202                    linger_mode=no
203                [/endlevel]
204            [/then]
205        [/if]
206    [/event]
207[/test]
208