Bitflags, or bit fields, are handy ways to compactly store data in a variable.

Since DM only supports floating point numbers, we are restricted to 24 bits (23 explicitly stored) per variable.

#define DISABILITY_EYE (1<<1) // 1
#define DISABILITY_ARM (1<<2) // 2
#define DISABILITY_LEG (1<<3) // 4

/mob/var/disabilities = 0

	disabilities |= dis

	if( disabilities & dis )
		return TRUE
		return FALSE

	disabilities &= ~dis

For a closer look at the binary math behind this, check out tgstation's article.


Using the above code snippet as a base, try implementing the ability to toggle a flag easily.

Hint: What other binary operators are there?