From db48e97a6b97a5736ebe061d76080cffea67257b Mon Sep 17 00:00:00 2001 From: Bryce Hutchings Date: Fri, 21 Jun 2002 04:11:34 +0000 Subject: [PATCH] fog laser --- reaction/cgame/cg_effects.c | 65 +++++++++++++++++++++++++++++++++++++ reaction/cgame/cg_ents.c | 13 +++++--- reaction/cgame/cg_local.h | 4 +++ reaction/cgame/cg_weapons.c | 12 +++++++ 4 files changed, 89 insertions(+), 5 deletions(-) diff --git a/reaction/cgame/cg_effects.c b/reaction/cgame/cg_effects.c index 1382d2bb..6c4d0f1f 100644 --- a/reaction/cgame/cg_effects.c +++ b/reaction/cgame/cg_effects.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.36 2002/06/21 04:11:34 niceass +// fog laser +// // Revision 1.35 2002/06/16 20:06:13 jbravo // Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap" // @@ -1148,3 +1151,65 @@ void CG_Pressure(vec3_t origin, vec3_t dir, int type, int speed) le->startTime = cg.time; le->endTime = le->startTime + 10000; } + +static void CG_VisibleLaser( vec3_t start, vec3_t finish ) { + refEntity_t re; + +// re.shaderTime = cg.time / 1000.0f; + re.reType = RT_RAIL_CORE; + re.customShader = cgs.media.railCoreShader; + + VectorCopy( start, re.origin ); + VectorCopy( finish, re.oldorigin ); + + re.shaderRGBA[0] = 255; + re.shaderRGBA[1] = 0; + re.shaderRGBA[2] = 0; + re.shaderRGBA[3] = 128; + + AxisClear( re.axis ); + + trap_R_AddRefEntityToScene( &re ); +} + + +void CG_DrawVisibleLaser( vec3_t origin, int clientNum) { + int num, sourceContentType, destContentType; + centity_t *cent; + vec3_t destination, start, end; + trace_t trace; + + for (num = 0; num < cg.snap->numEntities; num++) { + cent = &cg_entities[cg.snap->entities[num].number]; + if (cent->currentState.eType == ET_LASER && + cent->currentState.clientNum == clientNum ) { + VectorCopy(cent->lerpOrigin, destination); + break; + } + } + + VectorCopy(origin, start); + VectorCopy(destination, end); + + // Failed to find a laser dot that the player owns. + if (num == cg.snap->numEntities) + return; + + sourceContentType = trap_CM_PointContents(start, 0); + destContentType = trap_CM_PointContents(end, 0); + + // do a complete bubble trail if necessary + if ((sourceContentType == destContentType) && (sourceContentType & CONTENTS_FOG)) { + CG_VisibleLaser(start, end); + } + // bubble trail from water into air + else if ((sourceContentType & CONTENTS_FOG)) { + trap_CM_BoxTrace(&trace, end, start, NULL, NULL, 0, CONTENTS_FOG); + CG_VisibleLaser(start, trace.endpos); + } + // bubble trail from air into water + else if ((destContentType & CONTENTS_FOG)) { + trap_CM_BoxTrace(&trace, start, end, NULL, NULL, 0, CONTENTS_FOG); + CG_VisibleLaser(trace.endpos, end); + } +} diff --git a/reaction/cgame/cg_ents.c b/reaction/cgame/cg_ents.c index fdf3ac72..3b0b66f0 100644 --- a/reaction/cgame/cg_ents.c +++ b/reaction/cgame/cg_ents.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.28 2002/06/21 04:11:17 niceass +// fog laser +// // Revision 1.27 2002/06/16 20:06:13 jbravo // Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap" // @@ -1096,15 +1099,15 @@ static void CG_LaserSight(centity_t * cent) VectorCopy(cent->lerpOrigin, ent.oldorigin); if (cent->currentState.eventParm == 1) { - // NiceAss: Testing for foglasers... maybe i'll get this to work some day - //if (cent->currentState.eFlags & EF_FIRING) { - // CG_LightningBolt( cent, cent->lerpOrigin ); - //} ent.reType = RT_SPRITE; ent.radius = 3; ent.rotation = 0; ent.customShader = cgs.media.laserShader; - trap_R_AddRefEntityToScene(&ent); + + // NiceAss: If the dot is in the fog, don't draw it unless it's your laser. + if ( !(trap_CM_PointContents(cent->lerpOrigin, 0) & CONTENTS_FOG) || + cent->currentState.clientNum == cg.clientNum) + trap_R_AddRefEntityToScene(&ent); } else { trap_R_AddLightToScene(ent.origin, 200, 1, 1, 1); } diff --git a/reaction/cgame/cg_local.h b/reaction/cgame/cg_local.h index c44afda6..8227fa19 100644 --- a/reaction/cgame/cg_local.h +++ b/reaction/cgame/cg_local.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.98 2002/06/21 04:10:59 niceass +// fog laser +// // Revision 1.97 2002/06/19 05:17:57 niceass // scoreboard stuff // @@ -1902,6 +1905,7 @@ localEntity_t *CG_SmokePuff(const vec3_t p, void CG_BubbleTrail(vec3_t start, vec3_t end, float spacing); void CG_SpawnEffect(vec3_t org); void CG_ScorePlum(int client, vec3_t org, int score); +void CG_DrawVisibleLaser( vec3_t origin, int clientNum); //Blaze: for explosions void CG_Particle_Bleed(qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration); diff --git a/reaction/cgame/cg_weapons.c b/reaction/cgame/cg_weapons.c index 573f8eb4..0eaac5fd 100644 --- a/reaction/cgame/cg_weapons.c +++ b/reaction/cgame/cg_weapons.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.84 2002/06/21 04:09:44 niceass +// fog laser +// // Revision 1.83 2002/06/17 03:53:31 niceass // m4 muzzle flash is smaller // @@ -1723,6 +1726,15 @@ void CG_AddPlayerWeapon(refEntity_t * parent, playerState_t * ps, centity_t * ce cent->ejectBrassTime = 0; } + + + if ( cent->currentState.number != cg.predictedPlayerState.clientNum ) { + refEntity_t muzzle; + memset(&muzzle, 0, sizeof(muzzle)); + CG_PositionEntityOnTag(&muzzle, &gun, weapon->weaponModel, "tag_flash"); + CG_DrawVisibleLaser(muzzle.origin, cent->currentState.clientNum); + } + //Elder: re-added to fix loss of muzzle flashes! // impulse flash