2003-03-02 04:06:47 +00:00
|
|
|
/* SERVER
|
2003-03-04 23:15:54 +00:00
|
|
|
void () monster_death_use;
|
2002-02-15 17:57:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
CanDamage
|
|
|
|
|
|
|
|
Returns true if the inflictor can directly damage the target. Used for
|
|
|
|
explosions and melee attacks.
|
|
|
|
============
|
|
|
|
*/
|
2003-03-04 23:15:54 +00:00
|
|
|
float (entity targ, entity inflictor)
|
|
|
|
CanDamage =
|
2002-02-15 17:57:14 +00:00
|
|
|
{
|
2003-03-02 04:06:47 +00:00
|
|
|
// bmodels need special checking because their origin is 0,0,0
|
|
|
|
if (targ.movetype == MOVETYPE_PUSH) {
|
|
|
|
traceline (inflictor.origin, 0.5 * (targ.absmin + targ.absmax), TRUE,
|
|
|
|
self);
|
2002-02-15 17:57:14 +00:00
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
traceline (inflictor.origin, targ.origin, TRUE, self);
|
2002-02-15 17:57:14 +00:00
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
2003-03-02 04:06:47 +00:00
|
|
|
traceline (inflictor.origin, targ.origin + '15 15 0', TRUE, self);
|
2002-02-15 17:57:14 +00:00
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
2003-03-02 04:06:47 +00:00
|
|
|
traceline (inflictor.origin, targ.origin + '-15 -15 0', TRUE, self);
|
2002-02-15 17:57:14 +00:00
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
2003-03-02 04:06:47 +00:00
|
|
|
traceline (inflictor.origin, targ.origin + '-15 15 0', TRUE, self);
|
2002-02-15 17:57:14 +00:00
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
2003-03-02 04:06:47 +00:00
|
|
|
traceline (inflictor.origin, targ.origin + '15 -15 0', TRUE, self);
|
2002-02-15 17:57:14 +00:00
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
2003-03-04 23:15:54 +00:00
|
|
|
void (entity targ, entity attacker) ClientObituary;
|
|
|
|
|
|
|
|
void (entity targ, entity attacker)
|
|
|
|
Killed =
|
2002-02-15 17:57:14 +00:00
|
|
|
{
|
|
|
|
local entity oself;
|
|
|
|
|
|
|
|
oself = self;
|
|
|
|
self = targ;
|
|
|
|
|
|
|
|
if (self.health < -99)
|
|
|
|
self.health = -99; // don't let sbar look bad if a player
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
if (self.movetype == MOVETYPE_PUSH || self.movetype == MOVETYPE_NONE) {
|
|
|
|
// doors, triggers, etc
|
2002-02-15 17:57:14 +00:00
|
|
|
self.th_die ();
|
|
|
|
self = oself;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.enemy = attacker;
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// bump the monster counter
|
|
|
|
if (self.flags & FL_MONSTER) {
|
2002-02-15 17:57:14 +00:00
|
|
|
killed_monsters = killed_monsters + 1;
|
|
|
|
WriteByte (MSG_ALL, SVC_KILLEDMONSTER);
|
|
|
|
}
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
ClientObituary (self, attacker);
|
2002-02-15 17:57:14 +00:00
|
|
|
|
|
|
|
self.takedamage = DAMAGE_NO;
|
|
|
|
self.touch = SUB_Null;
|
|
|
|
self.effects = 0;
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
/* SERVER
|
|
|
|
monster_death_use ();
|
2002-02-15 17:57:14 +00:00
|
|
|
*/
|
|
|
|
self.th_die ();
|
|
|
|
|
|
|
|
self = oself;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
T_Damage
|
|
|
|
|
|
|
|
The damage is coming from inflictor, but get mad at attacker
|
|
|
|
This should be the only function that ever reduces health.
|
|
|
|
============
|
|
|
|
*/
|
2003-03-04 23:15:54 +00:00
|
|
|
void (entity targ, entity inflictor, entity attacker, float damage)
|
|
|
|
T_Damage=
|
2002-02-15 17:57:14 +00:00
|
|
|
{
|
2003-03-02 04:06:47 +00:00
|
|
|
local entity oldself;
|
|
|
|
local float save, take;
|
|
|
|
local string attackerteam, targteam;
|
|
|
|
local vector dir;
|
2002-02-15 17:57:14 +00:00
|
|
|
|
|
|
|
if (!targ.takedamage)
|
|
|
|
return;
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// used by buttons and triggers to set activator for target firing
|
2002-02-15 17:57:14 +00:00
|
|
|
damage_attacker = attacker;
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// check for quad damage powerup on the attacker
|
2002-02-15 17:57:14 +00:00
|
|
|
if (attacker.super_damage_finished > time && inflictor.classname != "door")
|
2003-03-02 04:06:47 +00:00
|
|
|
if (deathmatch == 4)
|
|
|
|
damage *= 8;
|
|
|
|
else
|
|
|
|
damage *= 4;
|
2002-02-15 17:57:14 +00:00
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// save damage based on the target's armor level
|
2002-02-15 17:57:14 +00:00
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
save = ceil (targ.armortype * damage);
|
|
|
|
if (save >= targ.armorvalue) {
|
2002-02-15 17:57:14 +00:00
|
|
|
save = targ.armorvalue;
|
|
|
|
targ.armortype = 0; // lost all armor
|
2003-03-02 04:06:47 +00:00
|
|
|
targ.items &= ~(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3);
|
2002-02-15 17:57:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
targ.armorvalue = targ.armorvalue - save;
|
2003-03-02 04:06:47 +00:00
|
|
|
take = ceil (damage - save);
|
|
|
|
|
|
|
|
// add to the damage total for clients, which will be sent as a single
|
|
|
|
// message at the end of the frame
|
|
|
|
// FIXME: remove after combining shotgun blasts?
|
|
|
|
if (targ.flags & FL_CLIENT) {
|
|
|
|
targ.dmg_take += take;
|
|
|
|
targ.dmg_save += save;
|
2002-02-15 17:57:14 +00:00
|
|
|
targ.dmg_inflictor = inflictor;
|
|
|
|
}
|
|
|
|
|
|
|
|
damage_inflictor = inflictor;
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// figure momentum add
|
|
|
|
if ((inflictor != world) && (targ.movetype == MOVETYPE_WALK)) {
|
2002-02-15 17:57:14 +00:00
|
|
|
dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5;
|
2003-03-02 04:06:47 +00:00
|
|
|
dir = normalize (dir);
|
2002-02-15 17:57:14 +00:00
|
|
|
// Set kickback for smaller weapons
|
|
|
|
//Zoid -- use normal NQ kickback
|
|
|
|
// // Read: only if it's not yourself doing the damage
|
2003-03-02 04:06:47 +00:00
|
|
|
// if ( (damage < 60) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker.netname != targ.netname))
|
2002-02-15 17:57:14 +00:00
|
|
|
// targ.velocity = targ.velocity + dir * damage * 11;
|
2003-03-02 04:06:47 +00:00
|
|
|
// else
|
|
|
|
// Otherwise, these rules apply to rockets and grenades
|
|
|
|
|
2002-02-15 17:57:14 +00:00
|
|
|
// for blast velocity
|
2003-03-02 04:06:47 +00:00
|
|
|
targ.velocity = targ.velocity + dir * damage * 8;
|
2002-02-15 17:57:14 +00:00
|
|
|
|
|
|
|
// Rocket Jump modifiers
|
2003-03-02 04:06:47 +00:00
|
|
|
if ((rj > 1) & ((attacker.classname == "player")
|
|
|
|
& (targ.classname == "player"))
|
|
|
|
& (attacker.netname == targ.netname))
|
2002-02-15 17:57:14 +00:00
|
|
|
targ.velocity = targ.velocity + dir * damage * rj;
|
|
|
|
}
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// check for godmode or invincibility
|
2002-02-15 17:57:14 +00:00
|
|
|
if (targ.flags & FL_GODMODE)
|
|
|
|
return;
|
2003-03-02 04:06:47 +00:00
|
|
|
|
|
|
|
if (targ.invincible_finished >= time) {
|
|
|
|
if (self.invincible_sound < time) {
|
2002-02-15 17:57:14 +00:00
|
|
|
sound (targ, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM);
|
|
|
|
self.invincible_sound = time + 2;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// team play damage avoidance
|
|
|
|
//ZOID 12-13-96: self.team doesn't work in QW. Use keys
|
|
|
|
attackerteam = infokey (attacker, "team");
|
|
|
|
targteam = infokey (targ, "team");
|
2002-02-15 17:57:14 +00:00
|
|
|
|
|
|
|
if ((teamplay == 1) && (targteam == attackerteam) &&
|
|
|
|
(attacker.classname == "player") && (attackerteam != "") &&
|
2003-03-02 04:06:47 +00:00
|
|
|
inflictor.classname != "door")
|
2002-02-15 17:57:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ((teamplay == 3) && (targteam == attackerteam) &&
|
|
|
|
(attacker.classname == "player") && (attackerteam != "") &&
|
2003-03-02 04:06:47 +00:00
|
|
|
(targ != attacker) && inflictor.classname != "door")
|
2002-02-15 17:57:14 +00:00
|
|
|
return;
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// do the damage
|
|
|
|
targ.health -= take;
|
|
|
|
|
|
|
|
if (targ.health <= 0) {
|
2002-02-15 17:57:14 +00:00
|
|
|
Killed (targ, attacker);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
// react to the damage
|
2002-02-15 17:57:14 +00:00
|
|
|
oldself = self;
|
|
|
|
self = targ;
|
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
/* SERVER
|
|
|
|
if ( (self.flags & FL_MONSTER) && attacker != world) {
|
2002-02-15 17:57:14 +00:00
|
|
|
// get mad unless of the same class (except for soldiers)
|
2003-03-02 04:06:47 +00:00
|
|
|
if (self != attacker && attacker != self.enemy) {
|
|
|
|
if ((self.classname != attacker.classname)
|
|
|
|
|| (self.classname == "monster_army")) {
|
2002-02-15 17:57:14 +00:00
|
|
|
if (self.enemy.classname == "player")
|
|
|
|
self.oldenemy = self.enemy;
|
|
|
|
self.enemy = attacker;
|
|
|
|
FoundTarget ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
if (self.th_pain)
|
|
|
|
self.th_pain (attacker, take);
|
|
|
|
|
|
|
|
self = oldself;
|
|
|
|
};
|
|
|
|
|
2003-03-04 23:15:54 +00:00
|
|
|
void (entity inflictor, entity attacker, float damage, entity ignore,
|
|
|
|
string dtype)
|
|
|
|
T_RadiusDamage =
|
2002-02-15 17:57:14 +00:00
|
|
|
{
|
2003-03-02 04:06:47 +00:00
|
|
|
local entity head;
|
|
|
|
local float points;
|
|
|
|
local vector org;
|
2002-02-15 17:57:14 +00:00
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
head = findradius (inflictor.origin, damage + 40);
|
2002-02-15 17:57:14 +00:00
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
while (head) {
|
|
|
|
// bprint (PRINT_HIGH, head.classname);
|
|
|
|
// bprint (PRINT_HIGH, " | ");
|
|
|
|
// bprint (PRINT_HIGH, head.netname);
|
|
|
|
// bprint (PRINT_HIGH, "\n");
|
2002-02-15 17:57:14 +00:00
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
if (head != ignore) {
|
|
|
|
if (head.takedamage) {
|
|
|
|
org = head.origin + (head.mins + head.maxs) * 0.5;
|
|
|
|
points = 0.5 * vlen (inflictor.origin - org);
|
2002-02-15 17:57:14 +00:00
|
|
|
if (points < 0)
|
|
|
|
points = 0;
|
|
|
|
points = damage - points;
|
|
|
|
|
|
|
|
if (head == attacker)
|
2003-03-02 04:06:47 +00:00
|
|
|
points *= 0.5;
|
|
|
|
if (points > 0) {
|
|
|
|
if (CanDamage (head, inflictor)) {
|
2002-02-15 17:57:14 +00:00
|
|
|
head.deathtype = dtype;
|
|
|
|
T_Damage (head, inflictor, attacker, points);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
head = head.chain;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2003-03-04 23:15:54 +00:00
|
|
|
void (entity attacker, float damage)
|
|
|
|
T_BeamDamage =
|
2002-02-15 17:57:14 +00:00
|
|
|
{
|
2003-03-02 04:06:47 +00:00
|
|
|
local entity head;
|
|
|
|
local float points;
|
2002-02-15 17:57:14 +00:00
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
head = findradius (attacker.origin, damage + 40);
|
2002-02-15 17:57:14 +00:00
|
|
|
|
2003-03-02 04:06:47 +00:00
|
|
|
while (head) {
|
|
|
|
if (head.takedamage) {
|
|
|
|
points = 0.5 * vlen (attacker.origin - head.origin);
|
2002-02-15 17:57:14 +00:00
|
|
|
if (points < 0)
|
|
|
|
points = 0;
|
|
|
|
points = damage - points;
|
|
|
|
if (head == attacker)
|
2003-03-02 04:06:47 +00:00
|
|
|
points *= 0.5;
|
|
|
|
if (points > 0) {
|
2002-02-15 17:57:14 +00:00
|
|
|
if (CanDamage (head, attacker))
|
|
|
|
T_Damage (head, attacker, attacker, points);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
head = head.chain;
|
|
|
|
}
|
|
|
|
};
|