From The DarkMod Wiki
Revision as of 18:05, 27 February 2021 by Dragofer (talk | contribs)
Jump to navigationJump to search


This article describes a feature that is to be added in TDM 2.10.

Secrets are typically well-hidden or hard to reach items or locations. You might like to recognise the player's achievement in finding a secret by showing a message with a sound, and show how many secrets the player has found at the end of the mission.

As of 2.10, this can be done easily with spawnargs or secret-related entities and no longer requires the mapper to use scripting or modify GUI files.

Setting up a secret

Frob-based secret

Often a secret is just a piece of loot or gear that the player can frob. Setting the spawnarg

"secret" "1" 

will mark it as a secret, and it will be considered found when the player frobs it. Each entity with this spawnarg will increase the total number of secrets in the map by 1, regardless of whether the player can frob the entity.

Trigger-based secret

An alternative way to setup a secret is by creating an


entity, found in the Info/ folder. When this entity is triggered by something, for example a lever, a trigger_once brush or as the "completion target" of an objective, the player is considered to have found a secret.

By default, each of these atdm:secret entities can only be triggered once and will add 1 to the total number of secrets in the map.

You can reuse an atdm:secret entity for multiple secrets by increasing the "count" spawnarg, but you should make sure that each secret can only send one trigger. A trigger_once brush would be suitable, but not a button or reversible objective.

The message

Whenever the player finds a secret a message will be shown and a sound will play. The message & sound change when the player has found all secrets.

You can customise or disable this by placing an entity of the following type in your map (found in the Info folder) and changing its spawnargs:


Spawnargs of the message entity

It offers the following spawnargs:

  • message and sound - These spawnargs determine whether and when a message or sound will appear.
    • 0 = never
    • 1 = whenever the player finds a secret (default)
    • 2 = only when the player has found all secrets
  • delay - Wait this amount of time in seconds after finding a secret before showing the message and starting the sound.
  • s_volume - This allows to increase or decrease the volume of the sound in dB.

The following spawnargs have either "found" or "found_all" in their names. This allows you to configure 2 different messages, depending on whether the player has found some or all secrets.

    • gui - which GUI to use for the message, i.e. a scroll or only white text. This also determines the position of the message.
    • show - how long to show the message.
    • lines - how many lines the message is long (affects positioning of the lines).
    • text - the text shown by the message.
    • snd - the sound to play. It should not loop

The text spawnargs deserve special mention since they support keywords that are automatically converted by the script:

  • ${numFound} - how many secrets the player has found so far.
  • ${numTotal} - how many secrets there are in total.
  • ${numRemaining} - how many secrets the player hasn't found yet.
  • ${s} - this letter only appears if the player has found 2 or more secrets.

As an example, these are the default text spawnarg values:

  • "text_found" "You found ${numFound} secret${s}, ${numRemaining} to go!"
  • "text_found_all" "Congratulations! You have found all ${numTotal} secrets!"

Listing all secrets

You can find out which entities are considered as secrets by the game at any time by placing this entity from the Info folder in your map:


At map start, it will post the names of all "secret" entities near the bottom of the console log and by how much each one increases the total number of secrets, i.e.

Secret, counts as 1: golden_chalice_1
Secret, counts as 1: atdm_secret_1
Secret, counts as 2: atdm_secret_4


The secrets system supports the following script events, allowing you to check the current status or even make your own system without using anything else mentioned in this article:

getMissionStatistic( "secretsFound" )
getMissionStatistic( "secretsTotal" )
setSecretsFound( float secrets )
setSecretsTotal( float secrets )

Updating your mission to use the secrets system

If you already have your own system for tracking secrets, you may want to update your FM so that secrets are shown on the statistics screen. This can be done ad hoc with little effort by adding the following to your script:

  • setSecretsTotal() at map start (i.e. in void main()), passing the total number of secrets.
  • setSecretsFound() when your script detects that a secret has been found, passing the variable for the number of secrets found so far.