Cascading Flags – Creating Variable Difficulty

Send In by: Lord Foul (08-23-2002) on the AOW2 Scenario Design Forum

Here’s a thought for an interesting way of making a map with variable difficulty; set events with particular cascaded flags such that they spawn units, using (say) turn end to spawn one extra unit every so often based on difficulty level. First, set the difficulty level with teleporters to which the wizard cannot return and from which he can do nothing (other than summon a hell hound, whoopee) – a small chamber in a corner underground is perfect. Set 3 portals in visual range, with signs for beginner, intermediate and expert difficulty. For reference, when I mention setting or testing flags unless I specify false, I intend true.

Set flag (1, 2, 3 for beginner, intermediate, expert)
Activate: (once)
Trigger player: (human)
Trigger event: unit enters area (portal) Range: 0, Stop: true

Admittedly, as it’ll show up without lots more events triggered to the portals, it isn’t tolerant of changed minds, so it could be an idea to trigger the teleport automatically; I’ll assume people are familiar with that.

Later on, after a series of count flag events, the number of which increases initial delay:

Set Flag n 
Activate: once
Trigger: new turn
Condition: Flag (n-1)

Then, you set your cascaded event:

Spawn unit X 
Activate: Always
Trigger: New Turn
Condition: Flag n
AND Flag 1 AND NOT flag 2 AND NOT flag 3

(there’s a LITTLE tolerance at least, bunks it out)

And a complementary pair with tougher units. Alternatively, if a unit per turn is a little much, set up an alternate counter which recycles:

Set flag (c) False
Activate: Always
Trigger: turn
Condition: flag (c+1)

(Note – this is part of the recycle)

Set flag (c)
Activate: Always
Trigger: turn
Condition: flag (c-1)
AND NOT flag (c+1)

(Note – this is part of the count, and tests to ensure it’s not in the recycle phase.)

Set flag (c+1) False 
Activate: Always
Trigger: turn
Condition: flag (c+1)
AND NOT flag (c)

(Note – as long as order of operations holds, if Flag (c+1) is already true, it’s the next turn and time to recycle it, as we did with flag c above.)

Set flag (c+1)
Activate: Always
Trigger: turn
Condition: Flag (c)

(Note – this is the count-up;we know that because Flag c is still true at this point. If it were recycling c would have been set false, so this is the “go” round. All game-event test conditions must come AFTER this event in processing order.)

Set flag (c)
Activate: Always
Trigger: turn
Condition: flag (c-1)

(Note – If c is on already there’s no change and if it’s off we’re starting the count again because both it AND (c+1) are off. )

Further notes: I’m too lazy to work out the correct order and events to manage a recycling delay of z turns using z+1 boolean variables, but my intuition tells me it’s easy (look out Fermat).

So once you have that unholy mess coded in (unless I’ve missed dotting an I that should be a nice little self-flipping switch) you should be able to use it to induce an additional check in the above spawn commands. So we’d get something like this:

Spawn unit X
Activate: Always
Trigger: New Turn
Condition: Flag n AND Flag 1 AND flag (c+1)
Spawn unit X
Activate: Always
Trigger: New turn
Condition: Flag n AND NOT flag 1
Spawn unit Y (larger unit)
Activate: Always
Trigger: new turn
Condition: Flag n AND flag 3 AND flag (c+1)

So every couple turns the beginner gets an X, the others get one per turn and the expert gets an additional Y every two turns. Of course this can be based on other plot elements than turns, increased in scale for a big fight, and the rest, but a two-stage count is not close to what can potentially be done with a series of boolean flags; that’s how computers translate from binary to better-than-most-of-us-at-decimal.

I also realised that it should be possible to do a binary counter with one holding flag as well, for anything up to a 16-round delay using 5 flags. Again, too lazy to work out the details…

I’m way too lazy to think about the kind of things that a count system like that could lend itself to, but if someone with some flair wants to pick at my logic and work out their own wrinkle, I’d love to see the result. (Ed note: yep, me too, please post your feedback on the Scenario Design forum.)

Back to Event Scripting Resource Database Menu

BACK TO SCENARIO DESIGN MAIN MENU