Skip to content

Commit

Permalink
TSG 6b: refactoring
Browse files Browse the repository at this point in the history
check the condition before the event
[ci skip]
  • Loading branch information
sevu committed Jun 4, 2020
1 parent 1b541da commit 2b732e4
Showing 1 changed file with 50 additions and 51 deletions.
101 changes: 50 additions & 51 deletions data/campaigns/The_South_Guard/scenarios/06b_The_Long_March.cfg
Expand Up @@ -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
Expand All @@ -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]

# 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]

[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]
[/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]

[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]

{CLEAR_VARIABLE got_a_quick_one_this_turn,undead_spawn_type,undead_spawn_x}
[/event]

[event]
Expand Down

0 comments on commit 2b732e4

Please sign in to comment.