Replace FOREACH

This commit is contained in:
fendrin 2016-08-06 05:30:31 +02:00
parent ed296f30a0
commit 8544320b58
3 changed files with 150 additions and 124 deletions

View file

@ -1033,18 +1033,22 @@ Behavior: $ai_controller.side_$ally_side|_current_settings.currently_doing_behav
[/split]
[/set_variables]
{FOREACH disabled_for_sides_array disabled_for_side_i}
[if]
[variable]
name=disabled_for_sides_array[$disabled_for_side_i].side
equals={SIDE}
[/variable]
[for]
array=disabled_for_sides_array
variable=disabled_for_side_i
[do]
[if]
[variable]
name=disabled_for_sides_array[$disabled_for_side_i].side
equals={SIDE}
[/variable]
[then]
{CLEAR_VARIABLE disabled_for_sides_array[$disabled_for_side_i]}
[/then]
[/if]
{NEXT disabled_for_side_i}
[then]
{CLEAR_VARIABLE disabled_for_sides_array[$disabled_for_side_i]}
[/then]
[/if]
[/do]
[/for]
[set_variable]
name=ai_controller_{AFFIX}.disabled_for_sides

View file

@ -135,31 +135,34 @@
type={TYPE}
[/filter]
{FOREACH side_{SIDE}_limited_recruits i}
[if]
[variable]
name=side_{SIDE}_limited_recruits[$i].type
equals=$unit.type
[/variable]
[foreach]
array=side_{SIDE}_limited_recruits
[do]
[if]
[variable]
name=this_item.type
equals=$unit.type
[/variable]
[then]
{VARIABLE_OP side_{SIDE}_limited_recruits[$i].number_recruited add 1}
[if]
[variable]
name=side_{SIDE}_limited_recruits[$i].number_recruited
greater_than_equal_to={LIMIT_NUMBER}
[/variable]
[then]
{VARIABLE_OP this_item.number_recruited add 1}
[if]
[variable]
name=this_item.number_recruited
greater_than_equal_to={LIMIT_NUMBER}
[/variable]
[then]
[disallow_recruit]
side={SIDE}
type={TYPE}
[/disallow_recruit]
[/then]
[/if]
[/then]
[/if]
{NEXT i}
[then]
[disallow_recruit]
side={SIDE}
type={TYPE}
[/disallow_recruit]
[/then]
[/if]
[/then]
[/if]
[/do]
[/foreach]
[/event]
#enddef

View file

@ -277,17 +277,20 @@
kill=yes
[/store_unit]
{FOREACH MODIFY_UNIT_store MODIFY_UNIT_i}
[set_variable]
name=MODIFY_UNIT_store[$MODIFY_UNIT_i].{VAR}
value={VALUE}
[/set_variable]
[foreach]
array=MODIFY_UNIT_store
[do]
[set_variable]
name=this_item.{VAR}
value={VALUE}
[/set_variable]
[unstore_unit]
variable=MODIFY_UNIT_store[$MODIFY_UNIT_i]
find_vacant=no
[/unstore_unit]
{NEXT MODIFY_UNIT_i}
[unstore_unit]
variable=this_item
find_vacant=no
[/unstore_unit]
[/do]
[/foreach]
{CLEAR_VARIABLE MODIFY_UNIT_store,MODIFY_UNIT_i}
#enddef
@ -303,15 +306,19 @@
kill=yes
[/store_unit]
{FOREACH MOVE_UNIT_store MOVE_UNIT_BY_i}
{VARIABLE_OP MOVE_UNIT_store[$MOVE_UNIT_BY_i].x add {OFFSET_X}}
{VARIABLE_OP MOVE_UNIT_store[$MOVE_UNIT_BY_i].y add {OFFSET_Y}}
[unstore_unit]
variable=MOVE_UNIT_store[$MOVE_UNIT_BY_i]
find_vacant=no
[/unstore_unit]
{NEXT MOVE_UNIT_BY_i}
{CLEAR_VARIABLE MOVE_UNIT_store,MOVE_UNIT_BY_i}
[for]
array=MOVE_UNIT_store
variable=MOVE_UNIT_BY_i
[do]
{VARIABLE_OP MOVE_UNIT_store[$MOVE_UNIT_BY_i].x add {OFFSET_X}}
{VARIABLE_OP MOVE_UNIT_store[$MOVE_UNIT_BY_i].y add {OFFSET_Y}}
[unstore_unit]
variable=MOVE_UNIT_store[$MOVE_UNIT_BY_i]
find_vacant=no
[/unstore_unit]
[/do]
[/for]
{CLEAR_VARIABLE MOVE_UNIT_store}
#enddef
#define MOVE_UNIT FILTER TO_X TO_Y
@ -516,39 +523,42 @@
[/and]
[/filter_condition]
{FOREACH unit.attack i}
[if]
#This is to mute a warning message about retrieving a member of non-existant wml container.
[variable]
name=unit.attack[$i].specials.length
greater_than=0
[/variable]
[foreach]
array=unit.attack
[do]
[if]
#This is to mute a warning message about retrieving a member of non-existant wml container.
[variable]
name=this_item.specials.length
greater_than=0
[/variable]
[variable]
name=unit.attack[$i].specials.chance_to_hit.length
greater_than=0
[/variable]
[variable]
name=this_item.specials.chance_to_hit.length
greater_than=0
[/variable]
[then]
[set_variables]
name=unit.attack[$i].specials.original_chance_to_hit
to_variable=unit.attack[$i].specials.chance_to_hit
[/set_variables]
[then]
[set_variables]
name=this_item.specials.original_chance_to_hit
to_variable=this_item.specials.chance_to_hit
[/set_variables]
{CLEAR_VARIABLE unit.attack[$i].specials.chance_to_hit}
[/then]
[/if]
{CLEAR_VARIABLE this_item.specials.chance_to_hit}
[/then]
[/if]
[set_variables]
name=unit.attack[$i].specials.chance_to_hit
[set_variables]
name=this_item.specials.chance_to_hit
[value]
id=forced_cth
value={CTH_NUMBER}
cumulative=no
[/value]
[/set_variables]
{NEXT i}
[value]
id=forced_cth
value={CTH_NUMBER}
cumulative=no
[/value]
[/set_variables]
[/do]
[/foreach]
[unstore_unit]
variable=unit
@ -559,16 +569,19 @@
name=attack end
delayed_variable_substitution=yes
{FOREACH unit.attack i}
{CLEAR_VARIABLE unit.attack[$i].specials.chance_to_hit}
[foreach]
array=unit.attack
[do]
{CLEAR_VARIABLE this_item.specials.chance_to_hit}
[set_variables]
name=unit.attack[$i].specials.chance_to_hit
to_variable=unit.attack[$i].specials.original_chance_to_hit
[/set_variables]
[set_variables]
name=this_item.specials.chance_to_hit
to_variable=this_item.specials.original_chance_to_hit
[/set_variables]
{CLEAR_VARIABLE unit.attack[$i].specials.original_chance_to_hit}
{NEXT i}
{CLEAR_VARIABLE this_item.specials.original_chance_to_hit}
[/do]
[/foreach]
[unstore_unit]
variable=unit
@ -598,38 +611,41 @@
[/and]
[/filter_condition]
{FOREACH second_unit.attack i}
[if]
[variable]
name=second_unit.attack[$i].specials.length
greater_than=0
[/variable]
[foreach]
array=second_unit.attack
[do]
[if]
[variable]
name=second_this_item.specials.length
greater_than=0
[/variable]
[variable]
name=second_unit.attack[$i].specials.chance_to_hit.length
greater_than=0
[/variable]
[variable]
name=second_this_item.specials.chance_to_hit.length
greater_than=0
[/variable]
[then]
[set_variables]
name=second_unit.attack[$i].specials.original_chance_to_hit
to_variable=second_unit.attack[$i].specials.chance_to_hit
[/set_variables]
[then]
[set_variables]
name=second_this_item.specials.original_chance_to_hit
to_variable=second_this_item.specials.chance_to_hit
[/set_variables]
{CLEAR_VARIABLE second_unit.attack[$i].specials.chance_to_hit}
[/then]
[/if]
{CLEAR_VARIABLE second_this_item.specials.chance_to_hit}
[/then]
[/if]
[set_variables]
name=second_unit.attack[$i].specials.chance_to_hit
[set_variables]
name=second_this_item.specials.chance_to_hit
[value]
id=forced_cth
value={CTH_NUMBER}
cumulative=no
[/value]
[/set_variables]
{NEXT i}
[value]
id=forced_cth
value={CTH_NUMBER}
cumulative=no
[/value]
[/set_variables]
[/do]
[/foreach]
[unstore_unit]
variable=second_unit
@ -640,16 +656,19 @@
name=attack end
delayed_variable_substitution=yes
{FOREACH second_unit.attack i}
{CLEAR_VARIABLE second_unit.attack[$i].specials.chance_to_hit}
[foreach]
array=second_unit.attack
[do]
{CLEAR_VARIABLE this_item.specials.chance_to_hit}
[set_variables]
name=second_unit.attack[$i].specials.chance_to_hit
to_variable=second_unit.attack[$i].specials.original_chance_to_hit
[/set_variables]
[set_variables]
name=this_item.specials.chance_to_hit
to_variable=this_item.specials.original_chance_to_hit
[/set_variables]
{CLEAR_VARIABLE second_unit.attack[$i].specials.original_chance_to_hit}
{NEXT i}
{CLEAR_VARIABLE this_item.specials.original_chance_to_hit}
[/do]
[/foreach]
[unstore_unit]
variable=second_unit