Add these two to the cshift_t struct:
Code: Select all
double time;
int initialpct;
Code: Select all
cl.cshifts[CSHIFT_DAMAGE].initialpct = cl.cshifts[CSHIFT_DAMAGE].percent;
cl.cshifts[CSHIFT_DAMAGE].time = cl.time;
Code: Select all
cl.cshifts[CSHIFT_BONUS].initialpct = 50;
cl.cshifts[CSHIFT_BONUS].time = cl.time;
Code: Select all
void V_DropCShift (cshift_t *cs, float droprate)
{
if (cs->time < 0)
cs->percent = 0;
else if ((cs->percent = cs->initialpct - (cl.time - cs->time) * droprate) <= 0)
{
cs->percent = 0;
cs->time = -1;
}
}
Code: Select all
// drop the damage and bonus values
V_DropCShift (&cl.cshifts[CSHIFT_DAMAGE], 150);
V_DropCShift (&cl.cshifts[CSHIFT_BONUS], 100);
You can also do the same with dynamic lights - store spawntime as cl.time in CL_AllocDlight, set initialradius to the same as radius for each light, then radius in CL_DecayLights becomes "dl->radius = dl->initialradius - (cl.time - dl->spawntime) * dl->decay;"