L: Replace FOREACH
This commit is contained in:
parent
4213c04dfb
commit
7012b998ba
3 changed files with 173 additions and 152 deletions
|
@ -281,31 +281,34 @@
|
|||
variable=stored_peasants
|
||||
[/store_unit]
|
||||
|
||||
{FOREACH stored_peasants i}
|
||||
[unit]
|
||||
side=1
|
||||
type=$stored_peasants[$i].abilities.outlaw_type_hack.id
|
||||
id=$stored_peasants[$i].id
|
||||
name=$stored_peasants[$i].name
|
||||
x,y=$stored_peasants[$i].x,$stored_peasants[$i].y
|
||||
hitpoints=$stored_peasants[$i].hitpoints
|
||||
moves=$stored_peasants[$i].moves
|
||||
experience=$stored_peasants[$i].experience
|
||||
gender=$stored_peasants[$i].gender
|
||||
facing=$stored_peasants[$i].facing
|
||||
profile=$stored_peasants[$i].profile
|
||||
unrenamable=$stored_peasants[$i].unrenamable
|
||||
canrecruit=$stored_peasants[$i].canrecruit
|
||||
overlays=$stored_peasants[$i].overlays
|
||||
random_traits=$stored_peasants[$i].random_traits
|
||||
role=$stored_peasants[$i].role
|
||||
[foreach]
|
||||
array=stored_peasants
|
||||
[do]
|
||||
[unit]
|
||||
side=1
|
||||
type=$this_item.abilities.outlaw_type_hack.id
|
||||
id=$this_item.id
|
||||
name=$this_item.name
|
||||
x,y=$this_item.x,$this_item.y
|
||||
hitpoints=$this_item.hitpoints
|
||||
moves=$this_item.moves
|
||||
experience=$this_item.experience
|
||||
gender=$this_item.gender
|
||||
facing=$this_item.facing
|
||||
profile=$this_item.profile
|
||||
unrenamable=$this_item.unrenamable
|
||||
canrecruit=$this_item.canrecruit
|
||||
overlays=$this_item.overlays
|
||||
random_traits=$this_item.random_traits
|
||||
role=$this_item.role
|
||||
|
||||
[insert_tag]
|
||||
name=modifications
|
||||
variable=stored_peasants[$i].modifications
|
||||
[/insert_tag]
|
||||
[/unit]
|
||||
{NEXT i}
|
||||
[insert_tag]
|
||||
name=modifications
|
||||
variable=this_item.modifications
|
||||
[/insert_tag]
|
||||
[/unit]
|
||||
[/do]
|
||||
[/foreach]
|
||||
|
||||
{CLEAR_VARIABLE stored_peasants}
|
||||
|
||||
|
|
|
@ -378,8 +378,12 @@
|
|||
variable=stored_changers
|
||||
[/store_unit]
|
||||
|
||||
{FOREACH stored_changers i}
|
||||
{FOREACH undead_transformation j}
|
||||
[for]
|
||||
array=stored_changers
|
||||
variable=i
|
||||
[for]
|
||||
array=undead_transformation
|
||||
variable=j
|
||||
[if]
|
||||
[variable]
|
||||
name=stored_changers[$i].type
|
||||
|
@ -391,7 +395,7 @@
|
|||
{VARIABLE j 999}
|
||||
[/then]
|
||||
[/if]
|
||||
{NEXT j}
|
||||
[/for]
|
||||
|
||||
{FALLBACK}
|
||||
[unit]
|
||||
|
@ -429,7 +433,7 @@
|
|||
[unstore_unit]
|
||||
variable=changer
|
||||
[/unstore_unit]
|
||||
{NEXT i}
|
||||
[/for]
|
||||
|
||||
{CLEAR_VARIABLE stored_changers,changer}
|
||||
[/then]
|
||||
|
@ -493,82 +497,89 @@
|
|||
variable=stored_changers
|
||||
[/store_unit]
|
||||
|
||||
{FOREACH stored_changers i}
|
||||
{FOREACH undead_transformation j}
|
||||
[for]
|
||||
array=stored_changers
|
||||
[do]
|
||||
[for]
|
||||
array=undead_transformation
|
||||
variable=j
|
||||
[do]
|
||||
[if]
|
||||
[variable]
|
||||
name=stored_changers[$i].type
|
||||
equals=$undead_transformation[$j].undead_type
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
{VARIABLE type_to_turn_into $undead_transformation[$j].human_type}
|
||||
{VARIABLE j 999}
|
||||
[/then]
|
||||
[/if]
|
||||
[/do]
|
||||
[/for]
|
||||
|
||||
{FALLBACK}
|
||||
[if]
|
||||
[variable]
|
||||
name=stored_changers[$i].type
|
||||
equals=$undead_transformation[$j].undead_type
|
||||
name=stored_changers[$i].variables.turned_to_undead_at_least_once
|
||||
equals=yes
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
{VARIABLE type_to_turn_into $undead_transformation[$j].human_type}
|
||||
{VARIABLE j 999}
|
||||
[unit]
|
||||
type=$type_to_turn_into
|
||||
side=3
|
||||
x,y=$stored_changers[$i].x,$stored_changers[$i].y
|
||||
id=$stored_changers[$i].id
|
||||
name=$stored_changers[$i].name
|
||||
experience=$stored_changers[$i].experience
|
||||
hitpoints=$stored_changers[$i].hitpoints
|
||||
canrecruit=$stored_changers[$i].canrecruit
|
||||
[modifications]
|
||||
[insert_tag]
|
||||
name=trait
|
||||
variable=stored_changers[$i].variables.stored_trait
|
||||
[/insert_tag]
|
||||
[/modifications]
|
||||
[variables]
|
||||
turned_to_undead_at_least_once=yes
|
||||
[/variables]
|
||||
to_variable=changer
|
||||
[/unit]
|
||||
[/then]
|
||||
|
||||
[else]
|
||||
[unit]
|
||||
type=$type_to_turn_into
|
||||
side=3
|
||||
x,y=$stored_changers[$i].x,$stored_changers[$i].y
|
||||
experience=$stored_changers[$i].experience
|
||||
hitpoints=$stored_changers[$i].hitpoints
|
||||
canrecruit=$stored_changers[$i].canrecruit
|
||||
random_traits=yes
|
||||
generate_name=yes
|
||||
to_variable=changer
|
||||
[/unit]
|
||||
[/else]
|
||||
[/if]
|
||||
{CLEAR_VARIABLE type_to_turn_into}
|
||||
|
||||
[if]
|
||||
[variable]
|
||||
name=changer.hitpoints
|
||||
greater_than=$changer.max_hitpoints
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
{VARIABLE changer.hitpoints $changer.max_hitpoints}
|
||||
[/then]
|
||||
[/if]
|
||||
{NEXT j}
|
||||
|
||||
{FALLBACK}
|
||||
[if]
|
||||
[variable]
|
||||
name=stored_changers[$i].variables.turned_to_undead_at_least_once
|
||||
equals=yes
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
[unit]
|
||||
type=$type_to_turn_into
|
||||
side=3
|
||||
x,y=$stored_changers[$i].x,$stored_changers[$i].y
|
||||
id=$stored_changers[$i].id
|
||||
name=$stored_changers[$i].name
|
||||
experience=$stored_changers[$i].experience
|
||||
hitpoints=$stored_changers[$i].hitpoints
|
||||
canrecruit=$stored_changers[$i].canrecruit
|
||||
[modifications]
|
||||
[insert_tag]
|
||||
name=trait
|
||||
variable=stored_changers[$i].variables.stored_trait
|
||||
[/insert_tag]
|
||||
[/modifications]
|
||||
[variables]
|
||||
turned_to_undead_at_least_once=yes
|
||||
[/variables]
|
||||
to_variable=changer
|
||||
[/unit]
|
||||
[/then]
|
||||
|
||||
[else]
|
||||
[unit]
|
||||
type=$type_to_turn_into
|
||||
side=3
|
||||
x,y=$stored_changers[$i].x,$stored_changers[$i].y
|
||||
experience=$stored_changers[$i].experience
|
||||
hitpoints=$stored_changers[$i].hitpoints
|
||||
canrecruit=$stored_changers[$i].canrecruit
|
||||
random_traits=yes
|
||||
generate_name=yes
|
||||
to_variable=changer
|
||||
[/unit]
|
||||
[/else]
|
||||
[/if]
|
||||
{CLEAR_VARIABLE type_to_turn_into}
|
||||
|
||||
[if]
|
||||
[variable]
|
||||
name=changer.hitpoints
|
||||
greater_than=$changer.max_hitpoints
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
{VARIABLE changer.hitpoints $changer.max_hitpoints}
|
||||
[/then]
|
||||
[/if]
|
||||
|
||||
[unstore_unit]
|
||||
variable=changer
|
||||
[/unstore_unit]
|
||||
{NEXT i}
|
||||
[unstore_unit]
|
||||
variable=changer
|
||||
[/unstore_unit]
|
||||
[/do]
|
||||
[/for]
|
||||
|
||||
{CLEAR_VARIABLE stored_changers,changer}
|
||||
[/then]
|
||||
|
|
|
@ -192,73 +192,80 @@
|
|||
[/case]
|
||||
[/switch]
|
||||
|
||||
{FOREACH guard_locs i}
|
||||
[for]
|
||||
array=guard_locs
|
||||
# The guard positions are designed to work with 4MP guards only, so
|
||||
# we need to make sure the guards cannot get the quick trait, and we
|
||||
# do this by randomizing their traits manually.
|
||||
[set_variables]
|
||||
name=traits_without_quick
|
||||
[do]
|
||||
[set_variables]
|
||||
name=traits_without_quick
|
||||
|
||||
[value]
|
||||
{TRAIT_STRONG}
|
||||
[/value]
|
||||
[value]
|
||||
{TRAIT_RESILIENT}
|
||||
[/value]
|
||||
[value]
|
||||
{TRAIT_FEARLESS}
|
||||
[/value]
|
||||
[value]
|
||||
{TRAIT_INTELLIGENT}
|
||||
[/value]
|
||||
[/set_variables]
|
||||
[value]
|
||||
{TRAIT_STRONG}
|
||||
[/value]
|
||||
[value]
|
||||
{TRAIT_RESILIENT}
|
||||
[/value]
|
||||
[value]
|
||||
{TRAIT_FEARLESS}
|
||||
[/value]
|
||||
[value]
|
||||
{TRAIT_INTELLIGENT}
|
||||
[/value]
|
||||
[/set_variables]
|
||||
|
||||
{VARIABLE_OP first_trait rand "0..3"}
|
||||
[set_variables]
|
||||
name=this_guard_traits
|
||||
to_variable=traits_without_quick[$first_trait].trait
|
||||
[/set_variables]
|
||||
{VARIABLE_OP first_trait rand "0..3"}
|
||||
[set_variables]
|
||||
name=this_guard_traits
|
||||
to_variable=traits_without_quick[$first_trait].trait
|
||||
[/set_variables]
|
||||
|
||||
# To prevent the same trait from being picked twice, we need to find
|
||||
# and remove the first picked trait from the array.
|
||||
{FOREACH traits_without_quick j}
|
||||
[if]
|
||||
[variable]
|
||||
name=traits_without_quick[$j].trait.id
|
||||
equals=$traits_without_quick[$first_trait].trait.id
|
||||
[/variable]
|
||||
# To prevent the same trait from being picked twice, we need to find
|
||||
# and remove the first picked trait from the array.
|
||||
[for]
|
||||
array=traits_without_quick
|
||||
variable=j
|
||||
[do]
|
||||
[if]
|
||||
[variable]
|
||||
name=traits_without_quick[$j].trait.id
|
||||
equals=$traits_without_quick[$first_trait].trait.id
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
{CLEAR_VARIABLE traits_without_quick[$first_trait]}
|
||||
[/then]
|
||||
[/if]
|
||||
{NEXT j}
|
||||
[then]
|
||||
{CLEAR_VARIABLE traits_without_quick[$first_trait]}
|
||||
[/then]
|
||||
[/if]
|
||||
[/do]
|
||||
[/for]
|
||||
|
||||
{VARIABLE_OP second_trait rand "0..2"}
|
||||
[set_variables]
|
||||
name=this_guard_traits
|
||||
mode=append
|
||||
to_variable=traits_without_quick[$second_trait].trait
|
||||
[/set_variables]
|
||||
{VARIABLE_OP second_trait rand "0..2"}
|
||||
[set_variables]
|
||||
name=this_guard_traits
|
||||
mode=append
|
||||
to_variable=traits_without_quick[$second_trait].trait
|
||||
[/set_variables]
|
||||
|
||||
{RANDOM "Shock Trooper,Iron Mauler"}
|
||||
{RANDOM "Shock Trooper,Iron Mauler"}
|
||||
|
||||
[unit]
|
||||
type=$random
|
||||
side=2
|
||||
x,y=$guard_locs[$i].x,$guard_locs[$i].y
|
||||
generate_name=yes
|
||||
random_traits=no
|
||||
[modifications]
|
||||
[insert_tag]
|
||||
name=trait
|
||||
variable=this_guard_traits
|
||||
[/insert_tag]
|
||||
[/modifications]
|
||||
[/unit]
|
||||
[unit]
|
||||
type=$random
|
||||
side=2
|
||||
x,y=$guard_locs[$i].x,$guard_locs[$i].y
|
||||
generate_name=yes
|
||||
random_traits=no
|
||||
[modifications]
|
||||
[insert_tag]
|
||||
name=trait
|
||||
variable=this_guard_traits
|
||||
[/insert_tag]
|
||||
[/modifications]
|
||||
[/unit]
|
||||
|
||||
{CLEAR_VARIABLE this_guard_traits}
|
||||
{NEXT i}
|
||||
{CLEAR_VARIABLE this_guard_traits}
|
||||
[/do]
|
||||
[/for]
|
||||
|
||||
{CLEAR_VARIABLE guard_locs,traits_without_quick,first_trait,second_trait,random}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue