Thread: Reducing damage
View Single Post
Re: Reducing damage
Old
  (#4)
voogru
Guest
 
Status:
Posts: n/a
Default Re: Reducing damage - 17-08-2004

Hook the Damage message.

It would look something like this:

Code:
void NSAMessage_Damage(void *buf, bool &bSend)
{
static int CurrentArg = 0;
if(buf == NULL)
{
CurrentArg = 0;
return;
}
float flDamage = 0;
CPlayer *pAttacker = NULL;
CPlayer *pVictim = NULL;
switch(CurrentArg)
{
case 1:
flDamage = (float)M_INT(buf);
if(UTIL_IsPlayerValid(CurrentMessageEdict) 
&& CurrentMessageEdict->v.dmg_inflictor != NULL
&& UTIL_IsPlayerValid(CurrentMessageEdict->v.dmg_inflictor->v.owner)
&& flDamage > 0)
{
pAttacker = GetPlayerPointer(CurrentMessageEdict->v.dmg_inflictor->v.owner);
pVictim = GetPlayerPointer(CurrentMessageEdict);
 
if(pAttacker == NULL || pVictim == NULL)
{
	CurrentArg++;
	break;
}
pVictim->pev->health += flDamage * 0.5;
M_INT(buf) = (int)flDamage * 0.5;
}
CurrentArg++;
break;
default:
CurrentArg++;
break;
}
}
That would make everyone take about half damage. The problem with this however is anything that does more damage than the player has health for wont work, since this is done after the fact. As far as I know theres no real way to limit the damage before its done.
  
Reply With Quote