Adding Muzzle Flashes that lights up the world

From Valve Developer Community
Revision as of 05:59, 18 October 2024 by Rixzzy (talk | contribs) (Edited this page)
Jump to navigation Jump to search

In this tutorial, I will show you how to add dlights to a Half Life 1 Mod (GoldSrc mod). dlights are better than elights but they take away your PC’s performance.

Let’s start. Well navigate to ev_hldm.h and scroll to the bottom. After that, add this:

void EV_HLDM_MuzzleFlash( vec3_t pos, float amount );

// make a dlight first dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight(0);

// Original color values int originalR = 231; int originalG = 219; int originalB = 14;

// Randomize color components within the range of +/- 20 dl->color.r = originalR + gEngfuncs.pfnRandomLong(-20, 20); dl->color.g = originalG + gEngfuncs.pfnRandomLong(-20, 20); dl->color.b = originalB + gEngfuncs.pfnRandomLong(0, 0);

// Randomize the die value by +/- 0.01 dl->die = gEngfuncs.GetClientTime() + 0.05 + gEngfuncs.pfnRandomFloat(-0.01, 0.01);

// Randomize the radius based on amount dl->radius = gEngfuncs.pfnRandomFloat(245.0f, 256.0f);

// Randomize the decay value dl->decay = gEngfuncs.pfnRandomFloat(400.0f, 600.0f);