-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmechanism.cfg
386 lines (353 loc) · 14.2 KB
/
mechanism.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#textdomain wesnoth-ANLEra
# This file includes the all ANL mechanisms,
# either directly or by using macros defined in other files.
# The intention is that there are two ways to load the mechanisms:
# either by the era or by loading this resource from a scenario.
# That way, it can be played with other eras too.
# To use this in a scenario:
# - use [load_resource] with id=anl_mechanism
# - use [remove_event] with id=exta_ai_units before "turn 1" events happen;
# This will disable differing behaviour when playing with the era.
# - use disallow_modification=Anewlandsp, as it is incompatible with this
# - use force_modification=ai_destroyers (optionally)
# - PS: if the scenario is not a competitive PvP one, you can additionally use
# [load_resource] with id=anl_faction_flags, though it only has an effect when playing with the era.
# It is not enabled by default, because it reveals each side's faction in the first turn.
[resource]
id=anl_mechanism
# This event loads Lua code … but nothing happens yet.
# It just defines functions, which can be used.
# When the game is loaded, the functions need to be redefined.
# This does the preload event.
[event]
name=preload
first_time_only=no
# Load the lua code from different files,
# put them together into one table.
#ifndef TESTING_IS_EASIER_WITH_THIS_CODE
# Changes in the Lua files take effect whenever this event is executed.
# E.g. when using the debug command :fire preload
[lua]
code=<<
anl = {}
wesnoth.dofile('~add-ons/ANLEra/utils/research.lua')
wesnoth.dofile('~add-ons/ANLEra/utils/diplomacy.lua')
wesnoth.dofile('~add-ons/ANLEra/utils/ai/extra_ai_units.lua')
wesnoth.dofile('~add-ons/ANLEra/utils/general_purpose/color.lua')
>>
[/lua]
#else
# This does the same, but the other players don't need to have the files on their computer.
# It reads the files with the preprocessor and sends them over the network.
# Drawback of this: changes in the Lua files take only effect when pressing F5 in the main menu
# (or restarting wesnoth)
[lua]
code=<< anl = {} >>
[/lua]
[lua]
code={~add-ons/ANLEra/utils/research.lua}
[/lua]
[lua]
code={~add-ons/ANLEra/utils/diplomacy.lua}
[/lua]
[lua]
code={~add-ons/ANLEra/utils/ai/extra_ai_units.lua}
[/lua]
[lua]
code={~add-ons/ANLEra/utils/general_purpose/color.lua}
[/lua]
#endif
# This can be used to define more Lua code in a scenario, which relies
# on being executed after the above, i. e. to overwrite negotiation options.
[fire_event]
name=after preload
[/fire_event]
[/event]
# The prestart event sets up ANL at game start … it happens after preload.
# All the right-click menus are now added to the game.
# Also some other things to change, like replacing terrain which does not fit good with ANL.
[event]
name=prestart
# Create variables for each player, which store information like the research progress.
[store_side]
variable=players
[/store_side]
[foreach]
array=players
[do]
{SET_SIDE_VARIABLES $this_item.side|}
[/do]
[/foreach]
{CLEAR_VARIABLE players}
# Adding menu_items for various purposes.
{ANL_HELP}
# (ANLEra Merman Citizen is added at a few selected places, should not be in this list)
{WORKER_OPTIONS "Goblin Spearman,Goblin Impaler,Goblin Rouser,Peasant,Ruffian,Woodsman,ANLEra Dwarvish Miner,Dwarvish Miner,ANLEra Elvish Civilian,ANLEra Drake Worker,ANLEra Young Saurian,ANLEra Dune Civilian,Walking Corpse,Soulless"}
#ifdef DEBUG_MODE
# Debug Tools. Can be activated by setting the variable anl_debug.
# E.g. ingame with :set_var anl_debug=yes
{ANL_TOOLS}
#endif
# Research Menu.
[set_menu_item]
id=anl_research
#textdomain wesnoth-anl
description=_ "Oversee Research"
#textdomain wesnoth-ANLEra
[default_hotkey]
key=3
[/default_hotkey]
[show_if]
[have_unit]
side=$side_number
x,y=$x1,$y1
type_adv_tree="ANLEra Novice Orcish Shaman,ANLEra Drake Apprentice,Saurian Augur,Elvish Shaman,Mage,ANLEra Dwarvish Witness,ANLEra Rogue Mage,Dark Adept,Dune Herbalist"
canrecruit=no
[not]
status=worked_this_turn
[/not]
[filter_location]
terrain={ANL_UNIVERSITIES}
[/filter_location]
[or]
side=$side_number
x,y=$x1,$y1
type_adv_tree="Mermaid Initiate"
canrecruit=no
[not]
status=worked_this_turn
[/not]
[filter_location]
terrain=Sm^Vm
[/filter_location]
[/or]
[/have_unit]
{VARIABLE_CONDITIONAL wml_implementation boolean_equals no}
[/show_if]
[command]
[lua]
code=anl.research_menu()
[/lua]
[/command]
[/set_menu_item]
# Menu for researched units.
[set_menu_item]
id=anl_choose_new_recruit
#textdomain wesnoth-anl
description=_ "Choose New Recruit"
#textdomain wesnoth-ANLEra
[default_hotkey]
key=4
[/default_hotkey]
[show_if]
[have_unit]
side=$side_number
x,y=$x1,$y1
type_adv_tree="ANLEra Novice Orcish Shaman,ANLEra Drake Apprentice,Saurian Augur,Elvish Shaman,Mage,ANLEra Dwarvish Witness,ANLEra Rogue Mage,Dark Adept,Dune Herbalist"
canrecruit=no
[not]
status=worked_this_turn
[/not]
[filter_location]
terrain={ANL_UNIVERSITIES}
[/filter_location]
[/have_unit]
[variable]
name=player_$side_number|.warfare.troop_available
greater_than=0
[/variable]
[lua]
code=<<
local x, researchable
x, researchable = anl.determine_faction(wml.variables['unit'].type)
return researchable[1] ~= nil
>>
[/lua]
{VARIABLE_CONDITIONAL wml_implementation boolean_equals no}
[/show_if]
[command]
[lua]
code=anl.choose_new_recruit()
[/lua]
[/command]
[/set_menu_item]
# Same menu, just with different text for flavor.
[set_menu_item]
id=anl_choose_special_recruit
description=_ "Choose Special Recruit"
[default_hotkey]
key=5
[/default_hotkey]
[show_if]
[have_unit]
side=$side_number
x,y=$x1,$y1
type_adv_tree="Mermaid Initiate"
canrecruit=no
[not]
status=worked_this_turn
[/not]
[filter_location]
terrain=Sm^Vm
[/filter_location]
[/have_unit]
[variable]
name=player_$side_number|.warfare.troop_available
greater_than=0
[/variable]
[lua]
code=<<
local x, researchable
x, researchable = anl.determine_faction(wml.variables['unit'].type)
return researchable[1] ~= nil
>>
[/lua]
{VARIABLE_CONDITIONAL wml_implementation boolean_equals no}
[/show_if]
[command]
[lua]
code=anl.choose_new_recruit()
[/lua]
[/command]
[/set_menu_item]
# Diplomacy Menu for leaders instead.
[set_menu_item]
id=anl_diplomacy
#textdomain wesnoth-anl
description=_ "Diplomacy"
#textdomain wesnoth-ANLEra
[default_hotkey]
key=2
[/default_hotkey]
[show_if]
[have_unit]
side=$side_number
x,y=$x1,$y1
canrecruit=yes
[not]
status=worked_this_turn
[/not]
[/have_unit]
{VARIABLE_CONDITIONAL wml_implementation boolean_equals no}
[/show_if]
[filter_location]
terrain={ANL_UNIVERSITIES}
[/filter_location]
[command]
[lua]
code=anl.diplomacy_menu()
[/lua]
[/command]
[/set_menu_item]
# If a worker starts its turn on *^Gvs terrain, it will give money.
# Place a flower on already existing *^Gvs terrain.
[store_locations]
variable=t
terrain=*^Gvs
[/store_locations]
[foreach]
array=t
[do]
{PLACE_IMAGE items/flower4.png $this_item.x $this_item.y}
[/do]
[/foreach]
{CLEAR_VARIABLE t}
# Replace problematic terrain
#ifver WESNOTH_VERSION >= 1.15.3
# Compatibility code, to be removed in the future.
# *^Uf looks like Tb^Tf, might cause confusion.
[terrain]
[and]
terrain=*^Ufi
[/and]
terrain=^Tfi
layer=overlay
[/terrain]
[terrain]
[and]
terrain=*^Uf
[/and]
terrain=^Tf
layer=overlay
[/terrain]
#endif
# Re is used for farms. To avoid that ^Gvs grows after an enemy L0 stepped onto it,
# replace pre-existing Re terrain with another one.
[terrain]
[and]
terrain=Re^*
[/and]
terrain=Rb
layer=base
[/terrain]
# Ket causes glitches when certain castle tiles are adjacent.
[terrain]
[and]
terrain=Ket^*
[/and]
terrain=Ke
layer=base
[/terrain]
#ifver WESNOTH_VERSION >= 1.16.0
# Replace duplicate team colors.
[if]
{VARIABLE_CONDITIONAL duplicate_team_colors boolean_equals no}
[then]
[fire_event]
# This is a way to ensure that this modification will be applied first.
id=Rav_Color_Mod_prestart
[/fire_event]
[lua]
name="ANL Teamcolor Change"
code=anl.fix_colors()
[/lua]
{CLEAR_VARIABLE duplicate_team_colors}
[/then]
[/if]
#endif
[/event]
# Disable building directly after recruitment or creation via plague.
# This adds an unit placed event.
{AUTO_BREAKFASTING (type="Goblin Spearman,Goblin Impaler,Goblin Rouser,Peasant,Ruffian,Woodsman,ANLEra Dwarvish Miner,Dwarvish Miner,ANLEra Elvish Civilian,ANLEra Drake Worker,ANLEra Young Saurian,ANLEra Dune Civilian,Walking Corpse,Soulless")}
# This event handles the ANL things which happen every turn.
[event]
name=side turn
first_time_only=no
# Auto-studying, happens first.
# (Mermaid Initiate is not in the list, but can also study, but on Merfolk Universities instead)
{AUTO_STUDYING "ANLEra Novice Orcish Shaman,ANLEra Drake Apprentice,Saurian Augur,Elvish Shaman,Mage,ANLEra Dwarvish Witness,ANLEra Rogue Mage,Dark Adept,Dune Herbalist"}
# Research complete messages.
[lua]
code=anl.research_complete()
[/lua]
# Auto-working. Happens after research, as research may have just improved farming or mining.
{AUTO_FARMING "Goblin Spearman,Goblin Impaler,Goblin Rouser,Peasant,Ruffian,Woodsman,ANLEra Dwarvish Miner,Dwarvish Miner,ANLEra Elvish Civilian,ANLEra Drake Worker,ANLEra Young Saurian,ANLEra Dune Civilian,Walking Corpse,Soulless"}
{AUTO_MINING "Goblin Spearman,Goblin Impaler,Goblin Rouser,Peasant,Ruffian,Woodsman,ANLEra Dwarvish Miner,Dwarvish Miner,ANLEra Elvish Civilian,ANLEra Drake Worker,ANLEra Young Saurian,ANLEra Dune Civilian,Walking Corpse,Soulless"}
{AUTO_HUNTING "Woodsman,Poacher,Trapper,Huntsman,Ranger"}
{AUTO_FISHING "ANLEra Merman Citizen,Merman Citizen"}
# Remove working status from any working units when starting a turn.
# Happens after the other automatic actions, as some of them do check the status.
{AUTO_RELAXING}
[/event]
#ifver WESNOTH_VERSION <= 1.17.12
# This is to add in the sidebar an icon when a unit has the status "stunned".
# The Code is from "Dead Water". Could also be used to add an icon for units which worked this turn.
[lua]
code=<<
local _ = wesnoth.textdomain "wesnoth-dw"
local old_unit_status = wesnoth.theme_items.unit_status
function wesnoth.theme_items.unit_status()
local u = wesnoth.get_displayed_unit()
if not u then return {} end
local s = old_unit_status()
if u.status.stunned then
table.insert(s, { "element", { image = "misc/stunned-status-icon.png",
tooltip = _"stunned: This unit is stunned. It cannot enforce its Zone of Control."
} } )
end
return s
end
>>
[/lua]
#endif
[/resource]