2001-12-31 16:16:59 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
2001-12-31 16:28:42 +00:00
|
|
|
// $Log$
|
2003-09-18 00:05:06 +00:00
|
|
|
// Revision 1.15 2003/09/18 00:05:06 makro
|
|
|
|
// Lens flares. Opendoor trigger_multiple fixes
|
|
|
|
//
|
2003-09-08 19:19:20 +00:00
|
|
|
// Revision 1.14 2003/09/08 19:19:20 makro
|
|
|
|
// New code for respawning entities in TP
|
|
|
|
//
|
2003-08-26 19:28:38 +00:00
|
|
|
// Revision 1.13 2003/08/26 19:28:38 makro
|
|
|
|
// target_speakers
|
|
|
|
//
|
2003-04-26 22:33:07 +00:00
|
|
|
// Revision 1.12 2003/04/26 22:33:06 jbravo
|
|
|
|
// Wratted all calls to G_FreeEnt() to avoid crashing and provide debugging
|
|
|
|
//
|
2003-03-22 20:29:26 +00:00
|
|
|
// Revision 1.11 2003/03/22 20:29:26 jbravo
|
|
|
|
// wrapping linkent and unlinkent calls
|
|
|
|
//
|
2003-01-06 00:23:29 +00:00
|
|
|
// Revision 1.10 2003/01/06 00:23:29 makro
|
|
|
|
// no message
|
|
|
|
//
|
2003-01-05 22:36:50 +00:00
|
|
|
// Revision 1.9 2003/01/05 22:36:50 makro
|
|
|
|
// Added "inactive" field for entities
|
|
|
|
// New "target_activate" entity
|
|
|
|
//
|
2002-06-16 20:06:15 +00:00
|
|
|
// Revision 1.8 2002/06/16 20:06:14 jbravo
|
|
|
|
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
|
|
|
|
//
|
2002-05-30 21:18:28 +00:00
|
|
|
// Revision 1.7 2002/05/30 21:18:28 makro
|
|
|
|
// Bots should reload/bandage when roaming around
|
|
|
|
// Added "pathtarget" key to all the entities
|
|
|
|
//
|
2002-05-23 18:37:50 +00:00
|
|
|
// Revision 1.6 2002/05/23 18:37:50 makro
|
|
|
|
// Bots should crouch more often when they attack with a SSG
|
|
|
|
// Made this depend on skill. Also, elevator stuff
|
|
|
|
//
|
2002-05-23 15:55:25 +00:00
|
|
|
// Revision 1.5 2002/05/23 15:55:25 makro
|
|
|
|
// Elevators
|
|
|
|
//
|
2002-01-11 19:48:33 +00:00
|
|
|
// Revision 1.4 2002/01/11 19:48:30 jbravo
|
|
|
|
// Formatted the source in non DOS format.
|
|
|
|
//
|
2001-12-31 16:28:42 +00:00
|
|
|
// Revision 1.3 2001/12/31 16:28:42 jbravo
|
|
|
|
// I made a Booboo with the Log tag.
|
|
|
|
//
|
2001-12-31 16:16:59 +00:00
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
2001-05-06 20:50:27 +00:00
|
|
|
// Copyright (C) 1999-2000 Id Software, Inc.
|
|
|
|
//
|
|
|
|
#include "g_local.h"
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_give (1 0 0) (-8 -8 -8) (8 8 8)
|
|
|
|
Gives the activator all the items pointed to.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void Use_Target_Give(gentity_t * ent, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
gentity_t *t;
|
|
|
|
trace_t trace;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!activator->client) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!ent->target) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
memset(&trace, 0, sizeof(trace));
|
2001-05-06 20:50:27 +00:00
|
|
|
t = NULL;
|
2002-06-16 20:06:15 +00:00
|
|
|
while ((t = G_Find(t, FOFS(targetname), ent->target)) != NULL) {
|
|
|
|
if (!t->item) {
|
2001-05-06 20:50:27 +00:00
|
|
|
continue;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
Touch_Item(t, activator, &trace);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// make sure it isn't going to respawn or show any events
|
|
|
|
t->nextthink = 0;
|
2011-07-14 18:37:19 +00:00
|
|
|
trap_UnlinkEntity(t);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_give(gentity_t * ent)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->use = Use_Target_Give;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_remove_powerups (1 0 0) (-8 -8 -8) (8 8 8)
|
|
|
|
takes away all the activators powerups.
|
|
|
|
Used to drop flight powerups into death puts.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void Use_target_remove_powerups(gentity_t * ent, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
if (!activator->client) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (activator->client->ps.powerups[PW_REDFLAG]) {
|
2001-05-06 20:50:27 +00:00
|
|
|
Team_ReturnFlag(TEAM_RED);
|
2002-06-16 20:06:15 +00:00
|
|
|
} else if (activator->client->ps.powerups[PW_BLUEFLAG]) {
|
2001-05-06 20:50:27 +00:00
|
|
|
Team_ReturnFlag(TEAM_BLUE);
|
2002-06-16 20:06:15 +00:00
|
|
|
} else if (activator->client->ps.powerups[PW_NEUTRALFLAG]) {
|
|
|
|
Team_ReturnFlag(TEAM_FREE);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
memset(activator->client->ps.powerups, 0, sizeof(activator->client->ps.powerups));
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_remove_powerups(gentity_t * ent)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->use = Use_target_remove_powerups;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_delay (1 0 0) (-8 -8 -8) (8 8 8)
|
|
|
|
"wait" seconds to pause before firing targets.
|
|
|
|
"random" delay variance, total delay = delay +/- random seconds
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void Think_Target_Delay(gentity_t * ent)
|
|
|
|
{
|
|
|
|
G_UseTargets(ent, ent->activator);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void Use_Target_Delay(gentity_t * ent, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
ent->nextthink = level.time + (ent->wait + ent->random * crandom()) * 1000;
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->think = Think_Target_Delay;
|
|
|
|
ent->activator = activator;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_delay(gentity_t * ent)
|
|
|
|
{
|
2002-05-23 18:37:50 +00:00
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
// check delay for backwards compatability
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!G_SpawnFloat("delay", "0", &ent->wait)) {
|
|
|
|
G_SpawnFloat("wait", "1", &ent->wait);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!ent->wait) {
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->wait = 1;
|
|
|
|
}
|
2002-05-23 18:37:50 +00:00
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->use = Use_Target_Delay;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_score (1 0 0) (-8 -8 -8) (8 8 8)
|
|
|
|
"count" number of points to add, default 1
|
|
|
|
|
|
|
|
The activator is given this many points.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void Use_Target_Score(gentity_t * ent, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
AddScore(activator, ent->r.currentOrigin, ent->count);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_score(gentity_t * ent)
|
|
|
|
{
|
|
|
|
if (!ent->count) {
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->count = 1;
|
|
|
|
}
|
|
|
|
ent->use = Use_Target_Score;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_print (1 0 0) (-8 -8 -8) (8 8 8) redteam blueteam private
|
|
|
|
"message" text to print
|
|
|
|
If "private", only the activator gets the message. If no checks, all clients get the message.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void Use_Target_Print(gentity_t * ent, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
2002-05-23 15:55:25 +00:00
|
|
|
//Makro - crash bug fix
|
2002-05-23 18:37:50 +00:00
|
|
|
if (activator) {
|
2002-06-16 20:06:15 +00:00
|
|
|
if (activator->client && (ent->spawnflags & 4)) {
|
|
|
|
trap_SendServerCommand(activator - g_entities, va("cp \"%s\"", ent->message));
|
2002-05-23 18:37:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (ent->spawnflags & 3) {
|
|
|
|
if (ent->spawnflags & 1) {
|
|
|
|
G_TeamCommand(TEAM_RED, va("cp \"%s\"", ent->message));
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
if (ent->spawnflags & 2) {
|
|
|
|
G_TeamCommand(TEAM_BLUE, va("cp \"%s\"", ent->message));
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_SendServerCommand(-1, va("cp \"%s\"", ent->message));
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_print(gentity_t * ent)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->use = Use_Target_Print;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
2003-08-26 19:28:38 +00:00
|
|
|
/*QUAKED target_speaker (1 0 0) (-8 -8 -8) (8 8 8) looped-on looped-off global activator nopvs
|
2001-05-06 20:50:27 +00:00
|
|
|
"noise" wav file to play
|
|
|
|
|
|
|
|
A global sound will play full volume throughout the level.
|
|
|
|
Activator sounds will play on the player that activated the target.
|
|
|
|
Global and activator sounds can't be combined with looping.
|
|
|
|
Normal sounds play each time the target is used.
|
|
|
|
Looped sounds will be toggled by use functions.
|
|
|
|
Multiple identical looping sounds will just increase volume without any speed cost.
|
|
|
|
"wait" : Seconds between auto triggerings, 0 = don't auto trigger
|
|
|
|
"random" wait variance, default is 0
|
|
|
|
*/
|
2003-09-18 00:05:06 +00:00
|
|
|
|
|
|
|
#define SF_TARGET_SPEAKER_LOOPEDON 1
|
|
|
|
#define SF_TARGET_SPEAKER_LOOPEDOFF 2
|
|
|
|
#define SF_TARGET_SPEAKER_GLOBAL 4
|
|
|
|
#define SF_TARGET_SPEAKER_ACTIVATOR 8
|
|
|
|
#define SF_TARGET_SPEAKER_NOPVS 16
|
|
|
|
|
2003-09-08 19:19:20 +00:00
|
|
|
void reset_target_speaker(gentity_t *ent)
|
|
|
|
{
|
|
|
|
//looped on
|
2003-09-18 00:05:06 +00:00
|
|
|
if (ent->spawnflags & SF_TARGET_SPEAKER_LOOPEDON)
|
2003-09-08 19:19:20 +00:00
|
|
|
ent->s.loopSound = ent->noise_index;
|
|
|
|
//looped off
|
2003-09-18 00:05:06 +00:00
|
|
|
else if (ent->spawnflags & SF_TARGET_SPEAKER_LOOPEDOFF)
|
2003-09-08 19:19:20 +00:00
|
|
|
ent->s.loopSound = 0;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void Use_Target_Speaker(gentity_t * ent, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
2003-09-18 00:05:06 +00:00
|
|
|
// looping sound toggles
|
|
|
|
if (ent->spawnflags & (SF_TARGET_SPEAKER_LOOPEDON | SF_TARGET_SPEAKER_LOOPEDOFF)) {
|
2003-09-08 19:19:20 +00:00
|
|
|
//Makro - check the pathtarget of the triggering entity
|
|
|
|
if (other->pathtarget) {
|
|
|
|
if (!Q_stricmp(other->pathtarget, "on")) {
|
|
|
|
ent->s.loopSound = ent->noise_index;
|
|
|
|
return;
|
|
|
|
} else if (!Q_stricmp(other->pathtarget, "off")) {
|
|
|
|
ent->s.loopSound = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
if (ent->s.loopSound)
|
|
|
|
ent->s.loopSound = 0; // turn it off
|
|
|
|
else
|
|
|
|
ent->s.loopSound = ent->noise_index; // start it
|
2002-06-16 20:06:15 +00:00
|
|
|
} else { // normal sound
|
2003-09-18 00:05:06 +00:00
|
|
|
if (ent->spawnflags & SF_TARGET_SPEAKER_ACTIVATOR) {
|
2002-06-16 20:06:15 +00:00
|
|
|
G_AddEvent(activator, EV_GENERAL_SOUND, ent->noise_index);
|
2003-09-18 00:05:06 +00:00
|
|
|
} else if (ent->spawnflags & SF_TARGET_SPEAKER_GLOBAL) {
|
2002-06-16 20:06:15 +00:00
|
|
|
G_AddEvent(ent, EV_GLOBAL_SOUND, ent->noise_index);
|
2001-05-06 20:50:27 +00:00
|
|
|
} else {
|
2002-06-16 20:06:15 +00:00
|
|
|
G_AddEvent(ent, EV_GENERAL_SOUND, ent->noise_index);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_speaker(gentity_t * ent)
|
|
|
|
{
|
|
|
|
char buffer[MAX_QPATH];
|
|
|
|
char *s;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
G_SpawnFloat("wait", "0", &ent->wait);
|
|
|
|
G_SpawnFloat("random", "0", &ent->random);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!G_SpawnString("noise", "NOSOUND", &s)) {
|
|
|
|
G_Error("target_speaker without a noise key at %s", vtos(ent->s.origin));
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
// force all client reletive sounds to be "activator" speakers that
|
|
|
|
// play on the entity that activates it
|
2002-06-16 20:06:15 +00:00
|
|
|
if (s[0] == '*') {
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->spawnflags |= 8;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!strstr(s, ".wav")) {
|
|
|
|
Com_sprintf(buffer, sizeof(buffer), "%s.wav", s);
|
2001-05-06 20:50:27 +00:00
|
|
|
} else {
|
2002-06-16 20:06:15 +00:00
|
|
|
Q_strncpyz(buffer, s, sizeof(buffer));
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
ent->noise_index = G_SoundIndex(buffer);
|
|
|
|
|
|
|
|
// a repeating speaker can be done completely client side
|
|
|
|
ent->s.eType = ET_SPEAKER;
|
|
|
|
ent->s.eventParm = ent->noise_index;
|
|
|
|
ent->s.frame = ent->wait * 10;
|
|
|
|
ent->s.clientNum = ent->random * 10;
|
2003-08-26 19:28:38 +00:00
|
|
|
//Makro - added
|
2003-09-18 00:05:06 +00:00
|
|
|
if ((ent->spawnflags & (SF_TARGET_SPEAKER_LOOPEDON | SF_TARGET_SPEAKER_LOOPEDOFF))
|
|
|
|
&& (ent->spawnflags & SF_TARGET_SPEAKER_NOPVS))
|
2003-08-26 19:28:38 +00:00
|
|
|
ent->s.weapon = 1;
|
|
|
|
else
|
|
|
|
ent->s.weapon = 0;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// check for prestarted looping sound
|
2003-09-18 00:05:06 +00:00
|
|
|
if (ent->spawnflags & SF_TARGET_SPEAKER_LOOPEDON) {
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->s.loopSound = ent->noise_index;
|
|
|
|
}
|
2003-09-08 19:19:20 +00:00
|
|
|
|
|
|
|
ent->reset = reset_target_speaker;
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->use = Use_Target_Speaker;
|
|
|
|
|
2003-09-18 00:05:06 +00:00
|
|
|
if (ent->spawnflags & SF_TARGET_SPEAKER_GLOBAL) {
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->r.svFlags |= SVF_BROADCAST;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorCopy(ent->s.origin, ent->s.pos.trBase);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// must link the entity so we get areas and clusters so
|
|
|
|
// the server can determine who to send updates to
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(ent);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_laser (0 .5 .8) (-8 -8 -8) (8 8 8) START_ON
|
|
|
|
When triggered, fires a laser. You can either set a target or a direction.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void target_laser_think(gentity_t * self)
|
|
|
|
{
|
|
|
|
vec3_t end;
|
|
|
|
trace_t tr;
|
|
|
|
vec3_t point;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// if pointed at another entity, set movedir to point at it
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->enemy) {
|
|
|
|
VectorMA(self->enemy->s.origin, 0.5, self->enemy->r.mins, point);
|
|
|
|
VectorMA(point, 0.5, self->enemy->r.maxs, point);
|
|
|
|
VectorSubtract(point, self->s.origin, self->movedir);
|
|
|
|
VectorNormalize(self->movedir);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
// fire forward and see what we hit
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorMA(self->s.origin, 2048, self->movedir, end);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_Trace(&tr, self->s.origin, NULL, NULL, end, self->s.number,
|
|
|
|
CONTENTS_SOLID | CONTENTS_BODY | CONTENTS_CORPSE);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (tr.entityNum) {
|
2001-05-06 20:50:27 +00:00
|
|
|
// hurt it if we can
|
2002-06-16 20:06:15 +00:00
|
|
|
G_Damage(&g_entities[tr.entityNum], self, self->activator, self->movedir,
|
|
|
|
tr.endpos, self->damage, DAMAGE_NO_KNOCKBACK, MOD_TARGET_LASER);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorCopy(tr.endpos, self->s.origin2);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
self->nextthink = level.time + FRAMETIME;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void target_laser_on(gentity_t * self)
|
2001-05-06 20:50:27 +00:00
|
|
|
{
|
|
|
|
if (!self->activator)
|
|
|
|
self->activator = self;
|
2002-06-16 20:06:15 +00:00
|
|
|
target_laser_think(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void target_laser_off(gentity_t * self)
|
2001-05-06 20:50:27 +00:00
|
|
|
{
|
2011-07-14 18:37:19 +00:00
|
|
|
trap_UnlinkEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
self->nextthink = 0;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void target_laser_use(gentity_t * self, gentity_t * other, gentity_t * activator)
|
2001-05-06 20:50:27 +00:00
|
|
|
{
|
|
|
|
self->activator = activator;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->nextthink > 0)
|
|
|
|
target_laser_off(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
else
|
2002-06-16 20:06:15 +00:00
|
|
|
target_laser_on(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void target_laser_start(gentity_t * self)
|
2001-05-06 20:50:27 +00:00
|
|
|
{
|
|
|
|
gentity_t *ent;
|
|
|
|
|
|
|
|
self->s.eType = ET_BEAM;
|
|
|
|
|
|
|
|
if (self->target) {
|
2002-06-16 20:06:15 +00:00
|
|
|
ent = G_Find(NULL, FOFS(targetname), self->target);
|
2001-05-06 20:50:27 +00:00
|
|
|
if (!ent) {
|
2002-06-16 20:06:15 +00:00
|
|
|
G_Printf("%s at %s: %s is a bad target\n", self->classname, vtos(self->s.origin), self->target);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
self->enemy = ent;
|
|
|
|
} else {
|
2002-06-16 20:06:15 +00:00
|
|
|
G_SetMovedir(self->s.angles, self->movedir);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self->use = target_laser_use;
|
|
|
|
self->think = target_laser_think;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!self->damage) {
|
2001-05-06 20:50:27 +00:00
|
|
|
self->damage = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self->spawnflags & 1)
|
2002-06-16 20:06:15 +00:00
|
|
|
target_laser_on(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
else
|
2002-06-16 20:06:15 +00:00
|
|
|
target_laser_off(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_laser(gentity_t * self)
|
2001-05-06 20:50:27 +00:00
|
|
|
{
|
|
|
|
// let everything else get spawned before we start firing
|
|
|
|
self->think = target_laser_start;
|
|
|
|
self->nextthink = level.time + FRAMETIME;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void target_teleporter_use(gentity_t * self, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
gentity_t *dest;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
if (!activator->client)
|
|
|
|
return;
|
2002-06-16 20:06:15 +00:00
|
|
|
dest = G_PickTarget(self->target);
|
2001-05-06 20:50:27 +00:00
|
|
|
if (!dest) {
|
2002-06-16 20:06:15 +00:00
|
|
|
G_Printf("Couldn't find teleporter destination\n");
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
TeleportPlayer(activator, dest->s.origin, dest->s.angles);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*QUAKED target_teleporter (1 0 0) (-8 -8 -8) (8 8 8)
|
|
|
|
The activator will be teleported away.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_teleporter(gentity_t * self)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
if (!self->targetname)
|
|
|
|
G_Printf("untargeted %s at %s\n", self->classname, vtos(self->s.origin));
|
|
|
|
|
|
|
|
self->use = target_teleporter_use;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_relay (.5 .5 .5) (-8 -8 -8) (8 8 8) RED_ONLY BLUE_ONLY RANDOM
|
|
|
|
This doesn't perform any actions except fire its targets.
|
|
|
|
The activator can be forced to be from a certain team.
|
|
|
|
if RANDOM is checked, only one of the targets will be fired, not all of them
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void target_relay_use(gentity_t * self, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
if ((self->spawnflags & 1) && activator->client && activator->client->sess.sessionTeam != TEAM_RED) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
if ((self->spawnflags & 2) && activator->client && activator->client->sess.sessionTeam != TEAM_BLUE) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->spawnflags & 4) {
|
|
|
|
gentity_t *ent;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
ent = G_PickTarget(self->target);
|
|
|
|
if (ent && ent->use) {
|
|
|
|
ent->use(ent, self, activator);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
G_UseTargets(self, activator);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_relay(gentity_t * self)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
self->use = target_relay_use;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_kill (.5 .5 .5) (-8 -8 -8) (8 8 8)
|
|
|
|
Kills the activator.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void target_kill_use(gentity_t * self, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
G_Damage(activator, NULL, NULL, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_kill(gentity_t * self)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
self->use = target_kill_use;
|
|
|
|
}
|
|
|
|
|
2003-01-05 22:36:50 +00:00
|
|
|
//==========================================================
|
|
|
|
|
|
|
|
/*QUAKED target_activate (.5 .5 .5) (-8 -8 -8) (8 8 8)
|
|
|
|
Activates/de-activates entities
|
|
|
|
Added by Makro
|
|
|
|
*/
|
|
|
|
void target_activate_use(gentity_t * self, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
gentity_t *loop = NULL;
|
|
|
|
int action = 0;
|
|
|
|
|
2003-01-06 00:23:29 +00:00
|
|
|
if (self->pathtarget) {
|
|
|
|
if (!Q_stricmp(self->pathtarget, "on")) {
|
|
|
|
action = 1;
|
|
|
|
} else if (!Q_stricmp(self->pathtarget, "off")) {
|
|
|
|
action = 2;
|
|
|
|
}
|
2003-01-05 22:36:50 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 00:23:29 +00:00
|
|
|
for (loop = G_Find(NULL, FOFS(activatename), self->target); loop; loop = G_Find(loop, FOFS(activatename), self->target)) {
|
2003-01-05 22:36:50 +00:00
|
|
|
switch (action) {
|
|
|
|
case 1:
|
|
|
|
loop->inactive = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
loop->inactive = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
loop->inactive = !loop->inactive;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SP_target_activate(gentity_t * self)
|
|
|
|
{
|
2003-01-06 00:23:29 +00:00
|
|
|
if (!self->target) {
|
|
|
|
G_Printf(S_COLOR_YELLOW "WARNING: target_activate with no target at %s^7\n", vtos(self->s.origin));
|
2011-07-14 18:58:56 +00:00
|
|
|
G_FreeEntity(self);
|
2003-01-06 00:23:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-01-05 22:36:50 +00:00
|
|
|
self->use = target_activate_use;
|
|
|
|
}
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
/*QUAKED target_position (0 0.5 0) (-4 -4 -4) (4 4 4)
|
|
|
|
Used as a positional target for in-game calculation, like jumppad targets.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_position(gentity_t * self)
|
|
|
|
{
|
|
|
|
G_SetOrigin(self, self->s.origin);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
static void target_location_linkup(gentity_t * ent)
|
2001-05-06 20:50:27 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int n;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (level.locationLinked)
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
level.locationLinked = qtrue;
|
|
|
|
|
|
|
|
level.locationHead = NULL;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_SetConfigstring(CS_LOCATIONS, "unknown");
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
for (i = 0, ent = g_entities, n = 1; i < level.num_entities; i++, ent++) {
|
2001-05-06 20:50:27 +00:00
|
|
|
if (ent->classname && !Q_stricmp(ent->classname, "target_location")) {
|
|
|
|
// lets overload some variables!
|
2002-06-16 20:06:15 +00:00
|
|
|
ent->health = n; // use for location marking
|
|
|
|
trap_SetConfigstring(CS_LOCATIONS + n, ent->message);
|
2001-05-06 20:50:27 +00:00
|
|
|
n++;
|
|
|
|
ent->nextTrain = level.locationHead;
|
|
|
|
level.locationHead = ent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// All linked together now
|
|
|
|
}
|
|
|
|
|
|
|
|
/*QUAKED target_location (0 0.5 0) (-8 -8 -8) (8 8 8)
|
|
|
|
Set "message" to the name of this location.
|
|
|
|
Set "count" to 0-7 for color.
|
|
|
|
0:white 1:red 2:green 3:yellow 4:blue 5:cyan 6:magenta 7:white
|
|
|
|
|
|
|
|
Closest target_location in sight used for the location, if none
|
|
|
|
in site, closest in distance
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_location(gentity_t * self)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
self->think = target_location_linkup;
|
2002-06-16 20:06:15 +00:00
|
|
|
self->nextthink = level.time + 200; // Let them all spawn first
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
G_SetOrigin(self, self->s.origin);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|