Added macros for handling persistent ai sides.

This commit is contained in:
Fabian Müller 2008-12-07 16:59:20 +00:00
parent cda03e1dcf
commit e5225549c1

View file

@ -246,3 +246,99 @@
{CLEAR_VARIABLE TRANSFER_VILLAGE_OWNERSHIP_villages}
#enddef
# Persistant macros
#define MAKE_AI_SIDE_PERSISTENT SIDE
#Macro to make a ai controlled side persistent.
#Needs to be placed below the side definition.
[+side]
controller=human
persistent=yes
[/side]
[event]
name=prestart
[modify_side]
side={SIDE}
controller=ai
[/modify_side]
[/event]
[event]
name=victory
[modify_side]
side={SIDE}
controller=human
[/modify_side]
[/event]
#enddef
#define RECALL_AI_SIDE SIDE
#Recalls an ai side that is persistent (MAKE_AI_SIDE_PERSISTENT)
#Needs to be placed below the side definition.
{MAKE_AI_SIDE_PERSISTENT {SIDE}}
[event]
name=prestart
[store_unit]
variable=recall_ai_side_units_{SIDE}
[filter]
side={SIDE}
[/filter]
[/store_unit]
[/event]
[event]
name=victory
{CLEAR_VARIABLE recall_ai_side_units_{SIDE}}
[/event]
[event]
name=ai turn
[if]
[variable]
name=side_number
equals={SIDE}
[/variable]
[and]
[have_unit]
canrecruit=yes
side={SIDE}
[filter_location]
terrain=K*
[/filter_location]
[/have_unit]
[/and]
[then]
[store_gold]
side={SIDE}
[/store_gold]
[while]
[variable]
name=gold
greater_than=19
[/variable]
[variable]
name=recall_ai_side_units_{SIDE}.length
greater_than=0
[/variable]
[do]
[gold]
side=2
amount=-20
[/gold]
[store_gold]
side={SIDE}
[/store_gold]
[recall]
id=$recall_ai_side_units_{SIDE}[0].id
[/recall]
{CLEAR_VARIABLE recall_ai_side_units_{SIDE}[0]}
[/do]
[/while]
{CLEAR_VARIABLE gold}
[/then]
[/if]
[/event]
#enddef