mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 11:33:52 +00:00

Also head off a potential bug noted by Mordante with WML that looks like {X_SPAN},{Y_SPAN}.
172 lines
4.9 KiB
INI
172 lines
4.9 KiB
INI
#textdomain wesnoth
|
|
# Side-limit macros for balancing AI behaviour. You can, for example
|
|
# give an AI side the possibility to recruit high level units but not to have
|
|
# too many of them at the same time. Note: These generate events, so they need
|
|
# to be placed directly under your [scenario] tag, and not within an event
|
|
# such as start or prestart.
|
|
|
|
#define LIMIT_CONTEMPORANEOUS_RECRUITS SIDE FILTER LIMIT_NUMBER
|
|
# Limit the number of units passing a specified filter that a side
|
|
# can have simultaneously. When the number of matching units
|
|
# side has reaches or exceeds LIMIT_NUMBER, that side is prevented from
|
|
# recruiting more until the number of units of that type drops
|
|
# below LIMIT_NUMBER again.
|
|
#
|
|
# Allow side 2 no more than 2 Troll Rocklobbers at a time
|
|
#! {LIMIT_CONTEMPORANEOUS_RECRUITS 2 type="Troll Rocklobber" 2}
|
|
[event]
|
|
name=side turn
|
|
first_time_only=no
|
|
|
|
[if]
|
|
[variable]
|
|
name=side_number
|
|
equals={SIDE}
|
|
[/variable]
|
|
|
|
[then]
|
|
[store_unit]
|
|
[filter]
|
|
side={SIDE}
|
|
{FILTER}
|
|
[/filter]
|
|
|
|
kill=no
|
|
variable=LIMIT_CONTEMPORANEOUS_RECRUITS_temp
|
|
[/store_unit]
|
|
|
|
[if]
|
|
[variable]
|
|
name=LIMIT_CONTEMPORANEOUS_RECRUITS_temp.length
|
|
greater_than_equal_to={LIMIT_NUMBER}
|
|
[/variable]
|
|
|
|
[then]
|
|
[disallow_recruit]
|
|
side={SIDE}
|
|
{FILTER}
|
|
[/disallow_recruit]
|
|
[/then]
|
|
|
|
[else]
|
|
[allow_recruit]
|
|
side={SIDE}
|
|
{FILTER}
|
|
[/allow_recruit]
|
|
[/else]
|
|
[/if]
|
|
|
|
{CLEAR_VARIABLE LIMIT_CONTEMPORANEOUS_RECRUITS_temp}
|
|
[/then]
|
|
[/if]
|
|
[/event]
|
|
|
|
[event]
|
|
name=recruit
|
|
first_time_only=no
|
|
|
|
[filter]
|
|
side={SIDE}
|
|
{FILTER}
|
|
[/filter]
|
|
|
|
[store_unit]
|
|
[filter]
|
|
side={SIDE}
|
|
{FILTER}
|
|
[/filter]
|
|
|
|
kill=no
|
|
variable=LIMIT_CONTEMPORANEOUS_RECRUITS_temp
|
|
[/store_unit]
|
|
|
|
[if]
|
|
[variable]
|
|
name=LIMIT_CONTEMPORANEOUS_RECRUITS_temp.length
|
|
greater_than_equal_to={LIMIT_NUMBER}
|
|
[/variable]
|
|
|
|
[then]
|
|
[disallow_recruit]
|
|
side={SIDE}
|
|
{FILTER}
|
|
[/disallow_recruit]
|
|
[/then]
|
|
[/if]
|
|
|
|
{CLEAR_VARIABLE LIMIT_CONTEMPORANEOUS_RECRUITS_temp}
|
|
[/event]
|
|
#enddef
|
|
|
|
#define LIMIT_RECRUITS SIDE TYPE LIMIT_NUMBER
|
|
# Limit the total number of units passing a specified filter that a given
|
|
# side can recruit in the scenario.
|
|
#
|
|
# Allow side 2 no more than 1 Draug in the entire scenario
|
|
#! {LIMIT_RECRUITS 2 Draug 1}
|
|
|
|
[event]
|
|
name=prestart
|
|
|
|
# the array holding the recruit-limited types is cleared here, because
|
|
# it could hold values carried over from the previous scenario
|
|
|
|
{CLEAR_VARIABLE side_{SIDE}_limited_recruits}
|
|
|
|
{VARIABLE side_{SIDE}_limited_recruits_length -1}
|
|
[/event]
|
|
|
|
# when the side recruits this given type for the first time, it's recorded
|
|
# in an array that holds info on all the recruit-limited types for this side
|
|
|
|
[event]
|
|
name=recruit
|
|
|
|
[filter]
|
|
side={SIDE}
|
|
type={TYPE}
|
|
[/filter]
|
|
|
|
{VARIABLE_OP side_{SIDE}_limited_recruits_length add 1}
|
|
|
|
{VARIABLE side_{SIDE}_limited_recruits[$side_{SIDE}_limited_recruits_length|].type $unit.type}
|
|
[/event]
|
|
|
|
# and every time when the side recruits this given type, we increment a
|
|
# counter, and if it matches or exceeds the limit, we disallow recruiting
|
|
# more of those units
|
|
|
|
[event]
|
|
name=recruit
|
|
first_time_only=no
|
|
|
|
[filter]
|
|
side={SIDE}
|
|
type={TYPE}
|
|
[/filter]
|
|
|
|
{VARIABLE_OP side_{SIDE}_limited_recruits[$side_{SIDE}_limited_recruits_length|].number_recruited add 1}
|
|
|
|
{FOREACH side_{SIDE}_limited_recruits i}
|
|
[if]
|
|
[variable]
|
|
name=side_{SIDE}_limited_recruits[$i].type
|
|
equals=$unit.type
|
|
[/variable]
|
|
|
|
[variable]
|
|
name=side_{SIDE}_limited_recruits[$i].number_recruited
|
|
greater_than_equal_to={LIMIT_NUMBER}
|
|
[/variable]
|
|
|
|
[then]
|
|
[disallow_recruit]
|
|
side={SIDE}
|
|
type={TYPE}
|
|
[/disallow_recruit]
|
|
[/then]
|
|
[/if]
|
|
{NEXT i}
|
|
[/event]
|
|
#enddef
|