2001-07-23 20:52:47 +00:00
|
|
|
#include "defs.qh"
|
2001-07-17 05:58:10 +00:00
|
|
|
/*======================================================
|
|
|
|
MEDIC.QC
|
|
|
|
|
|
|
|
SB-1 Tech 15/12/2000
|
|
|
|
========================================================
|
|
|
|
Functions for the MEDIC class and associated weaponry
|
|
|
|
========================================================*/
|
|
|
|
|
|
|
|
// Functions within this file:
|
|
|
|
|
|
|
|
float (entity targ, entity attacker, float prob) BioInfect;
|
|
|
|
void () BioGrenadeTouch;
|
|
|
|
void () BioGrenadeExplode;
|
|
|
|
|
|
|
|
// Functions referenced from this file:
|
|
|
|
|
|
|
|
void() BioInfection_Decay;
|
|
|
|
void(entity p) TeamFortress_SetSpeed;
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Attacker attempts to infect targ.
|
|
|
|
float (entity targ, entity attacker, float prob) BioInfect =
|
|
|
|
{
|
|
|
|
local entity BioInfection;
|
|
|
|
local float r;
|
|
|
|
|
|
|
|
// If they have medikit, don't infect them.
|
2001-07-23 20:52:47 +00:00
|
|
|
if (targ.weapons_carried & WEAP_MEDIKIT)
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
// Only allow one infection at once.
|
2001-07-23 20:52:47 +00:00
|
|
|
if (targ.tfstate & TFSTATE_INFECTED)
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
if (Teammate(targ.team_no, attacker.team_no) && targ != attacker)
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
if (targ.invincible_finished > time)
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
r = random();
|
|
|
|
if (prob < r)
|
2001-07-23 20:52:47 +00:00
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
r = random();
|
|
|
|
//Melee armour stops infection 75% of the time
|
2001-07-23 20:52:47 +00:00
|
|
|
if (targ.tf_items & NIT_GEL && r < 0.75)
|
|
|
|
return FALSE;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
if (attacker == targ) // we infected ourselves! lol
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(attacker,PRINT_HIGH,"You infect yourself!\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
/*bprint(PRINT_HIGH,attacker.netname);
|
|
|
|
bprint(PRINT_HIGH," infects himself!\n");*/
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(attacker,PRINT_HIGH,"Your grenade infects ");
|
|
|
|
sprint(attacker,PRINT_HIGH,targ.netname);
|
|
|
|
sprint(attacker,PRINT_HIGH,"!\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
2004-04-12 05:37:50 +00:00
|
|
|
targ.tfstate |= TFSTATE_INFECTED;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
BioInfection = spawn ();
|
|
|
|
BioInfection.classname = "timer";
|
|
|
|
BioInfection.netname = "biotimer";
|
|
|
|
BioInfection.owner = targ;
|
|
|
|
BioInfection.nextthink = time + 2;
|
|
|
|
BioInfection.think = BioInfection_Decay;
|
|
|
|
BioInfection.enemy = attacker;
|
|
|
|
|
|
|
|
targ.infection_team_no = attacker.team_no;
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Touch function for the bioinfection grenade.
|
|
|
|
void() BioGrenadeTouch =
|
|
|
|
{
|
|
|
|
if (other == self.owner)
|
|
|
|
return; // don't explode on owner
|
|
|
|
|
|
|
|
// Thrown grenades don't detonate when hitting an enemy
|
|
|
|
|
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';
|
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
// Biogrenade explosion. Does no damage...but infects...
|
|
|
|
void() BioGrenadeExplode =
|
|
|
|
{
|
|
|
|
local entity dier; // He's the dier and he's dying
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
dier = findradius(self.origin, BIO_GREN_RADIUS);
|
2001-07-17 05:58:10 +00:00
|
|
|
while (dier)
|
|
|
|
{
|
|
|
|
if (dier.classname == "player")
|
|
|
|
if (visible(dier))
|
|
|
|
if (dier.takedamage)
|
|
|
|
{
|
|
|
|
BioInfect(dier, self.owner, 1); // was 0.7
|
|
|
|
}
|
|
|
|
|
|
|
|
dier = dier.chain;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
float(entity doc, entity patient, vector org) CureAdverseEffects =
|
|
|
|
{
|
|
|
|
local entity te;
|
|
|
|
|
|
|
|
// remove concussion from player
|
|
|
|
// Try to find a concusstimer entity for this player
|
2012-07-06 02:29:18 +00:00
|
|
|
te = find(nil, classname, "timer");
|
2001-11-02 17:00:52 +00:00
|
|
|
while (((te.owner != patient) || (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
|
|
|
{
|
|
|
|
SpawnBlood(org, 20);
|
2004-04-12 05:37:50 +00:00
|
|
|
patient.tfstate &= ~TFSTATE_CONCUSSIONED;
|
2001-07-17 05:58:10 +00:00
|
|
|
if (doc == patient)
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(doc, PRINT_HIGH, "The ground is behaving itself now.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(patient, PRINT_HIGH, doc.netname, " heals you of your concussion\n");
|
|
|
|
sprint(doc, PRINT_HIGH, "You heal ", patient.netname, "'s concussion\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
// Give the medic a frag for doing it, only if it was caused by an enemy
|
|
|
|
if (!Teammate(doc.team_no,te.team_no))
|
|
|
|
{
|
|
|
|
doc.real_frags = doc.real_frags + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
if (!(toggleflags & TFLAG_TEAMFRAGS))
|
2001-07-17 05:58:10 +00:00
|
|
|
doc.frags = doc.real_frags;
|
|
|
|
}
|
|
|
|
TeamFortress_SetSpeed(patient);
|
|
|
|
dremove(te);
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// remove hallucination from player
|
|
|
|
// Try to find a hallucination timer entity for this player
|
2001-07-23 20:52:47 +00:00
|
|
|
if (patient.tfstate & TFSTATE_HALLUCINATING)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2012-07-06 02:29:18 +00:00
|
|
|
te = find(nil, classname, "timer");
|
2001-11-02 17:00:52 +00:00
|
|
|
while (((te.owner != patient) || (te.think != HallucinationTimer)) && (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-04-12 05:37:50 +00:00
|
|
|
patient.tfstate &= ~TFSTATE_HALLUCINATING;
|
2001-07-17 05:58:10 +00:00
|
|
|
SpawnBlood(org, 20);
|
|
|
|
if (patient == doc)
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(doc, PRINT_HIGH, "The visions have stopped.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(patient, PRINT_HIGH, doc.netname, " heals you of your hallucinations\n");
|
|
|
|
sprint(doc, PRINT_HIGH, "You halt ", patient.netname, "'s hallucinations\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
// Give the medic a frag for doing it, only if it was caused by an enemy
|
|
|
|
if (!Teammate(doc.team_no,te.team_no))
|
|
|
|
{
|
|
|
|
doc.real_frags = doc.real_frags + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
if (!(toggleflags & TFLAG_TEAMFRAGS))
|
2001-07-17 05:58:10 +00:00
|
|
|
doc.frags = doc.real_frags;
|
|
|
|
}
|
|
|
|
|
|
|
|
dremove(te);
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-27 07:07:26 +00:00
|
|
|
RPrint("Warning: Error in Hallucination Timer logic.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove tranquilisation from player
|
|
|
|
// Try to find a tranquilisation timer entity for this player
|
2001-07-23 20:52:47 +00:00
|
|
|
if (patient.tfstate & TFSTATE_TRANQUILISED)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
2012-07-06 02:29:18 +00:00
|
|
|
te = find(nil, classname, "timer");
|
2001-11-02 17:00:52 +00:00
|
|
|
while (((te.owner != patient) || (te.think != TranquiliserTimer)) && (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-04-12 05:37:50 +00:00
|
|
|
patient.tfstate &= ~TFSTATE_TRANQUILISED;
|
2001-07-17 05:58:10 +00:00
|
|
|
TeamFortress_SetSpeed(patient);
|
|
|
|
|
|
|
|
SpawnBlood(org, 20);
|
|
|
|
if (doc == patient)
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(doc, PRINT_HIGH, "You feel more alert now.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(patient, PRINT_HIGH, doc.netname, " heals you of your tranquilisation!\n");
|
|
|
|
sprint(doc, PRINT_HIGH, "You heal ", patient.netname, "'s tranquilisation\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
// Give the medic a frag for doing it, only if it was caused by an enemy
|
|
|
|
if (!Teammate(doc.team_no,te.team_no))
|
|
|
|
{
|
|
|
|
doc.real_frags = doc.real_frags + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
if (!(toggleflags & TFLAG_TEAMFRAGS))
|
2001-07-17 05:58:10 +00:00
|
|
|
doc.frags = doc.real_frags;
|
|
|
|
}
|
|
|
|
|
|
|
|
dremove(te);
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-27 07:07:26 +00:00
|
|
|
RPrint("Warning: Error in Tranquilisation Timer logic.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if the healed player is blinded
|
|
|
|
/*if (patient.tfstate & TFSTATE_STASIS)
|
|
|
|
{
|
2004-04-12 05:37:50 +00:00
|
|
|
patient.tfstate &= ~TFSTATE_STASIS;
|
2001-07-17 05:58:10 +00:00
|
|
|
TeamFortress_SetSpeed(patient);
|
|
|
|
if (doc == patient)
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(doc, PRINT_HIGH, "You can move freely again!\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(patient, PRINT_HIGH, doc.netname, " removes the effect of stasis on you!\n");
|
|
|
|
sprint(doc, PRINT_HIGH, "You halt the effects of stasis on ", patient.netname, "!\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
// patient.movetype = patient.stasismovetype;
|
|
|
|
patient.gravity = patient.stasisGravity;
|
2004-04-12 05:37:50 +00:00
|
|
|
patient.effects &= ~EF_BRIGHTFIELD;
|
2001-07-17 05:58:10 +00:00
|
|
|
return 1;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
// check if the healed player is infected
|
2001-07-23 20:52:47 +00:00
|
|
|
if (patient.tfstate & TFSTATE_INFECTED)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
local float healam;
|
|
|
|
local entity te;
|
|
|
|
|
|
|
|
healam = rint(patient.health / 2);
|
|
|
|
// remove the infection
|
2004-04-12 05:37:50 +00:00
|
|
|
patient.tfstate &= ~TFSTATE_INFECTED;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2012-07-06 02:29:18 +00:00
|
|
|
te = find(nil, netname, "biotimer");
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-11-02 17:00:52 +00:00
|
|
|
while (te)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
if (te.classname == "timer")
|
|
|
|
if (te.owner == patient)
|
|
|
|
dremove(te);
|
|
|
|
|
|
|
|
te = find(te, netname, "biotimer");
|
|
|
|
}
|
|
|
|
|
|
|
|
// some damage is caused (because of the use of leeches!)
|
|
|
|
// remove half their remaining health
|
2001-07-23 20:52:47 +00:00
|
|
|
deathmsg = DMSG_MEDIKIT;
|
|
|
|
TF_T_Damage(patient, doc, doc, healam, 0, TF_TD_OTHER);
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
SpawnBlood(org, 30);
|
|
|
|
if (doc == patient)
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(doc, PRINT_HIGH, "Your sores disappear.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(patient, PRINT_HIGH, doc.netname, " cures your infection!\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
if (doc.classname == "player")
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(doc, PRINT_HIGH, "You have healed ");
|
|
|
|
sprint(doc, PRINT_HIGH, patient.netname);
|
|
|
|
sprint(doc, PRINT_HIGH, " of the infection.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
// Give the medic a frag for doing it, only if it was caused by an enemy
|
|
|
|
if (!Teammate(patient.infection_team_no, doc.team_no))
|
|
|
|
{
|
|
|
|
doc.real_frags = doc.real_frags + 1;
|
2001-07-23 20:52:47 +00:00
|
|
|
if (!(toggleflags & TFLAG_TEAMFRAGS))
|
2001-07-17 05:58:10 +00:00
|
|
|
doc.frags = doc.real_frags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// put out the fire if they are burning
|
|
|
|
if (patient.numflames > 0)
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sound(patient, CHAN_WEAPON, "items/r_item1.wav", 1, ATTN_NORM);
|
2001-07-17 05:58:10 +00:00
|
|
|
patient.numflames = 0;
|
|
|
|
|
|
|
|
if (doc == patient)
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint (doc, PRINT_HIGH, "Your flames are extinguished!\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
else
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(patient, PRINT_HIGH, doc.netname, " stops you burning!\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
if (doc.classname == "player")
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
sprint(doc, PRINT_MEDIUM, "You have put out ");
|
|
|
|
sprint(doc, PRINT_MEDIUM, patient.netname);
|
|
|
|
sprint(doc, PRINT_MEDIUM, "'s fire.\n");
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
return TRUE;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
2012-07-06 02:29:18 +00:00
|
|
|
return FALSE;
|
2001-07-23 20:52:47 +00:00
|
|
|
};
|