diff options
Diffstat (limited to 'src/cgame/cg_weapons.c')
-rw-r--r-- | src/cgame/cg_weapons.c | 77 |
1 files changed, 71 insertions, 6 deletions
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index fc425d7f..64b36c96 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -291,6 +291,71 @@ void CG_RailTrail( vec3_t start, vec3_t end ) /* ========================== +CG_TeslaTrail +========================== +*/ +void CG_TeslaTrail( vec3_t start, vec3_t end ) +{ + int i; + vec3_t seg_start, seg_end, delta, dir, perpen, tangent; + float distance; + + localEntity_t *le; + refEntity_t *re; + + start[ 2 ] += 12; //nudge up a bit so the bolt comes from the sphere + + VectorCopy( start, seg_start ); + VectorSubtract( end, start, delta ); + distance = VectorLength( delta ); + VectorNormalize2( delta, dir ); + PerpendicularVector( perpen, dir ); + + //add a bunch of bolt segments + for( i = 1; i <= cg_teslaSegments.integer; i++ ) + { + le = CG_AllocLocalEntity(); + re = &le->refEntity; + + le->leType = LE_FADE_RGB; + le->startTime = cg.time; + le->endTime = cg.time + cg_teslaTrailTime.value; + le->lifeRate = 1.0 / ( le->endTime - le->startTime ); + + re->shaderTime = cg.time / 1000.0f; + re->reType = RT_RAIL_CORE; + re->customShader = cgs.media.lightningShader; + + VectorCopy( seg_start, re->origin ); + + if( i != cg_teslaSegments.integer ) + { + VectorMA( start, i * ( distance / cg_teslaSegments.integer ), dir, seg_end ); + RotatePointAroundVector( tangent, dir, perpen, rand( ) % 360 ); + VectorMA( seg_end, cg_teslaDeviation.value * random( ), tangent, seg_end ); + } + else + VectorCopy( end, seg_end ); + + VectorCopy( seg_end, re->oldorigin ); + VectorCopy( seg_end, seg_start ); + + re->shaderRGBA[0] = 255; + re->shaderRGBA[1] = 255; + re->shaderRGBA[2] = 255; + re->shaderRGBA[3] = 255; + + le->color[0] = 1.0f; + le->color[1] = 1.0f; + le->color[2] = 1.0f; + le->color[3] = 1.0f; + + AxisClear( re->axis ); + } +} + +/* +========================== CG_RocketTrail ========================== */ @@ -626,13 +691,13 @@ void CG_RegisterWeapon( int weaponNum ) { weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse ); break; - case WP_LIGHTNING: + case WP_TESLAGEN: MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f ); weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse ); weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/lightning/lg_hum.wav", qfalse ); weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse ); - cgs.media.lightningShader = trap_R_RegisterShader( "lightningBoltNew"); + cgs.media.lightningShader = trap_R_RegisterShader( "models/ammo/tesla/tesla_bolt"); cgs.media.lightningExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" ); cgs.media.sfx_lghit1 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit.wav", qfalse ); cgs.media.sfx_lghit2 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit2.wav", qfalse ); @@ -955,7 +1020,7 @@ static void CG_LightningBolt( centity_t *cent, vec3_t origin ) { vec3_t forward; vec3_t muzzlePoint, endPoint; - if ( cent->currentState.weapon != WP_LIGHTNING ) { + if ( cent->currentState.weapon != WP_TESLAGEN ) { return; } @@ -1233,7 +1298,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent } // add the flash - if ( ( weaponNum == WP_LIGHTNING || weaponNum == WP_GAUNTLET || weaponNum == WP_GRAPPLING_HOOK ) + if ( ( weaponNum == WP_TESLAGEN || weaponNum == WP_GAUNTLET || weaponNum == WP_GRAPPLING_HOOK ) && ( nonPredictedCent->currentState.eFlags & EF_FIRING ) ) { // continuous flash @@ -1727,7 +1792,7 @@ void CG_FireWeapon( centity_t *cent ) { cent->muzzleFlashTime = cg.time; // lightning gun only does this this on initial press - if ( ent->weapon == WP_LIGHTNING ) { + if ( ent->weapon == WP_TESLAGEN ) { if ( cent->pe.lightningFiring ) { return; } @@ -1798,7 +1863,7 @@ void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, im switch ( weapon ) { default: - case WP_LIGHTNING: + case WP_TESLAGEN: // no explosion at LG impact, it is added with the beam r = rand() & 3; if ( r < 2 ) { |