Location Damage…

Use this source here


 

Posted by Maj.Bitch (24.93.23.*) on March 26, 2000 at 15:11:32:
In reply to: Locational Damage Tut........ posted by IoN_PuLse (207.194.145.*) on March 26, 2000 at 13:21:20

Put this new routine in g_combat.c right about T_Damage()
<C&NBSP;CODE>
//==============================================================
// Scale damage amount by location of hit on player's body..
//==============================================================
#define VectorEmpty(a)  ((a[0]==0)&&(a[1]==0)&&(a[2]==0))
#define IsIn(x,a,b)     ((x)>=(a)&&(x)<=(b))

#define LEG_DAMAGE     (height/2.0)-abs(targ->mins[2])-3
#define STOMACH_DAMAGE (height/1.6)-abs(targ->mins[2])
#define CHEST_DAMAGE   (height/1.4)-abs(targ->mins[2])

//==============================================================
float location_scaling(edict_t *targ, vec3_t point, float damage, int mod) {
float z_rel, height;

  if (!(targ->flags&FL_GODMODE))
    if (!VectorEmpty(point))
      if (IsIn(mod, MOD_BLASTER, MOD_RAILGUN)) {
        height = abs(targ->mins[2])+targ->maxs[2];
        z_rel = point[2]-targ->s.origin[2];
        if (z_rel < LEG_DAMAGE)
          return 0.35;  // Scale down by 2/3
        else
        if (z_rel < STOMACH_DAMAGE)
          return 0.66;  // Scale down by 1/3
        else
        if (z_rel < CHEST_DAMAGE)
          return 1.20;  // Scale up by 1/5
        else
          return 10.0;} // Scale up by 10X

  return 1.0; // keep damage the same..
}
</C&NBSP;CODE>


Now in your T_Damage function add this line after the damage has been calculated and right before the meansOfDeath assignment..
<C&NBSP;CODE>

  // Scale damage by hit location (leg,stomach,chest,head)..
  damage *= location_scaling(targ, point, damage, mod);

  meansOfDeath=mod;
</C&NBSP;CODE>

That's it.. Simple but effective...

Maj.Bitch