mirror of
https://github.com/ReactionQuake3/reaction.git
synced 2025-02-17 01:22:32 +00:00
Explosion screen shake.
This commit is contained in:
parent
43abda6afa
commit
3a6ad64407
3 changed files with 36 additions and 1 deletions
|
@ -927,6 +927,9 @@ typedef struct {
|
|||
#define MAX_VISIBLE_FLARES 24
|
||||
#define NUM_FLARE_SHADERS 3
|
||||
|
||||
// Makro - explosion screen shake (in msec)
|
||||
#define EXPLOSION_SHAKE_TIME 500
|
||||
|
||||
typedef struct {
|
||||
int clientFrame; // incremented each frame
|
||||
|
||||
|
@ -1193,6 +1196,10 @@ typedef struct {
|
|||
|
||||
// Makro - time of death
|
||||
int timeOfDeath;
|
||||
|
||||
// Makro - explosion screen shake
|
||||
int explosionTime;
|
||||
float explosionForce;
|
||||
} cg_t;
|
||||
|
||||
//Blaze: struct to hold the func_breakable stuff
|
||||
|
|
|
@ -1047,6 +1047,16 @@ static int CG_CalcViewValues(void)
|
|||
CG_OffsetFirstPersonView();
|
||||
}
|
||||
|
||||
// Makro - explosion shake
|
||||
if (cg.explosionTime > cg.time)
|
||||
{
|
||||
const float frac = (cg.explosionTime - cg.time) / ((float)EXPLOSION_SHAKE_TIME);
|
||||
const float freq = 10.f;
|
||||
const float angle = frac * 10.f * cg.explosionForce;
|
||||
float wave = sin(freq * 2.f * M_PI * cg.time / 1000.f);
|
||||
cg.refdefViewAngles[ROLL] += wave * angle;
|
||||
}
|
||||
|
||||
// position eye reletive to origin
|
||||
if (cg.snap->ps.stats[STAT_HEALTH] > 0)
|
||||
AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
|
||||
|
@ -1054,6 +1064,7 @@ static int CG_CalcViewValues(void)
|
|||
if (cg.hyperspace) {
|
||||
cg.refdef.rdflags |= RDF_NOWORLDMODEL | RDF_HYPERSPACE;
|
||||
}
|
||||
|
||||
// field of view
|
||||
return CG_CalcFov();
|
||||
}
|
||||
|
|
|
@ -2607,10 +2607,27 @@ void CG_MissileHitWall(int weapon, int clientNum, vec3_t origin,
|
|||
//
|
||||
if (mod) {
|
||||
if (weapon == WP_GRENADE) {
|
||||
vec3_t delta;
|
||||
float severity;
|
||||
const float MAX_EXPLOSION_DIST = 800.f;
|
||||
|
||||
VectorSubtract(origin, cg.refdef.vieworg, delta);
|
||||
severity = Com_Clamp(0.f, 1.f, 1.f - VectorLength(delta) / MAX_EXPLOSION_DIST);
|
||||
if (severity > 0.f)
|
||||
{
|
||||
trace_t tr;
|
||||
CG_Trace(&tr, cg.refdef.vieworg, NULL, NULL, origin, cg.predictedPlayerState.clientNum, CONTENTS_SOLID);
|
||||
if (tr.fraction < 1.f)
|
||||
severity *= 0.5f;
|
||||
severity *= severity;
|
||||
if (cg.explosionTime < cg.time || severity > cg.explosionForce)
|
||||
cg.explosionForce = severity;
|
||||
cg.explosionTime = cg.time + EXPLOSION_SHAKE_TIME;
|
||||
}
|
||||
|
||||
le = CG_MakeExplosion(origin, dir, mod, shader, duration, isSprite);
|
||||
le->light = light;
|
||||
VectorCopy(lightColor, le->lightColor);
|
||||
|
||||
} else if (cg_RQ3_impactEffects.integer) {
|
||||
vec3_t temp, offsetDir;
|
||||
byte color[4];
|
||||
|
|
Loading…
Reference in a new issue