2001-07-23 20:52:47 +00:00
|
|
|
#include "defs.qh"
|
2001-07-17 05:58:10 +00:00
|
|
|
/*======================================================
|
|
|
|
TELEPORT.QC Custom TeamFortress v2.2
|
|
|
|
|
|
|
|
(c) Craig Hauser 23/3/00
|
|
|
|
========================================================
|
|
|
|
Functions for the teleporters
|
|
|
|
======================================================*/
|
|
|
|
|
|
|
|
void() Teleporter_touch;
|
|
|
|
void() Teleporter_Die;
|
|
|
|
void() Teleporter_heat_think;
|
2001-08-13 13:02:54 +00:00
|
|
|
integer (entity ent) Teleporter_CheckBlocked;
|
2001-07-17 05:58:10 +00:00
|
|
|
float(entity targ) Teleporter_check_person;
|
|
|
|
|
|
|
|
#define TELEPORTER_CELLS 8 //How many cells to use on teleport
|
|
|
|
#define TELEPORTER_WAIT 2 //How long to wait after teleport (whole number)
|
|
|
|
|
|
|
|
//====================
|
|
|
|
void() Teleporter_touch =
|
|
|
|
{
|
|
|
|
local entity te;
|
|
|
|
|
|
|
|
if (self.heat == 0)
|
|
|
|
{
|
|
|
|
if (Teleporter_check_person(other))
|
|
|
|
{
|
2001-11-02 17:00:52 +00:00
|
|
|
te = find(NIL, classname, "building_teleporter");
|
|
|
|
while (!(te.real_owner == self.real_owner && te != self) && te)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
te = find(te, classname, "building_teleporter");
|
|
|
|
}
|
2001-11-02 17:00:52 +00:00
|
|
|
if (te)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (te.heat == 0 && te.ammo_cells >= TELEPORTER_CELLS)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
self.heat = TELEPORTER_WAIT;
|
|
|
|
te.heat = TELEPORTER_WAIT;
|
|
|
|
if (self.is_malfunctioning & SCREWUP_FOUR || te.is_malfunctioning & SCREWUP_FOUR)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
CenterPrint(other, "The other teleporter is out of power.\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
self.ammo_cells = self.ammo_cells - TELEPORTER_CELLS;
|
|
|
|
te.ammo_cells = te.ammo_cells - TELEPORTER_CELLS;
|
2001-07-17 05:58:10 +00:00
|
|
|
local entity ote;
|
|
|
|
ote = te;
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.is_malfunctioning & SCREWUP_THREE || te.is_malfunctioning & SCREWUP_THREE) //sb
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
te = self.real_owner;
|
|
|
|
spawn_tdeath(te.origin + '0 0 32', te);
|
|
|
|
}
|
|
|
|
spawn_tfog (other.origin);
|
|
|
|
spawn_tdeath(te.origin + '0 0 32', other);
|
|
|
|
makeImmune(other,time + 2);
|
|
|
|
setorigin(other, te.origin + '0 0 32');
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.is_malfunctioning & SCREWUP_ONE || te.is_malfunctioning & SCREWUP_ONE) // SB
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
other.ammo_cells = 0;
|
|
|
|
other.ammo_shells = 0;
|
|
|
|
other.ammo_nails = 0;
|
|
|
|
other.ammo_rockets = 0;
|
|
|
|
other.armorvalue = 0;
|
|
|
|
other.ammo_detpack = 0;
|
|
|
|
other.ammo_c4det = 0;
|
|
|
|
other.ammo_medikit = 0;
|
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.is_malfunctioning & SCREWUP_TWO || te.is_malfunctioning & SCREWUP_TWO) // SB
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.is_malfunctioning & SCREWUP_TWO)
|
2001-07-17 05:58:10 +00:00
|
|
|
te.martyr_enemy = self.martyr_enemy;
|
2001-07-23 20:52:47 +00:00
|
|
|
else if (te.is_malfunctioning & SCREWUP_TWO)
|
2001-07-17 05:58:10 +00:00
|
|
|
self.martyr_enemy = te.martyr_enemy;
|
2001-07-23 20:52:47 +00:00
|
|
|
TF_T_Damage(other, self, self, 500, 0, TF_TD_OTHER);
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
spawn_tfog (te.origin + '0 0 32');
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.is_malfunctioning & SCREWUP_THREE || ote.is_malfunctioning & SCREWUP_THREE)
|
2001-07-17 05:58:10 +00:00
|
|
|
te = ote;
|
2001-07-23 20:52:47 +00:00
|
|
|
if ((te.ammo_cells >= TELEPORTER_CELLS && te.ammo_cells <= TELEPORTER_CELLS * 2) || (self.ammo_cells >= TELEPORTER_CELLS && self.ammo_cells <= TELEPORTER_CELLS * 2))
|
|
|
|
sprint (self.real_owner, PRINT_HIGH, "A teleporter is getting low on power.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
else if (te.ammo_cells < TELEPORTER_CELLS)
|
2001-07-17 05:58:10 +00:00
|
|
|
CenterPrint(other, "The other teleporter is out of power.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
//===============
|
|
|
|
float(entity targ) Teleporter_check_person =
|
|
|
|
{
|
2001-11-02 17:00:52 +00:00
|
|
|
if (infokey(NIL,"ceasefire")=="on") //To not cause loops
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-11-02 17:00:52 +00:00
|
|
|
if (!targ)//that would be bad.
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
|
|
|
if (targ.done_custom & CUSTOM_BUILDING)
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (targ.classname != "player")
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (targ.velocity != '0 0 0')
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (targ.health <= 0)
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (targ.has_disconnected)
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
|
|
|
if (targ.playerclass == PC_UNDEFINED)
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (targ.is_feigning)
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (targ.is_building)
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (targ.is_detpacking)
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2002-09-10 02:19:36 +00:00
|
|
|
if (self.ammo_cells < TELEPORTER_CELLS) {
|
|
|
|
if (Teammate(targ.team_no, self.team_no)) //only to team member
|
|
|
|
CenterPrint(other, "This teleporter is out of power.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (self.real_owner.has_teleporter == 1) {
|
|
|
|
if (Teammate(targ.team_no, self.team_no)) //only to team member
|
|
|
|
CenterPrint(other, "There is no other teleporter!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
if (targ.playerclass == PC_CIVILIAN) {
|
2001-07-17 05:58:10 +00:00
|
|
|
CenterPrint(targ, "Civilian + Teleporter = No, NFC!\n");
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
2003-12-03 02:43:02 +00:00
|
|
|
if (targ.effects & EF_ANYGLOW) {//no flag for you!
|
2001-07-17 05:58:10 +00:00
|
|
|
CenterPrint(targ, "Can't use teleporter while glowing!\n");
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//ALL NEW CHECKS _MUST_ BE ABOVE THIS LINE
|
|
|
|
if (teamplay)
|
|
|
|
{
|
|
|
|
if (Teammate(targ.team_no, self.team_no))
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (Teammate(targ.undercover_team, self.team_no))
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
};
|
|
|
|
//===============
|
|
|
|
void() Teleporter_heat_think =
|
|
|
|
{
|
|
|
|
//CH used to reduce the heat and check pos
|
|
|
|
if (self.heat <= 0)
|
|
|
|
self.heat = 0;
|
|
|
|
else
|
|
|
|
self.heat = self.heat - 1;
|
|
|
|
|
|
|
|
self.think = Teleporter_heat_think; //keep in loop
|
|
|
|
self.nextthink = time + 1;
|
2001-08-13 13:02:54 +00:00
|
|
|
if (Teleporter_CheckBlocked(self)) {
|
|
|
|
sprint (self.real_owner, PRINT_HIGH, "Not enough space for teleportation.\n");
|
2001-11-02 17:00:52 +00:00
|
|
|
TF_T_Damage (self, NIL, NIL, self.health + 1, 0, 0);
|
2001-08-13 13:02:54 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
integer (entity ent) Teleporter_CheckBlocked =
|
|
|
|
{
|
2001-10-12 06:10:59 +00:00
|
|
|
checkmove (ent.origin + '0 0 32', '-16 -16 -24', '16 16 32',
|
|
|
|
ent.origin + '0 0 32', MOVE_NOMONSTERS, ent);
|
|
|
|
|
|
|
|
if (trace_startsolid || trace_fraction != 1)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/*
|
2001-08-13 13:02:54 +00:00
|
|
|
local float pos, num;
|
|
|
|
local vector loc;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
//CH if spawnflags is >0 do extensive height checks b/c the pad just spawned.
|
2001-08-13 13:02:54 +00:00
|
|
|
if (ent.spawnflags > 0) {
|
|
|
|
ent.spawnflags = ent.spawnflags - 1;
|
2001-07-17 05:58:10 +00:00
|
|
|
num = 0; //16 checks
|
|
|
|
}
|
|
|
|
else
|
|
|
|
num = 15; //1 check
|
|
|
|
while (num < 16)
|
|
|
|
{
|
2001-08-13 13:02:54 +00:00
|
|
|
//sprint (ent.real_owner, PRINT_HIGH, "Checking space!\n");
|
|
|
|
loc = ent.origin;
|
2001-07-17 05:58:10 +00:00
|
|
|
loc_x = loc_x + ((rint(random() * 3 + 1) * 16) - 32);
|
|
|
|
loc_y = loc_y + ((rint(random() * 3 + 1) * 16) - 32);
|
2001-08-13 13:02:54 +00:00
|
|
|
loc_z = loc_z + (rint(random() * 8 + 1) * 8); //1-8 * 8 x+8 -> x+64
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
pos = pointcontents(loc);
|
2001-07-31 17:08:59 +00:00
|
|
|
if (pos == CONTENTS_SOLID || pos == CONTENTS_SKY)
|
2001-08-13 13:02:54 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
num = num + 1;
|
|
|
|
}
|
2001-08-13 13:02:54 +00:00
|
|
|
return FALSE;
|
2001-10-12 06:10:59 +00:00
|
|
|
*/
|
2001-07-17 05:58:10 +00:00
|
|
|
};
|
2001-08-13 13:02:54 +00:00
|
|
|
|
|
|
|
|
2001-07-17 05:58:10 +00:00
|
|
|
//================
|
|
|
|
void() Teleporter_Die =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(self.real_owner, PRINT_HIGH, "Your Teleporter Pad was destroyed.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
self.real_owner.has_teleporter = (self.real_owner.has_teleporter - 1);
|
|
|
|
|
|
|
|
// ThrowGib("progs/tgib1.mdl", -70);
|
|
|
|
// ThrowGib("progs/tgib2.mdl", -70);
|
|
|
|
// ThrowGib("progs/tgib3.mdl", -70);
|
|
|
|
|
2001-10-13 23:02:22 +00:00
|
|
|
WriteByte (MSG_MULTICAST, SVC_TEMPENTITY);
|
|
|
|
WriteByte (MSG_MULTICAST, TE_EXPLOSION);
|
|
|
|
WriteCoord (MSG_MULTICAST, self.origin_x);
|
|
|
|
WriteCoord (MSG_MULTICAST, self.origin_y);
|
|
|
|
WriteCoord (MSG_MULTICAST, self.origin_z);
|
2001-07-23 20:52:47 +00:00
|
|
|
multicast (self.origin, MULTICAST_PHS);
|
2001-07-17 05:58:10 +00:00
|
|
|
dremove(self);
|
|
|
|
};
|