|
Quake Style - Quake 3 Tutorials Game Enhancements - Locational Damage Explains how to detect damage in different locations. |
// added to facilitate damage algorithim float z_ratio; float z_rel; int height; float targ_maxs2;
Team_CheckHurtCarrier(targ, attacker);
if (targ->client) {
// set the last client who damaged the target
targ->client->lasthurt_client = attacker->s.number;
targ->client->lasthurt_mod = mod;
}
if (targ->client && attacker->client && targ->health > 0) //had to add attacker because it was crashing
{
targ_maxs2 = targ->r.maxs[2];
//somehow we have to handle crouching, but not now
height = abs(targ->r.mins[2]) + targ_maxs2;
//G_Printf("height is %d\n", height);
//project the z component of point onto the z component of the model's origin
// this results in the z component from the origin at 0
z_rel = point[2] - targ->r.currentOrigin[2] + abs(targ->r.mins[2]);
z_ratio = z_rel / height;
if (z_ratio > 0.85)
{
G_Printf("%s hit %s with a headshot\n", attacker->client->pers.netname, targ->client->pers.netname);
}
else if (z_ratio > 0.73)
{
G_Printf("%s hit %s in the torso\n", attacker->client->pers.netname, targ->client->pers.netname);
}
else if (z_ratio > 0.50)
{
G_Printf("%s hit %s in the stomach\n", attacker->client->pers.netname, targ->client->pers.netname);
}
else
{
G_Printf("%s hit %s in the legs\n", attacker->client->pers.netname, targ->client->pers.netname);
}
}
take *= 1.8;