prozac-qfcc/sniper.qc

199 lines
4.5 KiB
C++
Raw Normal View History

#include "defs.qh"
2001-07-17 05:58:10 +00:00
/*======================================================
SNIPER.QC
TeamFortress v2.5 29/2/97
========================================================
Functions for the SNIPER class and associated weaponry
========================================================*/
// Functions outside this file
// Functions inside this file
void() TeamFortress_SniperWeapon;
// Autozoom functions
void(float zoom_level) TF_zoom;
void() SniperSight_Update;
void() SniperSight_Update2;
void(float type) SniperSight_Create;
//=========================================================================
// Sniper/Auto Rifle selection function
void() TeamFortress_SniperWeapon =
{
self.impulse = 0;
if (self.tfstate & TFSTATE_RELOADING)
2001-07-17 05:58:10 +00:00
return;
if (!((self.weapons_carried & WEAP_SNIPER_RIFLE) && (self.weapons_carried & WEAP_AUTO_RIFLE)))
2001-07-17 05:58:10 +00:00
return;
if (self.ammo_shells < 5)
2001-07-17 05:58:10 +00:00
{ // don't have the ammo
sprint (self, PRINT_HIGH, "not enough ammo.\n");
2001-07-17 05:58:10 +00:00
return;
}
#ifndef NO_AUTORIFLE
if (self.current_weapon == WEAP_SNIPER_RIFLE)
2001-07-17 05:58:10 +00:00
{
self.current_weapon = WEAP_AUTO_RIFLE;
2001-07-17 05:58:10 +00:00
}
else
#endif
2001-07-17 05:58:10 +00:00
{
self.current_weapon = WEAP_SNIPER_RIFLE;
2001-07-17 05:58:10 +00:00
}
W_SetCurrentAmmo ();
};
//=========================================================================
// Do the autozoom of the sniper rifle
void(float zoom_level) TF_zoom =
{
local string zl;
if (self.tfstate & TFSTATE_ZOOMOFF)
2001-07-17 05:58:10 +00:00
return;
zl = ftos(zoom_level);
stuffcmd(self, "fov ");
stuffcmd(self, zl);
stuffcmd(self, "\n");
};
//=========================================================================
// Move the sight to the point the rifle's aiming at
void() SniperSight_Update =
{
local vector org;
if (!(self.owner.tfstate & TFSTATE_AIMING) || (self.owner.current_weapon != WEAP_SNIPER_RIFLE))
2001-07-17 05:58:10 +00:00
{
self.owner.tfstate = self.owner.tfstate - (self.owner.tfstate & TFSTATE_AIMING);
2001-07-17 05:58:10 +00:00
TeamFortress_SetSpeed(self.owner);
self.owner.heat = 0;
dremove(self);
return;
}
makevectors(self.owner.v_angle);
org = self.owner.origin + v_forward*10;
org_z = self.owner.absmin_z + self.owner.size_z * 0.7;
traceline (org, org + v_forward*9192, FALSE, self);
2001-07-17 05:58:10 +00:00
if (trace_fraction == 1.0)
{
setorigin(self, self.owner.origin );
return;
}
self.angles = vectoangles(v_forward);
setorigin(self, trace_endpos);
<Grievre> lemme see... fixes: stuck shamblers, cheat teslas, camming and sensing <Grievre> give mirvs the right death message, make them a little weaker and more spread out <Grievre> increased damage done by exp body... fixes not being able to use airfist if you have daedalus or lg with no cells <Grievre> made it so missing judo = you can't fire for 1.5 seconds, also judo doesn't always work, less chance of it working a) if they're facing you b) if they have knife, judo, or close combat <Grievre> you lose speed the more armor you have (so upgraded people can buy cougar and cheetah now) <Grievre> attempted to fix the respawn guard not telefragging bug (if it was still there) <Grievre> made it so you can tell a shambler to come, stop, or patrol even if it is fighting someone, doesn't really work most of the time but can "wake up" your shambler if it's being screwy <Grievre> (works for all demons) <Grievre> made it so a monster goes back to what it was doing before (following you, patrolling etc) once it's done with its enemy <Grievre> made the sniper rifle less cheap (or tried to), charging now = more accuracy, rather than more damage. OTR now does slightly less damage than regular, but isn't blocked by armor as much. <Grievre> autorifle now has half the rate of fire but does same damage as sniper rifle, but less accurate <Grievre> headshots always ignore armor if target has green armor, legshots always ignore armor except for red <Grievre> added bshams and shambler kings (can be disabled with infokeys) <Grievre> increased max knife blood to 32 <Grievre> made it so airfist bounces gymnasts twice as much, and bounces everyone a little more (I think), may cause stuck bugs but I think it won't. airfist does half damage to gymnasts and slightly more to hwguys <Grievre> made shamblers a little smarter and more powerful in general <Grievre> they now attack buildings (only bshams/kings) if they are attacked by them first <Grievre> bsham/king fireball now sets things on fire <Grievre> shamblers will generally attack the person who last hit them <Grievre> shortened judoka range (they have the old range if they get close combat <Grievre> shamblers will cycle the left-right slash or fireball longer than they did (but they won't keep doing it if their enemy is not visible) <Grievre> fixed shambler fireball so it doesn't miss and hurt itself so much <Grievre> #define OLD_AUTORIFLE <Grievre> will go to the old behavior of the auto rifle <Grievre> I think that's it <Grievre> oh, I changed the intro message and version string a little, you might want to change that
2003-11-12 04:58:19 +00:00
self.v_angle_z = self.owner.v_angle_z;
self.owner.heat *= 0.9;
self.owner.heat--;
<Grievre> lemme see... fixes: stuck shamblers, cheat teslas, camming and sensing <Grievre> give mirvs the right death message, make them a little weaker and more spread out <Grievre> increased damage done by exp body... fixes not being able to use airfist if you have daedalus or lg with no cells <Grievre> made it so missing judo = you can't fire for 1.5 seconds, also judo doesn't always work, less chance of it working a) if they're facing you b) if they have knife, judo, or close combat <Grievre> you lose speed the more armor you have (so upgraded people can buy cougar and cheetah now) <Grievre> attempted to fix the respawn guard not telefragging bug (if it was still there) <Grievre> made it so you can tell a shambler to come, stop, or patrol even if it is fighting someone, doesn't really work most of the time but can "wake up" your shambler if it's being screwy <Grievre> (works for all demons) <Grievre> made it so a monster goes back to what it was doing before (following you, patrolling etc) once it's done with its enemy <Grievre> made the sniper rifle less cheap (or tried to), charging now = more accuracy, rather than more damage. OTR now does slightly less damage than regular, but isn't blocked by armor as much. <Grievre> autorifle now has half the rate of fire but does same damage as sniper rifle, but less accurate <Grievre> headshots always ignore armor if target has green armor, legshots always ignore armor except for red <Grievre> added bshams and shambler kings (can be disabled with infokeys) <Grievre> increased max knife blood to 32 <Grievre> made it so airfist bounces gymnasts twice as much, and bounces everyone a little more (I think), may cause stuck bugs but I think it won't. airfist does half damage to gymnasts and slightly more to hwguys <Grievre> made shamblers a little smarter and more powerful in general <Grievre> they now attack buildings (only bshams/kings) if they are attacked by them first <Grievre> bsham/king fireball now sets things on fire <Grievre> shamblers will generally attack the person who last hit them <Grievre> shortened judoka range (they have the old range if they get close combat <Grievre> shamblers will cycle the left-right slash or fireball longer than they did (but they won't keep doing it if their enemy is not visible) <Grievre> fixed shambler fireball so it doesn't miss and hurt itself so much <Grievre> #define OLD_AUTORIFLE <Grievre> will go to the old behavior of the auto rifle <Grievre> I think that's it <Grievre> oh, I changed the intro message and version string a little, you might want to change that
2003-11-12 04:58:19 +00:00
local float diff = vlen(self.owner.v_angle - self.v_angle);
if (diff > 10) diff = 10;
<Grievre> lemme see... fixes: stuck shamblers, cheat teslas, camming and sensing <Grievre> give mirvs the right death message, make them a little weaker and more spread out <Grievre> increased damage done by exp body... fixes not being able to use airfist if you have daedalus or lg with no cells <Grievre> made it so missing judo = you can't fire for 1.5 seconds, also judo doesn't always work, less chance of it working a) if they're facing you b) if they have knife, judo, or close combat <Grievre> you lose speed the more armor you have (so upgraded people can buy cougar and cheetah now) <Grievre> attempted to fix the respawn guard not telefragging bug (if it was still there) <Grievre> made it so you can tell a shambler to come, stop, or patrol even if it is fighting someone, doesn't really work most of the time but can "wake up" your shambler if it's being screwy <Grievre> (works for all demons) <Grievre> made it so a monster goes back to what it was doing before (following you, patrolling etc) once it's done with its enemy <Grievre> made the sniper rifle less cheap (or tried to), charging now = more accuracy, rather than more damage. OTR now does slightly less damage than regular, but isn't blocked by armor as much. <Grievre> autorifle now has half the rate of fire but does same damage as sniper rifle, but less accurate <Grievre> headshots always ignore armor if target has green armor, legshots always ignore armor except for red <Grievre> added bshams and shambler kings (can be disabled with infokeys) <Grievre> increased max knife blood to 32 <Grievre> made it so airfist bounces gymnasts twice as much, and bounces everyone a little more (I think), may cause stuck bugs but I think it won't. airfist does half damage to gymnasts and slightly more to hwguys <Grievre> made shamblers a little smarter and more powerful in general <Grievre> they now attack buildings (only bshams/kings) if they are attacked by them first <Grievre> bsham/king fireball now sets things on fire <Grievre> shamblers will generally attack the person who last hit them <Grievre> shortened judoka range (they have the old range if they get close combat <Grievre> shamblers will cycle the left-right slash or fireball longer than they did (but they won't keep doing it if their enemy is not visible) <Grievre> fixed shambler fireball so it doesn't miss and hurt itself so much <Grievre> #define OLD_AUTORIFLE <Grievre> will go to the old behavior of the auto rifle <Grievre> I think that's it <Grievre> oh, I changed the intro message and version string a little, you might want to change that
2003-11-12 04:58:19 +00:00
local float heat = diff * 0.5 + vlen(self.owner.velocity) * 0.1;
if (self.owner.heat < heat)
self.owner.heat = heat;
<Grievre> lemme see... fixes: stuck shamblers, cheat teslas, camming and sensing <Grievre> give mirvs the right death message, make them a little weaker and more spread out <Grievre> increased damage done by exp body... fixes not being able to use airfist if you have daedalus or lg with no cells <Grievre> made it so missing judo = you can't fire for 1.5 seconds, also judo doesn't always work, less chance of it working a) if they're facing you b) if they have knife, judo, or close combat <Grievre> you lose speed the more armor you have (so upgraded people can buy cougar and cheetah now) <Grievre> attempted to fix the respawn guard not telefragging bug (if it was still there) <Grievre> made it so you can tell a shambler to come, stop, or patrol even if it is fighting someone, doesn't really work most of the time but can "wake up" your shambler if it's being screwy <Grievre> (works for all demons) <Grievre> made it so a monster goes back to what it was doing before (following you, patrolling etc) once it's done with its enemy <Grievre> made the sniper rifle less cheap (or tried to), charging now = more accuracy, rather than more damage. OTR now does slightly less damage than regular, but isn't blocked by armor as much. <Grievre> autorifle now has half the rate of fire but does same damage as sniper rifle, but less accurate <Grievre> headshots always ignore armor if target has green armor, legshots always ignore armor except for red <Grievre> added bshams and shambler kings (can be disabled with infokeys) <Grievre> increased max knife blood to 32 <Grievre> made it so airfist bounces gymnasts twice as much, and bounces everyone a little more (I think), may cause stuck bugs but I think it won't. airfist does half damage to gymnasts and slightly more to hwguys <Grievre> made shamblers a little smarter and more powerful in general <Grievre> they now attack buildings (only bshams/kings) if they are attacked by them first <Grievre> bsham/king fireball now sets things on fire <Grievre> shamblers will generally attack the person who last hit them <Grievre> shortened judoka range (they have the old range if they get close combat <Grievre> shamblers will cycle the left-right slash or fireball longer than they did (but they won't keep doing it if their enemy is not visible) <Grievre> fixed shambler fireball so it doesn't miss and hurt itself so much <Grievre> #define OLD_AUTORIFLE <Grievre> will go to the old behavior of the auto rifle <Grievre> I think that's it <Grievre> oh, I changed the intro message and version string a little, you might want to change that
2003-11-12 04:58:19 +00:00
self.v_angle = self.owner.v_angle;
2001-07-17 05:58:10 +00:00
self.nextthink = time + 0.1;
};
//CH used for the rl
void() SniperSight_Update2 =
{
//bprint(PRINT_HIGH, "Sight Think..\n");
2001-07-17 05:58:10 +00:00
local vector org;
if (!(self.owner.tfstate & TFSTATE_RL_LASER) || (self.owner.current_weapon != WEAP_ROCKET_LAUNCHER))
2001-07-17 05:58:10 +00:00
{
self.owner.tfstate = self.owner.tfstate - (self.owner.tfstate & TFSTATE_RL_LASER);
2001-07-17 05:58:10 +00:00
TeamFortress_SetSpeed(self.owner);
self.owner.heat = 0;
dremove(self);
return;
}
makevectors(self.owner.v_angle);
org = self.owner.origin + v_forward*10;
org_z = self.owner.absmin_z + self.owner.size_z * 0.7;
traceline (org, org + v_forward*9192, FALSE, self);
2001-07-17 05:58:10 +00:00
if (trace_fraction == 1.0)
{
setorigin(self, self.owner.origin );
return;
}
self.angles = vectoangles(v_forward);
setorigin(self, trace_endpos);
self.nextthink = time + 0.1;
};
//=========================================================================
// Create the sight
//CH type 1 = rl
void(float type) SniperSight_Create =
{
local entity sight;
if (type == 1)
self.tfstate = self.tfstate | TFSTATE_RL_LASER;
2001-07-17 05:58:10 +00:00
else
self.tfstate = self.tfstate | TFSTATE_AIMING;
2001-07-17 05:58:10 +00:00
sight = spawn ();
sight.owner = self;
sight.movetype = MOVETYPE_NOCLIP;
sight.solid = SOLID_NOT;
<Grievre> lemme see... fixes: stuck shamblers, cheat teslas, camming and sensing <Grievre> give mirvs the right death message, make them a little weaker and more spread out <Grievre> increased damage done by exp body... fixes not being able to use airfist if you have daedalus or lg with no cells <Grievre> made it so missing judo = you can't fire for 1.5 seconds, also judo doesn't always work, less chance of it working a) if they're facing you b) if they have knife, judo, or close combat <Grievre> you lose speed the more armor you have (so upgraded people can buy cougar and cheetah now) <Grievre> attempted to fix the respawn guard not telefragging bug (if it was still there) <Grievre> made it so you can tell a shambler to come, stop, or patrol even if it is fighting someone, doesn't really work most of the time but can "wake up" your shambler if it's being screwy <Grievre> (works for all demons) <Grievre> made it so a monster goes back to what it was doing before (following you, patrolling etc) once it's done with its enemy <Grievre> made the sniper rifle less cheap (or tried to), charging now = more accuracy, rather than more damage. OTR now does slightly less damage than regular, but isn't blocked by armor as much. <Grievre> autorifle now has half the rate of fire but does same damage as sniper rifle, but less accurate <Grievre> headshots always ignore armor if target has green armor, legshots always ignore armor except for red <Grievre> added bshams and shambler kings (can be disabled with infokeys) <Grievre> increased max knife blood to 32 <Grievre> made it so airfist bounces gymnasts twice as much, and bounces everyone a little more (I think), may cause stuck bugs but I think it won't. airfist does half damage to gymnasts and slightly more to hwguys <Grievre> made shamblers a little smarter and more powerful in general <Grievre> they now attack buildings (only bshams/kings) if they are attacked by them first <Grievre> bsham/king fireball now sets things on fire <Grievre> shamblers will generally attack the person who last hit them <Grievre> shortened judoka range (they have the old range if they get close combat <Grievre> shamblers will cycle the left-right slash or fireball longer than they did (but they won't keep doing it if their enemy is not visible) <Grievre> fixed shambler fireball so it doesn't miss and hurt itself so much <Grievre> #define OLD_AUTORIFLE <Grievre> will go to the old behavior of the auto rifle <Grievre> I think that's it <Grievre> oh, I changed the intro message and version string a little, you might want to change that
2003-11-12 04:58:19 +00:00
sight.v_angle = self.v_angle;
2001-07-17 05:58:10 +00:00
setmodel (sight, "progs/sight.spr");
sight.classname = "timer";
setorigin(sight, self.origin);
if (type == 1)
sight.think = SniperSight_Update2;
else
sight.think = SniperSight_Update;
sight.nextthink = time + 0.05;
};
// this toggles the snipers autozoom on/off
void() TeamFortress_AutoZoomToggle =
{
if (self.tfstate & TFSTATE_ZOOMOFF)
2001-07-17 05:58:10 +00:00
{
self.tfstate = self.tfstate - TFSTATE_ZOOMOFF;
sprint(self, PRINT_HIGH, "autozoom ON\n");
2001-07-17 05:58:10 +00:00
}
else
{
self.tfstate = self.tfstate | TFSTATE_ZOOMOFF;
sprint(self, PRINT_HIGH, "autozoom OFF\n");
2001-07-17 05:58:10 +00:00
}
};
//=========================================================================