2001-07-23 20:52:47 +00:00
|
|
|
#include "defs.qh"
|
2001-07-17 05:58:10 +00:00
|
|
|
/*====================================================
|
|
|
|
SCOUT.QC
|
|
|
|
|
|
|
|
TeamFortress v2.5 29/2/97
|
|
|
|
Craig Hauser 26/3/00
|
|
|
|
======================================================
|
|
|
|
Functions for the SCOUT class and associated weaponry
|
|
|
|
======================================================*/
|
|
|
|
// Functions outside this file
|
|
|
|
|
|
|
|
// Functions inside this file
|
|
|
|
// Concussion Grenade Functions
|
|
|
|
void() ConcussionGrenadeTouch;
|
|
|
|
void() ConcussionGrenadeExplode;
|
|
|
|
void() ConcussionGrenadeTimer;
|
|
|
|
// Scanner Functions
|
|
|
|
void(float scanrange,float inAuto) TeamFortress_Scan;
|
|
|
|
void(entity inflictor, entity attacker, float bounce, entity ignore) T_RadiusBounce;
|
|
|
|
entity(entity scanner, float scanrange, float enemies, float friends) T_RadiusScan;
|
|
|
|
|
|
|
|
//void(entity pl, string s1) CenterPrint;
|
|
|
|
void(entity pl, float fTime, string s1) StatusPrint;
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Touch Function for Flash Grenade
|
|
|
|
void() FlashGrenadeTouch =
|
|
|
|
{
|
|
|
|
// If the Flash Grenade hits a player, it just bounces off
|
2001-07-23 20:52:47 +00:00
|
|
|
sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
|
2001-07-17 05:58:10 +00:00
|
|
|
if (self.velocity == '0 0 0')
|
|
|
|
self.avelocity = '0 0 0';
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef NET_SERVER
|
2003-11-29 08:15:31 +00:00
|
|
|
#define SMOOTH_FLASH 0.3
|
2001-07-17 05:58:10 +00:00
|
|
|
#else
|
|
|
|
#define SMOOTH_FLASH 0.1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void() FlashTimer =
|
|
|
|
{
|
|
|
|
local entity te;
|
|
|
|
|
|
|
|
te = self.owner;
|
|
|
|
|
|
|
|
if (te.has_disconnected) //WK Safety, now that we call this to clean up after death
|
|
|
|
return;
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
te.FlashTime = te.FlashTime - SMOOTH_FLASH;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2003-11-29 08:15:31 +00:00
|
|
|
if (te.FlashTime < 4 && te.FlashTime != -1)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
te.FlashTime = 0;
|
2003-11-29 08:15:31 +00:00
|
|
|
stuffcmd(te, "v_cshift 0 0 0 0\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
local string st;
|
|
|
|
|
2003-11-29 08:15:31 +00:00
|
|
|
// Sequential III math proved useful! GR
|
|
|
|
st = ftos(-0.1 * (te.FlashTime - 5) * (te.FlashTime - 115));
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2003-11-29 08:15:31 +00:00
|
|
|
stuffcmd(te, "v_cshift 0 0 0 " + st + "\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
self.nextthink = time + SMOOTH_FLASH;
|
2001-07-17 05:58:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Flash Grenade explode function, for when the PRIMETIME runs out
|
|
|
|
void() FlashGrenadeExplode =
|
|
|
|
{
|
2001-09-23 04:25:02 +00:00
|
|
|
local entity te;
|
2003-11-29 08:15:31 +00:00
|
|
|
local float loopc = 0;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2004-04-12 05:37:50 +00:00
|
|
|
self.effects |= EF_BRIGHTLIGHT;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2003-11-29 08:15:31 +00:00
|
|
|
|
|
|
|
sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
// Find all people in area
|
2003-11-29 08:15:31 +00:00
|
|
|
while (loopc < 32)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2003-11-29 08:15:31 +00:00
|
|
|
te = checkclient();
|
2001-07-17 05:58:10 +00:00
|
|
|
// Player?
|
2003-11-29 08:15:31 +00:00
|
|
|
if (te && te.classname == "player")
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2003-11-29 08:15:31 +00:00
|
|
|
makevectors(te.v_angle);
|
2001-07-17 05:58:10 +00:00
|
|
|
// Damage player and explode
|
2003-11-29 08:15:31 +00:00
|
|
|
// no, don't damage
|
2003-12-01 22:41:49 +00:00
|
|
|
if (te.health > 0 && (normalize(self.origin - te.origin) * v_forward > -0.5) && visible(te))
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2003-11-29 08:15:31 +00:00
|
|
|
local float ft = 60 - (vlen(self.origin - te.origin) * 6 / 50);
|
|
|
|
|
2001-07-17 05:58:10 +00:00
|
|
|
if (te.FlashTime == 0)
|
|
|
|
{
|
|
|
|
// create flash timer
|
|
|
|
newmis = spawn();
|
|
|
|
newmis.classname = "timer";
|
|
|
|
newmis.netname = "flashtimer";
|
|
|
|
newmis.team_no = self.owner.team_no;
|
|
|
|
newmis.owner = te;
|
|
|
|
newmis.think = FlashTimer;
|
2003-11-29 08:15:31 +00:00
|
|
|
newmis.nextthink = time + 0.1;
|
2001-07-17 05:58:10 +00:00
|
|
|
newmis.heat = 1;
|
|
|
|
}
|
|
|
|
|
2003-11-29 08:15:31 +00:00
|
|
|
if (ft > 0)
|
|
|
|
te.FlashTime = ft;
|
|
|
|
|
2004-04-05 09:53:57 +00:00
|
|
|
stuffcmd (te, "v_cshift 255 255 255 245; bf\n"); // big white flash
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-29 08:15:31 +00:00
|
|
|
loopc++;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEMO_STUFF
|
|
|
|
// Remove any camera's locks on this missile
|
|
|
|
if (self.enemy)
|
|
|
|
CamProjectileLockOff();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
dremove(self);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Touch function for a concussion grenade
|
|
|
|
void() ConcussionGrenadeTouch =
|
|
|
|
{
|
|
|
|
// concussion grenades bounce off other players now
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
|
2001-07-17 05:58:10 +00:00
|
|
|
if (self.velocity == '0 0 0')
|
|
|
|
self.avelocity = '0 0 0';
|
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Concussion grenade explosion function
|
|
|
|
void() ConcussionGrenadeExplode =
|
|
|
|
{
|
2012-07-06 02:29:18 +00:00
|
|
|
T_RadiusBounce (self, self.owner, 240, nil);
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
#ifdef DEMO_STUFF
|
|
|
|
// Remove any camera's locks on this missile
|
|
|
|
if (self.enemy)
|
|
|
|
CamProjectileLockOff();
|
|
|
|
#endif
|
|
|
|
|
2001-10-13 23:02:22 +00:00
|
|
|
WriteByte (MSG_MULTICAST, SVC_TEMPENTITY);
|
|
|
|
WriteByte (MSG_MULTICAST, TE_EXPLOSION);
|
2012-07-06 02:29:18 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Concussion grenade timer to remove idlescale
|
|
|
|
void() ConcussionGrenadeTimer =
|
|
|
|
{
|
|
|
|
if (self.owner.invincible_finished > time)
|
|
|
|
{
|
2004-01-21 16:05:58 +00:00
|
|
|
sprint(self.owner, PRINT_HIGH, "The power heals your concussion\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
stuffcmd(self.owner, "v_idlescale 0\n");
|
2004-01-21 16:05:58 +00:00
|
|
|
self.owner.mangle = '0 0 0';
|
|
|
|
self.owner.tfstate &= ~TFSTATE_CONCUSSIONED;
|
2001-07-17 05:58:10 +00:00
|
|
|
dremove(self);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-01-21 16:05:58 +00:00
|
|
|
|
|
|
|
#ifdef GR_CONCUSS_BUBBLETIME
|
|
|
|
if (self.has_tesla < time)
|
|
|
|
{
|
|
|
|
newmis = spawn();
|
|
|
|
setmodel (newmis, "progs/s_bubble.spr");
|
|
|
|
setorigin (newmis, self.owner.origin);
|
|
|
|
newmis.movetype = MOVETYPE_NOCLIP;
|
|
|
|
newmis.solid = SOLID_NOT;
|
|
|
|
newmis.velocity = '0 0 15';
|
|
|
|
newmis.nextthink = time + 0.5;
|
|
|
|
newmis.think = bubble_bob;
|
|
|
|
newmis.touch = bubble_remove;
|
|
|
|
newmis.classname = "bubble";
|
|
|
|
newmis.frame = 0;
|
|
|
|
newmis.cnt = 0;
|
|
|
|
setsize(newmis, '-8 -8 -8', '8 8 8');
|
|
|
|
|
|
|
|
self.has_tesla += GR_CONCUSS_BUBBLETIME;
|
|
|
|
}
|
|
|
|
#endif
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
self.health = self.health - GR_CONCUSS_DEC;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
// medic recovers twice as fast
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.owner.weapons_carried & WEAP_MEDIKIT) //WK
|
|
|
|
self.health = self.health - GR_CONCUSS_DEC;
|
|
|
|
if (self.owner.cutf_items & CUTF_STEALTH)
|
|
|
|
self.health = self.health - GR_CONCUSS_DEC;
|
|
|
|
if (self.owner.cutf_items & CUTF_GYMNAST)
|
|
|
|
self.health = self.health - GR_CONCUSS_DEC;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
if (self.health < 0)
|
|
|
|
self.health = 0;
|
|
|
|
|
|
|
|
if (self.health == 0)
|
2004-01-21 16:05:58 +00:00
|
|
|
{
|
2004-04-07 16:22:57 +00:00
|
|
|
sprint (self.owner, PRINT_HIGH, "Your head feels better now\n");
|
2004-04-05 09:53:57 +00:00
|
|
|
#ifdef OLD_CONC_GRENADE
|
2004-01-21 16:05:58 +00:00
|
|
|
stuffcmd (self.owner, "v_idlescale 0\n");
|
2004-04-05 09:53:57 +00:00
|
|
|
#endif
|
2004-01-21 16:05:58 +00:00
|
|
|
self.owner.mangle = '0 0 0';
|
|
|
|
self.owner.tfstate &= ~TFSTATE_CONCUSSIONED;
|
2001-07-17 05:58:10 +00:00
|
|
|
dremove(self);
|
2004-01-21 16:05:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.nextthink = time + GR_CONCUSS_TIME;
|
|
|
|
|
|
|
|
#ifdef OLD_CONC_GRENADE
|
|
|
|
stuffcmd(self.owner, "v_idlescale " + ftos (self.health * GR_CONCUSS_IDLE) + "\n");
|
|
|
|
#else
|
|
|
|
|
|
|
|
if (self.has_camera < time)
|
|
|
|
{
|
|
|
|
self.owner.mangle = '0 0 0';
|
2004-04-05 09:09:22 +00:00
|
|
|
|
|
|
|
#ifdef GR_CONCUSS_SETANGLE
|
2004-01-21 16:05:58 +00:00
|
|
|
msg_entity = self.owner;
|
|
|
|
WriteByte (MSG_ONE, SVC_SETANGLE);
|
|
|
|
WriteAngleV (MSG_ONE, self.owner.v_angle);
|
2004-04-05 09:09:22 +00:00
|
|
|
#endif
|
2004-01-21 16:05:58 +00:00
|
|
|
|
|
|
|
self.has_camera = time + GR_CONCUSS_FIXTIME;
|
|
|
|
}
|
|
|
|
|
|
|
|
local float r = random();
|
|
|
|
local float amount = self.health;
|
|
|
|
|
|
|
|
if (amount > GR_CONCUSS_MAX)
|
|
|
|
amount = GR_CONCUSS_MAX;
|
|
|
|
|
|
|
|
amount *= (0.8 + random() * 0.2);
|
|
|
|
|
|
|
|
local float x = random() * amount;
|
|
|
|
local float y = amount - x;
|
|
|
|
|
|
|
|
if (random() < 0.5)
|
2012-07-06 02:29:18 +00:00
|
|
|
self.owner.mangle.x += x * GR_CONCUSS_X;
|
2004-01-21 16:05:58 +00:00
|
|
|
else
|
2012-07-06 02:29:18 +00:00
|
|
|
self.owner.mangle.x -= x * GR_CONCUSS_X;
|
2004-01-21 16:05:58 +00:00
|
|
|
|
|
|
|
if (random() < 0.5)
|
2012-07-06 02:29:18 +00:00
|
|
|
self.owner.mangle.y += y * GR_CONCUSS_Y;
|
2004-01-21 16:05:58 +00:00
|
|
|
else
|
2012-07-06 02:29:18 +00:00
|
|
|
self.owner.mangle.y -= y * GR_CONCUSS_Y;
|
2004-01-21 16:05:58 +00:00
|
|
|
|
2004-04-07 16:22:57 +00:00
|
|
|
local float rat = self.health / GR_CONCUSS_MAX;
|
2004-01-21 16:05:58 +00:00
|
|
|
|
2012-07-06 02:29:18 +00:00
|
|
|
if (self.owner.mangle.x > GR_CONCUSS_MAX_X * rat)
|
|
|
|
self.owner.mangle.x = GR_CONCUSS_MAX_X * rat;
|
|
|
|
if (self.owner.mangle.x < GR_CONCUSS_MIN_X * rat)
|
|
|
|
self.owner.mangle.x = GR_CONCUSS_MIN_X * rat;
|
|
|
|
if (self.owner.mangle.y > GR_CONCUSS_MAX_Y * rat)
|
|
|
|
self.owner.mangle.y = GR_CONCUSS_MAX_Y * rat;
|
|
|
|
if (self.owner.mangle.y < GR_CONCUSS_MIN_Y * rat)
|
|
|
|
self.owner.mangle.y = GR_CONCUSS_MIN_Y * rat;;
|
2004-01-21 16:05:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (self.owner.waterlevel || (self.owner.flags & FL_ONGROUND))
|
|
|
|
{
|
|
|
|
local float vel = vlen (self.owner.velocity);
|
|
|
|
|
2004-04-05 09:53:57 +00:00
|
|
|
x = random() * amount;
|
|
|
|
y = amount - x;
|
|
|
|
|
2004-01-21 16:05:58 +00:00
|
|
|
if (random() < 0.5)
|
2012-07-06 02:29:18 +00:00
|
|
|
self.owner.velocity.x += x * GR_CONCUSS_KICK * vel;
|
2004-01-21 16:05:58 +00:00
|
|
|
else
|
2012-07-06 02:29:18 +00:00
|
|
|
self.owner.velocity.x -= x * GR_CONCUSS_KICK * vel;
|
2004-01-21 16:05:58 +00:00
|
|
|
|
|
|
|
if (random() < 0.5)
|
2012-07-06 02:29:18 +00:00
|
|
|
self.owner.velocity.y += y * GR_CONCUSS_KICK * vel;
|
2004-01-21 16:05:58 +00:00
|
|
|
else
|
2012-07-06 02:29:18 +00:00
|
|
|
self.owner.velocity.y -= y * GR_CONCUSS_KICK * vel;
|
2004-01-21 16:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//sprint (self.owner, PRINT_HIGH, "mangle: " + vtos (self.owner.mangle) + "\n");
|
|
|
|
|
|
|
|
#endif
|
2001-07-17 05:58:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Handles the scanner function for Scouts
|
|
|
|
void(float scanrange,float inAuto) TeamFortress_Scan =
|
|
|
|
{
|
|
|
|
local string power;
|
2012-07-06 02:29:18 +00:00
|
|
|
local entity list = nil;
|
2001-07-17 05:58:10 +00:00
|
|
|
local float scen, scfr;
|
|
|
|
local vector lightningvec;
|
|
|
|
|
|
|
|
// added in for the direction scanner code
|
|
|
|
local float enemy_detected;
|
|
|
|
local float any_detected;
|
|
|
|
|
|
|
|
|
|
|
|
// prevent scan impulse from triggering anything else
|
|
|
|
self.impulse = 0;
|
|
|
|
self.last_impulse = 0;
|
|
|
|
|
|
|
|
if (self.classname == "player")
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (!(self.tf_items & NIT_SCANNER))
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
// If Impulse is TF_SCAN_ENEMY, toggle Scanning for Enemies
|
|
|
|
if (scanrange == TF_SCAN_ENEMY)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.tf_items_flags & NIT_SCANNER_ENEMY)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (self, PRINT_HIGH, "Enemy Scanning disabled.\n");
|
2004-04-12 05:37:50 +00:00
|
|
|
self.tf_items_flags &= ~NIT_SCANNER_ENEMY;
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (self, PRINT_HIGH, "Enemy Scanning enabled.\n");
|
2004-04-12 05:37:50 +00:00
|
|
|
self.tf_items_flags |= NIT_SCANNER_ENEMY;
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
// If Impulse is TF_SCAN_FRIENDLY, toggle Scanning for Friendlies
|
|
|
|
if (scanrange == TF_SCAN_FRIENDLY)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.tf_items_flags & NIT_SCANNER_FRIENDLY)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (self, PRINT_HIGH, "Friendly Scanning disabled.\n");
|
2004-04-12 05:37:50 +00:00
|
|
|
self.tf_items_flags &= ~NIT_SCANNER_FRIENDLY;
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (self, PRINT_HIGH, "Friendly Scanning enabled.\n");
|
2004-04-12 05:37:50 +00:00
|
|
|
self.tf_items_flags |= NIT_SCANNER_FRIENDLY;
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the user doesn't have as many cells as he/she specified, just
|
|
|
|
// use as many as they've got.
|
|
|
|
|
|
|
|
/* local float scancost;
|
|
|
|
|
|
|
|
scancost = ceil(scanrange / 20);
|
|
|
|
|
|
|
|
if (scancost > self.ammo_cells)
|
|
|
|
{
|
|
|
|
scanrange = self.ammo_cells * 20;
|
|
|
|
scancost = self.ammo_cells;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scanrange <= 0)
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(self, PRINT_HIGH, "No cells.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
2001-07-23 20:52:47 +00:00
|
|
|
if (scanrange > NIT_SCANNER_MAXCELL)
|
|
|
|
scanrange = NIT_SCANNER_MAXCELL;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
scen = 0;
|
|
|
|
scfr = 0;
|
|
|
|
// Set the Scanner flags
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.tf_items_flags & NIT_SCANNER_ENEMY)
|
2001-07-17 05:58:10 +00:00
|
|
|
scen = 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.tf_items_flags & NIT_SCANNER_FRIENDLY)
|
2001-07-17 05:58:10 +00:00
|
|
|
scfr = 1;
|
|
|
|
|
|
|
|
// If no entity type is enabled, don't scan
|
|
|
|
if ((scen == 0) && (scfr == 0))
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(self, PRINT_HIGH, "All scanner functions are disabled.\nEnable with 'scane' or 'scanf'.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use up cells to power the scanner
|
|
|
|
// additions:
|
|
|
|
// altered this so scanner could be more easily tested
|
|
|
|
//WK self.ammo_cells = self.ammo_cells - scancost;
|
2001-07-23 20:52:47 +00:00
|
|
|
scanrange = scanrange * NIT_SCANNER_POWER;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
if (!inAuto) { //WK Only sprint() if not autoscanner
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (self, PRINT_HIGH, "Range: ");
|
2001-07-17 05:58:10 +00:00
|
|
|
power = ftos(ceil(scanrange));
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (self, PRINT_HIGH, power);
|
|
|
|
sprint (self, PRINT_HIGH, ". Scanning...\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the list of entities the scanner finds
|
|
|
|
list = T_RadiusScan(self, scanrange, scen, scfr);
|
|
|
|
}
|
|
|
|
// Base Defence scanning code here
|
|
|
|
|
|
|
|
// Reset the entity counts
|
|
|
|
scen = 0;
|
|
|
|
scfr = 0;
|
|
|
|
|
|
|
|
// the vectors v_forward and v_right are required to
|
|
|
|
// 'triangulate' the enemies position
|
|
|
|
makevectors(self.v_angle);
|
|
|
|
|
|
|
|
// Walk the list
|
|
|
|
// For now, just count the entities.
|
|
|
|
// In the future, we'll display bearings :)
|
|
|
|
// additions: the future is now!
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
if (list != self)
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
// sets the enemy_detected flag to TRUE if not on your team, FALSE if so
|
|
|
|
any_detected = TRUE; // this flag is set to false if bogie is moving
|
2001-07-17 05:58:10 +00:00
|
|
|
// too slow to be detected (and velocity checking is on)
|
|
|
|
|
|
|
|
if (vlen(list.origin - self.origin) <= scanrange) //CH Secondary check NEEDED!!!
|
|
|
|
{
|
|
|
|
// If this scanner is a motion detector, don't record
|
|
|
|
// object that don't have the required velocity to be detected.
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.tf_items_flags & NIT_SCANNER_MOVEMENT)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (vlen(list.velocity) > NIT_SCANNER_MIN_MOVEMENT)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
if (list.classname == "monster_demon1" && list.health > 0) //Because they dont have teams
|
|
|
|
{
|
|
|
|
if (Teammate(list.real_owner.team_no,self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (list.classname == "monster_army" && list.health > 0) //Because they dont have teams
|
|
|
|
{
|
|
|
|
if (Teammate(list.real_owner.team_no,self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (list.classname == "monster_shambler" && list.health > 0) //Because they dont have teams
|
|
|
|
{
|
|
|
|
if (Teammate(list.real_owner.team_no,self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//- OfN -
|
|
|
|
else if (list.classname == "monster_wizard" && list.health > 0) //Because they dont have teams
|
|
|
|
{
|
|
|
|
if (Teammate(list.real_owner.team_no,self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (list.classname == "item_tfgoal" && list.owned_by > 0 && list.team_no > 0 && self.team_no > 0) //Because they use owned_by
|
|
|
|
{
|
|
|
|
if (list.owned_by == self.team_no && list.team_no != self.team_no)
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else if (list.owned_by == self.team_no && list.team_no == self.team_no)
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else if (list.owned_by != self.team_no && list.team_no == self.team_no)
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
2001-07-23 20:52:47 +00:00
|
|
|
any_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
else if ((list.classname == "player" || list.classname == "building_sentrygun" || list.classname == "building_tesla" || list.classname == "building_teleporter") && list.health > 0 && !(list.cutf_items & CUTF_JAMMER))
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
if (Teammate(list.team_no, self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
any_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
any_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (list.classname == "monster_demon1" && list.health > 0) //Because they dont have teams
|
|
|
|
{
|
|
|
|
if (Teammate(list.real_owner.team_no,self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (list.classname == "monster_army" && list.health > 0) //Because they dont have teams
|
|
|
|
{
|
|
|
|
if (Teammate(list.real_owner.team_no, self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (list.classname == "monster_shambler" && list.health > 0) //Because they dont have teams
|
|
|
|
{
|
|
|
|
if (Teammate(list.real_owner.team_no, self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//- OfN -
|
|
|
|
if (list.classname == "monster_wizard" && list.health > 0) //Because they dont have teams
|
|
|
|
{
|
|
|
|
if (Teammate(list.real_owner.team_no, self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (list.classname == "item_tfgoal" && list.owned_by > 0 && list.team_no > 0 && self.team_no > 0) //Because they use owned_by
|
|
|
|
{
|
|
|
|
if (list.owned_by == self.team_no && list.team_no != self.team_no)
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else if (list.owned_by == self.team_no && list.team_no == self.team_no)
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else if (list.owned_by != self.team_no && list.team_no == self.team_no)
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
2001-07-23 20:52:47 +00:00
|
|
|
any_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
else if ((list.classname == "player" || list.classname == "building_sentrygun" || list.classname == "building_tesla" || list.classname == "building_teleporter") && list.health > 0 && !(list.cutf_items & CUTF_JAMMER))
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
if (Teammate(list.team_no, self.team_no))
|
|
|
|
{
|
|
|
|
scfr = scfr + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scen = scen + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
enemy_detected = TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
any_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
any_detected = FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// this displays the direction of the detected player
|
|
|
|
// using the cosine rule to find the angle
|
|
|
|
// cos theta = A.B divided by |A||B|
|
|
|
|
// it should return a value between 1 and -1
|
|
|
|
if (any_detected)
|
|
|
|
{
|
|
|
|
// Get the unit vector
|
|
|
|
lightningvec = normalize(list.origin - self.origin);
|
|
|
|
lightningvec = lightningvec * (vlen(list.origin - self.origin) / 5);
|
|
|
|
lightningvec = lightningvec + self.origin;
|
|
|
|
|
|
|
|
// Create the Lightning
|
|
|
|
msg_entity = self;
|
2001-07-23 20:52:47 +00:00
|
|
|
WriteByte (MSG_ONE, SVC_TEMPENTITY);
|
|
|
|
WriteByte (MSG_ONE, TE_LIGHTNING1);
|
|
|
|
WriteEntity (MSG_ONE, self);
|
2012-07-06 02:29:18 +00:00
|
|
|
WriteCoord (MSG_ONE, self.origin.x);
|
|
|
|
WriteCoord (MSG_ONE, self.origin.y);
|
|
|
|
WriteCoord (MSG_ONE, self.origin.z + 8);
|
|
|
|
WriteCoord (MSG_ONE, lightningvec.x);
|
|
|
|
WriteCoord (MSG_ONE, lightningvec.y);
|
|
|
|
WriteCoord (MSG_ONE, lightningvec.z + 8);
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
self.scaned = list; //CH for the sbar
|
|
|
|
if (!inAuto)
|
|
|
|
{
|
|
|
|
self.StatusRefreshTime = time + 0.2;
|
|
|
|
self.StatusBarScreen = 5;
|
|
|
|
}
|
|
|
|
} // end if(any_detected)
|
|
|
|
}
|
|
|
|
list = list.linked_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display the counts
|
|
|
|
// For Base Defences, it will display the counts to all team members
|
|
|
|
if ((scen == 0) && (scfr == 0) && (!inAuto))
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (self, PRINT_HIGH, "No blips.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update ammo levels
|
|
|
|
//W_SetCurrentAmmo ();
|
|
|
|
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Acts just like T_RadiusDamage, but doesn't damage things, just pushes them away
|
|
|
|
// from the explosion at a speed relative to the distance from the explosion's origin.
|
|
|
|
void(entity inflictor, entity attacker, float bounce, entity ignore) T_RadiusBounce =
|
|
|
|
{
|
|
|
|
local float points;
|
|
|
|
local entity head, te;
|
|
|
|
local vector org;
|
|
|
|
|
|
|
|
head = findradius(inflictor.origin, bounce+40);
|
|
|
|
|
|
|
|
while (head)
|
|
|
|
{
|
|
|
|
if (head != ignore)
|
|
|
|
{
|
2001-09-23 21:31:06 +00:00
|
|
|
if (head.takedamage && head.classname != "monster_shambler")
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
org = head.origin + (head.mins + head.maxs)*0.5;
|
|
|
|
points = 0.5*vlen (org - inflictor.origin);
|
|
|
|
if (points < 0)
|
|
|
|
points = 0;
|
|
|
|
points = bounce - points;
|
2001-07-23 20:52:47 +00:00
|
|
|
if (head.cutf_items & CUTF_GYMNAST)
|
2001-07-17 05:58:10 +00:00
|
|
|
points = points * 2;
|
|
|
|
|
|
|
|
if (!IsBuilding(head) && points > 0)
|
|
|
|
{
|
|
|
|
// Bounce!!
|
2004-04-05 08:11:46 +00:00
|
|
|
#ifdef NEW_CONCUSS_BOUNCE
|
2004-01-21 16:05:58 +00:00
|
|
|
head.velocity += normalize (org - inflictor.origin) * points * 8;
|
2004-04-05 08:11:46 +00:00
|
|
|
#else
|
|
|
|
head.velocity = org - inflictor.origin;
|
|
|
|
head.velocity *= points / 20;
|
|
|
|
#endif
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
if (head.classname != "player")
|
|
|
|
{
|
2004-04-12 05:37:50 +00:00
|
|
|
head.flags &= ~FL_ONGROUND;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//WK Add cheat immunity since they fly
|
|
|
|
makeImmune(head,time+3);
|
|
|
|
|
|
|
|
// Concuss 'em!!
|
|
|
|
// If they are already concussed, set the concussion back up
|
|
|
|
// Try to find a concusstimer entity for this player
|
2004-01-21 16:05:58 +00:00
|
|
|
|
|
|
|
head.tfstate |= TFSTATE_CONCUSSIONED;
|
|
|
|
|
2012-07-06 02:29:18 +00:00
|
|
|
te = find(nil, classname, "timer");
|
2001-11-02 17:00:52 +00:00
|
|
|
while (((te.owner != head) || (te.think != ConcussionGrenadeTimer)) && (te))
|
2001-07-17 05:58:10 +00:00
|
|
|
te = find(te, classname, "timer");
|
2001-11-02 17:00:52 +00:00
|
|
|
if (te)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2004-01-21 16:05:58 +00:00
|
|
|
te.health += GR_CONCUSS_AMOUNT;
|
|
|
|
#ifdef OLD_CONC_GRENADE
|
2004-04-05 09:53:57 +00:00
|
|
|
stuffcmd(head, "v_idlescale " +
|
|
|
|
ftos (te.health * GR_CONCUSS_IDLE) + "\n");
|
2004-01-21 16:05:58 +00:00
|
|
|
#endif
|
2001-07-23 20:52:47 +00:00
|
|
|
te.nextthink = time + GR_CONCUSS_TIME;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-01-21 16:05:58 +00:00
|
|
|
#ifdef OLD_CONC_GRENADE
|
2004-04-05 09:53:57 +00:00
|
|
|
stuffcmd(head,"v_idlescale " +
|
|
|
|
ftos (GR_CONCUSS_AMOUNT * GR_CONCUSS_IDLE)+ "\n");
|
2004-01-21 16:05:58 +00:00
|
|
|
#endif
|
2001-07-17 05:58:10 +00:00
|
|
|
stuffcmd(head,"bf\n");
|
|
|
|
// Create a timer entity
|
|
|
|
te = spawn();
|
2001-07-23 20:52:47 +00:00
|
|
|
te.nextthink = time + GR_CONCUSS_TIME;
|
2001-07-17 05:58:10 +00:00
|
|
|
te.think = ConcussionGrenadeTimer;
|
|
|
|
te.team_no = attacker.team_no;
|
|
|
|
te.classname = "timer";
|
|
|
|
te.owner = head;
|
2004-01-21 16:05:58 +00:00
|
|
|
te.health += GR_CONCUSS_AMOUNT;
|
2004-04-05 08:11:46 +00:00
|
|
|
te.has_tesla = time + 0.1;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
head = head.chain;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
//CH checks a player and returns True of False
|
|
|
|
float(entity scan, entity targ, float enemies, float friends) Scanner_Check_Player =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (targ.playerclass == PC_UNDEFINED) {
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
else if (targ.done_custom & CUSTOM_BUILDING) {
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else if (targ.health <= 0) {
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else if (targ.has_disconnected) {
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else if (targ == scan) {
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
else if (targ.flags & FL_NOTARGET) {
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
2001-07-23 20:52:47 +00:00
|
|
|
else if (targ.cutf_items & CUTF_JAMMER)
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
//CH ALL NEW CHECKS ABOVE THIS LINE
|
|
|
|
if (teamplay)
|
|
|
|
{
|
|
|
|
if ( friends && Teammate(targ.team_no,scan.team_no) )
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
if ( enemies && !Teammate(targ.team_no,scan.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
|
|
|
};
|
|
|
|
//=========================================================================
|
|
|
|
// Returns a list of players within a radius around the origin, like findradius,
|
|
|
|
// except that some parsing of the list can be done based on the parameters passed in.
|
|
|
|
// Make sure you check that the return value is not NULL b4 using it.
|
|
|
|
entity(entity scanner, float scanrange, float enemies, float friends) T_RadiusScan =
|
|
|
|
{
|
|
|
|
local entity head;
|
|
|
|
local entity list_head;
|
|
|
|
local entity list;
|
|
|
|
local float gotatarget;
|
2012-07-06 02:29:18 +00:00
|
|
|
list_head = nil;
|
|
|
|
list = nil;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
head = findradius(scanner.origin, scanrange+40);
|
|
|
|
|
|
|
|
while (head)
|
|
|
|
{
|
|
|
|
gotatarget = 0;
|
|
|
|
if (head != scanner && (friends || enemies)) // Don't pick up the entity that's scanning
|
|
|
|
{
|
|
|
|
if (head.takedamage) //item_tfgoal does not take dammage
|
|
|
|
{
|
|
|
|
if (head.classname == "player")
|
|
|
|
{
|
|
|
|
gotatarget = Scanner_Check_Player(scanner, head, enemies, friends);
|
|
|
|
}
|
2001-07-19 05:46:41 +00:00
|
|
|
else if ((head.classname == "building_tesla" || head.classname == "building_sentrygun" || head.classname == "building_teleporter") && (head.health > 0)) //CH uses team_no :)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
if (teamplay)
|
|
|
|
{
|
|
|
|
if ( friends && Teammate(head.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
if ( enemies && !Teammate(head.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else if ((head.classname == "monster_demon1") && head.health > 0) //CH demons trace back to real_owner
|
|
|
|
{
|
|
|
|
if (teamplay)
|
|
|
|
{
|
|
|
|
if ( friends && Teammate(head.real_owner.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
if ( enemies && !Teammate(head.real_owner.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else if ((head.classname == "monster_army") && head.health > 0) //CH demons trace back to real_owner
|
|
|
|
{
|
|
|
|
if (teamplay)
|
|
|
|
{
|
|
|
|
if ( friends && Teammate(head.real_owner.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
if ( enemies && !Teammate(head.real_owner.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else if ((head.classname == "monster_shambler") && head.health > 0) //CH demons trace back to real_owner
|
|
|
|
{
|
|
|
|
if (teamplay)
|
|
|
|
{
|
|
|
|
if ( friends && Teammate(head.real_owner.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
if ( enemies && !Teammate(head.real_owner.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
//- OfN -
|
|
|
|
else if ((head.classname == "monster_wizard") && head.health > 0) //CH demons trace back to real_owner
|
|
|
|
{
|
|
|
|
if (teamplay)
|
|
|
|
{
|
|
|
|
if ( friends && Teammate(head.real_owner.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
if ( enemies && !Teammate(head.real_owner.team_no, scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (head.classname == "item_tfgoal") //CH flags used owned_by for what team it is
|
|
|
|
{
|
|
|
|
if (teamplay)
|
|
|
|
{
|
|
|
|
if ( friends && (head.team_no > 0) && (head.owned_by > 0) && (scanner.team_no > 0) && (head.team_no == scanner.team_no) && (head.owned_by == scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
if ( friends && (head.team_no > 0) && (head.owned_by > 0) && (scanner.team_no > 0) && (head.team_no != scanner.team_no) && (head.owned_by == scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
if ( enemies && (head.team_no > 0) && (head.owned_by > 0) && (scanner.team_no > 0) && (head.team_no == scanner.team_no) && (head.owned_by != scanner.team_no) )
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gotatarget = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add this entity to the linked list if it matches the target criteria
|
|
|
|
if (gotatarget)
|
|
|
|
{
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
list.linked_list = head;
|
|
|
|
list = list.linked_list;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
list_head = head;
|
|
|
|
list = head;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
head = head.chain;
|
|
|
|
}
|
|
|
|
|
|
|
|
return list_head;
|
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Caltrop Grenade explosion
|
|
|
|
|
|
|
|
#define GR_TYPE_CALTROP_NO 5
|
|
|
|
|
|
|
|
void (vector org, entity shooter) CreateCaltrop;
|
|
|
|
void() CaltropTouch;
|
|
|
|
|
|
|
|
void() CaltropGrenadeExplode =
|
|
|
|
{
|
|
|
|
local float i;
|
|
|
|
|
|
|
|
/* deathmsg = DMSG_GREN_CALTROP;
|
2012-07-06 02:29:18 +00:00
|
|
|
T_RadiusDamage (self, self.owner, 50, nil);
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-10-13 23:02:22 +00:00
|
|
|
WriteByte (MSG_MULTICAST, SVC_TEMPENTITY);
|
|
|
|
WriteByte (MSG_MULTICAST, TE_EXPLOSION);
|
2012-07-06 02:29:18 +00:00
|
|
|
WriteCoord (MSG_MULTICAST, self.origin.x);
|
|
|
|
WriteCoord (MSG_MULTICAST, self.origin.y);
|
|
|
|
WriteCoord (MSG_MULTICAST, self.origin.z);
|
2001-07-25 21:10:26 +00:00
|
|
|
multicast (self.origin, MULTICAST_PHS);
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
self.solid = SOLID_NOT;
|
2001-07-17 05:58:10 +00:00
|
|
|
*/
|
|
|
|
// Very well admiral. Engage the rebels.
|
|
|
|
i = 0;
|
2001-07-23 20:52:47 +00:00
|
|
|
while (i < GR_TYPE_CALTROP_NO)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
CreateCaltrop(self.origin + '0 0 -1',self.owner);
|
|
|
|
i = i + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEMO_STUFF
|
|
|
|
// Remove any camera's locks on this missile
|
|
|
|
if (self.enemy)
|
|
|
|
CamProjectileLockOff();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//BecomeExplosion();
|
|
|
|
dremove(self);
|
|
|
|
};
|
|
|
|
|
|
|
|
void (vector org, entity shooter) CreateCaltrop =
|
|
|
|
{
|
|
|
|
local float xdir,ydir,zdir;
|
|
|
|
|
|
|
|
xdir = 80 * random() - 40;
|
|
|
|
ydir = 80 * random() - 40;
|
|
|
|
zdir = 15 + 15 * random();
|
|
|
|
|
|
|
|
newmis = spawn ();
|
|
|
|
newmis.owner = shooter;
|
2001-07-23 20:52:47 +00:00
|
|
|
newmis.movetype = MOVETYPE_BOUNCE;
|
|
|
|
newmis.solid = SOLID_TRIGGER;
|
|
|
|
//newmis.solid = SOLID_BBOX;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
newmis.classname = "caltrop";
|
2001-07-23 20:52:47 +00:00
|
|
|
newmis.weapon = DMSG_CALTROP;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
newmis.touch = CaltropTouch;
|
|
|
|
newmis.think = SUB_Remove;
|
|
|
|
|
|
|
|
newmis.nextthink = time + 14 + random()*6; // was 7+random()
|
|
|
|
newmis.heat = time + 2; // The caltrop doesn't activate for 2 seconds
|
|
|
|
|
2012-07-06 02:29:18 +00:00
|
|
|
newmis.velocity.x = xdir * 2;
|
|
|
|
newmis.velocity.y = ydir * 2;
|
|
|
|
newmis.velocity.z = zdir * 15;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
newmis.avelocity = '500 500 500';
|
|
|
|
|
|
|
|
setmodel (newmis, "progs/caltrop.mdl");
|
|
|
|
setsize (newmis, '-10 -10 -9', '0 0 0');
|
|
|
|
//setsize (newmis, '-5 -5 -4', '5 5 5');
|
|
|
|
|
|
|
|
setorigin (newmis, org);
|
|
|
|
};
|
|
|
|
|
|
|
|
void() CaltropTouch =
|
|
|
|
{
|
|
|
|
if (self.velocity == '0 0 0')
|
|
|
|
{
|
|
|
|
self.avelocity = '0 0 0';
|
|
|
|
self.angles = '0 0 0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self.heat > time)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (other.takedamage && other.classname == "player")
|
|
|
|
{
|
|
|
|
if (Teammate(self.owner.team_no, other.team_no) && other != self.owner)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//if (other.classname == "player")
|
|
|
|
|
|
|
|
|
|
|
|
if (self.velocity == '0 0 0') // supposedly on the ground..
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(other, PRINT_HIGH, "Ouch! Ouch! Caltrops!\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
other.leg_damage = other.leg_damage + 2;
|
|
|
|
TeamFortress_SetSpeed(other);
|
2001-07-23 20:52:47 +00:00
|
|
|
deathmsg = DMSG_CALTROP;
|
|
|
|
TF_T_Damage(other, self, self.owner, 16, 0, TF_TD_OTHER);
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else // if its moving...
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(other, PRINT_HIGH, "Woah! Caltrops!\n");
|
|
|
|
deathmsg = DMSG_FLYCALTROP;
|
|
|
|
TF_T_Damage(other, self, self.owner, 20 + random() * 9, 0, TF_TD_OTHER);
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dremove(self);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|