Introduction
In most games these days, they have locational damage because it seems "realistic" to them, taking more damage from the head than other parts of the body. WELL LET'S PUT THAT IN QUAKE NO?
The real meat
Open WEAPONS.QC.
Replace the TraceAttack function with this:
// Now with locational damage
void(float damage, vector dir) TraceAttack =
{
local vector vel, org;
local float f_damage;
vel = normalize(dir + v_up*crandom() + v_right*crandom());
vel = vel + 2*trace_plane_normal;
vel = vel * 200;
org = trace_endpos - dir*4;
if (trace_ent.takedamage)
{
if (trace_fraction >= 1)
return;
if (trace_endpos_z > (trace_ent.origin_z + 18))
{
f_damage = damage * 2; // This is a head shot
}
else if (trace_endpos_z < trace_ent.origin_z)
{
f_damage = damage * 0.5; // This is a leg shot
}
else
{
f_damage = damage; // Anywhere else (torso)
}
SpawnBlood (org, vel*0.2, f_damage * 0.3);
AddMultiDamage (trace_ent, f_damage);
}
else
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_GUNSHOT);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
}
};
The final step
There is no final step. YOU ARE DONE! :D
Now, compile your code, run your mod, and kick some arse! Aim for the head if you can find it.
(This code is adopted from Miles Invictus' old locational damage code with permission, and heavily simplified by yours truly, to allow easy addition into mods. Tutorial written in October 2003.)
This looks cool. I'm thinking of coding something similar for DooM if I can.
This would only work against humans and other creatures with the same proportions, would it not?