Page 1 of 1

Headshot problem.

PostPosted: Mon May 07, 07 2:59 pm
by Cozmo
I was making a mod that gives a UT style head shot, but it's being weird.

First, it doesn't hurt scripted pawns, and it doesn't decapitate people when it kills them. :?

Code: Select all
Var Pawn HeadShottedPlayer;

auto simulated state Flying
{
   simulated function Touch(actor Other)
   {
      local PlayerPawn p;
         
      p=PlayerPawn(Other);

      if(p == none) return;

      HeadShottedPlayer = p;
      SetTimer(0.2, false);

      super.Touch(other);
   }
}

function Timer()
{
   local vector loc;

   if(HeadShottedPlayer.HealthHead >= 1)
   {
      if(HeadShottedPlayer.bIsFemale == True)
      {
         loc.X += HeadShottedPlayer.CollisionRadius * 0.25;
         loc.Z += HeadShottedPlayer.BaseEyeHeight*0.9;
      }
      else
      {
         loc.X += HeadShottedPlayer.collisionradius * 0.5;
         loc.Z += HeadShottedPlayer.BaseEyeHeight*0.925;
      }
      loc = loc >> rotation;
      loc += location;

      HeadShottedPlayer.MultiSkins[3] = Texture'PinkMaskTex';
      HeadShottedPlayer.MultiSkins[4] = Texture'PinkMaskTex';
      HeadShottedPlayer.MultiSkins[5] = Texture'PinkMaskTex';
      HeadShottedPlayer.MultiSkins[6] = Texture'PinkMaskTex';
      HeadShottedPlayer.MultiSkins[7] = Texture'PinkMaskTex';
   
      spawn(Class'FleshFragment',HeadShottedPlayer,,loc,rotation);
      spawn(Class'FleshFragment',HeadShottedPlayer,,loc,rotation);
      spawn(Class'FleshFragment',HeadShottedPlayer,,loc,rotation);

      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);
      spawn(Class'BloodDrop',HeadShottedPlayer,,loc,rotation);

      HeadShottedPlayer = None;
   }
}

PostPosted: Mon May 07, 07 3:02 pm
by Allan
What type of class is that in? Projectile/gun?

PostPosted: Mon May 07, 07 3:04 pm
by Cozmo
The projectile. I wasn't sure how I'd call it form a Weapon. :?

PostPosted: Mon May 07, 07 3:39 pm
by Dae
Why do you use a Timer?

PostPosted: Mon May 07, 07 4:08 pm
by Cozmo
Just in case it checked the damage before it was done. It was just a guess.

PostPosted: Mon May 07, 07 5:07 pm
by Allan
Probably that timer is the root-of-all-evil right thar. Copy + Paste its code into the function in place of that timer.

And you may wish to check if the mesh of the player being head-shotted is a normal one for mp (mp_jumpsuit, GM_Trench) before cutting their head off. ;)

PostPosted: Tue May 08, 07 5:07 pm
by Cozmo
I finally stopped being lazy and got round to it. I realized it was because I was testing it on 'MPMJ12''s, because I can't host, and that the accessed none protection stops the Timer() being called.

Then something weird happened. When I tested it again, a torso shot would only hurt him, and would not decapitate him, as planned. But when I got a headshot, he explodes as if he was telefragged. :shock:

Any ideas? :?

[EDIT]:
[A]llan wrote:And you may wish to check if the mesh of the player being head-shotted is a normal one for mp (mp_jumpsuit, GM_Trench) before cutting their head off.


Yeah, good idea. Before, I shot JCDenton and it removed his cape and came out with "Headshot". :lol:

PostPosted: Tue May 08, 07 5:50 pm
by Allan
How much damage does this projectile do, and is its damagetype set as Exploding?

Both could be contributors in this.

PostPosted: Tue May 08, 07 9:13 pm
by Cozmo
Ok, thanks. :) I changed the Damagetype, but now it's being weirder. :? It's just like the normal headshot, except it just makes the corpse vanish. :?

PostPosted: Tue May 08, 07 9:48 pm
by Allan
Try and figure out which MultiSkins are the heads respective to the mesh.

IE:

Code: Select all
if(HeadShottedPlayer.Mesh==LodMesh'DeusExCharacters.GM_Trench')
{
MultiSkins[0]=Texture'DeusExItems.Skins.PinkMaskTex';
MultiSkins[5]=Texture'DeusExItems.Skins.PinkMaskTex';
MultiSkins[7]=Texture'DeusExItems.Skins.PinkMaskTex';
MultiSkins[6]=Texture'DeusExItems.Skins.GrayMaskTex';
}
else if(HeadShottedPlayer.Mesh==LodMesh'MPCharacters.mp_jumpsuit')
{
MultiSkins[3]=Texture'DeusExItems.Skins.PinkMaskTex';
MultiSkins[4]=Texture'DeusExItems.Skins.PinkMaskTex';
MultiSkins[5]=None;
MultiSkins[6]=Texture'DeusExItems.Skins.PinkMaskTex';
MultiSkins[7]=Texture'DeusExItems.Skins.PinkMaskTex';
}


That should work a treat. Only thing is: Due to the texture mapping process used when the meshes were made, taking the heads off also takes off their hands.

PostPosted: Tue May 08, 07 9:57 pm
by Alex
So, I have seen this topic before, but only really paid attention to it today. I just searched for 3 minutes about scope & headshot things. I found this:

In the class DeusExPlayer.uc, there exists a function called GetMPHitLocation(<VECTOR>);

Taken from code in DeusExPlayer.uc:

Code: Select all
      MPHitLoc = GetMPHitLocation(HitLocation);

      if (MPHitLoc == 0)
         return;
      else if (MPHitLoc == 1 )
      {
         // MP Headshot is 2x damage
         // narrow the head region
         actualDamage *= 2;
         HealthHead -= actualDamage;
         bodyString = HeadString;
         if (bPlayAnim)
            PlayAnim('HitHead', , 0.1);
      }


Maybe this improves your code ;) Just get your weapon to check where it hit the player, or projectile, and use the function GetMPHitLocation. It is how I would do it.

PostPosted: Wed May 09, 07 7:59 pm
by Cozmo
~[A]lex~ wrote:So, I have seen this topic before, but only really paid attention to it today. I just searched for 3 minutes about scope & headshot things. I found this:

In the class DeusExPlayer.uc, there exists a function called GetMPHitLocation(<VECTOR>);

Taken from code in DeusExPlayer.uc:

Code:
MPHitLoc = GetMPHitLocation(HitLocation);

if (MPHitLoc == 0)
return;
else if (MPHitLoc == 1 )
{
// MP Headshot is 2x damage
// narrow the head region
actualDamage *= 2;
HealthHead -= actualDamage;
bodyString = HeadString;
if (bPlayAnim)
PlayAnim('HitHead', , 0.1);
}


Maybe this improves your code Wink Just get your weapon to check where it hit the player, or projectile, and use the function GetMPHitLocation. It is how I would do it.


:D Thanks Alex! But I've still got one problem; I get a compile message reading
Code: Select all
 Error, Function parameter: Missing variable type


This is how I used the function, but I'm not sure how else I could. :oops:

Code: Select all
function GetMPHitLocation(1)
{


Then the rest of it. I also looked on UnrealWiki compile errors but couldn't find it.

PostPosted: Wed May 09, 07 8:07 pm
by Alex
GetMPHitLocation(Vector!)

You must use the location of the spot you have hit in this function.

You need to find out what function is called when the projectile actually hits something, which also brings a vector with it.

PostPosted: Wed May 09, 07 8:10 pm
by Cozmo
~[A]lex~ wrote:GetMPHitLocation(Vector!)

You must use the location of the spot you have hit in this function.

You need to find out what function is called when the projectile actually hits something, which also brings a vector with it.


Oh, it was this bit
Code: Select all
else if (MPHitLoc == 1 )
that threw me off, I'll work it out later. :?

PostPosted: Wed Nov 21, 07 3:31 pm
by Batchy
Here's a snippet from Bowens headshot gun.

Code: Select all
simulated function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
      if ((Other != None) && Other.IsA('Pawn'))
          if (HitLocation.Z > (Other.Location.Z + Pawn(Other).BaseEyeHeight))
                Other.TakeDamage(5000, Pawn(Owner), Other.Location, HitNormal, 'Exploded');
     Super.ProcessTraceHit (Other, HitLocation, HitNormal, X, Y, Z);
}


I don't know if thats what your looking for =D

Edit: Oh, I didnt see
decapitate people


:P