Game Development Community

Headshots

by Brian · in General Discussion · 11/22/2006 (5:57 pm) · 10 replies

Are headshots avilible in the game engine or do you have to script it yourself?

About the author


#1
11/22/2006 (6:14 pm)
In the starter kit? No. Easily scripted in however.

function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
   // Apply damage to the object all shape base objects
   if ( %this.directDamage > 0 )
   {
      if ( %col.getType() & ($TypeMasks::ShapeBaseObjectType) )
      {
         %headshot = false;
         if ( %col.getClassName() $= "Player" )
         {
            %damLoc = firstWord( %col.getDamageLocation( %position ) );
            if ( %damLoc $= "head" )
               %headshot = true;
         }
         %col.damage( %obj, %pos, ( %headshot == true ? %this.directDamage * 1.5 : %this.directDamage ), "Projectile" );
      }
   }
}
#2
11/22/2006 (8:21 pm)
Thanks, all i have to do is script it? After the head shot do i have to script that he does a ragdoll death.
#3
11/22/2006 (8:28 pm)
Ragdoll requires engine changes and script.
#4
11/22/2006 (9:44 pm)
If you want ragdoll deaths, the easiest but not real solution is the ragdoll animation pack
http://www.garagegames.com/products/65/
#5
11/02/2009 (6:12 pm)
where do you add that snippet? is it in the weapon.cs file?
#6
11/02/2009 (7:26 pm)
Slaps for resurrecting a 3 year old thread

function ProjectileData::onCollision, is in each individual weapon's cs file (eg: crossbow.cs).

A "search in files" using some sort of text viewer or IDE (notepad C++ or Torsion, etc) is useful for finding the location of things such as functions or testing to see whether they are already existing.
#7
11/03/2009 (4:29 pm)
would all you need is that snippet, wouldnt you need something else to identify what exactly is considered the "head"? sorry for the noob questions, im new at scripting
#8
11/03/2009 (4:44 pm)
I think that "head" is just what the top area of the bounding box is called. I've no idea where the actual script/code for it is though.
#9
11/03/2009 (5:33 pm)
box_Percentage..... of Player datablock.
// Damage location details
   boxNormalHeadPercentage       = 0.83;
   boxNormalTorsoPercentage      = 0.49;
   boxHeadLeftPercentage         = 0;
   boxHeadRightPercentage        = 1;
   boxHeadBackPercentage         = 0;
   boxHeadFrontPercentage        = 1;
is where it's found....also the global variables at the top of the file help in deathSequence playback...
$PlayerDeathAnim::TorsoFrontFallForward = 1;
$PlayerDeathAnim::TorsoFrontFallBack = 2;
$PlayerDeathAnim::TorsoBackFallForward = 3;
$PlayerDeathAnim::TorsoLeftSpinDeath = 4;
$PlayerDeathAnim::TorsoRightSpinDeath = 5;
$PlayerDeathAnim::LegsLeftGimp = 6;
$PlayerDeathAnim::LegsRightGimp = 7;
$PlayerDeathAnim::TorsoBackFallForward = 8;
$PlayerDeathAnim::HeadFrontDirect = 9;
$PlayerDeathAnim::HeadBackFallForward = 10;
$PlayerDeathAnim::ExplosionBlowBack = 11;
#10
11/04/2009 (12:06 pm)
Just bear in mind that the vital area in the head is a little less than half of it's size. Shooting someone in jaw or mouth is not fatal.