Code: Select all
if(GetAttribute(HEALTHATTRIBUTE) < lasthp)
{
lastdamage = lasthp - GetAttribute(HEALTHATTRIBUTE);
Check if the health attribute has decreased since last check and if so, calculate how much damage has been taken. Store this value to a variable called 'lastdamage'.
Code: Select all
if(LeftCopy(GetLastBoneHit(),4) = "head")
{
ModifyAttribute(HEALTHATTRIBUTE,-2*lastdamage);
AddExplosion("headshot",GetLastBoneHit(),0,0,0);
splatter();
headshot = true;
}
If the first four letters of the bone that was hit last are 'head' (for example, bones called 'head_mouth', 'head_hat') take triple damage (the original damage + 2x the original damage). Add the blood effect of a headshot and call the 'splatter()' function. This function is another function in the script and it shoots blood to the wall behind the enemy. Additionally, set 'headshot = true' for various reasons.
Code: Select all
else
{
if(random(0,100) < 25)
{
splatter();
}
headshot = false;
}
Other hits than headshots have a 25% chance of leaving a bloodstain on the wall (aka. calling the 'splatter()' function).
Code: Select all
if(LeftCopy(GetLastBoneHit(),3) = "arm")
{
ModifyAttribute(HEALTHATTRIBUTE,lastdamage/2);
}
if(LeftCopy(GetLastBoneHit(),4) = "feet")
{
ModifyAttribute(HEALTHATTRIBUTE,lastdamage/2);
}
Hits to arms and feet deal only half the damage.
Code: Select all
AddExplosion("bullethit",GetLastBoneHit(),0,0,0);
lasthp = GetAttribute(HEALTHATTRIBUTE);
Always add a blood effect and update the 'lasthp' variable so we can calculate 'lastdamage' next time the pawn is hit.
Code: Select all
if(GetAttribute(HEALTHATTRIBUTE) < 0)
{
self.think = "die";
return 0;
}
return true;
}
If health is less than zero the pawn dies. Also, 'if(GetAttribute(HEALTHATTRIBUTE) < lasthp)' ends here; So if the pawn is damaged, the function returns true.
Code: Select all
if(GetAttribute(HEALTHATTRIBUTE) < 0)
{
self.think = "die";
return 0;
}
return false;
} ]
Check if health is less than zero even if the health attribute hasn't decreased. Otherwise, if no damage has been taken and health > zero, the function returns false.
So basically what does this mean? You can check if the pawn has been damaged with the line:
or, even simpler:
And it
automatically adds the blood effects, makes the pawn die and calculates the extra damages or damage reductions.
Of course, without modifications it only works with my models and the original script. To make it work with perfectai you have to add the variables I've used (lastdamage, lasthp) and the custom function called splatter() that can be found in my scripts.
Pain is only psychological.