Making a kill counter with mtl_trigger_counter

Making a kill counter with mtl_trigger_counter
Making a kill counter with mtl_trigger_counter

Table of contents:

1. Introduction

Remember that part in Lambda Core where Gordon had to kill 4 alien grunts before a frightened scientist would open the door? Let's recreate that - but, instead of only triggering something when all grunts are killed, we will also display a unique text message after every kill.

In the original level, the grunts, when killed, would trigger a multisource, which activated the door-opening sequence once all grunts were killed. Instead of a multisource, a game_counter with a target count of 4 would also have worked.

In our map we will use an mtl_trigger_counter instead. This is essentially a multi-target variant of game_counter that can trigger multiple targets at specific counter values:

Alien grunts triggering a counter, which triggers messages and a door
Alien grunts triggering a counter, which triggers messages and a door

2. Entity setup

First, create 4 monster_alien_grunt entities and set their properties as following:

property value
TriggerTarget agrunt_kill_counter
Trigger Condition Death

Then create an mtl_trigger_counter with the following properties:

property value
Targetname agrunt_kill_counter
Trigger mode Increment when triggered
Initial counter value 0

Now disable SmartEdit mode and add the following key/value pairs to the mtl_trigger_counter:

property value
msg_kill_11
msg_kill_22
msg_kill_33
msg_kill_4, +door14

The keys are targets, and the values are the counter values at which those targets will be triggered.

Note the final target: MESS provides several convenient 'target patterns', such as the ability to trigger multiple targets by using a comma-separated list, or the ability to send an 'on' signal to an entity by adding a + in front of the target's name. So instead of having to create a multi_manager that triggers msg_kill4 and a trigger_relay that sends an 'on' signal to door1, MESS will automatically generate those entities for us.

Finally, create 4 game_text entities named 'msg_kill_1', 'msg_kill_2', 'msg_kill_3' and 'msg_kill_4', give them some interesting messages (be sure to enable their 'All players' flag), and create a door named 'door1'.

Now, each time we kill an alien grunt, it will trigger our mtl_trigger_counter, incrementing its counter. When the first alien grunt is killed, the first kill message is displayed. When the second grunt is killed, the second message is shown, and so on. When the fourth grunt is killed, the final message is shown, and the door is opened:

Congratulations, you did it!
Congratulations, you did it!

3. Example map

Example map: