Git Repos / fte_dogmode / qc / func / laser.qc
Last update to this file was on 2024-06-15 at 19:50.
Show laser.qc
//==============================================================================
// func_laser -- selections from Rubicon 2 qc by john fitzgibbons
//==============================================================================
//======================================================================
// constants
//======================================================================
#ifdef SSQC
const float LASER_START_OFF = 1;
const float LASER_SOLID = 2;
#endif
//======================================================================
// forward declarations
//======================================================================
// temp_laser_helper
#ifdef SSQC
void() temp_laser_helper_think;
entity(entity own, float newalpha) spawn_temp_laser_helper;
void(entity e) temp_laser_helper_init;
strip void() temp_laser_helper;
#endif
// func_laser
#ifdef SSQC
void() func_laser_touch;
void() func_laser_use;
void(entity e) func_laser_init;
void() func_laser;
#endif
//------------------------------------------------------------------------------
//----------------------------------------------------------------------
// class temp_laser_helper: base_tempentity
// {
#ifdef SSQC
//--------------------------------------------------------------
void() temp_laser_helper_think =
{
if (!self.owner || self.owner.classtype != CT_FUNC_LASER)
{
remove (self);
return;
}
if (!(self.owner.spawnflags & LASER_START_OFF))
self.owner.alpha = self.alpha * 0.8 +
self.alpha * random() * 0.4;
self.nextthink = time + 0.05;
};
//--------------------------------------------------------------
entity(entity own, float newalpha) spawn_temp_laser_helper =
{
local entity e = spawn ();
e.owner = own;
e.alpha = newalpha;
temp_laser_helper_init (e);
return e;
};
//--------------------------------------------------------------
void(entity e) temp_laser_helper_init =
{
e.classname = "temp_laser_helper";
e.classtype = CT_TEMP_LASER_HELPER;
base_tempentity_init (e);
e.think = temp_laser_helper_think;
e.nextthink = 0.05;
};
//--------------------------------------------------------------
strip void() temp_laser_helper =
{
temp_laser_helper_init (self);
};
#endif
// };
/*QUAKED func_laser (0 .5 .8) ? LASER_START_OFF LASER_SOLID 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 toggleable laser, hurts to touch, can be used to block players
LASER_START_OFF: Laser starts off.
LASER_SOLID: Laser blocks movement while turned on.
Keys:
"dmg" damage to do on touch. default 1
"alpha" approximate alpha you want the laser drawn at. default 0.5. alpha will vary by 20% of this value.
"message" message to display when activated
"message2" message to display when deactivated
*/
//----------------------------------------------------------------------
// class func_laser: base_func
// {
#ifdef SSQC
//--------------------------------------------------------------
void() func_laser_touch =
{
// from Copper -- dumptruck_ds
if (other.movetype == MOVETYPE_NOCLIP)
return;
if (other.takedamage && self.attack_finished < time)
{
t_damage2 (other, self, self, self.dmg);
self.attack_finished = time + 0.1;
}
};
//--------------------------------------------------------------
void() func_laser_use =
{
if (self.spawnflags & LASER_START_OFF)
{
setorigin (self, '0 0 0');
self.spawnflags = self.spawnflags - LASER_START_OFF;
// changed for progs_dump: the laser sound is now
// emitted from the func_laser itself instead of
// from the activator -- iw
sound (self, CHAN_VOICE, self.noise,
VOL_HIGH, ATTN_NORM);
if (activator.classtype == CT_PLAYER &&
self.message != "")
{
centerprint (activator, self.message);
}
}
else
{
// changed for progs_dump: the laser sound is now
// emitted from the func_laser itself instead of
// from the activator -- iw
sound (self, CHAN_VOICE, self.noise1,
VOL_HIGH, ATTN_NORM);
setorigin (self, '0 0 9000');
self.spawnflags = self.spawnflags + LASER_START_OFF;
if (activator.classtype == CT_PLAYER &&
self.message2 != "")
{
centerprint (activator, self.message2);
}
}
};
//--------------------------------------------------------------
void(entity e) func_laser_init =
{
e.classname = "func_laser";
e.classtype = CT_FUNC_LASER;
base_func_init (e);
setmodel (e, e.model);
precache_sound ("buttons/switch02.wav");
precache_sound ("buttons/switch04.wav");
if (e.spawnflags & LASER_SOLID)
{
// so you can shoot between lasers in a single bmodel
e.solid = SOLID_BSP;
// required becuase of SOLID_BSP
e.movetype = MOVETYPE_PUSH;
}
else
{
e.solid = SOLID_TRIGGER;
e.movetype = MOVETYPE_NONE;
}
if (!e.alpha)
e.alpha = 0.5;
if (!e.dmg)
e.dmg = 1;
e.touch = func_laser_touch;
e.use = func_laser_use;
if (e.spawnflags & LASER_START_OFF)
setorigin (e, '0 0 9000');
if (e.noise != "")
precache_sound (e.noise);
else
e.noise = "buttons/switch02.wav";
if (e.noise1 != "")
precache_sound (e.noise1);
else
e.noise1 = "buttons/switch04.wav";
// spawn a second entity to handle alpha changes, since
// MOVETYPE_PUSH doesn't support think functions
spawn_temp_laser_helper (e, e.alpha);
};
//--------------------------------------------------------------
void() func_laser =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
func_laser_init (self);
};
#endif
// };
Return to the top of this page or return to the overview of this repo.
Log laser.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-06-15 | Major update, committing as-is, will have bugs | cev | +14 | -2 |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +109 | -73 |
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 | +133 | -108 |
2023-12-09 | Start OO / class-based refactor, work on items | cev | +8 | -7 |
2023-11-27 | Code reorg, minor movement changes, misc | cev | +150 |
Return to the top of this page or return to the overview of this repo.