TSG 6b: refactoring

check the condition before the event
[ci skip]
This commit is contained in:
Severin Glöckner 2020-06-04 23:33:46 +02:00
parent 1b541dadcb
commit 2b732e4a59

View File

@ -1088,7 +1088,8 @@ _f, _f, Re, _f
[event]
name=new turn
first_time_only=no
[if]
[filter_condition]
[variable]
name=turn_number
greater_than=$first_undead_spawn_turn
@ -1100,68 +1101,66 @@ _f, _f, Re, _f
race=bats,undead
count=0-30
[/have_unit]
[/filter_condition]
[then]
{VARIABLE got_a_quick_one_this_turn no}
{VARIABLE got_a_quick_one_this_turn no}
[repeat]
times="$(min($turn_number - $first_undead_spawn_turn, 5))"
[repeat]
times="$(min($turn_number - $first_undead_spawn_turn, 5))"
[do]
{VARIABLE_OP undead_spawn_x rand "11..22"}
[do]
{VARIABLE_OP undead_spawn_x rand "11..22"}
# If there's already been a quick unit (bat)
# spawned this turn, don't make any more
[if]
[variable]
name=got_a_quick_one_this_turn
equals=yes
[/variable]
# If there's already been a quick unit (bat)
# spawned this turn, don't make any more
[if]
[variable]
name=got_a_quick_one_this_turn
boolean_equals=yes
[/variable]
[then]
[then]
#ifdef EASY
{VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Necrophage"}
{VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Necrophage"}
#else
{VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Deathblade,Necrophage"}
{VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Deathblade,Necrophage"}
#endif
[/then]
[/then]
[else]
[else]
#ifdef EASY
{VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Blood Bat,Necrophage"}
{VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Blood Bat,Necrophage"}
#else
{VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Deathblade,Blood Bat,Dread Bat,Necrophage"}
{VARIABLE_OP undead_spawn_type rand "Bone Shooter,Revenant,Deathblade,Blood Bat,Dread Bat,Necrophage"}
#endif
[/else]
[/if]
[/else]
[/if]
# This checks whether the current spawn is going to be a
# "quick" one, so on the next repeat the above [if] will
# know whether we've already gotten a quick one this turn
{VARIABLE quick_spawn_types "Blood Bat,Dread Bat"}
[if]
[variable]
name=quick_spawn_types
contains=$undead_spawn_type
[/variable]
# This checks whether the current spawn is going to be a
# "quick" one, so on the next repeat the above [if] will
# know whether we've already gotten a quick one this turn
{VARIABLE quick_spawn_types "Blood Bat,Dread Bat"}
[if]
[variable]
name=quick_spawn_types
contains=$undead_spawn_type
[/variable]
[then]
{VARIABLE got_a_quick_one_this_turn yes}
[/then]
[/if]
[then]
{VARIABLE got_a_quick_one_this_turn yes}
[/then]
[/if]
[unit]
side=2
type=$undead_spawn_type
x=$undead_spawn_x
y=45
[/unit]
[/do]
[/repeat]
[unit]
side=2
type=$undead_spawn_type
x=$undead_spawn_x
y=45
[/unit]
[/do]
[/repeat]
{CLEAR_VARIABLE got_a_quick_one_this_turn,undead_spawn_type,undead_spawn_x}
[/then]
[/if]
{CLEAR_VARIABLE got_a_quick_one_this_turn,undead_spawn_type,undead_spawn_x}
[/event]
[event]