/* * CG_PlasmaExplosion */ void CG_PlasmaExplosion( vec3_t pos, vec3_t dir, int fire_mode, float radius ) { lentity_t *le; vec3_t angles; float model_radius = PLASMA_EXPLOSION_MODEL_RADIUS; VecToAngles( dir, angles ); if( fire_mode == FIRE_MODE_STRONG ) { le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 4, 1, 1, 1, 1, 150, 0, 0.75, 0, CG_MediaModel( cgs.media.modPlasmaExplosion ), NULL ); le->ent.scale = radius/model_radius; } else { le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 4, 1, 1, 1, 1, 80, 0, 0.75, 0, CG_MediaModel( cgs.media.modPlasmaExplosion ), NULL ); le->ent.scale = radius/model_radius; } le->ent.rotation = rand() % 360; CG_SpawnDecal( pos, dir, 90, 16, 1, 1, 1, 1, 4, 1, qtrue, CG_MediaShader( cgs.media.shaderPlasmaMark ) ); }
/* * CG_GunBladeBlastImpact */ void CG_GunBladeBlastImpact( vec3_t pos, vec3_t dir, float radius ) { lentity_t *le; lentity_t *le_explo; vec3_t angles; float model_radius = GUNBLADEBLAST_EXPLOSION_MODEL_RADIUS; VecToAngles( dir, angles ); le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 2, //3 frames 1, 1, 1, 1, //full white no inducted alpha 0, 0, 0, 0, //dlight CG_MediaModel( cgs.media.modBladeWallHit ), //"models/weapon_hits/gunblade/hit_blast.md3" NULL ); le->ent.rotation = rand() % 360; le->ent.scale = 1.0f; // this is the small bullet impact le_explo = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 2 + ( radius/16.1f ), 1, 1, 1, 1, //full white no inducted alpha 0, 0, 0, 0, //dlight CG_MediaModel( cgs.media.modBladeWallExplo ), NULL ); le_explo->ent.rotation = rand() % 360; le_explo->ent.scale = radius/model_radius; CG_SpawnDecal( pos, dir, random()*360, 3+( radius*0.5f ), 1, 1, 1, 1, 10, 1, qfalse, CG_MediaShader( cgs.media.shaderExplosionMark ) ); }
/* * CG_InstaExplosionMode */ void CG_InstaExplosionMode( vec3_t pos, vec3_t dir, int fire_mode ) { lentity_t *le; vec3_t angles; VecToAngles( dir, angles ); le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 6, // 6 is time 1, 1, 1, 1, //full white no inducted alpha 250, 0.65, 0.65, 0.65, //white dlight CG_MediaModel( cgs.media.modInstagunWallHit ), NULL ); le->ent.rotation = rand() % 360; if( fire_mode == FIRE_MODE_STRONG ) { le->ent.scale = 1.5f; // add white energy particles on the impact CG_ImpactPuffParticles( pos, dir, 12, 1.25f, 1, 1, 1, 1, CG_MediaShader( cgs.media.shaderAdditiveParticleShine ) ); } else { le->ent.scale = 1.0f; CG_ImpactPuffParticles( pos, dir, 12, 1.0f, 1, 1, 1, 1, NULL ); } CG_SpawnDecal( pos, dir, random()*360, 8, 1, 1, 1, 1, 10, 1, qtrue, CG_MediaShader( cgs.media.shaderInstagunMark ) ); }
/* * CG_BoltExplosionMode */ void CG_BoltExplosionMode( const vec3_t pos, const vec3_t dir, int fire_mode, int surfFlags ) { lentity_t *le; vec3_t angles; if( !CG_SpawnDecal( pos, dir, random()*360, 12, 1, 1, 1, 1, 10, 1, true, CG_MediaShader( cgs.media.shaderElectroboltMark ) ) ) { if( surfFlags & (SURF_SKY|SURF_NOMARKS|SURF_NOIMPACT) ) { return; } } VecToAngles( dir, angles ); le = CG_AllocModel( LE_INVERSESCALE_ALPHA_FADE, pos, angles, 6, // 6 is time 1, 1, 1, 1, //full white no inducted alpha 250, 0.75, 0.75, 0.75, //white dlight CG_MediaModel( cgs.media.modElectroBoltWallHit ), NULL ); le->ent.rotation = rand() % 360; le->ent.scale = ( fire_mode == FIRE_MODE_STRONG ) ? 1.5f : 1.0f; // add white energy particles on the impact CG_ImpactPuffParticles( pos, dir, 15, 0.75f, 1, 1, 1, 1, NULL ); trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxElectroboltHit ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_STATIC ); }
/* * CG_BladeImpact */ void CG_BladeImpact( const vec3_t pos, const vec3_t dir ) { lentity_t *le; vec3_t angles; vec3_t end; vec3_t local_pos, local_dir; trace_t trace; //find what are we hitting VectorCopy( pos, local_pos ); VectorNormalize2( dir, local_dir ); VectorMA( pos, -1.0, local_dir, end ); CG_Trace( &trace, local_pos, vec3_origin, vec3_origin, end, cg.view.POVent, MASK_SHOT ); if( trace.fraction == 1.0 ) return; VecToAngles( local_dir, angles ); if( trace.surfFlags & SURF_FLESH || ( trace.ent > 0 && cg_entities[trace.ent].current.type == ET_PLAYER ) || ( trace.ent > 0 && cg_entities[trace.ent].current.type == ET_CORPSE ) ) { le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 3, //3 frames for weak 1, 1, 1, 1, //full white no inducted alpha 0, 0, 0, 0, //dlight CG_MediaModel( cgs.media.modBladeWallHit ), NULL ); le->ent.rotation = rand() % 360; le->ent.scale = 1.0f; trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxBladeFleshHit[(int)( random()*3 )] ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_NORM ); } else if( trace.surfFlags & SURF_DUST ) { // throw particles on dust CG_ParticleEffect( trace.endpos, trace.plane.normal, 0.30f, 0.30f, 0.25f, 30 ); //fixme? would need a dust sound trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxBladeWallHit[(int)( random()*2 )] ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_NORM ); } else { le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 3, //3 frames for weak 1, 1, 1, 1, //full white no inducted alpha 0, 0, 0, 0, //dlight CG_MediaModel( cgs.media.modBladeWallHit ), NULL ); le->ent.rotation = rand() % 360; le->ent.scale = 1.0f; CG_ParticleEffect( trace.endpos, trace.plane.normal, 0.30f, 0.30f, 0.25f, 15 ); trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxBladeWallHit[(int)( random()*2 )] ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_NORM ); if( !( trace.surfFlags & SURF_NOMARKS ) ) CG_SpawnDecal( pos, dir, random()*10, 8, 1, 1, 1, 1, 10, 1, false, CG_MediaShader( cgs.media.shaderBladeMark ) ); } }
/* * CG_BulletImpact */ static void CG_BulletImpact( trace_t *tr ) { // bullet impact CG_BulletExplosion( tr->endpos, NULL, tr ); // throw particles on dust if( tr->surfFlags & SURF_DUST ) CG_ParticleEffect( tr->endpos, tr->plane.normal, 0.30f, 0.30f, 0.25f, 20 ); // spawn decal CG_SpawnDecal( tr->endpos, tr->plane.normal, random()*360, 8, 1, 1, 1, 1, 8, 1, qfalse, CG_MediaShader( cgs.media.shaderBulletMark ) ); }
/* * CG_GenericExplosion */ void CG_GenericExplosion( vec3_t pos, vec3_t dir, int fire_mode, float radius ) { lentity_t *le; vec3_t angles; vec3_t decaldir; vec3_t origin, vec; float expvelocity = 8.0f; VectorCopy( dir, decaldir ); VecToAngles( dir, angles ); //if( CG_PointContents( pos ) & MASK_WATER ) //jalfixme: (shouldn't we do the water sound variation?) if( fire_mode == FIRE_MODE_STRONG ) CG_SpawnDecal( pos, decaldir, random()*360, radius * 0.5, 1, 1, 1, 1, 10, 1, qfalse, CG_MediaShader( cgs.media.shaderExplosionMark ) ); else CG_SpawnDecal( pos, decaldir, random()*360, radius * 0.25, 1, 1, 1, 1, 10, 1, qfalse, CG_MediaShader( cgs.media.shaderExplosionMark ) ); // animmap shader of the explosion VectorMA( pos, radius*0.15f, dir, origin ); le = CG_AllocSprite( LE_ALPHA_FADE, origin, radius * 0.5f, 8, 1, 1, 1, 1, radius*4, 0.75f, 0.533f, 0, // yellow dlight CG_MediaShader( cgs.media.shaderRocketExplosion ) ); VectorSet( vec, crandom()*expvelocity, crandom()*expvelocity, crandom()*expvelocity ); VectorScale( dir, expvelocity, le->velocity ); VectorAdd( le->velocity, vec, le->velocity ); le->ent.rotation = rand() % 360; // use the rocket explosion sounds if( fire_mode == FIRE_MODE_STRONG ) trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxRocketLauncherStrongHit ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_DISTANT ); else trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxRocketLauncherWeakHit ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_DISTANT ); }
/* * CG_InstaExplosionMode */ void CG_InstaExplosionMode( const vec3_t pos, const vec3_t dir, int fire_mode, int surfFlags, int owner ) { int team = -1; vec4_t tcolor = { 0.65f, 0.0f, 0.26f, 1.0f }; lentity_t *le; vec3_t angles; if( cg_teamColoredInstaBeams->integer && owner && ( owner < gs.maxclients + 1 ) ) team = cg_entities[owner].current.team; if( ( team == TEAM_ALPHA ) || ( team == TEAM_BETA ) ) { CG_TeamColor( team, tcolor ); tcolor[0] *= 0.65f; tcolor[1] *= 0.65f; tcolor[2] *= 0.65f; } if( !CG_SpawnDecal( pos, dir, random()*360, 12, tcolor[0], tcolor[1], tcolor[2], 1.0f, 10, 1, true, CG_MediaShader( cgs.media.shaderInstagunMark ) ) ) { if( surfFlags & (SURF_SKY|SURF_NOMARKS|SURF_NOIMPACT) ) { return; } } VecToAngles( dir, angles ); le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 6, // 6 is time tcolor[0], tcolor[1], tcolor[2], 1, 250, 0.65, 0.65, 0.65, //white dlight CG_MediaModel( cgs.media.modInstagunWallHit ), NULL ); le->ent.rotation = rand() % 360; le->ent.scale = ( fire_mode == FIRE_MODE_STRONG ) ? 1.5f : 1.0f; // add white energy particles on the impact CG_ImpactPuffParticles( pos, dir, 15, 0.75f, 1, 1, 1, 1, NULL ); trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxElectroboltHit ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_STATIC ); }
/* * CG_RocketExplosionMode */ void CG_RocketExplosionMode( vec3_t pos, vec3_t dir, int fire_mode, float radius ) { lentity_t *le; vec3_t angles, vec; vec3_t origin; float expvelocity = 8.0f; VecToAngles( dir, angles ); if( fire_mode == FIRE_MODE_STRONG ) { //trap_S_StartSound ( pos, 0, 0, CG_MediaSfx (cgs.media.sfxRocketLauncherStrongHit), cg_volume_effects->value, ATTN_NORM, 0 ); CG_SpawnDecal( pos, dir, random()*360, radius * 0.5, 1, 1, 1, 1, 10, 1, qfalse, CG_MediaShader( cgs.media.shaderExplosionMark ) ); } else { //trap_S_StartSound ( pos, 0, 0, CG_MediaSfx (cgs.media.sfxRocketLauncherWeakHit), cg_volume_effects->value, ATTN_NORM, 0 ); CG_SpawnDecal( pos, dir, random()*360, radius * 0.25, 1, 1, 1, 1, 10, 1, qfalse, CG_MediaShader( cgs.media.shaderExplosionMark ) ); } // animmap shader of the explosion VectorMA( pos, radius*0.12f, dir, origin ); le = CG_AllocSprite( LE_ALPHA_FADE, origin, radius * 0.5f, 8, 1, 1, 1, 1, radius*4, 0.75f, 0.533f, 0, // yellow dlight CG_MediaShader( cgs.media.shaderRocketExplosion ) ); VectorSet( vec, crandom()*expvelocity, crandom()*expvelocity, crandom()*expvelocity ); VectorScale( dir, expvelocity, le->velocity ); VectorAdd( le->velocity, vec, le->velocity ); le->ent.rotation = rand() % 360; if( cg_explosionsRing->integer ) { // explosion ring sprite VectorMA( pos, radius*0.20f, dir, origin ); le = CG_AllocSprite( LE_ALPHA_FADE, origin, radius, 3, 1, 1, 1, 1, 0, 0, 0, 0, // no dlight CG_MediaShader( cgs.media.shaderRocketExplosionRing ) ); le->ent.rotation = rand() % 360; } if( cg_explosionsDust->integer == 1 ) { // dust ring parallel to the contact surface CG_ExplosionsDust(pos, dir, radius); } // Explosion particles CG_ParticleExplosionEffect( pos, dir, 1, 0.5, 0, 32 ); if( fire_mode == FIRE_MODE_STRONG ) trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxRocketLauncherStrongHit ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_DISTANT ); else trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxRocketLauncherWeakHit ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_DISTANT ); //jalfixme: add sound at water? }
/* * CG_BulletExplosion */ void CG_BulletExplosion( vec3_t pos, vec_t *dir, trace_t *trace ) { lentity_t *le; vec3_t angles; vec3_t local_dir, end; trace_t local_trace, *tr; assert( dir || trace ); if( dir ) { // find what are we hitting tr = &local_trace; VectorMA( pos, -1.0, dir, end ); CG_Trace( tr, pos, vec3_origin, vec3_origin, end, cg.view.POVent, MASK_SHOT ); if( tr->fraction == 1.0 ) return; } else { tr = trace; dir = local_dir; VectorCopy( tr->plane.normal, dir ); } VecToAngles( dir, angles ); if( tr->surfFlags & SURF_FLESH || ( tr->ent > 0 && cg_entities[tr->ent].current.type == ET_PLAYER ) || ( tr->ent > 0 && cg_entities[tr->ent].current.type == ET_CORPSE ) ) { le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 3, //3 frames for weak 1, 0, 0, 1, //full white no inducted alpha 0, 0, 0, 0, //dlight CG_MediaModel( cgs.media.modBulletExplode ), NULL ); le->ent.rotation = rand() % 360; le->ent.scale = 1.0f; if( ISVIEWERENTITY( tr->ent ) ) le->ent.renderfx |= RF_VIEWERMODEL; } else if( tr->surfFlags & SURF_DUST ) { // throw particles on dust CG_ImpactSmokePuff( tr->endpos, tr->plane.normal, 4, 0.6f, 6, 8 ); } else { le = CG_AllocModel( LE_ALPHA_FADE, pos, angles, 3, //3 frames for weak 1, 1, 1, 1, //full white no inducted alpha 0, 0, 0, 0, //dlight CG_MediaModel( cgs.media.modBulletExplode ), NULL ); le->ent.rotation = rand() % 360; le->ent.scale = 1.0f; CG_ImpactSmokePuff( tr->endpos, tr->plane.normal, 2, 0.6f, 6, 8 ); if( !( tr->surfFlags & SURF_NOMARKS ) ) CG_SpawnDecal( pos, dir, random()*360, 8, 1, 1, 1, 1, 10, 1, qfalse, CG_MediaShader( cgs.media.shaderBulletMark ) ); } }
/* * CG_GrenadeExplosionMode */ void CG_GrenadeExplosionMode( vec3_t pos, vec3_t dir, int fire_mode, float radius ) { lentity_t *le; vec3_t angles; vec3_t decaldir; vec3_t origin, vec; float expvelocity = 8.0f; VectorCopy( dir, decaldir ); VecToAngles( dir, angles ); //if( CG_PointContents( pos ) & MASK_WATER ) //jalfixme: (shouldn't we do the water sound variation?) if( fire_mode == FIRE_MODE_STRONG ) { CG_SpawnDecal( pos, decaldir, random()*360, radius * 0.5, 1, 1, 1, 1, 10, 1, qfalse, CG_MediaShader( cgs.media.shaderExplosionMark ) ); } else { CG_SpawnDecal( pos, decaldir, random()*360, radius * 0.25, 1, 1, 1, 1, 10, 1, qfalse, CG_MediaShader( cgs.media.shaderExplosionMark ) ); } // animmap shader of the explosion VectorMA( pos, radius*0.15f, dir, origin ); le = CG_AllocSprite( LE_ALPHA_FADE, origin, radius * 0.5f, 8, 1, 1, 1, 1, radius*4, 0.75f, 0.533f, 0, // yellow dlight CG_MediaShader( cgs.media.shaderRocketExplosion ) ); VectorSet( vec, crandom()*expvelocity, crandom()*expvelocity, crandom()*expvelocity ); VectorScale( dir, expvelocity, le->velocity ); VectorAdd( le->velocity, vec, le->velocity ); le->ent.rotation = rand() % 360; // explosion ring sprite if( cg_explosionsRing->integer ) { VectorMA( pos, radius*0.25f, dir, origin ); le = CG_AllocSprite( LE_ALPHA_FADE, origin, radius, 3, 1, 1, 1, 1, 0, 0, 0, 0, // no dlight CG_MediaShader( cgs.media.shaderRocketExplosionRing ) ); le->ent.rotation = rand() % 360; } if( cg_explosionsDust->integer == 1 ) { // dust ring parallel to the contact surface CG_ExplosionsDust(pos, dir, radius); } // Explosion particles CG_ParticleExplosionEffect( pos, dir, 1, 0.5, 0, 32 ); if( fire_mode == FIRE_MODE_STRONG ) trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxGrenadeStrongExplosion ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_DISTANT ); else trap_S_StartFixedSound( CG_MediaSfx( cgs.media.sfxGrenadeWeakExplosion ), pos, CHAN_AUTO, cg_volume_effects->value, ATTN_DISTANT ); }