wesnoth/data/utils.cfg
Yann Dirson f9b291f695 added improved version of silene's macros...
...to hide column separators from campaign writers, use them in all
campaigns, and switch from , to = as separator to match C++ code
2004-12-11 17:04:55 +00:00

175 lines
3.1 KiB
INI

#this file contains utility macros
#macro to define a 'quantity' differently based on difficulty levels
#define QUANTITY ATTRIBUTE ON_EASY ON_NORMAL ON_HARD
#ifdef EASY
{ATTRIBUTE}={ON_EASY}
#endif
#ifdef NORMAL
{ATTRIBUTE}={ON_NORMAL}
#endif
#ifdef HARD
{ATTRIBUTE}={ON_HARD}
#endif
#enddef
#macro to define AI attack depth for different difficulty levels
#define ATTACK_DEPTH ON_EASY ON_NORMAL ON_HARD
{QUANTITY attack_depth {ON_EASY} {ON_NORMAL} {ON_HARD}}
#enddef
#macro to define number of turns for different difficulty levels
#define TURNS ON_EASY ON_NORMAL ON_HARD
{QUANTITY turns {ON_EASY} {ON_NORMAL} {ON_HARD}}
#enddef
#macro to make an AI team not recruit scouts
#define NO_SCOUTS
villages_per_scout=0
#enddef
#macro which will let you go {GOLD x y z} to set
#the gold depending on easy/medium/hard - x/y/z
#define GOLD ON_EASY ON_NORMAL ON_HARD
{QUANTITY gold {ON_EASY} {ON_NORMAL} {ON_HARD}}
#enddef
#define INCOME ON_EASY ON_NORMAL ON_HARD
#ifdef EASY
income={ON_EASY}
#endif
#ifdef NORMAL
income={ON_NORMAL}
#endif
#ifdef HARD
income={ON_HARD}
#endif
#enddef
#define DOT X Y
[image]
x,y={X},{Y}
file=misc/dot.png
delay=500
[/image]
#enddef
#define CROSS X Y
[image]
x,y={X},{Y}
file=misc/cross.png
delay=500
[/image]
#enddef
#macro to quickly pick a random value (in the $random variable, to avoid
#cluterring up savegames with such temporary variables)
#define RANDOM RANGE
[set_variable]
name=random
random={RANGE}
[/set_variable]
#enddef
#macro to initialize a variable
#define VARIABLE VAR VALUE
[set_variable]
name={VAR}
value={VALUE}
[/set_variable]
#enddef
#macro to do mathematical operations on variables
#define VARIABLE_OP VAR OP ARG
[set_variable]
name={VAR}
{OP}={ARG}
[/set_variable]
#enddef
#define CLEAR_VARIABLE VAR
[clear_variable]
name={VAR}
[/clear_variable]
#enddef
#macro to iterate over an array
#define FOREACH ARRAY VAR
{VARIABLE {VAR} 0}
[while]
[variable]
name={VAR}
less_than=${ARRAY}.length
[/variable]
[do]
#enddef
#define NEXT VAR
[set_variable]
name={VAR}
add=1
[/set_variable]
[/do]
[/while]
{CLEAR_VARIABLE {VAR}}
#enddef
#define DEBUG_MSG MSG
[message]
speaker=narrator
message={MSG}
[/message]
#enddef
#macro to make a side start a scenario with villages
#define STARTING_VILLAGES SIDE RADIUS
[event]
name=prestart
[store_starting_location]
side={SIDE}
variable=temp_starting_location
[/store_starting_location]
[store_locations]
x,y=$temp_starting_location.x,$temp_starting_location.y
radius={RADIUS}
variable=temp_starting_locs
#all the types of villages
terrain=ZYtvVD
[/store_locations]
{FOREACH temp_starting_locs i}
{VARIABLE_OP temp_x_var to_variable temp_starting_locs[$i].x}
{VARIABLE_OP temp_y_var to_variable temp_starting_locs[$i].y}
[capture_village]
side={SIDE}
x,y=$temp_x_var,$temp_y_var
[/capture_village]
{NEXT i}
{CLEAR_VARIABLE temp_x_var}
{CLEAR_VARIABLE temp_y_var}
{CLEAR_VARIABLE temp_starting_location}
{CLEAR_VARIABLE temp_starting_locs}
{CLEAR_VARIABLE i}
[/event]
#enddef
#define MENU_IMG_TXT IMG TXT
"&"+{IMG}+"="+{TXT}#enddef
#define MENU_IMG_TXT2 IMG TXT1 TXT2
"&"+{IMG}+"="+{TXT1}+"="+{TXT2}#enddef