Keybind for showing secrets (am_map_secrets)

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
User avatar
SilverBlue
Posts: 3
Joined: Fri Jan 21, 2022 6:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Keybind for showing secrets (am_map_secrets)

Post by SilverBlue »

Hello everybody,

I have a specific question about GZDoom:
Is it possible to map a keybind, so that when I press a given button it will show me the secrets on the map and when pressing it again it will hide them? (I have set the unfound secrets with a different color)
I know there is a integer on config called

Code: Select all

am_map_secrets
which can have values 0 - 2.

What I am asking is would it be possible to map this to a button, that when pressed, it will change it´s value from 1 (default) to 2? And by pressing it again changing it back from 2 to 1?
If it would not be technically possible, I would not mind having a 2 different keys for this (one bind with

Code: Select all

am_map_secrets=1
, other with

Code: Select all

am_map_secrets=2
).

I was not able to figure out how to bind this, so help would be appreciated.
Thanks.
User avatar
Rachael
Admin
Posts: 12966
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Keybind for showing secrets (am_map_secrets)

Post by Rachael »

Code: Select all

mapbind <key> "eval - 3 $am_map_secrets am_map_secrets"
eval works a little bit weirdly in that the operator precedes both of the operands - and in this case one of them is the existing cvar $am_map_secrets (which is an alias to internally evaluate to the value of the cvar itself). Then putting a cvar at the end stores the value of that cvar. This works even if the cvar is used as an operand - which will then cause the value to be stored after the eval expression is completed.

Since you're switching between 1 and 2, the most effective way to do that is to subtract either of them from 3.

In order to switch between the two though, am_map_secrets will have to already be 1 or 2 - or else it will just subtract its value whatever it happens to be from 3 and store that result instead.

Also you may notice I used mapbind instead of bind - that causes the key to be bound only when the map is open - which means you can reuse that key for something else in normal gameplay. If for whatever reason you don't want this behavior you can use bind instead.

Of course, replace <key> with the desired key, without the quotation <> marks.
User avatar
SilverBlue
Posts: 3
Joined: Fri Jan 21, 2022 6:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Keybind for showing secrets (am_map_secrets)

Post by SilverBlue »

Thank you for the help.

I was able to execute that command and it did add the keybind to the gzdoom.ini, but when I am in the map and I press the button, nothing happens.
I already have the am_map_secrets set to 1 by default, am I doing something wrong?
Should it show the secrets even when the map portion has not been revealed yet (ie. an the beginning of the level)?

I am uploading my gzdoom file just to be sure.
You do not have the required permissions to view the files attached to this post.
User avatar
Rachael
Admin
Posts: 12966
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Keybind for showing secrets (am_map_secrets)

Post by Rachael »

I think a lot of that depends on whether you have the automap cheat turned on or if you have the computer area map powerup. Otherwise, I am not sure. I gave you the console details about flipping a variable from one value to another using a keypress and I am certain all that information is correct - but beyond that, I don't know what exactly is going on with your automap.
User avatar
SilverBlue
Posts: 3
Joined: Fri Jan 21, 2022 6:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Keybind for showing secrets (am_map_secrets)

Post by SilverBlue »

Gotcha.

I got it working!
You were right, I needed to switch automap cheat from 0 to 1, then I could use your command, and return it to the default state by changing automap back to 0, reverting the map back to it´s "default" state (you see only already discovered parts, "fog of war" is back on).

These are the bindings I have used in the end (I decided to use Insert, Home and Page Up buttons, as they are fairly out of the way and I am not gonna use this often):

Code: Select all

Home=eval - 1 $am_cheat am_cheat
PgUp=eval - 3 $am_map_secrets am_map_secrets
Ins=eval + 1 $am_cheat am_cheat
Thank you again for your help.

Return to “General”