Detecting if a DMFLAG is off or on.

Discuss all aspects related to modding Zandronum here.
Post Reply
Mr. Satan
New User
Posts: 10
Joined: Thu Oct 15, 2015 7:28 am

Detecting if a DMFLAG is off or on.

#1

Post by Mr. Satan » Thu Oct 29, 2015 4:21 pm

How would you go about detecting whether a particular DMFLAG (No Monsters for example) is off or on from the number outputted when you GetCvar DMFlags?

User avatar
Ænima
Addicted to Zandronum
Posts: 3583
Joined: Tue Jun 05, 2012 6:12 pm

RE: Detecting if a DMFLAG is off or on.

#2

Post by Ænima » Thu Oct 29, 2015 4:41 pm

Converting the number to binary might help.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

User avatar
Empyre
Zandrone
Posts: 1316
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

RE: Detecting if a DMFLAG is off or on.

#3

Post by Empyre » Thu Oct 29, 2015 4:56 pm

Do you have access to an AND operator in your expressions? If so, find out the number for that DMFLAG and then take the GetCVar DMFlags number and AND it with the number for that particular DMFLAG. The result will be 0 if the flag is off and the DMFLAG's number if it is on.
"For the world is hollow, and I have touched the sky."

User avatar
Dusk
Developer
Posts: 581
Joined: Thu May 24, 2012 9:59 pm
Location: Turku

RE: Detecting if a DMFLAG is off or on.

#4

Post by Dusk » Thu Oct 29, 2015 5:45 pm

Code: Select all

if (GetCVar ("sv_nomonsters"))
{
    // ...
}

TerminusEst13
Retired Staff / Community Team Member
Posts: 865
Joined: Tue Jun 05, 2012 11:06 pm

RE: Detecting if a DMFLAG is off or on.

#5

Post by TerminusEst13 » Thu Oct 29, 2015 7:01 pm

Every sum total of dmflags or dmflags2 or etc is the result of singular cvars being turned on and off. The question is just checking for that flag.

dmflags 4096, for example, means sv_nomonsters is 1. dmflags 16384 means sv_itemrespawn is 1. Etc.
The Ranger - New class for HeXen.
ZDoom Wars - I drew some pictures.
Samsara - Some class-based mod I guess?
Metroid: Dreadnought - I am a dumb fanboy.
DemonSteele - ~come with me to anime world~

Post Reply