Author Topic: Detecting a Headshot  (Read 804 times)

Im just wondering if there is a nice clean way to detect headshots from players or bots/zombies?

Code: [Select]
AddDamageType("HeadshotNormal",'<bitmap:add-ons/Weapon_Gun/CI_gun> %1','%2 <bitmap:add-ons/Weapon_Gun/CI_gun> %1',0.2,1);
AddDamageType("HeadshotSpecial",'headshotted %1','%2 headshotted %1',0.2,1);
datablock ProjectileData(headshotProjectile : gunProjectile)
{
directDamage = 30;
directDamageType = $DamageType::HeadshotNormal;
radiusDamageType = $DamageType::HeadshotNormal;
uiName = "Headshot Bullet";
};
function headshotProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getType() & $TypeMasks::PlayerObjectType && minigameCanDamage(%obj,%col) && isObject(%obj.client) && isObject(%col.client))
{
for(%i=0;%i<63;%i++)
{
%color = getColorIDTable(%i);
if(%color != %col.client.hatColor && %color != %col.client.headColor)
{
%oldcurrentcolor = %obj.client.currentColor;
%obj.client.currentColor = %i;
break;
}
}
%oldhatcolor = %col.client.hatColor;
%oldheadcolor = %col.client.hatColor;
bluePaintProjectile.onCollision(%this,%obj,%col,%fade,%pos,%normal);
        cancel(%col.tempColorSchedule);
if(%oldhatcolor != %col.client.hatColor || %oldheadcolor != %col.client.headColor)
{
%obj.client.currentColor = %oldcurrentcolor;
%col.setNodeColor("Head",%oldheadcolor);
%col.setNodeColor("Hat",%oldhatcolor);
%col.damage(%obj,%pos,%col.getDatablock().maxHealth,$DamageType::HeadshotSpecial);
}
else
{
%col.client.applyBodyColors();
%this.damage(%obj,%col,%fade,%pos,%normal);
}
}
}
I'm not positive if it'll work, give it a try.
« Last Edit: October 14, 2009, 05:48:08 AM by Destiny/Zack0Wack0 »

Code: [Select]
cancel(%col.tempColorSchedule);
Where is %col.tempColorSchedule defined?

Where is %col.tempColorSchedule defined?
When you're painted by someone, which is how this detects it.

I don't think being painted changes your head/hatColor, though. I saw a script somewhere that did this by detecting a setNodeColor change on the headSkin node when painted in a similar way.

Will this work with thrown weapons too?

Well, currently it won't work with anything but when it's fixed it'll work with any kind of weapon.

Try this script, it was made by Jookia.

Usage: getHitbox(%obj, %projectile, %pos)
Returns a list of nodes that would have been painted if the projectile was paint.