djcev.com

//

Git Repos / fte_dogmode / qc / func / fall.qc

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

Show fall.qc

//==============================================================================
// func_fall from RennyC
//
// A brush that drops and fades away when touched or triggered.
//
// dumptruck_ds
// noise = sound to play when triggered
// wait = wait this long before falling
//==============================================================================

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

const float FUNCFADE_DONT_FADE = 1;
const float FUNCFADE_SILENT = 2;

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

// func_fall
void() func_fall_think;
void() func_fall_touch;
void() func_fall_use;
void(entity e) func_fall_init;
void() func_fall;

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

/*QUAKED func_fall (0 .5 .8) ? DONT_FADE 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
A brush that drops and fades away when touched and/or triggered.
Add some spice to your jumping puzzles or other scripted sequences!
Monsters will not trigger func_fall but will be gibbed if one falls on them.
NOTE: When a func_fall brush touches another brush or entity it will stop, which can look odd in certain situations.
noise = sound to play when triggered, the default is a switch sound.
wait = wait this long before falling.
Use the DONT_FADE spawnflag if desired.

Falling brush upon touch
*/
//----------------------------------------------------------------------
// class func_fall: base_func
// {
//--------------------------------------------------------------
void() func_fall_think =
{
if (self.cnt == TRUE && self.attack_finished < time)
{
self.solid = SOLID_BBOX;
self.movetype = MOVETYPE_TOSS;

if (!(self.spawnflags & FUNCFADE_DONT_FADE))
{
if (self.alpha > 0.1)
{
self.alpha = self.alpha - 0.03;
}
else
{
remove (self);
return;
}
}
}
self.nextthink = time + 0.1;
};

//--------------------------------------------------------------
void() func_fall_touch =
{
if (other.classtype == CT_PLAYER)
{
if (!(other.flags & FL_ONGROUND))
other.flags = other.flags | FL_ONGROUND;
}
else if (other.flags & FL_MONSTER)
{
t_damage2 (other, self, other, 50000);
}
else
{
return;
}

if (self.cnt == TRUE)
return;

self.attack_finished = time + self.wait;
self.cnt = TRUE;

if (!(self.spawnflags & FUNCFADE_SILENT))
{
if (self.noise != "")
sound (self, CHAN_AUTO, self.noise,
1, ATTN_NORM);
else
sound (self, CHAN_AUTO, "buttons/switch21.wav",
1, ATTN_NORM);
}
};

//--------------------------------------------------------------
void() func_fall_use =
{
// thanks again RennyC for help on revisions --dumptruck_ds
self.attack_finished = time + self.wait;
self.cnt = TRUE;

if (self.noise != "")
sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
else
sound (self, CHAN_AUTO, "buttons/switch21.wav",
1, ATTN_NORM);
};

//--------------------------------------------------------------
void(entity e) func_fall_init =
{
e.classname = "func_fall";
e.classtype = CT_FUNC_FALL;
base_func_init (e);

precache_sound ("buttons/switch21.wav");
if (e.noise != "")
precache_sound (e.noise);

e.alpha = 1;
e.cnt = FALSE;
e.solid = SOLID_BSP;
e.movetype = MOVETYPE_PUSH;
e.use = func_fall_use;
e.touch = func_fall_touch;
e.think = func_fall_think;
e.nextthink = time;
setmodel (e, e.model);
};

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

func_fall_init (self);
};
// };

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

Log fall.qc

Date Commit Message Author + -
2024-03-24 2nd pass refactor, rework QC class structure cev +70 -43
2024-02-18 Client/player, projectiles, entrypoints refactor cev +1 -1
2024-01-31 Class based monster refactor & start projectiles cev +1 -1
2024-01-09 Continue OO / Class-based refactor cev +90 -86
2023-11-27 Code reorg, minor movement changes, misc cev +117  

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