Key pickup resets palette



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

Technical
The level of yellow palette 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 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 to fade back to normal.

Doom has three separate functions for handling item pickups: P_GiveWeapon, P_TouchSpecialThing, and P_GiveCard. The first handles weapon pickups, the third handles key pickups, and the second handles all other pickups.

The first two contain code like the following:

player->bonuscount += BONUSADD;

Where BONUSADD is defined as 6. P_GiveCard, however, contains the following:

player->bonuscount = BONUSADD;

Therefore, instead of adding 6 to player->bonuscount</tt>, this function sets it to 6 directly. This means that if player->bonuscount</tt> is much larger than 6 when a key is picked up, it will immediately drop to 6, and the yellow palette will drop to the lowest level along with it.