Key pickup resets palette



In Doom, picking up multiple items in quick succession results in the game's palette tint growing increasingly more yellow before fading back to normal. If the player picks up a key, however, the palette tint is immediately reset back to its lowest level of yellow instead of fading normally.

Technical
The level of yellow palette tint for item pickups is controlled in Doom by a variable called player->bonuscount. Normally this variable is 0, but when it is greater than 0, it causes the game to display a yellow palette tint that grows increasingly yellow based on how large player->bonuscount is. player->bonuscount also decrements by 1 every tic until it returns to 0, causing the yellow palette tint to fade back to normal.

Doom has three separate functions for handling item pickups: P_TouchSpecialThing, P_GiveWeapon, and P_GiveCard. The first handles all pickups, but it calls the second to specially handle weapon pickups and the third to specially handle key pickups.

When a player picks up an item, P_TouchSpecialThing will call the following code at the end of the function:

player->bonuscount += BONUSADD;

Where BONUSADD is defined as 6. If the item is a key, however, the game will first call P_GiveCard</tt>, which contains the following:

player->bonuscount = BONUSADD;

Instead of adding 6 to player->bonuscount</tt>, this function sets it to 6 directly. This means that even if player->bonuscount</tt> is larger than 6 when a key is picked up, it will immediately drop to 6, and the yellow palette tint will decrease accordingly. (P_TouchSpecialThing</tt> will then immediately add another 6 to player->bonuscount</tt>, resulting in a final value of 12. This behavior also means that any key pickup will result in a yellow palette tint lasting twice as long as a normal single item pickup.)