Difference between revisions of "Talk:Lighting effects"

From DoomWiki.org

("17: fire flicker")
 
(Code)
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: [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)
 +
 +
: This is the function which [[Thinker|thinks]] for a fire flicker effect every tic:
 +
<source lang="C">
 +
//
 +
// 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;
 +
}
 +
</source>
 +
: And this is the function that spawns it at level start.
 +
<source lang="C">
 +
//
 +
// 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;
 +
}
 +
</source>
 +
: 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.
 +
: --[[User:Quasar|Quasar]] ([[User talk:Quasar|talk]]) 19:45, 5 July 2014 (UTC)

Revision as of 14:45, 5 July 2014

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:

<source lang="C"> // // 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;

} </source>

And this is the function that spawns it at level start.

<source lang="C"> // // 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;

} </source>

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.
--Quasar (talk) 19:45, 5 July 2014 (UTC)