Announcement

Collapse
No announcement yet.

Headshot help needed, Please.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Headshot help needed, Please.

    I’m trying to create a headshot Super shock rifle but running into some problems.

    I created a class that extends SuperShockBeamFire and tried adding the code I found in the class SniperFire that detects the headshots, it works but it does not show the beam from the shockrifle, it acts and shoots like the sniper rifle only 1 shot kills.

    Any ideas on what I would have to edit to get this working properly?

    Thanx for your time,
    Vlad

    #2
    BTW, bascly i copied everything out of the SniperFire class and pasted it into my class, god I'm such a n00b at this.

    I could post the code if you think that will help.

    Vlad

    Comment


      #3
      instead of copying everything, just extend the Fire class from the shockrifle, and implement ONLY the code that checks for the headshot (from the sniperfire).

      Comment


        #4
        I tried that, or at least i think i got what checks for the headshots, but i'm not 100% sure.

        Code:
         ReflectNum = 0;
            while (true)
            {
                bDoReflect = false;
                X = Vector(Dir);
                End = Start + tmpTraceRange * X;
                Other = Weapon.Trace(HitLocation, HitNormal, End, Start, true);
        
                if ( Other != None && (Other != Instigator || ReflectNum > 0) )
                {
                    if (bReflective && Other.IsA('xPawn') && xPawn(Other).CheckReflect(HitLocation, RefNormal, DamageMin*0.25))
                    {
                        bDoReflect = true;
                    }
                    else if ( Other != mainArcHitTarget )
                    {
                        if ( !Other.bWorldGeometry )
                        {
                            Damage = (DamageMin + Rand(DamageMax - DamageMin)) * DamageAtten;
        
                            if (Vehicle(Other) != None)
                                HeadShotPawn = Vehicle(Other).CheckForHeadShot(HitLocation, X, 1.0);
        
                            if (HeadShotPawn != None)
                                HeadShotPawn.TakeDamage(Damage * HeadShotDamageMult, Instigator, HitLocation, Momentum*X, DamageTypeHeadShot);
        					else if ( (Pawn(Other) != None) && (arcsRemaining == NumArcs)
        						&& Pawn(Other).IsHeadShot(HitLocation, X, 1.0) )
                                Other.TakeDamage(Damage * HeadShotDamageMult, Instigator, HitLocation, Momentum*X, DamageTypeHeadShot);
                            else
                            {
        						if ( arcsRemaining < NumArcs )
        							Damage *= SecDamageMult;
                                Other.TakeDamage(Damage, Instigator, HitLocation, Momentum*X, DamageType);
        					}
                        }
                        else
        					HitLocation = HitLocation + 2.0 * HitNormal;
                    }
                }
                else
                {
                    HitLocation = End;
                    HitNormal = Normal(Start - End);
                }
                if ( Weapon == None )
        			return;
                hitEmitter = xEmitter(Weapon.Spawn(tmpHitEmitClass,,, arcEnd, Rotator(HitNormal)));
                if ( hitEmitter != None )
        			hitEmitter.mSpawnVecA = HitLocation;
        		if ( HitScanBlockingVolume(Other) != None )
        			return;
        
                if( arcsRemaining == NumArcs )
                {
                    mainArcHit = HitLocation + (HitNormal * 2.0);
                    if ( Other != None && !Other.bWorldGeometry )
                        mainArcHitTarget = Other;
                }
        
                if (bDoReflect && ++ReflectNum < 4)
                {
                    //Log("reflecting off"@Other@Start@HitLocation);
                    Start = HitLocation;
                    Dir = Rotator( X - 2.0*RefNormal*(X dot RefNormal) );
                }
                else if ( arcsRemaining > 0 )
                {
                    arcsRemaining--;
        
                    // done parent arc, now move trace point to arc trace hit location and try child arcs from there
                    Start = mainArcHit;
                    Dir = Rotator(VRand());
                    tmpHitEmitClass = SecHitEmitterClass;
                    tmpTraceRange = SecTraceDist;
                    arcEnd = mainArcHit;
                }
                else
                {
                    break;
                }
            }
        }

        Comment


          #5
          Code:
          if (Vehicle(Other) != None)
                                  HeadShotPawn = Vehicle(Other).CheckForHeadShot(HitLocation, X, 1.0);
          
                              if (HeadShotPawn != None)
                                  HeadShotPawn.TakeDamage(Damage * HeadShotDamageMult, Instigator, HitLocation, Momentum*X, DamageTypeHeadShot);
          					else if ( (Pawn(Other) != None) && (arcsRemaining == NumArcs)
          						&& Pawn(Other).IsHeadShot(HitLocation, X, 1.0) )
                                  Other.TakeDamage(Damage * HeadShotDamageMult, Instigator, HitLocation, Momentum*X, DamageTypeHeadShot);
                              else
                              {
          						if ( arcsRemaining < NumArcs )
          							Damage *= SecDamageMult;
                                  Other.TakeDamage(Damage, Instigator, HitLocation, Momentum*X, DamageType);
          }
          this is the important bit I think. this should be placed in the DoTrace() function. this isnt present in the shockbeamfire, but it's in instantfire (the parentclass). you need to redifine DoTrace in your custom fire class.

          Comment


            #6
            Thanx man, i"m getting there, now my only problem is that i can kill with a headshot but if i shoot anywhere else on the player it does no damage so only headshots kill.

            here's what i got so far

            Code:
            function DoTrace(Vector Start, Rotator Dir)
            {
                local Vector X, End, HitLocation, HitNormal, RefNormal;
                local Actor Other;
                local int Damage;
                local bool bDoReflect;
                local int ReflectNum;
                local Pawn HeadShotPawn;
            
            	MaxRange();
            
                ReflectNum = 0;
                while (true)
                {
                    bDoReflect = false;
                    X = Vector(Dir);
                    End = Start + TraceRange * X;
            
                    Other = Weapon.Trace(HitLocation, HitNormal, End, Start, true);
            
                    if ( Other != None && (Other != Instigator || ReflectNum > 0) )
                    {
                        if (bReflective && Other.IsA('xPawn') && xPawn(Other).CheckReflect(HitLocation, RefNormal, DamageMin*0.25))
                        {
                            bDoReflect = true;
                            HitNormal = Vect(0,0,0);
                        }
                        else if ( !Other.bWorldGeometry )
            
                        Damage = (DamageMin + Rand(DamageMax - DamageMin)) * DamageAtten;
            
                                if (Vehicle(Other) != None)
                                    HeadShotPawn = Vehicle(Other).CheckForHeadShot(HitLocation, X, 1.0);
            
                                if (HeadShotPawn != None)
                                    HeadShotPawn.TakeDamage(Damage * HeadShotDamageMult, Instigator, HitLocation, Momentum*X, DamageTypeHeadShot);
            					else if ( (Pawn(Other) != None)
            						&& Pawn(Other).IsHeadShot(HitLocation, X, 1.0) )
                                    Other.TakeDamage(Damage * HeadShotDamageMult, Instigator, HitLocation, Momentum*X, DamageTypeHeadShot);
            
                                    //===================
            
                        else if ( WeaponAttachment(Weapon.ThirdPersonActor) != None )
            				WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other,HitLocation,HitNormal);
                    }
                    else
                    {
                        HitLocation = End;
                        HitNormal = Vect(0,0,0);
            			WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other,HitLocation,HitNormal);
                    }
            
                    SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, ReflectNum);
            
                    if (bDoReflect && ++ReflectNum < 4)
                    {
                        //Log("reflecting off"@Other@Start@HitLocation);
                        Start = HitLocation;
                        Dir = Rotator(RefNormal); //Rotator( X - 2.0*RefNormal*(X dot RefNormal) );
                    }
                    else
                    {
                        break;
                    }
                }
             }
            Vlad

            Comment


              #7
              OK i got it working, Thanx for all the help bro:up:

              Vlad

              Comment

              Working...
              X