Game Development Community

Headshots

by Brian · in General Discussion · 11/23/2006 (1:57 am) · 10 replies

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

About the author


#1
11/23/2006 (2:14 am)
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/23/2006 (4:21 am)
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/23/2006 (4:28 am)
Ragdoll requires engine changes and script.
#4
11/23/2006 (5:44 am)
If you want ragdoll deaths, the easiest but not real solution is the ragdoll animation pack
http://www.garagegames.com/products/65/
#5
11/03/2009 (2:12 am)
where do you add that snippet? is it in the weapon.cs file?
#6
11/03/2009 (3:26 am)
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/04/2009 (12:29 am)
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/04/2009 (12:44 am)
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/04/2009 (1:33 am)
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 (8: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.