Page 1 of 1
Keybind for showing secrets (am_map_secrets)
Posted: Fri Jan 21, 2022 7:54 pm
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
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
, other with
).
I was not able to figure out how to bind this, so help would be appreciated.
Thanks.
Re: Keybind for showing secrets (am_map_secrets)
Posted: Fri Jan 21, 2022 11:22 pm
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.
Re: Keybind for showing secrets (am_map_secrets)
Posted: Sat Jan 22, 2022 10:19 am
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.
Re: Keybind for showing secrets (am_map_secrets)
Posted: Sat Jan 22, 2022 9:34 pm
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.
Re: Keybind for showing secrets (am_map_secrets)
Posted: Sun Jan 23, 2022 8:04 am
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.