djcev.com

//

Git Repos / fte_dogmode / qc / triggers / shake.qc

Last update to this file was on 2024-03-24 at 02:40.

Show shake.qc

//==============================================================================
// trigger_shake -- point entity from Rubicon Rumble Pack; requires TARGETNAME
//==============================================================================

//======================================================================
// constants
//======================================================================

const float TRIGGER_SHAKE_VIEWONLY = 1;

//======================================================================
// forward declarations
//======================================================================

// trigger_shake
void() trigger_shake_think;
void() trigger_shake_use;
void(entity e) trigger_shake_init;
void() trigger_shake;

//------------------------------------------------------------------------------

/*QUAKED trigger_shake (.5 0 .5) (-8 -8 -8) (8 8 8) TRIGGER_SHAKE_VIEWONLY X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY

Earthquake trigger - shakes players in it's radius when active.
Strength of tremor is greatest at the centre.
dmg Strength at center (default is 120)
wait Duration of shake (default is 1)
count Affect radius (defalt is 200)
noise Noise to play when starting to shake
noise1 Noise to play when stopping
targetname Must be triggered
Spawnflags
TRIGGER_SHAKE_VIEWONLY Shakes the view, but player movement is not affected
*/
//----------------------------------------------------------------------
// class trigger_shake: base_trigger
// {
//--------------------------------------------------------------
// was shake_think
//--------------------------------------------------------------
void() trigger_shake_think =
{
if (self.attack_finished < time)
{
// Done
self.nextthink = -1;

if (self.noise1 != "")
sound (self, CHAN_VOICE, self.noise1,
1, ATTN_NORM);

return;
}

// Shake all players in the effect radius...
local entity p;
p = findradius (self.origin, self.count);

while (p)
{
if (p.flags & FL_CLIENT)
{
local float d;

// Scale effect by distance
d = vlen (self.origin - p.origin);
d = (self.count - d) / self.count;

if (d > 0)
{
// shake up the view
p.punchangle_x = -1 * (random() +
(0.025 * self.dmg * d));

// push the player around
if (p.flags & FL_ONGROUND
&& !(self.spawnflags &
TRIGGER_SHAKE_VIEWONLY))
{
d = self.dmg * d;
p.velocity_x = p.velocity_x +
(random() * d * 2 - d);
p.velocity_y = p.velocity_y +
(random() * d * 2 - d);
// always push up
p.velocity_z = p.velocity_z +
(random() * d);
}
}
}
p = p.chain;
}

// keep going
self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
void() trigger_shake_use =
{
// already active
if (self.attack_finished > time)
return;

// Start...
if (self.noise != "")
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);

self.attack_finished = time + self.wait;
self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
void(entity e) trigger_shake_init =
{
e.classname = "trigger_shake";
e.classtype = CT_TRIGGER_SHAKE;

if (!e.targetname)
objerror ("trigger_shake without name");

if (e.noise != "")
precache_sound (e.noise);
if (e.noise1 != "")
precache_sound (e.noise1);

if (!e.dmg)
e.dmg = 120;
if (e.count <= 0)
e.count = 200;
if (e.wait <= 0)
e.wait = 1.0;

base_trigger_init (e);

setorigin (e, e.origin);
e.think = trigger_shake_think;
e.use = trigger_shake_use;
e.nextthink = -1;
};

//--------------------------------------------------------------
void() trigger_shake =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

trigger_shake_init (self);
};
// };

Return to the top of this page or return to the overview of this repo.

Log shake.qc

Date Commit Message Author + -
2024-03-24 2nd pass refactor, rework QC class structure cev +65 -39
2024-01-31 Class based monster refactor & start projectiles cev +1 -1
2024-01-09 Continue OO / Class-based refactor cev +12 -12
2023-12-09 Start OO / class-based refactor, work on items cev +102 -98
2023-11-16 pmove bug fixes, moved q3 compat code, cleanup cev +122  

Return to the top of this page or return to the overview of this repo.