Creating a Risk/King of the Hill-style custom scenario

I recently created a Risk/King of the Hill-style custom scenario. You can see a video of it below:

And you can download this scenario here.

In this scenario, the Keep changes hands every time it is destroyed; if Red destroys a Blue Keep, a Red Keep will pop up in its place and vice-versa. Additionally, when the Keep is under Blue control, Red will train Champions (if the Barrack is still up) and Paladins (if the Stable is still up) and have those units try to recapture the Keep.

There are two ways to create this type of scenario: by exclusively using triggers, and by using an AI script to deal with unit training.

Method 1: Using Only Triggers
First, let’s create our variables. To do that, create the following trigger:

  • Trigger Name: Initial
  • Trigger Starting State: On
  • Trigger Looping: No
  • Effect: Change Variable. Set Variable 1 name to Tower, Operation to Set and Quantity to 0
  • Effect: Change Variable. Set Variable 2 name to RedStables, Operation to Set and Quantity to 1
  • Effect: Change Variable. Set Variable 3 name to RedBar, Operation to Set and Quantity to 1

The Towers variable is used in the objective descriptions. To do that, create a loop trigger with starting state on. In the trigger description and/or short description, add the following line:

+ Towers Controlled (<Towers>/1)

In the scenario, the Keep is originally controlled by Player 3 (Green) who is allied with both Red and Blue. In turn, we need to create a trigger that replaces the Green Keep with a Blue Keep:

  • Trigger Name: InitialCapture
  • Trigger Starting State: On
  • Trigger Looping: No
  • Condition: Objects in Area. Source Player = Player 1, Quantity = 1. Set Area to area around Keep.
  • Effect: Remove Object. Have this effect remove the Green Keep.
  • Effect: Create Object. Have this effect create a Blue Keep at the location of Green Keep. Be sure to move the Green Keep so you can set spawn location below the Green Keep.
  • Effect: Activate Trigger → Activate WhenBlueKeepIsBuilt

Now let’s create the WhenBlueKeepIsBuilt trigger:

  • Trigger Name: WhenBlueKeepIsBuilt
  • Trigger Starting State: Off
  • Trigger Looping: No
  • Condition: Objects in Area. Object List = Keep, Source Player = Player 1, Quantity = 1. Don’t forget to set Area.
  • Effect: Activate Trigger → Activate RedTrainStable
  • Effect: Activate Trigger → Activate RedTrainBarracks
  • Effect: Activate Trigger → Activate RedTrainTimer
  • Effect: Activate Trigger → Activate RedDestroyBlue
  • Effect: Change Variable. Variable = Towers, Operation = Add, Quantity = 1
  • Effect: Deactivate Trigger → Deactivate BlueKeepBuilder

Here’s the trigger to tell Red to train Paladins every 2 seconds as long a Red’s military population is below 10 and that a Stable still exists:

  • Trigger Name: RedTrainStable
  • Trigger Starting State: Off
  • Trigger Looping: Yes
  • Condition: Timer = 2
  • Condition: Accumulate Attribute. Source Player = Player 2, Tribute List = Military Population, Quantity = 10
  • Condition: Variable Value. Variable = RedStables, Comparison = Equal, Quantity = 1
  • Effect: Create Object. Object List = Paladin, Source Player = Player 2. Don’t forget to set Location.
  • Effect: Task Object. Source Player = Player 2. Set Area to the Create Object location and the Location to a gather point.

In general, when you’re spawning units and want them to immediately move out the way, you must place the Task Object effect after the Create Object effect.

Here’s the trigger to tell Red to train Champions every 2 seconds as long a Red’s military population is below 10 and that a Barrack still exists:

  • Trigger Name: RedTrainBarracks
  • Trigger Starting State: Off
  • Trigger Looping: Yes
  • Condition: Timer = 2
  • Condition: Accumulate Attribute. Source Player = Player 2, Tribute List = Military Population, Quantity = 10
  • Condition: Variable Value. Variable = RedBar, Comparison = Equal, Quantity = 1
  • Effect: Create Object. Object List = Champion, Source Player = Player 2. Don’t forget to set Location.
  • Effect: Task Object. Source Player = Player 2. Set Area to the Create Object location and the Location to a gather point.

Here’s the Trigger to tell Red to attack once they reach 10 military population:

  • Trigger Name: RedTrainTimer
  • Trigger Starting State: Off
  • Trigger Looping: No
  • Condition: Accumulate Attribute. Source Player = Player 2, Tribute List = Military Population, Quantity = 10
  • Effect: Activate Trigger → Activate RedRetake

This trigger commands Red units to retake the Keep, after a 10 second delay. It also re-enables the RedTrainTimer trigger.

  • Trigger Name: RedRetake
  • Trigger Starting State: Off
  • Trigger Looping: No
  • Condition: Timer = 10
  • Effect: Attack Move. Source Player = Player 2. Set Area to the gather point and Location to the Keep.
  • Effect: Activate Trigger → Activate RedTrainTimer

Here’s the Trigger that defines what happens when the Blue Keep is destroyed:

  • Trigger Name: RedDestroyBlue
  • Trigger Starting State: Off
  • Trigger Looping: No
  • Condition: Own Fewer Object. Object List = Keep, Source Player = Player 1, Quantity = 0. Also set Area to the area around the Keep.
  • Effect: Activate Trigger → Activate RedKeepBuilder
  • Effect: Activate Trigger → Activate WhenRedKeepIsBuilt
  • Effect: Change Variable. Name = Towers, Operation = Subtract, Quantity = 1

The Create Object effect will not work if there is a unit occupying the tile where the object was supposed to be created. We can solve this issue by looping the Create Object effect:

  • Trigger Name: RedKeepBuilder
  • Trigger Starting State: Off
  • Trigger Looping: Yes
  • Condition: Objects in Area. Source Player = Player 2, Object List = Keep, Quantity = 0. Set Area to area around Keep.
  • Effect: Create Object. Source Player = 2, Object List = Keep. As always, set the Location to location of the existing Keep.

Once the Red Keep is built, we need to disable the RedKeepBuilder trigger, the training/attacking triggers and activate the trigger that will fire when the Red Keep is destroyed.

  • Trigger Name: WhenRedKeepIsBuilt
  • Trigger Starting State: Off
  • Trigger Looping: No
  • Condition: Objects in Area. Source Player = Player 2, Object List = Keep, Quantity = 1. Set Area to area round Keep.
  • Effect: Activate Trigger → Activate BlueDestroyRed
  • Effect: Deactivate Trigger → Deactivate RedTrainStable
  • Effect: Deactivate Trigger → Deactivate RedTrainBarracks
  • Effect: Deactivate Trigger → Deactivate RedRedtake
  • Effect: Deactivate Trigger → Deactivate RedKeepBuilder

Now it’s time to create the trigger that will define what happens when the Red Keep is destroyed. This trigger will also loop us back to the WhenBlueKeepIsBuilt trigger.

  • Trigger Name: BlueDestroyRed
  • Trigger Starting State: Off
  • Trigger Looping: No
  • Condition: Own Fewer Object. Object List = Keep, Source Player = Player 2, Quantity = 0. Set Area to the area around the Keep.
  • Effect: Activate Trigger → Activate BlueKeepBuilder
  • Effect: Activate Trigger → Activate WhenBlueKeepIsBuilt

And finally, the looping trigger to make sure Blue Keep is built:

  • Trigger Name: RedKeepBuilder
  • Trigger Starting State: Off
  • Trigger Looping: Yes
  • Condition: Objects in Area. Source Player = Player 1, Object List = Keep, Quantity = 0. Set Area to area around Keep.
  • Effect: Create Object. Source Player = 1, Object List = Keep. As always, set the Location to location of the existing Keep.

When you play this scenario, be sure to set Player 2’s and Player 3’s AI to an immobile AI. I personally prefer ADVANCED Immobile Units AI v1.1.

To summarize, here are the triggers that will need to be created for this scenario:

  • InitialCapture
  • WhenBlueKeepIsBuilt
  • RedTrainStable
  • RedTrainBarracks
  • RedTrainTimer
  • RedRetake
  • RedDestroyBlue
  • RedKeepBuilder
  • WhenRedKeepIsBuilt
  • BlueDestroyRed
  • RedKeepBuilder

Method 2: AI Script
You can use an AI script to reduce the number of triggers and effects. Here’s a script I wrote that commands Red to train only Knight-line and Militia-line units:

(defrule
	(true)
=>
	(set-strategic-number sn-maximum-food-drop-distance 6)
	(set-strategic-number sn-maximum-wood-drop-distance 6)
	(set-strategic-number sn-maximum-gold-drop-distance 6)
	(set-strategic-number sn-maximum-hunt-drop-distance 0)
	(set-strategic-number sn-maximum-stone-drop-distance 6)
	(set-strategic-number sn-food-gatherer-percentage 25)
	(set-strategic-number sn-wood-gatherer-percentage 25)
	(set-strategic-number sn-gold-gatherer-percentage 25)
	(set-strategic-number sn-stone-gatherer-percentage 25)
	(set-strategic-number sn-percent-civilian-gatherers 95)
	(set-strategic-number sn-percent-civilian-builders 5)	
	(set-strategic-number sn-cap-civilian-explorers 0)
	(set-strategic-number sn-percent-civilian-explorers 0) 
	(disable-self)
)

(defrule
	(building-type-count-total farm less-than 6)
	(can-build farm)
=>
	(build farm)
)

(defrule	
	(true)
=>
	(set-strategic-number sn-percent-enemy-sighted-response 100)
	(set-strategic-number sn-hits-before-alliance-change 25)
	(set-strategic-number sn-number-explore-groups 0)
	(set-strategic-number sn-percent-attack-soldiers 0)
	(set-strategic-number sn-task-ungrouped-soldiers 0)
	(set-strategic-number sn-number-attack-groups 0)
	(set-strategic-number sn-enemy-sighted-response-distance 10)
	(set-strategic-number sn-total-number-explorers 0)
	(set-strategic-number sn-relic-return-distance 0)
	(disable-self)
)


(defrule
	;(game-time greater-than 100)
	(unit-type-count-total militiaman-line less-than 10)
	(can-train militiaman-line)
=>
	(train militiaman-line)
	(chat-local-to-self "militiaman-line")
)

(defrule
	(unit-type-count-total knight-line less-than 10)
	(can-train knight-line)
=>
	(train knight-line)
	(chat-local-to-self "knight-line")
)

The trigger setup will be the same as method 1, minus the training triggers (RedTrainBarracks, RedTrainStables, RedTrainTimer). This means that you won’t need the RedBar and RedStables variables, and that overall you’ll have fewer Activate/Deactivate Trigger effects.

To summarize, here are the triggers that will need to be created is we use an AI script in the scenario:

  • InitialCapture
  • WhenBlueKeepIsBuilt
  • RedRetake
  • RedDestroyBlue
  • RedKeepBuilder
  • WhenRedKeepIsBuilt
  • BlueDestroyRed
  • RedKeepBuilder
1 Like