Overview
In this Game Recipe, we will be going over how to gate progression by forcing the player to defeat enemies. We will be using a zone to prevent progression, however this can be achieved in many other ways. Some examples include using actors to block areas, changing tiles to reveal hidden paths, or teleporting the player.
Requirements
- A map with enemies to defeat.
- A method of defeating enemies for the player (Weapons, Traps, etc).
- A path to be blocked until enemies are defeated.
Setup
- Open the map you want to battle enemies on.
- Edit the map properties (Right Click Map > Properties).
- Select the Edit Variables button under Map Variables.
- Click the Add to Map Variables button.
- Set the Name of the variable and keep the Default Value set to 0. In this example we are going to set the Name to Enemies_Defeated.
- Select the Edit Variables button under Map Variables.
- Close the Map Variables window and press OK on the Map Properties window to save your changes.
- Using the Pointer or Actor tool, edit the properties of the enemy the player will be defeating.**If your actor does not allow changes in template, select the Edit button next to Template.**
- Select the Add button under the Triggers section.
- Select the Defeated / Destroyed trigger and click the OK button.
- In the Defeated / Destroyed window that appears, click the OK button.
- The scripting window should pop up. Place a Map Variable Operation event, you may need to enable the Advanced scripting complexity option, or simply search for it using the search feature.
- Select the Map we are working with.
- Select the Map Variable we created, “Defeated_Enemies”.
- Set the Value drop-down to Add, then put 1 in the box.
- Press OK to save and close the event.
- Press OK to save and close the scripting window.
- Press OK to save and close the actor window.(Pressing OK to save and close the second actor window if needed)
- Select the Add button under the Triggers section.
- Select the Zone tool and place a zone in the area you want to block player access to.
- Set the Display Name for the zone.
- Enable the Act as Blocking as Well. Optionally you can click on the Edit Blocked Templates to allow certain actors (Such as enemies) through this zone.
- Select the Collided With Actor (Player) scripting trigger, then click the Edit Script button.
- Place a Comparison Branch event.
- For Expression, select the use-value box.
- Select the Map Variable use-value.
- Select the Map we are working with.
- Select the Map Variable we created, “Defeated_Enemies”.
- Set the Operator drop-down to >= (Greater Than or Equal).
- Set the Value to the number of enemies that have to be defeated.
- Press OK to save and close the event.
- With the Comparison Branch event selected, add an Enable/Disable Blocking of Zone event.
- For Zone, select (This).
- For Blocking, select Unblock.
- Press OK to save and close the event.
- Press OK to save and close the script.
- Place a Comparison Branch event.
- Press OK to save and close the zone.
- Test your project to make sure that the progression gate works properly.