Git Repos / fte_dogmode / qc / func / elvtr_button.qc
Last update to this file was on 2024-06-15 at 19:50.
Show elvtr_button.qc
//==============================================================================
// func_elvtr_button - Rogue Dissolution Of Eternity
//==============================================================================
// elevator button
// pmack
// sept 96
//======================================================================
// constants
//======================================================================
#ifdef SSQC
const float BUTTON_ELVTR_DOWN = 1;
#endif
//======================================================================
// globals
//======================================================================
#ifdef SSQC
float elv_butn_dir;
#endif
//======================================================================
// forward declarations
//======================================================================
// func_elvtr_button
#ifdef SSQC
void() func_elvtr_button_wait;
void() func_elvtr_button_done;
void() func_elvtr_button_return;
void() func_elvtr_button_fire;
void() func_elvtr_button_blocked;
void(vector dir) func_elvtr_button_destroy;
void() func_elvtr_button_touch;
void() func_elvtr_button_use;
void(entity e) func_elvtr_button_init;
void() func_elvtr_button;
#endif
//------------------------------------------------------------------------------
/*QUAKED func_elvtr_button (0 .5 .8) ? ELVTR_DOWN 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
ELEVATOR BUTTON ONLY!
ELVTR_DOWN causes this to be a DOWN button.
Default is UP.
When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again.
"angle" determines the opening direction
"target" all entities with a matching targetname will be used
"speed" override the default 40 speed
"wait" override the default 1 second wait (-1 = never return)
"lip" override the default 4 pixel lip remaining at end of move
"health" if set, the button must be killed instead of touched
"sounds"
0) steam metal
1) wooden clunk
2) metallic click
3) in-out
*/
//----------------------------------------------------------------------
// class func_elvtr_button: base_func
// {
#ifdef SSQC
//--------------------------------------------------------------
void() func_elvtr_button_wait =
{
// elv_butn_dir = 0;
if (self.spawnflags & BUTTON_ELVTR_DOWN)
elv_butn_dir = -1;
else
elv_butn_dir = 1;
self.state = FUNC_STATE_TOP;
activator = self.enemy;
sub_usetargets ();
// use alternate textures
self.frame = 1;
// schedule next action
self.think = func_elvtr_button_return;
self.nextthink = self.ltime + self.wait;
};
//--------------------------------------------------------------
void() func_elvtr_button_done =
{
self.state = FUNC_STATE_BOTTOM;
};
//--------------------------------------------------------------
void() func_elvtr_button_return =
{
self.state = FUNC_STATE_DOWN;
sub_calcmove (self, self.pos1, self.speed,
func_elvtr_button_done);
// use normal textures
self.frame = 0;
if (self.health)
// can be shot again
self.takedamage = DAMAGE_YES;
};
//--------------------------------------------------------------
void() func_elvtr_button_fire =
{
if (self.state == FUNC_STATE_UP || self.state == FUNC_STATE_TOP)
return;
sound (self, CHAN_VOICE, self.noise, VOL_MID, ATTN_NORM);
self.state = FUNC_STATE_UP;
sub_calcmove (self, self.pos2, self.speed,
func_elvtr_button_wait);
};
//--------------------------------------------------------------
void() func_elvtr_button_blocked =
{
// do nothing, just don't come all the way back out
};
//--------------------------------------------------------------
void(vector dir) func_elvtr_button_destroy =
{
self.enemy = damage_attacker;
self.health = self.max_health;
// wil be reset upon return
self.takedamage = DAMAGE_NO;
func_elvtr_button_fire ();
};
//--------------------------------------------------------------
void() func_elvtr_button_touch =
{
// if (self.health > 0)
// return;
if (other.classtype != CT_PLAYER)
return;
self.enemy = other;
func_elvtr_button_fire ();
};
//--------------------------------------------------------------
void() func_elvtr_button_use =
{
self.enemy = activator;
func_elvtr_button_fire ();
};
//--------------------------------------------------------------
void(entity e) func_elvtr_button_init =
{
e.classname = "func_elvtr_button";
e.classtype = CT_FUNC_ELVTR_BUTTON;
base_func_init (e);
if (e.sounds == 0)
{
precache_sound ("buttons/airbut1.wav");
e.noise = "buttons/airbut1.wav";
}
if (e.sounds == 1)
{
precache_sound ("buttons/switch21.wav");
e.noise = "buttons/switch21.wav";
}
if (e.sounds == 2)
{
precache_sound ("buttons/switch02.wav");
e.noise = "buttons/switch02.wav";
}
if (e.sounds == 3)
{
precache_sound ("buttons/switch04.wav");
e.noise = "buttons/switch04.wav";
}
sub_setmovedir (e);
e.movetype = MOVETYPE_PUSH;
e.solid = SOLID_BSP;
setmodel (e, e.model);
e.blocked = func_elvtr_button_blocked;
e.use = func_elvtr_button_use;
if (e.health)
{
e.max_health = e.health;
e.takedamage = DAMAGE_YES;
e.destroy = func_elvtr_button_destroy;
}
else
{
e.touch = func_elvtr_button_touch;
}
if (!e.speed)
e.speed = 40;
if (!e.wait)
e.wait = 1;
if (!e.lip)
e.lip = 4;
e.state = FUNC_STATE_BOTTOM;
e.pos1 = e.origin;
e.pos2 = e.pos1 + e.movedir *
(fabs(e.movedir * e.size) - e.lip);
};
//--------------------------------------------------------------
void() func_elvtr_button =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
func_elvtr_button_init (self);
};
#endif
// };
Return to the top of this page or return to the overview of this repo.
Log elvtr_button.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-06-15 | Major update, committing as-is, will have bugs | cev | +9 | -1 |
2024-04-12 | Moveable gibs, heads, some bugfixes | cev | +2 | -2 |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +120 | -94 |
2024-02-18 | Client/player, projectiles, entrypoints refactor | cev | +11 | -12 |
2024-01-31 | Class based monster refactor & start projectiles | cev | +20 | -1 |
2024-01-09 | Continue OO / Class-based refactor | cev | +137 | -136 |
2023-11-27 | Code reorg, minor movement changes, misc | cev | +182 |
Return to the top of this page or return to the overview of this repo.