2006-01-01 00:37:52 +00:00
|
|
|
|
|
|
|
void() T_MissileTouch;
|
|
|
|
void() info_player_start;
|
|
|
|
void(entity targ, entity attacker) ClientObituary;
|
|
|
|
void(entity inflictor, entity attacker, float damage, entity ignore, string dtype) T_RadiusDamage;
|
2009-11-05 03:40:39 +00:00
|
|
|
float (float int) getperk;
|
2006-01-01 00:37:52 +00:00
|
|
|
void() monster_death_use;
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
CanDamage
|
|
|
|
|
|
|
|
Returns true if the inflictor can directly damage the target. Used for
|
|
|
|
explosions and melee attacks.
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
float(entity targ, entity inflictor) CanDamage =
|
|
|
|
{
|
|
|
|
// 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);
|
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
traceline(inflictor.origin, targ.origin, TRUE, self);
|
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
traceline(inflictor.origin, targ.origin + '15 15 0', TRUE, self);
|
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
traceline(inflictor.origin, targ.origin + '-15 -15 0', TRUE, self);
|
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
traceline(inflictor.origin, targ.origin + '-15 15 0', TRUE, self);
|
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
traceline(inflictor.origin, targ.origin + '15 -15 0', TRUE, self);
|
|
|
|
if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Killed
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void(entity targ, entity attacker) Killed =
|
|
|
|
{
|
|
|
|
local entity oself;
|
|
|
|
|
|
|
|
oself = self;
|
|
|
|
self = targ;
|
|
|
|
|
|
|
|
if (self.health < -99)
|
|
|
|
self.health = -99; // don't let sbar look bad if a player
|
|
|
|
|
|
|
|
if (self.movetype == MOVETYPE_PUSH || self.movetype == MOVETYPE_NONE)
|
|
|
|
{ // doors, triggers, etc
|
|
|
|
self.th_die ();
|
|
|
|
self = oself;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.enemy = attacker;
|
|
|
|
|
2006-01-02 00:14:21 +00:00
|
|
|
targ.grab = 0;
|
2006-01-09 02:52:18 +00:00
|
|
|
targ.equipment_slot = 0; //turn off stealth-boys, climbing gear, etc
|
2006-01-02 00:14:21 +00:00
|
|
|
|
2006-01-01 00:37:52 +00:00
|
|
|
// bump the monster counter
|
|
|
|
if (self.flags & FL_MONSTER)
|
|
|
|
{
|
|
|
|
killed_monsters = killed_monsters + 1;
|
|
|
|
WriteByte (MSG_ALL, SVC_KILLEDMONSTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
ClientObituary(self, attacker);
|
|
|
|
|
2006-01-02 00:14:21 +00:00
|
|
|
if (self.classname == "player") //so dead players can spectate
|
2006-01-06 17:38:51 +00:00
|
|
|
{
|
2006-01-02 00:14:21 +00:00
|
|
|
self.ghost = 1;
|
2006-01-06 17:38:51 +00:00
|
|
|
self.flags = self.flags | FL_FINDABLE_NONSOLID; //so tracelines can find them
|
|
|
|
}
|
2006-01-02 00:14:21 +00:00
|
|
|
|
2006-01-01 00:37:52 +00:00
|
|
|
self.takedamage = DAMAGE_NO;
|
|
|
|
self.touch = SUB_Null;
|
|
|
|
self.effects = 0;
|
|
|
|
|
|
|
|
monster_death_use();
|
2006-01-06 17:38:51 +00:00
|
|
|
|
2006-01-01 00:37:52 +00:00
|
|
|
self.th_die ();
|
|
|
|
|
|
|
|
self = oself;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-21 02:22:41 +00:00
|
|
|
void(entity targ, entity attacker) ArmorNoise =
|
|
|
|
{
|
|
|
|
local float r;
|
|
|
|
|
|
|
|
if (targ.classname != "player" && targ.classname != "monster")
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (attacker.classname != "player" && attacker.classname != "monster")
|
|
|
|
return;
|
|
|
|
|
|
|
|
r = random();
|
|
|
|
|
|
|
|
if (r <= 0.33)
|
|
|
|
sound (targ, CHAN_WEAPON, "contact/armor1.wav", 1, ATTN_NORM);
|
|
|
|
else if (r <= 0.67)
|
|
|
|
sound (targ, CHAN_WEAPON, "contact/armor2.wav", 1, ATTN_NORM);
|
|
|
|
else
|
|
|
|
sound (targ, CHAN_WEAPON, "contact/armor3.wav", 1, ATTN_NORM);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-01-01 00:37:52 +00:00
|
|
|
/*
|
|
|
|
============
|
|
|
|
T_Damage
|
|
|
|
|
|
|
|
The damage is coming from inflictor, but get mad at attacker
|
|
|
|
This should be the only function that ever reduces health.
|
|
|
|
============
|
|
|
|
*/
|
2006-01-01 21:33:21 +00:00
|
|
|
|
|
|
|
void(entity targ, entity inflictor, entity attacker, float damage) T_Damage =
|
2006-01-01 00:37:52 +00:00
|
|
|
{
|
|
|
|
local entity oldself;
|
2009-11-17 14:22:17 +00:00
|
|
|
local float save, dm, radpenalty;
|
2006-01-01 21:33:21 +00:00
|
|
|
local float take, severity, helm;
|
2006-01-01 00:37:52 +00:00
|
|
|
local string attackerteam, targteam;
|
2009-11-11 07:31:51 +00:00
|
|
|
local string info1, info2;
|
2006-01-01 00:37:52 +00:00
|
|
|
|
|
|
|
if (!targ.takedamage)
|
|
|
|
return;
|
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
damage = floor(damage);
|
|
|
|
targ.health = floor(targ.health);
|
2009-11-07 03:43:48 +00:00
|
|
|
|
2009-11-21 02:22:41 +00:00
|
|
|
|
2009-11-23 05:04:45 +00:00
|
|
|
if (challenge_rating >= 20 && attacker.classname == "monster")
|
|
|
|
damage = damage * 1.30;
|
|
|
|
else if (challenge_rating <= 12 && attacker.classname == "monster")
|
|
|
|
damage = damage * 1.20;
|
|
|
|
else if (challenge_rating <= 9 && attacker.classname == "monster")
|
|
|
|
damage = damage * 1.10;
|
2009-11-21 02:22:41 +00:00
|
|
|
|
2009-11-17 14:22:17 +00:00
|
|
|
if (targ.radiation > 0)
|
|
|
|
{
|
2009-11-19 17:19:05 +00:00
|
|
|
radpenalty = 1 + (targ.radiation/200);
|
|
|
|
damage = damage * radpenalty;
|
|
|
|
}
|
2009-11-17 14:22:17 +00:00
|
|
|
|
2009-11-19 17:19:05 +00:00
|
|
|
if (attacker.radiation > 0)
|
|
|
|
{
|
|
|
|
radpenalty = 1 - (targ.radiation/200);
|
2009-11-17 14:22:17 +00:00
|
|
|
damage = damage * radpenalty;
|
|
|
|
}
|
2009-11-05 03:40:39 +00:00
|
|
|
|
2009-11-19 17:19:05 +00:00
|
|
|
if (targ.classname == "player" && attacker.classname == "monster")
|
|
|
|
targ.superenemy = attacker;
|
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
//getting hurt is slightly painful to the score, play cautiously!
|
|
|
|
if (attacker.classname == "monster" && targ.classname == "player")
|
2009-11-07 03:43:48 +00:00
|
|
|
targ.score = targ.score - 1;
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
//flanking monsters awards points
|
|
|
|
if (attacker.classname == "player" && targ.classname == "monster" && targ.enemy != attacker)
|
2009-11-07 03:43:48 +00:00
|
|
|
attacker.score = attacker.score + 1;
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
//aimed shots awards points
|
|
|
|
if (attacker.classname == "player" && targ.classname == "monster" && attacker.recoil <= 5)
|
|
|
|
attacker.score = attacker.score + 1;
|
|
|
|
|
2009-11-23 05:04:45 +00:00
|
|
|
//attacking a monster from behind awards points
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
local vector vec;
|
|
|
|
local float dot;
|
|
|
|
|
|
|
|
if (attacker.classname == "player" && targ.classname == "monster")
|
|
|
|
{
|
|
|
|
makevectors (targ.angles);
|
|
|
|
vec = normalize (attacker.origin - targ.origin);
|
|
|
|
dot = (vec * v_forward);
|
|
|
|
|
2009-11-23 05:04:45 +00:00
|
|
|
if (dot < 0.3)
|
2009-11-07 03:43:48 +00:00
|
|
|
attacker.score = attacker.score + 1;
|
2009-11-23 05:04:45 +00:00
|
|
|
|
|
|
|
if (attacker.perk1 == 15 || attacker.perk2 == 15)
|
|
|
|
{
|
|
|
|
bprint(2, "SNEAK ATTACK\n");
|
|
|
|
damage = damage * (1 + (attacker.skill_sneak/15));
|
|
|
|
}
|
2009-11-05 03:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//attacking a team-mate is a HUGE penalty
|
|
|
|
if (attacker.classname == "player" && targ.classname == "player")
|
|
|
|
{
|
2009-11-23 05:04:45 +00:00
|
|
|
attacker.score = attacker.score - 5;
|
2009-11-05 03:40:39 +00:00
|
|
|
sprint(attacker, 2, "you just shot a teammate! be careful!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
//attacking a hostage is a HUGE penalty
|
|
|
|
if (attacker.classname == "player" && targ.classname == "hostage")
|
|
|
|
{
|
2009-11-23 05:04:45 +00:00
|
|
|
attacker.score = attacker.score - 5;
|
2009-11-05 03:40:39 +00:00
|
|
|
sprint(attacker, 2, "you just shot a hostage! be careful!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
//using cover awards points
|
|
|
|
if (targ.classname == "monster" && attacker.classname == "player" && attacker.rage == 777)
|
|
|
|
attacker.score = attacker.score + 1;
|
|
|
|
|
|
|
|
//dodge chance
|
|
|
|
|
|
|
|
if (targ.position == 0 && random()<0.05)
|
|
|
|
{
|
|
|
|
sound (targ, CHAN_BODY, "effects/miss.wav", 1, ATTN_NORM);
|
|
|
|
return;
|
|
|
|
}
|
2009-11-23 05:04:45 +00:00
|
|
|
else if (targ.position == 1 && random()<0.10)
|
2009-11-05 03:40:39 +00:00
|
|
|
{
|
|
|
|
sound (targ, CHAN_BODY, "effects/miss.wav", 1, ATTN_NORM);
|
|
|
|
return;
|
|
|
|
}
|
2009-11-23 05:04:45 +00:00
|
|
|
else if (targ.position == 2 && random()<0.20)
|
2009-11-05 03:40:39 +00:00
|
|
|
{
|
|
|
|
sound (targ, CHAN_BODY, "effects/miss.wav", 1, ATTN_NORM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-23 05:04:45 +00:00
|
|
|
//stay low: if taking cover, 20% miss chance (others get 10% bonus)
|
2009-11-05 03:40:39 +00:00
|
|
|
if (targ.rage == 777)
|
|
|
|
{
|
2009-11-23 05:04:45 +00:00
|
|
|
if (targ.perk1 == 4 || targ.perk2 == 4)
|
2009-11-05 03:40:39 +00:00
|
|
|
{
|
|
|
|
if (random()<0.20)
|
|
|
|
{
|
|
|
|
sound (targ, CHAN_BODY, "effects/miss.wav", 1, ATTN_NORM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-23 05:04:45 +00:00
|
|
|
if (random()<0.10)
|
2009-11-05 03:40:39 +00:00
|
|
|
{
|
|
|
|
sound (targ, CHAN_BODY, "effects/miss.wav", 1, ATTN_NORM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//master blaster: the more you burst, the higher the damage bonus
|
2009-11-23 05:04:45 +00:00
|
|
|
if (attacker.perk1 == 14 || attacker.perk2 == 14)
|
2009-11-05 03:40:39 +00:00
|
|
|
{
|
2009-11-23 05:04:45 +00:00
|
|
|
if (attacker.recoil > 5)
|
2009-11-05 03:40:39 +00:00
|
|
|
{
|
2009-11-23 05:04:45 +00:00
|
|
|
damage = damage * (1 + (attacker.recoil * 0.03));
|
2009-11-05 03:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-13 05:05:32 +00:00
|
|
|
|
2009-11-23 05:04:45 +00:00
|
|
|
//stay low
|
2009-11-13 05:05:32 +00:00
|
|
|
if (targ.perk1 == 4 || targ.perk2 == 4)
|
|
|
|
{
|
|
|
|
if (targ.position == 2)
|
2009-11-23 05:04:45 +00:00
|
|
|
damage = damage * 0.75;
|
2009-11-13 05:05:32 +00:00
|
|
|
}
|
|
|
|
|
2009-11-15 02:36:24 +00:00
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
//sneak attack: if you attack a creature who isn't fighting you, bonus damage
|
2009-11-23 05:04:45 +00:00
|
|
|
if (attacker.skill_sneak > 0 && attacker.sneak > 0)
|
2009-11-05 03:40:39 +00:00
|
|
|
{
|
|
|
|
if (targ.enemy != attacker)
|
2009-11-23 05:04:45 +00:00
|
|
|
{
|
|
|
|
bprint(2, "SNEAK ATTACK\n");
|
|
|
|
damage = damage * (1 + (attacker.skill_sneak/15));
|
|
|
|
}
|
2009-11-05 03:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-01 00:37:52 +00:00
|
|
|
// used by buttons and triggers to set activator for target firing
|
|
|
|
damage_attacker = attacker;
|
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
if (attacker.classname == "monster")
|
|
|
|
{
|
2009-11-21 02:22:41 +00:00
|
|
|
if (random()*100>= 95)
|
2009-11-05 03:40:39 +00:00
|
|
|
attacker.critical = 3;
|
|
|
|
else
|
|
|
|
attacker.critical = 0;
|
|
|
|
}
|
|
|
|
|
2009-11-23 05:04:45 +00:00
|
|
|
if (attacker.critical == 3 && targ.classname == "car")//attacker scored a headshot/critical
|
2009-11-05 03:40:39 +00:00
|
|
|
{
|
|
|
|
if (attacker.critical == 3)
|
|
|
|
{
|
|
|
|
|
2009-11-21 02:22:41 +00:00
|
|
|
damage = (damage * 2);
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
if (targ.classname == "monster")
|
2009-11-07 03:43:48 +00:00
|
|
|
attacker.score = attacker.score + 1;
|
2009-11-05 03:40:39 +00:00
|
|
|
|
2009-11-23 05:04:45 +00:00
|
|
|
sound (targ, CHAN_VOICE, "player/headshot.wav", 1, ATTN_NORM);
|
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
makevectors (targ.v_angle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-21 02:22:41 +00:00
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
// 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 = targ.dmg_take + take;
|
|
|
|
targ.dmg_save = targ.dmg_save + save;
|
|
|
|
targ.dmg_inflictor = inflictor;
|
|
|
|
}
|
|
|
|
|
|
|
|
damage_inflictor = inflictor;
|
|
|
|
|
|
|
|
/*
|
|
|
|
// figure momentum add
|
|
|
|
if ( (inflictor != world) && (targ.movetype == MOVETYPE_WALK) )
|
|
|
|
{
|
|
|
|
dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5;
|
|
|
|
dir = normalize(dir);
|
|
|
|
// Set kickback for smaller weapons
|
|
|
|
//Zoid -- use normal NQ kickback
|
|
|
|
// // Read: only if it's not yourself doing the damage
|
|
|
|
// if ( (damage < 60) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker.netname != targ.netname))
|
|
|
|
// targ.velocity = targ.velocity + dir * damage * 11;
|
|
|
|
// else
|
|
|
|
// Otherwise, these rules apply to rockets and grenades
|
|
|
|
// for blast velocity
|
|
|
|
targ.velocity = targ.velocity + dir * damage * 8;
|
|
|
|
|
|
|
|
// Rocket Jump modifiers
|
|
|
|
if ( (rj > 1) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker.netname == targ.netname))
|
|
|
|
targ.velocity = targ.velocity + dir * damage * rj;
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check for godmode or invincibility
|
|
|
|
if (targ.flags & FL_GODMODE)
|
|
|
|
return;
|
|
|
|
if (targ.invincible_finished >= time)
|
|
|
|
{
|
|
|
|
if (self.invincible_sound < time)
|
|
|
|
{
|
|
|
|
sound (targ, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM);
|
|
|
|
self.invincible_sound = time + 2;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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");
|
|
|
|
|
|
|
|
if ((teamplay == 1) && (targteam == attackerteam) &&
|
|
|
|
(attacker.classname == "player") && (attackerteam != "") &&
|
|
|
|
inflictor.classname !="door")
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((teamplay == 3) && (targteam == attackerteam) &&
|
|
|
|
(attacker.classname == "player") && (attackerteam != "") &&
|
|
|
|
(targ != attacker)&& inflictor.classname !="door")
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
take = damage;
|
|
|
|
|
|
|
|
// do the damage
|
|
|
|
//different sorts of armour simply subtract different amounts
|
|
|
|
//this makes armor like the force armor good against many small rounds
|
|
|
|
//(SMG, shotguns, swords, etc) but useless against big damage (grenades)
|
|
|
|
//power armor, which has the best of both worlds, is also the heaviest :p
|
|
|
|
|
|
|
|
//fix: soldiers inherent armor bonus applies to armor absorb
|
|
|
|
//fix: psycho drug gives similar benefits to a soldiers bonus
|
|
|
|
|
|
|
|
if (self.rage == IID_CHEM_PSYCHO)
|
|
|
|
take -= 3;
|
|
|
|
|
|
|
|
switch(ToIID(targ.islot3))
|
|
|
|
{
|
|
|
|
case IID_ARM_DESERT:
|
2009-11-17 14:22:17 +00:00
|
|
|
take -= 1;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
|
|
|
case IID_ARM_LEATHER:
|
2009-11-17 14:22:17 +00:00
|
|
|
take -= 2;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
2009-11-09 04:48:58 +00:00
|
|
|
case IID_ARM_VANDAL:
|
2009-11-17 14:22:17 +00:00
|
|
|
take -= 3;
|
2009-11-09 04:48:58 +00:00
|
|
|
break;
|
2009-11-05 03:40:39 +00:00
|
|
|
case IID_ARM_METAL:
|
2009-11-15 02:36:24 +00:00
|
|
|
take -= 1;
|
2009-11-09 04:48:58 +00:00
|
|
|
break;
|
|
|
|
case IID_ARM_TESLA:
|
2009-11-17 14:22:17 +00:00
|
|
|
take -= 5;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
|
|
|
case IID_ARM_COMBAT:
|
2009-11-09 04:48:58 +00:00
|
|
|
take -= 6;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
2009-11-09 04:48:58 +00:00
|
|
|
case IID_ARM_SEVA:
|
2009-11-17 14:22:17 +00:00
|
|
|
take -= 5;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
|
|
|
case IID_ARM_FORCE:
|
2009-11-15 02:36:24 +00:00
|
|
|
take -= 9;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
|
|
|
case IID_ARM_LPOWER:
|
2009-11-17 14:22:17 +00:00
|
|
|
take -= 8;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(ToIID(targ.islot3))
|
|
|
|
{
|
2009-11-09 04:48:58 +00:00
|
|
|
case IID_ARM_LEATHER:
|
2009-11-05 03:40:39 +00:00
|
|
|
take = take * 0.80;
|
|
|
|
break;
|
2009-11-09 04:48:58 +00:00
|
|
|
case IID_ARM_VANDAL:
|
2009-11-17 14:22:17 +00:00
|
|
|
take = take * 0.65;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
2009-11-09 04:48:58 +00:00
|
|
|
case IID_ARM_METAL:
|
2009-11-15 02:36:24 +00:00
|
|
|
take = take * 0.40;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
2009-11-09 04:48:58 +00:00
|
|
|
case IID_ARM_TESLA:
|
2009-11-15 02:36:24 +00:00
|
|
|
take = take * 0.60;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
|
|
|
case IID_ARM_COMBAT:
|
|
|
|
take = take * 0.60;
|
|
|
|
break;
|
2009-11-09 04:48:58 +00:00
|
|
|
case IID_ARM_SEVA:
|
2009-11-15 02:36:24 +00:00
|
|
|
take = take * 0.60;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
|
|
|
case IID_ARM_FORCE:
|
|
|
|
take = take * 0.90;
|
|
|
|
break;
|
|
|
|
case IID_ARM_LPOWER:
|
2009-11-15 02:36:24 +00:00
|
|
|
take = take * 0.40;
|
2009-11-05 03:40:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (targ.classname == "player" && targ.zoom > 0)
|
|
|
|
{
|
|
|
|
targ.maxspeed = targ.maxspeed * 0.33;
|
2009-11-23 05:04:45 +00:00
|
|
|
stuffcmd(targ, "v_idlescale 10\n");
|
2009-11-05 03:40:39 +00:00
|
|
|
}
|
|
|
|
else if (take > 20 && targ.classname == "player")
|
|
|
|
{
|
|
|
|
targ.maxspeed = targ.maxspeed * 0.25;
|
|
|
|
stuffcmd(targ, "v_cshift 100 0 0 100\n");
|
|
|
|
stuffcmd(targ, "v_idlescale 30\n");
|
|
|
|
}
|
|
|
|
else if (take > 0)
|
|
|
|
{
|
|
|
|
targ.maxspeed = targ.maxspeed * 0.50;
|
|
|
|
stuffcmd(targ, "v_cshift 100 0 0 50\n");
|
|
|
|
}
|
|
|
|
|
2009-11-23 05:04:45 +00:00
|
|
|
|
|
|
|
ArmorNoise(targ, attacker);
|
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
if (take <= 0)
|
|
|
|
{
|
|
|
|
take = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-12 20:36:42 +00:00
|
|
|
if (targ.hold <= 0)
|
|
|
|
targ.health = targ.health - take;
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
if (targ.classname == "monster" && targ.enemy.classname != "player" && attacker.classname == "player")
|
|
|
|
{
|
|
|
|
targ.enemy = attacker;
|
|
|
|
targ.think = HuntTarget;
|
|
|
|
targ.nextthink = time + 0.1;
|
|
|
|
}
|
|
|
|
|
|
|
|
local string lm;
|
|
|
|
|
|
|
|
if (targ.health <= 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
//vanquishing a monster earns points for all players
|
|
|
|
if (attacker.classname == "player" && targ.classname == "monster")
|
|
|
|
{
|
|
|
|
local entity te;
|
|
|
|
te = findradius(attacker.origin, 1000);
|
|
|
|
while (te)
|
|
|
|
{
|
|
|
|
if (te.classname == "player")
|
2009-11-07 03:43:48 +00:00
|
|
|
te.score = te.score + 2;
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
te = te.chain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Killed (targ, attacker);
|
2009-11-19 17:19:05 +00:00
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// react to the damage
|
|
|
|
oldself = self;
|
|
|
|
self = targ;
|
|
|
|
|
|
|
|
//SERVER
|
2006-01-01 00:37:52 +00:00
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
if ( (self.flags & FL_MONSTER) && attacker != world)
|
|
|
|
{
|
|
|
|
// get mad unless of the same class (except for soldiers)
|
|
|
|
if (self != attacker && attacker != self.enemy)
|
|
|
|
{
|
|
|
|
if ((self.classname != attacker.classname))
|
|
|
|
{
|
|
|
|
if (self.enemy.classname == "player")
|
|
|
|
self.oldenemy = self.enemy;
|
|
|
|
self.enemy = attacker;
|
|
|
|
FoundTarget ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-01 00:37:52 +00:00
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
if (self.th_pain)
|
|
|
|
{
|
|
|
|
self.th_pain (attacker, take);
|
|
|
|
}
|
|
|
|
|
|
|
|
self = oldself;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-01-01 00:37:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
T_RadiusDamage
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void(entity inflictor, entity attacker, float damage, entity ignore, string dtype) T_RadiusDamage =
|
|
|
|
{
|
2009-11-05 03:40:39 +00:00
|
|
|
local float points, srange, brange;
|
2006-01-01 00:37:52 +00:00
|
|
|
local entity head;
|
|
|
|
local vector org;
|
|
|
|
|
|
|
|
head = findradius(inflictor.origin, damage+40);
|
|
|
|
|
|
|
|
while (head)
|
|
|
|
{
|
|
|
|
//bprint (PRINT_HIGH, head.classname);
|
|
|
|
//bprint (PRINT_HIGH, " | ");
|
|
|
|
//bprint (PRINT_HIGH, head.netname);
|
|
|
|
//bprint (PRINT_HIGH, "\n");
|
|
|
|
|
|
|
|
if (head != ignore)
|
|
|
|
{
|
|
|
|
if (head.takedamage)
|
|
|
|
{
|
|
|
|
org = head.origin + (head.mins + head.maxs)*0.5;
|
2009-11-05 03:40:39 +00:00
|
|
|
points = vlen(inflictor.origin - org);
|
|
|
|
points = points + damage*0.50;
|
2006-01-01 00:37:52 +00:00
|
|
|
if (points < 0)
|
|
|
|
points = 0;
|
|
|
|
points = damage - points;
|
|
|
|
|
|
|
|
if (points > 0)
|
|
|
|
{
|
|
|
|
if (CanDamage (head, inflictor))
|
|
|
|
{
|
|
|
|
head.deathtype = dtype;
|
|
|
|
T_Damage (head, inflictor, attacker, points);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
head = head.chain;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-11-05 03:40:39 +00:00
|
|
|
|
|
|
|
void (entity inflictor, entity attacker, float damage, entity ignore, float xrange) T_RadiusDamage2 =
|
|
|
|
{
|
|
|
|
local float points;
|
|
|
|
local entity head;
|
|
|
|
local vector org;
|
|
|
|
local float srange;
|
|
|
|
local float sub;
|
|
|
|
local float damaget;
|
|
|
|
|
|
|
|
head = findradius (inflictor.origin, xrange);
|
|
|
|
while (head)
|
|
|
|
{
|
|
|
|
if (head != ignore)
|
|
|
|
{
|
|
|
|
if (head.takedamage)
|
|
|
|
{
|
|
|
|
org = head.origin;
|
|
|
|
srange = vlen ((inflictor.origin - org));
|
|
|
|
points = (xrange / srange);
|
|
|
|
sub = (1 / points);
|
|
|
|
damaget = (damage - (damage * sub));
|
|
|
|
if (damaget > 0)
|
|
|
|
if (CanDamage (head, inflictor))
|
|
|
|
T_Damage (head, inflictor, attacker, damaget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
head = head.chain;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-01-01 00:37:52 +00:00
|
|
|
/*
|
|
|
|
============
|
|
|
|
T_BeamDamage
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void(entity attacker, float damage) T_BeamDamage =
|
|
|
|
{
|
|
|
|
local float points;
|
|
|
|
local entity head;
|
|
|
|
|
|
|
|
head = findradius(attacker.origin, damage+40);
|
|
|
|
|
|
|
|
while (head)
|
|
|
|
{
|
|
|
|
if (head.takedamage)
|
|
|
|
{
|
|
|
|
points = 0.5*vlen (attacker.origin - head.origin);
|
|
|
|
if (points < 0)
|
|
|
|
points = 0;
|
|
|
|
points = damage - points;
|
|
|
|
if (head == attacker)
|
|
|
|
points = points * 0.5;
|
|
|
|
if (points > 0)
|
|
|
|
{
|
|
|
|
if (CanDamage (head, attacker))
|
|
|
|
T_Damage (head, attacker, attacker, points);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
head = head.chain;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|