Secrets: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Dragofer (talk | contribs)
mNo edit summary
Dragofer (talk | contribs)
mNo edit summary
Line 10: Line 10:
== Setting up a secret ==
== Setting up a secret ==
=== Frob-based secret ===
=== Frob-based secret ===
Often a secret is just a well-hidden piece of loot or gear that the player can frob. Setting the spawnarg  
Often a secret is just a piece of loot or gear that the player can frob. Setting the spawnarg  
  "secret" "1"  
  "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.
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.

Revision as of 17:07, 27 February 2021

Secrets

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

atdm:secret

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:

atdm:secret_messages

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:

atdm:secrets_list

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


Scripting

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 )