Update for new QF features.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2003-03-03 19:17:04 +00:00
parent f9c0b28fec
commit e16af82af2
23 changed files with 4122 additions and 4878 deletions

View file

@ -1,5 +1,5 @@
/*
#FILENAME#
triggers.qc
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -22,11 +22,10 @@
$Id$
*/
entity stemp, otemp, s, old;
void() trigger_reactivate =
void ()
trigger_reactivate =
{
self.solid = SOLID_TRIGGER;
};
@ -37,29 +36,26 @@ float SPAWNFLAG_NOMESSAGE = 1;
float SPAWNFLAG_NOTOUCH = 1;
// the wait time has passed, so set back up for another activation
void() multi_wait =
void ()
multi_wait =
{
if (self.max_health)
{
if (self.max_health) {
self.health = self.max_health;
self.takedamage = DAMAGE_YES;
self.solid = SOLID_BBOX;
}
};
// the trigger was just touched/killed/used
// self.enemy should be set to the activator so it can be held through a delay
// so wait for the delay time before firing
void() multi_trigger =
void ()
multi_trigger =
{
if (self.nextthink > time)
{
return; // allready been triggered
}
if (self.classname == "trigger_secret")
{
if (self.classname == "trigger_secret") {
if (self.enemy.classname != "player")
return;
found_secrets = found_secrets + 1;
@ -69,20 +65,18 @@ void() multi_trigger =
if (self.noise)
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
// don't trigger again until reset
// don't trigger again until reset
self.takedamage = DAMAGE_NO;
activator = self.enemy;
SUB_UseTargets();
if (self.wait > 0)
{
SUB_UseTargets ();
if (self.wait > 0) {
self.think = multi_wait;
self.nextthink = time + self.wait;
}
else
{ // we can't just remove (self) here, because this is a touch function
} else {
// we can't just remove (self) here, because this is a touch function
// called wheil C code is looping through area links...
self.touch = SUB_Null;
self.nextthink = time + 0.1;
@ -90,26 +84,28 @@ void() multi_trigger =
}
};
void() multi_killed =
void ()
multi_killed =
{
self.enemy = damage_attacker;
multi_trigger();
multi_trigger ();
};
void() multi_use =
void ()
multi_use =
{
self.enemy = activator;
multi_trigger();
multi_trigger ();
};
void() multi_touch =
void ()
multi_touch =
{
if (other.classname != "player")
return;
// if the trigger has an angles field, check player's facing direction
if (self.movedir != '0 0 0')
{
// if the trigger has an angles field, check player's facing direction
if (self.movedir != '0 0 0') {
makevectors (other.angles);
if (v_forward * self.movedir < 0)
return; // not facing the right way
@ -132,32 +128,32 @@ sounds
4)
set "message" to text string
*/
void() trigger_multiple =
void ()
trigger_multiple =
{
if (self.sounds == 1)
{
switch (self.sounds) {
case 1:
precache_sound ("misc/secret.wav");
self.noise = "misc/secret.wav";
}
else if (self.sounds == 2)
{
break;
case 2:
precache_sound ("misc/talk.wav");
self.noise = "misc/talk.wav";
}
else if (self.sounds == 3)
{
break;
case 3:
precache_sound ("misc/trigger1.wav");
self.noise = "misc/trigger1.wav";
default:
break;
}
if (!self.wait)
self.wait = 0.2;
self.use = multi_use;
InitTrigger ();
if (self.health)
{
if (self.health) {
if (self.spawnflags & SPAWNFLAG_NOTOUCH)
objerror ("health and notouch don't make sense\n");
self.max_health = self.health;
@ -165,17 +161,12 @@ void() trigger_multiple =
self.takedamage = DAMAGE_YES;
self.solid = SOLID_BBOX;
setorigin (self, self.origin); // make sure it links into the world
}
else
{
if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
{
} else {
if (!(self.spawnflags & SPAWNFLAG_NOTOUCH))
self.touch = multi_touch;
}
}
};
/*QUAKED trigger_once (.5 .5 .5) ? notouch
Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching
"targetname". If "health" is set, the trigger must be killed to activate.
@ -189,10 +180,11 @@ sounds
4)
set "message" to text string
*/
void() trigger_once =
void ()
trigger_once =
{
self.wait = -1;
trigger_multiple();
trigger_multiple ();
};
//=============================================================================
@ -200,12 +192,12 @@ void() trigger_once =
/*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8)
This fixed size trigger cannot be touched, it can only be fired by other events. It can contain killtargets, targets, delays, and messages.
*/
void() trigger_relay =
void ()
trigger_relay =
{
self.use = SUB_UseTargets;
};
//=============================================================================
/*QUAKED trigger_secret (.5 .5 .5) ?
@ -217,24 +209,25 @@ sounds
4)
set "message" to text string
*/
void() trigger_secret =
void ()
trigger_secret =
{
total_secrets = total_secrets + 1;
total_secrets++;
self.wait = -1;
if (!self.message)
self.message = "You found a secret area!";
if (!self.sounds)
switch (self.sounds) {
default:
self.sounds = 1;
if (self.sounds == 1)
{
case 1:
precache_sound ("misc/secret.wav");
self.noise = "misc/secret.wav";
}
else if (self.sounds == 2)
{
break;
case 2:
precache_sound ("misc/talk.wav");
self.noise = "misc/talk.wav";
break;
}
trigger_multiple ();
@ -242,34 +235,38 @@ void() trigger_secret =
//=============================================================================
void() counter_use =
void ()
counter_use =
{
self.count = self.count - 1;
self.count--;
if (self.count < 0)
return;
if (self.count != 0)
{
if (self.count > 0) {
if (activator.classname == "player"
&& (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
{
if (self.count >= 4)
&& (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0) {
switch (self.count) {
default:
centerprint (activator, "There are more to go...");
else if (self.count == 3)
break;
case 3:
centerprint (activator, "Only 3 more to go...");
else if (self.count == 2)
break;
case 2:
centerprint (activator, "Only 2 more to go...");
else
break;
case 1:
centerprint (activator, "Only 1 more to go...");
break;
}
}
return;
}
if (activator.classname == "player"
&& (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
centerprint(activator, "Sequence completed!");
self.enemy = activator;
&& (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
centerprint (activator, "Sequence completed!");
self.enemy = activator;
multi_trigger ();
};
@ -280,94 +277,87 @@ If nomessage is not set, t will print "1 more.. " etc when triggered and "sequen
After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
*/
void() trigger_counter =
void ()
trigger_counter =
{
self.wait = -1;
self.wait--;
if (!self.count)
self.count = 2;
self.use = counter_use;
};
/*
==============================================================================
TELEPORT TRIGGERS
==============================================================================
*/
// TELEPORT TRIGGERS ==========================================================
float PLAYER_ONLY = 1;
float SILENT = 2;
void() play_teleport =
void ()
play_teleport =
{
local float v;
local string tmpstr;
local string tmpstr = "misc/r_tele5.wav";
v = random() * 5;
if (v < 1)
switch (rint (5 * random())) {
case 0:
tmpstr = "misc/r_tele1.wav";
else if (v < 2)
break;
case 1:
tmpstr = "misc/r_tele2.wav";
else if (v < 3)
break;
case 2:
tmpstr = "misc/r_tele3.wav";
else if (v < 4)
break;
case 3:
tmpstr = "misc/r_tele4.wav";
else
tmpstr = "misc/r_tele5.wav";
break;
default:
// tmpstr = "misc/r_tele5.wav";
break;
}
sound (self, CHAN_VOICE, tmpstr, 1, ATTN_NORM);
remove (self);
};
void(vector org) spawn_tfog =
void (vector org)
spawn_tfog =
{
s = spawn ();
s.origin = org;
s.nextthink = time + 0.2;
s.think = play_teleport;
WriteByte (MSG_MULTICAST, SVC_TEMPENTITY);
WriteByte (MSG_MULTICAST, TE_TELEPORT);
WriteCoord (MSG_MULTICAST, org_x);
WriteCoord (MSG_MULTICAST, org_y);
WriteCoord (MSG_MULTICAST, org_z);
WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_TELEPORT);
WriteCoordV (MSG_MULTICAST, org);
multicast (org, MULTICAST_PHS);
};
void() tdeath_touch =
void ()
tdeath_touch =
{
if (other == self.owner)
return;
// frag anyone who teleports in on top of an invincible player
if (other.classname == "player")
{
// frag anyone who teleports in on top of an invincible player
if (other.classname == "player") {
if (other.invincible_finished > time)
self.classname = "teledeath2";
if (self.owner.classname != "player")
{ // other monsters explode themselves
if (self.owner.classname != "player") {
// other monsters explode themselves
T_Damage (self.owner, self, self, 50000);
return;
}
}
if (other.health)
{
T_Damage (other, self, self, 50000);
}
};
void(vector org, entity death_owner) spawn_tdeath =
void (vector org, entity death_owner)
spawn_tdeath =
{
local entity death;
local entity death;
death = spawn();
death = spawn ();
death.classname = "teledeath";
death.movetype = MOVETYPE_NONE;
death.solid = SOLID_TRIGGER;
@ -382,82 +372,73 @@ local entity death;
force_retouch = 2; // make sure even still objects get hit
};
void() teleport_touch =
void ()
teleport_touch =
{
local entity t;
local vector org;
local entity t;
local vector org;
if (self.targetname)
{
if (self.nextthink < time)
{
return; // not fired yet
}
}
if (self.spawnflags & PLAYER_ONLY)
{
if (other.classname != "player")
return;
}
// only teleport living creatures
// only teleport living creatures
if (other.health <= 0 || other.solid != SOLID_SLIDEBOX)
return;
SUB_UseTargets ();
// put a tfog where the player was
// put a tfog where the player was
spawn_tfog (other.origin);
t = find (world, targetname, self.target);
if (!t)
objerror ("couldn't find target");
// spawn a tfog flash in front of the destination
// spawn a tfog flash in front of the destination
makevectors (t.mangle);
org = t.origin + 32 * v_forward;
spawn_tfog (org);
spawn_tdeath(t.origin, other);
spawn_tdeath (t.origin, other);
// move the player and lock him down for a little while
if (!other.health)
{
// move the player and lock him down for a little while
if (!other.health) {
other.origin = t.origin;
other.velocity = (v_forward * other.velocity_x) + (v_forward * other.velocity_y);
other.velocity = v_forward * (other.velocity_x + other.velocity_y);
return;
}
setorigin (other, t.origin);
other.angles = t.mangle;
if (other.classname == "player")
{
// Teleporting - detach hook (wedge)
if (other.weapon == IT_GRAPPLE && other.hook_out)
{
sound (other, CHAN_WEAPON, "weapons/bounce2.wav", 1, ATTN_NORM);
other.on_hook = FALSE;
other.hook_out = FALSE;
other.weaponframe = 0;
other.attack_finished = time + 0.75;// avoid instant rehook
}
if (other.classname == "player") {
// Teleporting - detach hook (wedge)
if (other.weapon == IT_GRAPPLE && other.hook_out) {
sound (other, CHAN_WEAPON, "weapons/bounce2.wav", 1, ATTN_NORM);
other.on_hook = FALSE;
other.hook_out = FALSE;
other.weaponframe = 0;
other.attack_finished = time + 0.75;// avoid instant rehook
}
other.fixangle = 1; // turn this way immediately
other.fixangle = 1; // turn this way immediately
other.teleport_time = time + 0.7;
if (other.flags & FL_ONGROUND)
other.flags = other.flags - FL_ONGROUND;
other.flags &= ~FL_ONGROUND;
other.velocity = v_forward * 300;
}
other.flags = other.flags - other.flags & FL_ONGROUND;
other.flags &= ~FL_ONGROUND;
};
/*QUAKED info_teleport_destination (.5 .5 .5) (-8 -8 -8) (8 8 32)
This is the destination marker for a teleporter. It should have a "targetname" field with the same value as a teleporter's "target" field.
*/
void() info_teleport_destination =
void ()
info_teleport_destination =
{
// this does nothing, just serves as a target spot
// this does nothing, just serves as a target spot
self.mangle = self.angles;
self.angles = '0 0 0';
self.model = "";
@ -466,7 +447,8 @@ void() info_teleport_destination =
objerror ("no targetname");
};
void() teleport_use =
void ()
teleport_use =
{
self.nextthink = time + 0.2;
force_retouch = 2; // make sure even still objects get hit
@ -478,9 +460,10 @@ Any object touching this will be transported to the corresponding info_teleport_
If the trigger_teleport has a targetname, it will only teleport entities when it has been fired.
*/
void() trigger_teleport =
void ()
trigger_teleport =
{
local vector o;
local vector o;
InitTrigger ();
self.touch = teleport_touch;
@ -489,41 +472,30 @@ void() trigger_teleport =
objerror ("no target");
self.use = teleport_use;
if (!(self.spawnflags & SILENT))
{
if (!(self.spawnflags & SILENT)) {
precache_sound ("ambience/hum1.wav");
o = (self.mins + self.maxs)*0.5;
ambientsound (o, "ambience/hum1.wav",0.5 , ATTN_STATIC);
o = (self.mins + self.maxs) * 0.5;
ambientsound (o, "ambience/hum1.wav", 0.5 , ATTN_STATIC);
}
};
/*
==============================================================================
trigger_setskill
==============================================================================
*/
// trigger_setskill ===========================================================
/*QUAKED trigger_setskill (.5 .5 .5) ?
sets skill level to the value of "message".
Only used on start map.
*/
void() trigger_setskill =
void ()
trigger_setskill =
{
remove (self);
};
/*
==============================================================================
// ONLY REGISTERED TRIGGERS ===================================================
ONLY REGISTERED TRIGGERS
==============================================================================
*/
void() trigger_onlyregistered_touch =
void ()
trigger_onlyregistered_touch =
{
if (other.classname != "player")
return;
@ -531,16 +503,12 @@ void() trigger_onlyregistered_touch =
return;
self.attack_finished = time + 2;
if (cvar("registered"))
{
if (cvar ("registered")) {
self.message = "";
SUB_UseTargets ();
remove (self);
}
else
{
if (self.message != "")
{
} else {
if (self.message != "") {
centerprint (other, self.message);
sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM);
}
@ -550,7 +518,8 @@ void() trigger_onlyregistered_touch =
/*QUAKED trigger_onlyregistered (.5 .5 .5) ?
Only fires if playing the registered version, otherwise prints the message
*/
void() trigger_onlyregistered =
void ()
trigger_onlyregistered =
{
precache_sound ("misc/talk.wav");
InitTrigger ();
@ -559,16 +528,17 @@ void() trigger_onlyregistered =
//============================================================================
void() hurt_on =
void ()
hurt_on =
{
self.solid = SOLID_TRIGGER;
self.nextthink = -1;
};
void() hurt_touch =
void ()
hurt_touch =
{
if (other.takedamage)
{
if (other.takedamage) {
self.solid = SOLID_NOT;
T_Damage (other, self, self, self.dmg);
self.think = hurt_on;
@ -583,7 +553,8 @@ Any object touching this will be hurt
set dmg to damage amount
defalt dmg = 5
*/
void() trigger_hurt =
void ()
trigger_hurt =
{
InitTrigger ();
self.touch = hurt_touch;
@ -595,17 +566,15 @@ void() trigger_hurt =
float PUSH_ONCE = 1;
void() trigger_push_touch =
void ()
trigger_push_touch =
{
if (other.classname == "grenade")
other.velocity = self.speed * self.movedir * 10;
else if (other.health > 0)
{
else if (other.health > 0) {
other.velocity = self.speed * self.movedir * 10;
if (other.classname == "player")
{
if (other.fly_sound < time)
{
if (other.classname == "player") {
if (other.fly_sound < time) {
other.fly_sound = time + 1.5;
sound (other, CHAN_AUTO, "ambience/windfly.wav", 1, ATTN_NORM);
}
@ -615,11 +584,11 @@ void() trigger_push_touch =
remove(self);
};
/*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE
Pushes the player
*/
void() trigger_push =
void ()
trigger_push =
{
InitTrigger ();
precache_sound ("ambience/windfly.wav");
@ -630,19 +599,20 @@ void() trigger_push =
//============================================================================
void() trigger_monsterjump_touch =
void ()
trigger_monsterjump_touch =
{
if ( other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER )
if (other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER)
return;
// set XY even if not on ground, so the jump will clear lips
// set XY even if not on ground, so the jump will clear lips
other.velocity_x = self.movedir_x * self.speed;
other.velocity_y = self.movedir_y * self.speed;
if ( !(other.flags & FL_ONGROUND) )
if (!(other.flags & FL_ONGROUND))
return;
other.flags = other.flags - FL_ONGROUND;
other.flags &= ~FL_ONGROUND;
other.velocity_z = self.height;
};
@ -652,7 +622,8 @@ Walking monsters that touch this will jump in the direction of the trigger's ang
"speed" default to 200, the speed thrown forward
"height" default to 200, the speed thrown upwards
*/
void() trigger_monsterjump =
void ()
trigger_monsterjump =
{
if (!self.speed)
self.speed = 200;
@ -663,4 +634,3 @@ void() trigger_monsterjump =
InitTrigger ();
self.touch = trigger_monsterjump_touch;
};