Doom Wiki

Player face grins after restoring savefile

3,479pages on
this wiki
Add New Page
Add New Page Talk0

The status bar face momentarily displays a malicious grin whenever the player obtains a new weapon. After a saved game is loaded, however, the grin also appears the first time any item is picked up, weapon or otherwise.


The malicious grin is triggered during the function ST_updateFaceWidget in st_stuff.c:

   if (plyr->bonuscount)
       // picking up bonus
       doevilgrin = false;
       for (i=0;i<NUMWEAPONS;i++)
           if (oldweaponsowned[i] != plyr->weaponowned[i])
               doevilgrin = true;
               oldweaponsowned[i] = plyr->weaponowned[i];
       if (doevilgrin) 
           // evil grin if just picked up weapon
           priority = 8;
           st_facecount = ST_EVILGRINCOUNT;
           st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;

The bonuscount field is initially set to zero upon creation of the player thing (P_SpawnPlayer in p_mobj.c), but can be assigned a nonzero value by picking up almost any beneficial object (see the function P_TouchSpecialThing in p_inter.c). Because the variable oldweaponsowned is local to st_stuff.c, its value cannot be recorded in the savefile, so it contains uninitialized "junk" values the first time the above conditional statement is executed. Therefore, the bolded test is virtually guaranteed to return TRUE and produce a grinning face in that instance.

This bug can also manifest itself when the IDKFA or IDFA cheat code is invoked, because the cheats give weapons to the player by directly updating plyr->weaponowned, bypassing the status bar face completely (see the function ST_Responder in st_stuff.c). The next time the player collects any item, the status bar will then "notice" the change in weapons owned and the grinning face will be displayed at that time, even if the new item being collected is a weapon already possessed or an unrelated thing like a health bonus.

Also on Fandom

Random Wiki