djcev.com

//

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

Last update to this file was on 2025-03-30 at 19:29.

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
//======================================================================

#ifdef SSQC
//----------------------------------------------------------------------
// func_fall spawnflags -- CEV
//----------------------------------------------------------------------
typedef enumflags
{
SPAWNFLAG_FUNC_FADE_DONT_FADE = 1,
SPAWNFLAG_FUNC_FADE_SILENT = 2
// SPAWNFLAG_NOT_ON_EASY = 256, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_NORMAL = 512,
// SPAWNFLAG_NOT_ON_HARD_OR_NIGHTMARE = 1024,
// SPAWNFLAG_NOT_IN_DEATHMATCH = 2048,
// SPAWNFLAG_NOT_IN_COOP = 4096,
// SPAWNFLAG_NOT_IN_SP = 8192,
// SPAWNFLAG_NOT_ON_SKILL2 = 32768, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_SKILL3 = 65536, // see base_entities.qc -- CEV
// SPAWNFLAG_CENTERPRINTALL = 131072 // see base_entities.qc -- CEV
} func_fall_spawnflags;
#endif

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

// func_fall
#ifdef CSQC
void(float isnew) func_fall_netreceive;
#endif
#ifdef SSQC
void() func_fall_think;
void() func_fall_touch;
void() func_fall_use;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) func_fall_init;
#endif
#ifdef SSQC
void() func_fall;
#endif

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

/*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
// {
#ifdef CSQC
//--------------------------------------------------------------
void(float isnew) func_fall_netreceive =
{
// creates the netflag variable -- CEV
BASE_FUNC_NETRECEIVE (func_fall_init)
};
#endif

#ifdef SSQC
//--------------------------------------------------------------
void() func_fall_think =
{
if (self.cnt == TRUE && self.attack_finished < time)
{
self.solid = SOLID_BBOX;
self.movetype = MOVETYPE_TOSS;
self.SendFlags |= NETFLAG_BASE_ENTITY_ORIGIN |
NETFLAG_BASE_ENTITY_SOLID;

if (!(self.classgroup & CG_FRAMETICK))
self.classgroup |= CG_FRAMETICK;

if (!(self.spawnflags & SPAWNFLAG_FUNC_FADE_DONT_FADE))
{
if (self.alpha > 0.1)
{
self.alpha = self.alpha - 0.03;
self.SendFlags |=
NETFLAG_BASE_ENTITY_ALPHA;
}
else
{
self.classgroup &= ~CG_FRAMETICK;
base_entity_remove (self);
return;
}
}
}
else if (self.flags & FL_ONGROUND)
{
if (self.classgroup & CG_FRAMETICK)
self.classgroup &= ~CG_FRAMETICK;
}

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 & SPAWNFLAG_FUNC_FADE_SILENT))
{
if (self.noise != "")
sound (self, CHAN_AUTO, self.noise,
VOL_HIGH, ATTN_NORM);
else
sound (self, CHAN_AUTO, "buttons/switch21.wav",
VOL_HIGH, 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",
VOL_HIGH, ATTN_NORM);
};
#endif

#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) func_fall_init =
{
e.classname = "func_fall";
e.classtype = CT_FUNC_FALL;
base_func_init (e);

#ifdef CSQC
setmodelindex (e, e.modelindex);
setsize (e, e.mins, e.maxs);
setorigin (e, e.origin);
e.drawmask = DRAWMASK_NORMAL;
e.predraw = base_func_predraw;
#endif

#ifdef SSQC
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);

e.customphysics = base_entity_movetype_push;
e.tick = base_func_neteval;
e.SendEntity = base_entity_netsend;
e.SendFlags = NETFLAG_BASE_ENTITY_FULLSEND;
#endif
};
#endif

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

func_fall_init (self);
};
#endif
// };

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

Log fall.qc

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