2001-12-31 16:16:59 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
2001-12-31 16:28:42 +00:00
|
|
|
// $Log$
|
2005-02-15 16:33:39 +00:00
|
|
|
// Revision 1.33 2005/02/15 16:33:39 makro
|
|
|
|
// Tons of updates (entity tree attachment system, UI vectors)
|
|
|
|
//
|
2004-03-13 01:17:32 +00:00
|
|
|
// Revision 1.32 2004/03/13 01:17:32 makro
|
|
|
|
// no message
|
|
|
|
//
|
2004-03-12 15:56:46 +00:00
|
|
|
// Revision 1.31 2004/03/12 15:56:46 makro
|
|
|
|
// no message
|
|
|
|
//
|
2003-09-18 00:05:06 +00:00
|
|
|
// Revision 1.30 2003/09/18 00:05:06 makro
|
|
|
|
// Lens flares. Opendoor trigger_multiple fixes
|
|
|
|
//
|
2003-09-16 23:25:32 +00:00
|
|
|
// Revision 1.29 2003/09/16 23:25:32 makro
|
|
|
|
// trigger_multiple - new spawnflag, 3 new keys
|
|
|
|
//
|
2003-09-08 19:19:20 +00:00
|
|
|
// Revision 1.28 2003/09/08 19:19:20 makro
|
|
|
|
// New code for respawning entities in TP
|
|
|
|
//
|
2003-07-30 16:05:47 +00:00
|
|
|
// Revision 1.27 2003/07/30 16:05:46 makro
|
|
|
|
// no message
|
|
|
|
//
|
2003-04-26 22:33:07 +00:00
|
|
|
// Revision 1.26 2003/04/26 22:33:07 jbravo
|
|
|
|
// Wratted all calls to G_FreeEnt() to avoid crashing and provide debugging
|
|
|
|
//
|
2003-03-22 20:29:26 +00:00
|
|
|
// Revision 1.25 2003/03/22 20:29:26 jbravo
|
|
|
|
// wrapping linkent and unlinkent calls
|
|
|
|
//
|
2002-07-22 06:35:03 +00:00
|
|
|
// Revision 1.24 2002/07/22 06:32:27 niceass
|
|
|
|
// cleaned up the powerup code
|
|
|
|
//
|
2002-06-16 20:06:15 +00:00
|
|
|
// Revision 1.23 2002/06/16 20:06:14 jbravo
|
|
|
|
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
|
|
|
|
//
|
2002-06-06 18:08:01 +00:00
|
|
|
// Revision 1.22 2002/06/06 18:08:01 makro
|
|
|
|
// Removed pathtarget code for trigger_pushes for now
|
|
|
|
//
|
2002-06-04 21:35:40 +00:00
|
|
|
// Revision 1.21 2002/06/04 21:35:40 makro
|
|
|
|
// Updated trigger_push code
|
|
|
|
//
|
2002-06-04 20:53:19 +00:00
|
|
|
// Revision 1.20 2002/06/04 20:53:19 makro
|
|
|
|
// Trigger_pushes can now be teamed up
|
|
|
|
//
|
2002-05-30 21:18:28 +00:00
|
|
|
// Revision 1.19 2002/05/30 21:18:28 makro
|
|
|
|
// Bots should reload/bandage when roaming around
|
|
|
|
// Added "pathtarget" key to all the entities
|
|
|
|
//
|
2002-05-29 13:49:26 +00:00
|
|
|
// Revision 1.18 2002/05/29 13:49:26 makro
|
|
|
|
// Elevators/doors
|
|
|
|
//
|
2002-05-23 18:37:50 +00:00
|
|
|
// Revision 1.17 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.16 2002/05/23 15:55:25 makro
|
|
|
|
// Elevators
|
|
|
|
//
|
2002-05-22 04:19:45 +00:00
|
|
|
// Revision 1.15 2002/05/22 04:19:45 blaze
|
|
|
|
// Sound entity changes as per Sze
|
|
|
|
//
|
2002-05-18 14:52:16 +00:00
|
|
|
// Revision 1.14 2002/05/18 14:52:16 makro
|
|
|
|
// Bot stuff. Other stuff. Just... stuff :p
|
|
|
|
//
|
2002-05-16 06:57:54 +00:00
|
|
|
// Revision 1.13 2002/05/16 06:57:54 makro
|
|
|
|
// Doors with health (again !), bot-only trigger_pushes
|
|
|
|
//
|
2002-05-11 22:01:41 +00:00
|
|
|
// Revision 1.12 2002/05/11 22:01:41 makro
|
|
|
|
// Trigger_hurt
|
|
|
|
//
|
2002-05-11 17:59:49 +00:00
|
|
|
// Revision 1.11 2002/05/11 17:59:49 makro
|
|
|
|
// Trigger_hurt update
|
|
|
|
//
|
2002-05-11 00:38:47 +00:00
|
|
|
// Revision 1.10 2002/05/11 00:38:47 blaze
|
|
|
|
// trigger_push and target_push default to no noise when the noise flag is not set.
|
|
|
|
//
|
2002-05-05 15:18:03 +00:00
|
|
|
// Revision 1.9 2002/05/05 15:18:03 makro
|
|
|
|
// Fixed some crash bugs. Bot stuff. Triggerable func_statics.
|
|
|
|
// Made flags only spawn in CTF mode
|
|
|
|
//
|
2002-03-18 06:20:39 +00:00
|
|
|
// Revision 1.8 2002/03/18 06:20:39 blaze
|
|
|
|
// noise tag will play sounds for trigger_push and target_push
|
|
|
|
//
|
2002-01-11 19:48:33 +00:00
|
|
|
// Revision 1.7 2002/01/11 19:48:30 jbravo
|
|
|
|
// Formatted the source in non DOS format.
|
|
|
|
//
|
2001-12-31 16:28:42 +00:00
|
|
|
// Revision 1.6 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"
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void InitTrigger(gentity_t * self)
|
|
|
|
{
|
|
|
|
if (!VectorCompare(self->s.angles, vec3_origin))
|
|
|
|
G_SetMovedir(self->s.angles, self->movedir);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_SetBrushModel(self, self->model);
|
|
|
|
self->r.contents = CONTENTS_TRIGGER; // replaces the -1 from trap_SetBrushModel
|
2001-05-06 20:50:27 +00:00
|
|
|
self->r.svFlags = SVF_NOCLIENT;
|
|
|
|
}
|
|
|
|
|
2003-09-16 23:25:32 +00:00
|
|
|
/*QUAKED trigger_multiple (.5 .5 .5) ? DOOR
|
|
|
|
"wait" : Seconds between triggerings, 0.5 default, -1 = one time only.
|
|
|
|
"random" wait variance, default is 0
|
|
|
|
Variable sized repeatable trigger. Must be targeted at one or more entities.
|
|
|
|
so, the basic time between firing is a random time between
|
|
|
|
(wait - random) and (wait + random)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SF_TRIGGER_MULTIPLE_RED 1
|
|
|
|
#define SF_TRIGGER_MULTIPLE_BLUE 2
|
|
|
|
#define SF_TRIGGER_MULTIPLE_DOOR 4
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
// the wait time has passed, so set back up for another activation
|
2002-06-16 20:06:15 +00:00
|
|
|
void multi_wait(gentity_t * ent)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->nextthink = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// the trigger was just activated
|
|
|
|
// ent->activator should be set to the activator so it can be held through a delay
|
|
|
|
// so wait for the delay time before firing
|
2002-06-16 20:06:15 +00:00
|
|
|
void multi_trigger(gentity_t * ent, gentity_t * activator)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->activator = activator;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (ent->nextthink) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return; // can't retrigger until the wait is over
|
|
|
|
}
|
2003-07-30 16:05:47 +00:00
|
|
|
//Makro - inactive trigger ?
|
|
|
|
if (ent->inactive) {
|
2003-09-18 00:05:06 +00:00
|
|
|
//note - since the trigger is not sent to the clients, we cannot send the event
|
|
|
|
//either, so we'll just play the sound locally
|
2003-09-16 23:25:32 +00:00
|
|
|
if (ent->soundInactive)
|
2003-09-18 00:05:06 +00:00
|
|
|
G_AddEvent(ent->activator, EV_GENERAL_SOUND, ent->soundInactive);
|
2003-09-16 23:25:32 +00:00
|
|
|
if (ent->targetInactive)
|
2003-09-18 00:05:06 +00:00
|
|
|
G_UseEntities(ent->activator, ent->targetInactive, activator);
|
|
|
|
ent->think = multi_wait;
|
|
|
|
ent->nextthink = level.time + (ent->wait + ent->random * crandom()) * 1000;
|
2003-07-30 16:05:47 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-05-05 15:18:03 +00:00
|
|
|
//Makro - added check; Q3 crashed in archives when playing
|
|
|
|
//with .dll's and shooting one of the barrels
|
2002-06-16 20:06:15 +00:00
|
|
|
if (activator != NULL) {
|
|
|
|
if (activator->client) {
|
2003-09-16 23:25:32 +00:00
|
|
|
if ((ent->spawnflags & SF_TRIGGER_MULTIPLE_RED) && activator->client->sess.sessionTeam != TEAM_RED) {
|
2002-05-05 15:18:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-09-16 23:25:32 +00:00
|
|
|
if ((ent->spawnflags & SF_TRIGGER_MULTIPLE_BLUE) && activator->client->sess.sessionTeam != TEAM_BLUE) {
|
2002-05-05 15:18:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-16 23:25:32 +00:00
|
|
|
if (ent->sound1to2)
|
2003-09-18 00:05:06 +00:00
|
|
|
G_AddEvent(ent->activator, EV_GENERAL_SOUND, ent->sound1to2);
|
2002-06-16 20:06:15 +00:00
|
|
|
G_UseTargets(ent, ent->activator);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (ent->wait > 0) {
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->think = multi_wait;
|
2002-06-16 20:06:15 +00:00
|
|
|
ent->nextthink = level.time + (ent->wait + ent->random * crandom()) * 1000;
|
2001-05-06 20:50:27 +00:00
|
|
|
} else {
|
|
|
|
// we can't just remove (self) here, because this is a touch function
|
|
|
|
// called while looping through area links...
|
2003-09-08 19:19:20 +00:00
|
|
|
//Makro - we no longer remove the entity, we just make it inactive
|
|
|
|
//otherwise, we would only be able to use it during the first
|
|
|
|
//round in TP games
|
|
|
|
/*
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->touch = 0;
|
|
|
|
ent->nextthink = level.time + FRAMETIME;
|
2011-07-14 18:58:56 +00:00
|
|
|
ent->think = G_FreeEntity;
|
2003-09-08 19:19:20 +00:00
|
|
|
*/
|
2003-09-18 00:05:06 +00:00
|
|
|
//On second thought, now that I've added those soundInactive/targetInactive keys
|
|
|
|
//I think just setting touch to 0 will do
|
|
|
|
//ent->inactive = 1;
|
|
|
|
ent->touch = 0;
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void Use_Multi(gentity_t * ent, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
multi_trigger(ent, activator);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void Touch_Multi(gentity_t * self, gentity_t * other, trace_t * trace)
|
|
|
|
{
|
2005-02-15 16:33:39 +00:00
|
|
|
if (!other || !other->client) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-02-15 16:33:39 +00:00
|
|
|
if (self->spawnflags & SF_TRIGGER_MULTIPLE_DOOR) {
|
|
|
|
if (!other->client->openDoor || other->client->openDoorTime <= self->timestamp)
|
|
|
|
return;
|
|
|
|
self->timestamp = other->client->openDoorTime;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
multi_trigger(self, other);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2003-09-08 19:19:20 +00:00
|
|
|
void Reset_Multi(gentity_t *ent)
|
|
|
|
{
|
|
|
|
ent->inactive = ent->unbreakable;
|
|
|
|
ent->think = 0;
|
|
|
|
ent->nextthink = 0;
|
2003-09-18 00:05:06 +00:00
|
|
|
ent->touch = Touch_Multi;
|
2003-09-08 19:19:20 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_trigger_multiple(gentity_t * ent)
|
|
|
|
{
|
2003-09-16 23:25:32 +00:00
|
|
|
char *s;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
G_SpawnFloat("wait", "0.5", &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 (ent->random >= ent->wait && ent->wait >= 0) {
|
2001-05-06 20:50:27 +00:00
|
|
|
ent->random = ent->wait - FRAMETIME;
|
2002-06-16 20:06:15 +00:00
|
|
|
G_Printf("trigger_multiple has random >= wait\n");
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
2003-09-16 23:25:32 +00:00
|
|
|
//Makro - added
|
|
|
|
if (G_SpawnString("soundInactive", "", &s))
|
|
|
|
ent->soundInactive = G_SoundIndex(s);
|
|
|
|
if (G_SpawnString("noise", "", &s))
|
|
|
|
ent->sound1to2 = G_SoundIndex(s);
|
|
|
|
else if (G_SpawnString("sound", "", &s))
|
|
|
|
ent->sound1to2 = G_SoundIndex(s);
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
ent->touch = Touch_Multi;
|
|
|
|
ent->use = Use_Multi;
|
2003-09-08 19:19:20 +00:00
|
|
|
ent->unbreakable = ent->inactive;
|
|
|
|
ent->reset = Reset_Multi;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
InitTrigger(ent);
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(ent);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
trigger_always
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void trigger_always_think(gentity_t * ent)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
G_UseTargets(ent, ent);
|
2004-03-13 01:17:32 +00:00
|
|
|
//Makro - we want to be able to re-use this entity (round-based gametypes)
|
|
|
|
//so we're not going to free it
|
2011-07-14 18:58:56 +00:00
|
|
|
//G_FreeEntity(ent);
|
2011-07-14 18:37:19 +00:00
|
|
|
trap_UnlinkEntity(ent);
|
2004-03-13 01:17:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Makro - reset function
|
|
|
|
void trigger_always_reset(gentity_t *ent)
|
|
|
|
{
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(ent);
|
2004-03-13 01:17:32 +00:00
|
|
|
ent->nextthink = level.time + 300;
|
|
|
|
ent->think = trigger_always_think;
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*QUAKED trigger_always (.5 .5 .5) (-8 -8 -8) (8 8 8)
|
|
|
|
This trigger will always fire. It is activated by the world.
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_trigger_always(gentity_t * ent)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
// we must have some delay to make sure our use targets are present
|
|
|
|
ent->nextthink = level.time + 300;
|
|
|
|
ent->think = trigger_always_think;
|
2004-03-13 01:17:32 +00:00
|
|
|
//Makro - reset function
|
|
|
|
ent->reset = trigger_always_reset;
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
trigger_push
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void trigger_push_touch(gentity_t * self, gentity_t * other, trace_t * trace)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-06 18:08:01 +00:00
|
|
|
if (!other || !self)
|
|
|
|
return;
|
2002-06-16 20:06:15 +00:00
|
|
|
|
|
|
|
if (!other->client) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-06-04 20:53:19 +00:00
|
|
|
//Makro - too soon to activate ?
|
2002-06-06 18:08:01 +00:00
|
|
|
/*if (level.time < self->s.legsAnim) {
|
2002-06-16 20:06:15 +00:00
|
|
|
return;
|
|
|
|
} */
|
2002-06-04 20:53:19 +00:00
|
|
|
|
2002-05-16 06:57:54 +00:00
|
|
|
//Makro - bot only triggers
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->spawnflags & 1) {
|
|
|
|
if (!(other->r.svFlags & SVF_BOT)) {
|
2002-05-16 06:57:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
BG_TouchJumpPad(&other->client->ps, &self->s);
|
2002-06-06 18:08:01 +00:00
|
|
|
//Makro - "team up" trigger_pushes
|
|
|
|
//something is broken here :/
|
|
|
|
/*
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->pathtarget) {
|
|
|
|
if (self->pathtarget[0]) {
|
|
|
|
gentity_t *loop = NULL;
|
|
|
|
for (loop = G_Find2(NULL, FOFS(classname), self->classname, FOFS(pathtarget), self->pathtarget); loop; G_Find2(loop, FOFS(classname), self->classname, FOFS(pathtarget), self->pathtarget)) {
|
|
|
|
//Makro - delay 5 seconds before triggering another trigger_push from the same "team"
|
|
|
|
if (self->distance) {
|
|
|
|
loop->s.legsAnim = level.time + self->distance * 1000;
|
|
|
|
} else {
|
|
|
|
loop->s.legsAnim = level.time + 5 * 1000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} */
|
2002-06-04 20:53:19 +00:00
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
AimAtTarget
|
|
|
|
|
|
|
|
Calculate origin2 so the target apogee will be hit
|
|
|
|
=================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void AimAtTarget(gentity_t * self)
|
|
|
|
{
|
|
|
|
gentity_t *ent;
|
|
|
|
vec3_t origin;
|
|
|
|
float height, gravity, time, forward;
|
|
|
|
float dist;
|
|
|
|
|
|
|
|
VectorAdd(self->r.absmin, self->r.absmax, origin);
|
|
|
|
VectorScale(origin, 0.5, origin);
|
|
|
|
|
|
|
|
ent = G_PickTarget(self->target);
|
|
|
|
if (!ent) {
|
2011-07-14 18:58:56 +00:00
|
|
|
G_FreeEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
height = ent->s.origin[2] - origin[2];
|
|
|
|
gravity = g_gravity.value;
|
2002-06-16 20:06:15 +00:00
|
|
|
time = sqrt(height / (.5 * gravity));
|
|
|
|
if (!time) {
|
2011-07-14 18:58:56 +00:00
|
|
|
G_FreeEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// set s.origin2 to the push velocity
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorSubtract(ent->s.origin, origin, self->s.origin2);
|
2001-05-06 20:50:27 +00:00
|
|
|
self->s.origin2[2] = 0;
|
2002-06-16 20:06:15 +00:00
|
|
|
dist = VectorNormalize(self->s.origin2);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
forward = dist / time;
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorScale(self->s.origin2, forward, self->s.origin2);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
self->s.origin2[2] = time * gravity;
|
|
|
|
}
|
|
|
|
|
2002-05-16 06:57:54 +00:00
|
|
|
/*QUAKED trigger_push (.5 .5 .5) ? BOT_ONLY
|
2001-05-06 20:50:27 +00:00
|
|
|
Must point at a target_position, which will be the apex of the leap.
|
|
|
|
This will be client side predicted, unlike target_push
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_trigger_push(gentity_t * self)
|
|
|
|
{
|
2001-12-17 15:08:34 +00:00
|
|
|
char *sound;
|
2002-06-16 20:06:15 +00:00
|
|
|
|
|
|
|
InitTrigger(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// unlike other triggers, we need to send this one to the client
|
2001-12-17 15:08:34 +00:00
|
|
|
// NiceAss: Added for custom push sounds. Default is none. Q3 is "sounds/world/bouncepad.wav"
|
2002-06-16 20:06:15 +00:00
|
|
|
//Changed from noise to sound as per Sze
|
|
|
|
if (G_SpawnString("sound", "sound/misc/silence.wav", &sound)) {
|
|
|
|
self->s.generic1 = G_SoundIndex(sound);
|
2001-12-17 15:08:34 +00:00
|
|
|
}
|
2002-05-18 14:52:16 +00:00
|
|
|
//Makro - for bot-only triggers
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!(self->spawnflags & 1)) {
|
2002-05-18 14:52:16 +00:00
|
|
|
self->r.svFlags &= ~SVF_NOCLIENT;
|
|
|
|
}
|
2002-05-29 13:49:26 +00:00
|
|
|
self->s.powerups = (self->spawnflags & 1);
|
2001-05-06 20:50:27 +00:00
|
|
|
self->s.eType = ET_PUSH_TRIGGER;
|
|
|
|
self->touch = trigger_push_touch;
|
|
|
|
self->think = AimAtTarget;
|
|
|
|
self->nextthink = level.time + FRAMETIME;
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void Use_target_push(gentity_t * self, 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.pm_type != PM_NORMAL) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorCopy(self->s.origin2, activator->client->ps.velocity);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// play fly sound every 1.5 seconds
|
2002-06-16 20:06:15 +00:00
|
|
|
if (activator->fly_sound_debounce_time < level.time) {
|
2001-05-06 20:50:27 +00:00
|
|
|
activator->fly_sound_debounce_time = level.time + 1500;
|
2001-06-24 02:08:15 +00:00
|
|
|
//Elder: added to check noise_index
|
|
|
|
if (self->noise_index)
|
2002-06-16 20:06:15 +00:00
|
|
|
G_Sound(activator, CHAN_AUTO, self->noise_index);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*QUAKED target_push (.5 .5 .5) (-8 -8 -8) (8 8 8) bouncepad
|
|
|
|
Pushes the activator in the direction.of angle, or towards a target apex.
|
|
|
|
"speed" defaults to 1000
|
|
|
|
if "bouncepad", play bounce noise instead of windfly
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_target_push(gentity_t * self)
|
|
|
|
{
|
|
|
|
char *sound;
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
if (!self->speed) {
|
|
|
|
self->speed = 1000;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
G_SetMovedir(self->s.angles, self->s.origin2);
|
|
|
|
VectorScale(self->s.origin2, self->speed, self->s.origin2);
|
|
|
|
//Changed from noise to sound as per Sze
|
|
|
|
if (G_SpawnString("sound", "sound/misc/silence.wav", &sound)) {
|
2002-05-16 06:57:54 +00:00
|
|
|
//Makro - debug message, no longer needed
|
|
|
|
//G_Printf("^2Sound was %s\n",sound);
|
2002-06-16 20:06:15 +00:00
|
|
|
self->noise_index = G_SoundIndex(sound);
|
2002-03-18 06:20:39 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->spawnflags & 1) {
|
2001-06-08 04:47:30 +00:00
|
|
|
//Elder: edited for now TODO: let mappers use a key pair
|
|
|
|
//self->noise_index = G_SoundIndex("sound/world/jumppad.wav");
|
2001-05-06 20:50:27 +00:00
|
|
|
} else {
|
2001-06-08 04:47:30 +00:00
|
|
|
//Elder: edited for now TODO: let mappers use a key pair
|
|
|
|
//self->noise_index = G_SoundIndex("sound/misc/windfly.wav");
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->target) {
|
|
|
|
VectorCopy(self->s.origin, self->r.absmin);
|
|
|
|
VectorCopy(self->s.origin, self->r.absmax);
|
2001-05-06 20:50:27 +00:00
|
|
|
self->think = AimAtTarget;
|
|
|
|
self->nextthink = level.time + FRAMETIME;
|
|
|
|
}
|
|
|
|
self->use = Use_target_push;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
trigger_teleport
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void trigger_teleporter_touch(gentity_t * self, gentity_t * other, trace_t * trace)
|
|
|
|
{
|
|
|
|
gentity_t *dest;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!other->client) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
if (other->client->ps.pm_type == PM_DEAD) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Spectators only?
|
2002-06-16 20:06:15 +00:00
|
|
|
if ((self->spawnflags & 1) && other->client->sess.sessionTeam != TEAM_SPECTATOR) {
|
2001-05-06 20:50:27 +00:00
|
|
|
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(other, dest->s.origin, dest->s.angles);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*QUAKED trigger_teleport (.5 .5 .5) ? SPECTATOR
|
|
|
|
Allows client side prediction of teleportation events.
|
|
|
|
Must point at a target_position, which will be the teleport destination.
|
|
|
|
|
|
|
|
If spectator is set, only spectators can use this teleport
|
|
|
|
Spectator teleporters are not normally placed in the editor, but are created
|
|
|
|
automatically near doors to allow spectators to move through them
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_trigger_teleport(gentity_t * self)
|
|
|
|
{
|
|
|
|
InitTrigger(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// unlike other triggers, we need to send this one to the client
|
|
|
|
// unless is a spectator trigger
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->spawnflags & 1) {
|
2001-05-06 20:50:27 +00:00
|
|
|
self->r.svFlags |= SVF_NOCLIENT;
|
|
|
|
} else {
|
|
|
|
self->r.svFlags &= ~SVF_NOCLIENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure the client precaches this sound
|
|
|
|
G_SoundIndex("sound/world/jumppad.wav");
|
|
|
|
|
|
|
|
self->s.eType = ET_TELEPORT_TRIGGER;
|
|
|
|
self->touch = trigger_teleporter_touch;
|
|
|
|
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
trigger_hurt
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*QUAKED trigger_hurt (.5 .5 .5) ? START_OFF - SILENT NO_PROTECTION SLOW
|
|
|
|
Any entity that touches this will be hurt.
|
|
|
|
It does dmg points of damage each server frame
|
|
|
|
Targeting the trigger will toggle its on / off state.
|
|
|
|
|
|
|
|
SILENT supresses playing the sound
|
|
|
|
SLOW changes the damage rate to once per second
|
|
|
|
NO_PROTECTION *nothing* stops the damage
|
|
|
|
|
|
|
|
"dmg" default 5 (whole numbers only)
|
|
|
|
|
|
|
|
*/
|
2004-03-12 15:56:46 +00:00
|
|
|
//Makro - reset function
|
|
|
|
void hurt_reset(gentity_t *ent)
|
|
|
|
{
|
|
|
|
ent->timestamp = level.time;
|
|
|
|
if (!(ent->spawnflags & 1)) {
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(ent);
|
2004-03-12 15:56:46 +00:00
|
|
|
} else {
|
|
|
|
//Makro - added
|
2011-07-14 18:37:19 +00:00
|
|
|
trap_UnlinkEntity(ent);
|
2004-03-12 15:56:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void hurt_use(gentity_t * self, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
|
|
|
if (self->r.linked) {
|
2011-07-14 18:37:19 +00:00
|
|
|
trap_UnlinkEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
} else {
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void hurt_touch(gentity_t * self, gentity_t * other, trace_t * trace)
|
|
|
|
{
|
|
|
|
int dflags;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!other->takedamage) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->timestamp > level.time) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->spawnflags & 16) {
|
2001-05-06 20:50:27 +00:00
|
|
|
self->timestamp = level.time + 1000;
|
|
|
|
} else {
|
|
|
|
self->timestamp = level.time + FRAMETIME;
|
|
|
|
}
|
|
|
|
|
|
|
|
// play sound
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!(self->spawnflags & 4)) {
|
|
|
|
G_Sound(other, CHAN_AUTO, self->noise_index);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (self->spawnflags & 8)
|
|
|
|
dflags = DAMAGE_NO_PROTECTION;
|
|
|
|
else
|
|
|
|
dflags = 0;
|
2005-02-15 16:33:39 +00:00
|
|
|
if (self->methodOfDeath)
|
|
|
|
{
|
|
|
|
G_Damage(other, self, self, NULL, NULL, self->damage, dflags, MOD_CUSTOM+self->methodOfDeath-1);
|
|
|
|
} else {
|
|
|
|
G_Damage(other, self, self, NULL, NULL, self->damage, dflags, MOD_TRIGGER_HURT);
|
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_trigger_hurt(gentity_t * self)
|
|
|
|
{
|
|
|
|
InitTrigger(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
self->noise_index = G_SoundIndex("sound/world/electro.wav");
|
2001-05-06 20:50:27 +00:00
|
|
|
self->touch = hurt_touch;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!self->damage) {
|
2001-05-06 20:50:27 +00:00
|
|
|
self->damage = 5;
|
|
|
|
}
|
|
|
|
|
2012-01-13 17:20:39 +00:00
|
|
|
//self->r.contents = CONTENTS_TRIGGER;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2005-02-15 16:33:39 +00:00
|
|
|
//Makro - custom death message
|
|
|
|
G_InitCustomDeathMessage(self, &self->methodOfDeath);
|
|
|
|
|
2002-05-11 17:59:49 +00:00
|
|
|
//Makro - removed this check
|
|
|
|
//if ( self->spawnflags & 2 ) {
|
2002-06-16 20:06:15 +00:00
|
|
|
self->use = hurt_use;
|
2002-05-11 17:59:49 +00:00
|
|
|
//}
|
2004-03-12 15:56:46 +00:00
|
|
|
//Makro - reset function
|
|
|
|
self->reset = hurt_reset;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// link in to the world if starting active
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!(self->spawnflags & 1)) {
|
2011-07-14 18:29:55 +00:00
|
|
|
trap_LinkEntity(self);
|
2002-05-11 22:01:41 +00:00
|
|
|
} else {
|
|
|
|
//Makro - added
|
2011-07-14 18:37:19 +00:00
|
|
|
trap_UnlinkEntity(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
timer
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*QUAKED func_timer (0.3 0.1 0.6) (-8 -8 -8) (8 8 8) START_ON
|
|
|
|
This should be renamed trigger_timer...
|
|
|
|
Repeatedly fires its targets.
|
|
|
|
Can be turned on or off by using.
|
|
|
|
|
|
|
|
"wait" base time between triggering all targets, default is 1
|
|
|
|
"random" wait variance, default is 0
|
|
|
|
so, the basic time between firing is a random time between
|
|
|
|
(wait - random) and (wait + random)
|
|
|
|
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void func_timer_think(gentity_t * self)
|
|
|
|
{
|
|
|
|
G_UseTargets(self, self->activator);
|
2001-05-06 20:50:27 +00:00
|
|
|
// set time before next firing
|
2002-06-16 20:06:15 +00:00
|
|
|
self->nextthink = level.time + 1000 * (self->wait + crandom() * self->random);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void func_timer_use(gentity_t * self, gentity_t * other, gentity_t * activator)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
self->activator = activator;
|
|
|
|
|
|
|
|
// if on, turn it off
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->nextthink) {
|
2001-05-06 20:50:27 +00:00
|
|
|
self->nextthink = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// turn it on
|
2002-06-16 20:06:15 +00:00
|
|
|
func_timer_think(self);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void SP_func_timer(gentity_t * self)
|
|
|
|
{
|
|
|
|
G_SpawnFloat("random", "1", &self->random);
|
|
|
|
G_SpawnFloat("wait", "1", &self->wait);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
self->use = func_timer_use;
|
|
|
|
self->think = func_timer_think;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->random >= self->wait) {
|
2001-05-06 20:50:27 +00:00
|
|
|
self->random = self->wait - FRAMETIME;
|
2002-06-16 20:06:15 +00:00
|
|
|
G_Printf("func_timer at %s has random >= wait\n", vtos(self->s.origin));
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (self->spawnflags & 1) {
|
2001-05-06 20:50:27 +00:00
|
|
|
self->nextthink = level.time + FRAMETIME;
|
|
|
|
self->activator = self;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->r.svFlags = SVF_NOCLIENT;
|
|
|
|
}
|