- // do trails
- if (e->render.flags & RENDER_GLOWTRAIL)
- trailtype = 9;
- if (trailtype >= 0)
- CL_RocketTrail(e->persistent.trail_origin, origin, trailtype, e->state_current.glowcolor, e);
- VectorCopy(origin, e->persistent.trail_origin);
- // tenebrae's sprites are all additive mode (weird)
- if (gamemode == GAME_TENEBRAE && e->render.model && e->render.model->type == mod_sprite)
- e->render.effects |= EF_ADDITIVE;
- // player model is only shown with chase_active on
- if (!e->csqc)
- if (e->state_current.number == cl.viewentity)
- e->render.flags |= RENDER_EXTERIORMODEL;
- // transparent stuff can't be lit during the opaque stage
- if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
- e->render.flags |= RENDER_TRANSPARENT;
- // double sided rendering mode causes backfaces to be visible
- // (mostly useful on transparent stuff)
- if (e->render.effects & EF_DOUBLESIDED)
- e->render.flags |= RENDER_NOCULLFACE;
- // either fullbright or lit
- if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
- e->render.flags |= RENDER_LIGHT;
- // hide player shadow during intermission or nehahra movie
- if (!(e->render.effects & EF_NOSHADOW)
- && !(e->render.flags & (RENDER_VIEWMODEL | RENDER_TRANSPARENT))
- && (!(e->render.flags & RENDER_EXTERIORMODEL) || (!cl.intermission && cl.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
- e->render.flags |= RENDER_SHADOW;
- // as soon as player is known we can call V_CalcRefDef
- if (!csqc_loaded)
- if (e->state_current.number == cl.viewentity)
- V_CalcRefdef();
- if (e->render.model && e->render.model->name[0] == '*' && e->render.model->TraceBox)
- cl_brushmodel_entities[cl_num_brushmodel_entities++] = e->state_current.number;
- // don't show entities with no modelindex (note: this still shows
- // entities which have a modelindex that resolved to a NULL model)
- if (e->render.model && !(e->render.effects & EF_NODRAW) && r_refdef.numentities < r_refdef.maxentities)
- r_refdef.entities[r_refdef.numentities++] = &e->render;
- //if (cl.viewentity && e->state_current.number == cl.viewentity)
- // Matrix4x4_Print(&e->render.matrix);
+ if (e->render.effects & EF_FLAME)
+ CL_ParticleTrail(EFFECT_EF_FLAME, 0, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false);
+ if (e->render.effects & EF_STARDUST)
+ CL_ParticleTrail(EFFECT_EF_STARDUST, 0, origin, origin, vec3_origin, vec3_origin, NULL, 0, true, false);
+ }
+ // muzzleflash fades over time, and is offset a bit
+ if (e->persistent.muzzleflash > 0 && r_refdef.numlights < MAX_DLIGHTS)
+ {
+ vec3_t v2;
+ vec3_t color;
+ trace_t trace;
+ matrix4x4_t tempmatrix;
+ Matrix4x4_Transform(&e->render.matrix, muzzleflashorigin, v2);
+ trace = CL_Move(origin, vec3_origin, vec3_origin, v2, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, true, false, NULL, false);
+ Matrix4x4_Normalize(&tempmatrix, &e->render.matrix);
+ Matrix4x4_SetOrigin(&tempmatrix, trace.endpos[0], trace.endpos[1], trace.endpos[2]);
+ Matrix4x4_Scale(&tempmatrix, 150, 1);
+ VectorSet(color, e->persistent.muzzleflash * 4.0f, e->persistent.muzzleflash * 4.0f, e->persistent.muzzleflash * 4.0f);
+ R_RTLight_Update(&r_refdef.lights[r_refdef.numlights++], false, &tempmatrix, color, -1, NULL, true, 0, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
+ }
+ // LordHavoc: if the model has no flags, don't check each
+ if (e->render.model && e->render.model->flags && (!e->state_current.tagentity && !(e->render.flags & RENDER_VIEWMODEL)))
+ {
+ if (e->render.model->flags & EF_GIB)
+ trailtype = EFFECT_TR_BLOOD;
+ else if (e->render.model->flags & EF_ZOMGIB)
+ trailtype = EFFECT_TR_SLIGHTBLOOD;
+ else if (e->render.model->flags & EF_TRACER)
+ trailtype = EFFECT_TR_WIZSPIKE;
+ else if (e->render.model->flags & EF_TRACER2)
+ trailtype = EFFECT_TR_KNIGHTSPIKE;
+ else if (e->render.model->flags & EF_ROCKET)
+ trailtype = EFFECT_TR_ROCKET;
+ else if (e->render.model->flags & EF_GRENADE)
+ {
+ // LordHavoc: e->render.alpha == -1 is for Nehahra dem compatibility (cigar smoke)
+ trailtype = e->render.alpha == -1 ? EFFECT_TR_NEHAHRASMOKE : EFFECT_TR_GRENADE;
+ }
+ else if (e->render.model->flags & EF_TRACER3)
+ trailtype = EFFECT_TR_VORESPIKE;
+ }
+ // LordHavoc: customizable glow
+ if (e->state_current.glowsize)
+ {
+ // * 4 for the expansion from 0-255 to 0-1023 range,
+ // / 255 to scale down byte colors
+ dlightradius = max(dlightradius, e->state_current.glowsize * 4);
+ VectorMA(dlightcolor, (1.0f / 255.0f), (unsigned char *)&palette_complete[e->state_current.glowcolor], dlightcolor);