Author Topic: Fallout-style hit detection  (Read 3205 times)

It would detect where you would get hit and do different things in different areas.
EX:
Head: Double damage.
Body: Regular damage and higher knockback.
Legs: Slow moving speed.
Arms: Slow weapon switch time.
Back: 50% higher damage.

I don't think it's possible with the players hitbox being it's whole body instead of each limb, but I might be wrong.
Okay nevermind
« Last Edit: November 21, 2012, 11:32:15 PM by mr. pedophile »

it'd be a complete remodel.

could use that though

slower weapons switching sounds like a pain in the ass, also you might be able to detect his in the body head and feet area but not that hands

You would be able to detect all of those things using paint particle detection, which is how headshots work now

slower weapons switching sounds like a pain in the ass, also you might be able to detect his in the body head and feet area but not that hands
Hey, If you got shot in the hand, you wouldn't be quick on the trigger.

You would be able to detect all of those things using paint particle detection, which is how headshots work now
paint particle detection?

Hey, If you got shot in the hand, you wouldn't be quick on the trigger.
no what I'm trying to say is that this would be hard to achieve script wise

Swollow is right
The hands one would be the most difficult to do, because of the way weapon datablocks are set up. I don't think there's a proper callback for when weapons are switched, but I may be wrong. The legs one would require some playertypes, again because of how datablocks work

I don't think there's a proper callback for when weapons are switched

servercmdUseTool(%cl, %slot);

Check out my Glock18 and Musket, they already have hitbox detection that can detect practically any bodypart.
Here's the code with isLegShot and isHeadShot, looking at %test variable will give you an idea on how to add new functions.
Code: [Select]
// Hitbox Detection
function isHeadShot( %list )
{
   %list = "\t" @ %list @ "\t";
   %test = "plume triPlume septPlume visor helmet pointyHelmet flareHelmet scoutHat bicorn copHat knitHat headSkin";
   %cnt = getWordCount( %test );

   for ( %i = 0 ; %i < %cnt ; %i++ )
   {
    %word = "\t" @ getWord( %test, %i ) @ "\t";

    if ( striPos( %list, %word ) >= 0 )
    {
     return true;
    }
   }

   return false;
}
//I'm thinking of modifying it a little bit so it returns which hitbox has been hit instead of just returning "true" so it only would require one function.
function isLegShot( %list )
{
   %list = "\t" @ %list @ "\t";
   %test = "rshoe rpeg lshoe lpeg pants skirtHip skirtTrimRight skirtTrimLeft";
   %cnt = getWordCount( %test );

   for ( %i = 0 ; %i < %cnt ; %i++ )
   {
    %word = "\t" @ getWord( %test, %i ) @ "\t";

    if ( striPos( %list, %word ) >= 0 )
    {
     return true;
    }
   }

   return false;
}

function Player::getLastImpactPosition( %this )
{
   return $_detectHitboxPosition;
}

function getLastImpactPosition()
{
   return $_detectHitboxPosition;
}

function getHitbox( %obj, %col, %pos )
{
   $_detectHitboxActive = true;
   $_detectHitboxList = "";
   $_detectHitboxPosition = %pos;

   paintProjectile::onCollision( "", %obj, %col, "", %pos, "" );
   cancel( %col.tempColorSchedule );
   %list = trim( $_detectHitboxList );

   deleteVariables( "$_detectHitbox*" );

   if ( ( %col.getType() & $TypeMasks::PlayerObjectType ) && isObject( %cl = %col.client ) )
   {
      %cl.applyBodyColors();
      %cl.applyBodyParts();
   }

   return %list;
}

package hitboxDetection
{
   function shapeBase::setNodeColor( %this, %node, %color )
   {
    if ( $_detectHitboxActive )
    {
     $_detectHitboxList = trim( $_detectHitboxList TAB %node );
     return;
    }

    parent::setNodeColor( %this, %node, %color );
   }
};

activatePackage( "hitboxDetection" );


To use hitboxes, in your projectile's damage:

Code: [Select]
function FlyingPigsProjectile::damage(%this, %obj, %col, %fade, %pos, %normal)
{
   %damage = %this.directDamage;
   %headshot = isHeadShot( getHitbox( %obj, %col, %pos ) );
   %legshot = isLegShot( getHitBox( %obj, %col, %pos ) );
//add those two at the beginning for convenience.

   if ( %headshot )
   {
     %damageType = $DamageType::CarrotHeadshot;
     %col.playThread( "headUp" );
     %damage *= 3;
   }
   else
   if ( %legshot )
   {
      %damage /= 1.5;
      // tumble(%col);
   }

   %col.damage( %obj, %pos, %damage, %this.directDamageType );

   if ( %headshot && %col.getState() $= "Dead" )
   {
     %col.setNodeColor( "headSkin", "1 0 0 1" );
//colors the head red, duh.
   }
}

Most of the credit goes to our magician Port. He gave me the original support script
« Last Edit: December 07, 2012, 02:25:02 AM by Crystalwarrior »

*pauses game*
*Aims at person while they are immobilized*
*Fires many shots in slow motion which decapitates them*

*pauses game*
*Aims at person while they are immobilized*
*Fires many shots in slow motion which decapitates them*
Congratulations. You can read the word "fallout" but not an op.

Congratulations. You can read the word "fallout" but not an op.


Congratulations. You can quote posts while contributing absolutely nothing to the topic.