Author Topic: Headshots without using Raycasts?  (Read 1044 times)

I just need to know if I can make critical hits/headshots without using raycasts, and how to do it, because every critical hit weapon Ive seen(that works) so far uses raycasts.

1. you haven't looked very hard
2. what's wrong with raycasts

1. you haven't looked very hard
2. what's wrong with raycasts
1. The only weapons I could think of were The TF2 Butterfly Knife, Ambassador, and Strato's Steyr AUG(Which doesnt have working headshots)
2. I dont want a one-hit kill raycasting deathmachine. I want a one-hit kill rifle that launches targets when headshotted.

It shouldn't be necessary for me to say this but you can make raycasting weapons that aren't instant kill and additionally raycasts aren't that different from projectiles

1. The only weapons I could think of were The TF2 Butterfly Knife, Ambassador, and Strato's Steyr AUG(Which doesnt have working headshots)
there was a sniper with bullets that did, AWM or something, and the SSG thingy

The Huntsman has a headshot script as far as i know.

It shouldn't be necessary for me to say this but you can make raycasting weapons that aren't instant kill and additionally raycasts aren't that different from projectiles
I. Dont. Want. To. Use. Raycasts.

That is the entire reason this topic exists.

there was a sniper with bullets that did, AWM or something, and the SSG thingy
The what?

The what?
it's blue, has 2 prongs on the end which i think are supports, which fails badly as it never rests on anything, makes a funny sputting noise when fired, says "Headshot!" to the client in centerprint in the default red when you get a headshot

T+T sport rifle does critical hits and shoots projectiles. It's the one on Wizzard's Dogfight.

I. Dont. Want. To. Use. Raycasts.
raycasts aren't that different from projectiles
IE you learn from a raycasting weapon and apply it to a projectile.
« Last Edit: January 12, 2011, 08:06:55 PM by Amade »

it's blue, has 2 prongs on the end which i think are supports, which fails badly as it never rests on anything, makes a funny sputting noise when fired, says "Headshot!" to the client in centerprint in the default red when you get a headshot
SIG SG550 v2?
http://forum.blockland.us/index.php?topic=72261
http://forum.blockland.us/index.php?topic=76067.0

I haven't tested it, but it should work.
Code: [Select]
//Quickly whipped up, mostly stolen from Tier Tactical but allows for more ease of use
//Zack0Wack0 9:46 AM 13/01/2011
//Example (you can make the damage values different, obviously):
//datablock ProjectileData(YourProjectile)
//{
// ...
// directDamage = 25;
// directHeadshotDamage = 50;
// directHeadShotDamageType = $DamageType::YourWeaponHeadshot;
// ...
//};
if($Support_Headshots >= 0.1)
return;
$Support_Headshots = 0.1;
package Support_Headshots
{
function ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%this.directDamage <= 0)
return;
%damageType = $DamageType::Direct;
if(%this.directDamageType)
%damageType = %this.directDamageType;
%scale = getWord(%obj.getScale(),2);
%directDamage = mClampF(%this.directDamage,-100,100)*%scale;
if(%col.getType() & $TypeMasks::PlayerObjectType)
{
%colScale = getWord(%col.getScale(),2);
if(getWord(%pos, 2) > (getWord(%col.getWorldBoxCenter(), 2)-3.3)*%colScale)
{
%directDamage = %this.directHeadshotDamage;
%damageType = %this.directHeadshotDamageType;
if(isObject(critProjectile))
{
%col.spawnExplosion(critProjectile,%colScale);
if(isObject(%col.client))
%col.client.play2d(critRecieveSound);
}
if(isObject(%obj.client.player))
{
if(isObject(critProjectile))
{
serverplay3d(critFireSound,%obj.client.player.getHackPosition());
if(isObject(%obj.client))
%obj.client.play2d(critHitSound);
}
}
}
%col.damage(%obj,%pos,%directDamage,%damageType);
}
else
{
%col.damage(%obj,%pos,%directDamage,%damageType);
}
}
};
activatePackage(Support_Headshots);
Put directHeadshotDamage and directHeadshotDamageType in your projectile. You would make directHeadshotDamage larger then the normal directDamage of course.

:o

Thanks, Ill test it.

And if it doesnt work, Ill just try looking at the tier+Tactical set.

EDIT:

Er, stuff.

I want to spawn a different explosion depending on where I hit them (so I can spawn one that sends them flying), not alter the damage amount. Can I set it to change the vertical/impact impulse instead of the damage? Or is that static after the server is started? (I know that when I try to use the console to change it in-game, it doesnt do anything until I load a new mission.) I know how I could change the code to do that, but would it actually change?
« Last Edit: January 12, 2011, 09:45:05 PM by takato14 »

Try putting
Code: [Select]
%col.addVelocity(vectorScale(-getWord(%normal,0) SPC -getWord(%normal,1) SPC -getWord(%normal,2),%velocityScale);inside the part where it checks if it is a head shot (if(getWord(%pos, 2) > (getWord(%col.getWorldBoxCenter(), 2)-3.3)*%colScale)).

%velocityScale is the amount you want to push them away. I'm guessing this should work.