Difference between revisions of "Talk:Lighting effects"

From DoomWiki.org

(More use of source tags not found by the supposed almighty search function)
(HTTP->HTTPS in doomworld.com links. See here and here.)
Line 1: Line 1:
Recent dwforums post mentioning this article: [http://www.doomworld.com/vb/post/1278640].  Changing it would just replace one unreferenced statement with another — a source code excerpt would be more reassuring, but I can't find one.    [[User:Ryan W|Ryan W]] ([[User talk:Ryan W|talk]]) 16:27, 5 July 2014 (UTC)
+
Recent dwforums post mentioning this article: [https://www.doomworld.com/vb/post/1278640].  Changing it would just replace one unreferenced statement with another — a source code excerpt would be more reassuring, but I can't find one.    [[User:Ryan W|Ryan W]] ([[User talk:Ryan W|talk]]) 16:27, 5 July 2014 (UTC)
  
 
: This is the function which [[Thinker|thinks]] for a fire flicker effect every tic:
 
: This is the function which [[Thinker|thinks]] for a fire flicker effect every tic:

Revision as of 02:29, 14 December 2019

Recent dwforums post mentioning this article: [1].  Changing it would just replace one unreferenced statement with another — a source code excerpt would be more reassuring, but I can't find one.    Ryan W (talk) 16:27, 5 July 2014 (UTC)

This is the function which thinks for a fire flicker effect every tic:
 //
 // T_FireFlicker
 //
 void T_FireFlicker (fireflicker_t* flick)
 {
     int	amount;
	
     if (--flick->count)
	 return;
	
     amount = (P_Random()&3)*16;
    
     if (flick->sector->lightlevel - amount < flick->minlight)
	 flick->sector->lightlevel = flick->minlight;
     else
 	flick->sector->lightlevel = flick->maxlight - amount;
 
     flick->count = 4;
 }
And this is the function that spawns it at level start.
 //
 // P_SpawnFireFlicker
 //
 void P_SpawnFireFlicker (sector_t*	sector)
 {
     fireflicker_t*	flick;
 	
     // Note that we are resetting sector attributes.
     // Nothing special about it during gameplay.
     sector->special = 0; 
 	
     flick = Z_Malloc ( sizeof(*flick), PU_LEVSPEC, 0);
 
     P_AddThinker (&flick->thinker);
 
     flick->thinker.function.acp1 = (actionf_p1) T_FireFlicker;
     flick->sector = sector;
     flick->maxlight = sector->lightlevel;
     flick->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel)+16;
     flick->count = 4;
 }
The light can be seen to flicker to a random value between the sector's light and the minimum surrounding light plus 16 every 4 tics. It does so only in steps of 16 (the minimum amount of difference between two light levels in vanilla Doom).
--Quasar (talk) 19:45, 5 July 2014 (UTC)