prozac-qfcc/security.qc
Finny Merrill 8c2d5fdd12 1) Attempted to give players positive frags whenever possible. You now
should get frags for blowing people up with others' dispensers/mines/expbody,
airfisting rockets, etc.

2) Redid Give_Frags_Out

3) Changed many uses of pointcontents and ugly hacks to use hullpointcontents
and checkmove, now a lot cleaner and less buggy

4) You can grapple builds again. This caused really odd bugs.

5) You can now damage your own buildings again (gasp). Any time a tesla or sentry
is damaged it turns on its attacker, friendly or otherwise. This is both a counter-TK
and counter-spy mechanism.

6) Teslas are now entirely inside their bounding box

7) Now check every frame for players startsolid and for outside of the map cube.

8) #define WALL_HURT to make it hurt when you hit a wall

9) Used some cool ideas (aka laws of physics) to make the airfist a little less annoying

10) You now only get 1 mirv per slot without bandolier. Demoman and hwguy gain bandolier.
    demoman loses his extra mirv but gains an extra grenade and pair of detpacks. Hwguy
    gets extra grenade.

11) New and improved EMP grenade now does damage based on range. no longer blows up shells.
    Doesn't directly damage sentries anymore, but does significant damage to dispensers.
    EMP someone who's setting a det and it blows up in their face.

12) Players now do radius damage from getting EMPed (again)

13) EMPs now go through walls (again)

14) EMP number lowered by one (3 without, 4 with bandolier) and cost raised by $100

15) You can only have 2 frag grens, 3 with bandolier now.

16) Hover boots will now eat cells if they get low on charge. In addition, the silly bug
    where their charge wasn't restored when you die is fixed now.

17) EMPing a detpack now sets its timer to anywhere between 1 and 121 seconds from current time,
    with a logarithmic probability of it being lower. (random() * random() * 120 + 1). Also, probably
    more time the closer it is to the EMP.

18) Judo can now be blocked by people with close combat, knife or judo. Blocked judo means that the
    attacker loses 3 seconds of attack.

19) Judo missing now makes them unable to fire.

20) Shortened judo range (back to normal if w/ close combat)

21) Attempted to rework the railgun. Seems to be okay now.

Probably still a lot of bugs in here, but since this is the devel version I thought I would commit
all my changes so people could start testing it. I'll commit fixes as soon as I find the bugs.
2003-11-26 08:53:44 +00:00

293 lines
7.4 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "defs.qh"
/*======================================================
SECURITY.QC Custom TeamFortress v3.1
(c) Craig Hauser 26/3/00
========================================================
Functions for the security camera
======================================================*/
void() Security_Camera_Idle;
float() Security_Camera_FindTarget;
void(entity attacker, float damage) Security_Camera_Pain;
void() Security_Camera_Die;
void() Security_Camera_PrintTarget;
void() Security_Camera_Spawn;
float() Security_Camera_FindFakeTarget;
void() SecurityCameraTossTouch;
//used for print
string(float tno) GetTrueTeamName;
string(float pc) TeamFortress_GetClassName;
string(float pc) TeamFortress_GetJobName;
//===================================================================
void() Security_Camera_Idle =
{
if (Security_Camera_FindTarget())
self.nextthink = time + 2; //CH if found wait 2 sec before do another check
else
self.nextthink = time + 0.5; //CH else 2 checks per sec
self.think = Security_Camera_Idle;
};
//========
float() Security_Camera_FindTarget =
{
local entity client = NIL;
local float r, gotone, loopc;
if (self.is_malfunctioning & SCREWUP_TWO) // SB how tragic, camera can't see
return FALSE;
if (self.is_malfunctioning & SCREWUP_THREE) // oh no, we're reading incorrect signals
{
if (Security_Camera_FindFakeTarget())
return TRUE;
else
return FALSE;
}
// Try a few checks to make it react faster
r = 0;
loopc = 0;
gotone = FALSE;
local float trange; //- OfN - Hack
trange=1000;
if (self.num_mines & IMPROVED_ONE)
trange=1250;
//CH Theortetically this will check every client on the server now
while (loopc < 32 && gotone == FALSE)
{
client = checkclient();
gotone = TRUE;
if (!client)
gotone = FALSE;
if (!Pharse_Client(client, self, 1, trange, 0, 1))
gotone = FALSE;
loopc = loopc + 1;
if (gotone) loopc = 1000;
}
if (!gotone)
return FALSE;
// Found a Target
self.enemy = client;
if (self.enemy.classname != "player")
{
self.enemy = self.enemy.enemy;
if (self.enemy.classname != "player")
{
self.enemy = NIL;
return FALSE;
}
}
// Spotted sound
if (self.heat == 3) { //CH so it does not beep all the time.
sound (self, CHAN_WEAPON, "weapons/camera_beep.wav", 1, ATTN_NORM);
self.heat = 0;
}
else
self.heat = self.heat + 1;
Security_Camera_PrintTarget ();
return TRUE;
};
float() Security_Camera_FindFakeTarget =
{
local entity client = NIL;
local float r, gotone, loopc;
if (self.is_malfunctioning & SCREWUP_THREE) // SB how tragic, camera can't see
return FALSE;
// Try a few checks to make it react faster
r = 0;
loopc = 0;
gotone = FALSE;
// Pick a random client
while (loopc < 32 && gotone == FALSE)
{
client = checkclient();
gotone = TRUE;
if (!client)
gotone = FALSE;
if (random() < 0.05)
gotone = FALSE;
if (client.playerclass == PC_UNDEFINED) {
return FALSE;
}
if (client.done_custom & CUSTOM_BUILDING) {
return FALSE;
}
if (client.health <= 0) {
return FALSE;
}
if (client.has_disconnected) {
return FALSE;
}
loopc = loopc + 1;
if (gotone) loopc = 1000;
}
if (!gotone)
return FALSE;
// Found a Target
self.enemy = client;
if (self.enemy.classname != "player")
{
self.enemy = self.enemy.enemy;
if (self.enemy.classname != "player")
{
self.enemy = NIL;
return FALSE;
}
}
// Spotted sound
if (self.heat == 3) { //CH so it does not beep all the time.
sound (self, CHAN_WEAPON, "weapons/camera_beep.wav", 1, ATTN_NORM);
self.heat = 0;
}
else
self.heat = self.heat + 1;
if (!(self.is_malfunctioning & SCREWUP_ONE))
Security_Camera_PrintTarget ();
return TRUE;
};
//========
void(entity attacker, float damage) Security_Camera_Pain =
{
sound (self, CHAN_WEAPON, "weapons/camera_beep.wav", 1, ATTN_NORM);
};
//======
void() Security_Camera_Die =
{
sprint(self.real_owner, PRINT_HIGH, "Your security camera was destroyed.\n");
self.real_owner.has_camera = FALSE;
// ThrowGib("progs/tgib1.mdl", -70);
// ThrowGib("progs/tgib2.mdl", -70);
// ThrowGib("progs/tgib3.mdl", -70);
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);
multicast (self.origin, MULTICAST_PHS);
dremove(self);
//SwitchFromCamera();
};
//==========
//Prints the person to owner/team
//Outputs: "<>SECURITY CAMERA<> Team_color class/job (netname)\n"
void() Security_Camera_PrintTarget =
{
local string st;
sprint(self.real_owner, PRINT_HIGH, "<1F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "); //<>Security camera<>
st = GetTrueTeamName(self.enemy.team_no);
sprint(self.real_owner, PRINT_HIGH, st);
sprint(self.real_owner, PRINT_HIGH, " ");
if (self.enemy.playerclass != PC_CUSTOM)
st = TeamFortress_GetClassName(self.enemy.playerclass);
else
st = TeamFortress_GetJobName(self.enemy.job);
sprint(self.real_owner, PRINT_HIGH, st);
sprint(self.real_owner, PRINT_HIGH, " (");
sprint(self.real_owner, PRINT_HIGH, self.enemy.netname);
sprint(self.real_owner, PRINT_HIGH, ")\n");
};
//==========
void() Security_Camera_Spawn =
{
if (self.ammo_cells < BUILD_COST_CAMERA)
{
sprint(self,PRINT_HIGH,"Not enough cells to build a Security Camera\n");
}
else
{
self.ammo_cells = self.ammo_cells - BUILD_COST_CAMERA;
self.has_camera = TRUE;
newmis = spawn();
newmis.movetype = MOVETYPE_BOUNCE;
setsize (newmis, '-16 -16 -3', '16 16 5');
// setsize (newmis, '-8 -8 -8', '8 8 8');
newmis.solid = SOLID_BBOX;
newmis.takedamage = DAMAGE_AIM;
newmis.classname = "building_camera";
newmis.netname = "security_camera";
newmis.origin = self.origin;
newmis.owner = NIL;
newmis.real_owner = self;
makevectors (self.v_angle);
newmis.avelocity = '0 0 0';
newmis.velocity = v_forward*800 + v_up * 200 + v_right*10 + v_up*10;
newmis.origin += (normalize(newmis.velocity) * 20);
setorigin(newmis, newmis.origin);
newmis.angles = '0 0 0';
newmis.angles_y = anglemod(self.angles_y + 180);
// newmis.skin = 1;
newmis.th_die = Security_Camera_Die; // Death function
newmis.th_pain = Security_Camera_Pain;
newmis.mdl = "progs/camera.mdl"; //CH temp model
setmodel (newmis, newmis.mdl);
newmis.team_no = self.team_no;
newmis.colormap = self.colormap;
newmis.heat = 0; //Beeps
newmis.think = Security_Camera_Die;
newmis.nextthink = time + 5;
newmis.health = newmis.max_health = BUILD_HEALTH_CAMERA;
newmis.touch = SecurityCameraTossTouch;
newmis.num_mines=0; // OfN - reset HACKER improvements
W_SetCurrentAmmo();
}
};
//========
void() SecurityCameraTossTouch =
{
if (other || other == self.real_owner)
return;
local integer pc = entpointcontents(self);
if (pc == CONTENTS_SOLID || pc == CONTENTS_SKY)
{
Security_Camera_Die();
return;
}
sprint (self.real_owner, PRINT_HIGH, "You finish building the Security Camera.\n");
teamprefixsprint(self.real_owner.team_no,self.real_owner); //- OfN
teamsprint(self.real_owner.team_no, self.real_owner, self.real_owner.netname);
teamsprint(self.real_owner.team_no, self.real_owner, " has built a Security Camera.\n");
self.real_owner.option = time + 2; // so ppl cant destroy it for 2 seconds
self.movetype = MOVETYPE_NONE;
setsize (self, '-16 -16 -6', '16 16 10');
self.solid = SOLID_BBOX;
self.takedamage = DAMAGE_AIM;
sound (self, CHAN_WEAPON, "weapons/guerilla_set.wav", 1, ATTN_NORM);
self.think = Security_Camera_Idle;
self.nextthink = time + 1;
};