Announcement

Collapse
No announcement yet.

Getting a reward by killing people with reflected shockbeams

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

    Getting a reward by killing people with reflected shockbeams

    Im working on a new weapon that features reflective beams like in the mayhem weapons mod, I adapted the code so it has a special multihit beam that shoots thru the victims allowing multikills with only one beamshot (that's without the reflective beam option), now with that reflective beam code added it's possible to get more than 100 kills with one shot in theory because the beam also reflects/bounces when it hits a wall but that's ofcourse only possible if you play with 100 bots on one tiny 1on1 map.

    The thing I need is a code to notify the player how many kills he has got from one single reflective beam shot and maybe reward the player when he has more than x-amount of kills with that shot.

    Here's the code

    Code:
    class SSFire extends InstantFire;
    
    var() class<SSBeamEffect> BeamEffectClass;
    var() class<SSBeamEffectR> ReflectedBeamEffectClass;
    var float DampeningFactor, NewDamage;
    var byte BounceMaxNum, BounceNum;
    var bool bHitWithoutBounce;
    
    #exec OBJ LOAD FILE=..\Sounds\WeaponSounds.uax
    
    event ModeDoFire()
    {
        Super.ModeDoFire();
    }
    
    function DoFireEffect()
    {
        local Vector StartTrace,X,Y,Z;
        local Rotator R, Aim;
    
        Instigator.MakeNoise(1.0);
    
        StartTrace = Instigator.Location + Instigator.EyePosition();
        if ( PlayerController(Instigator.Controller) != None )
        {
    		// for combos
    	   Weapon.GetViewAxes(X,Y,Z);
    		StartTrace = StartTrace + X*class'SSaltfire'.Default.ProjSpawnOffset.X;
    		if ( !Weapon.WeaponCentered() )
    			StartTrace = StartTrace + Weapon.Hand * Y*class'SSaltfire'.Default.ProjSpawnOffset.Y + Z*class'SSaltfire'.Default.ProjSpawnOffset.Z;
    	}
    
        Aim = AdjustAim(StartTrace, AimError);
    	R = rotator(vector(Aim) + VRand()*FRand()*Spread);
        DoTrace(StartTrace, R);
    }
    
    function DoTrace(Vector Start, Rotator Dir)
    {
        local Vector X, End, HitLocation, HitNormal, RefNormal;
        local Actor Other;
        local bool bDoReflect;
        local int ReflectNum;
        const MaxTrace = 45000;
        local float RemainingTrace;
        
        RemainingTrace = MaxTrace;
    
        bHitWithoutBounce = False;
    
        //Log("Start Trace-----------------------------------------------------------------------------------------------------------");
        For (BounceNum = 0; BounceNum <= BounceMaxNum; BounceNum++)
        {
            MaxRange();
            ReflectNum = 0;
    
            TraceRange = fMin(RemainingTrace, TraceRange);
    
            if ( RemainingTrace < 15000 )
            {
                //Log("Short Segment detected, aborting beam draw.");
                Break;
            }
    
            while (True)
            {
                bDoReflect = false;
                X = Vector(Dir);
                End = Start + TraceRange * X;
    
                Other = Weapon.Trace(HitLocation, HitNormal, End, Start, true);
                //Log(VSize(Start - HitLocation));  // Tracer log
                if ( Other != None && (Other != Instigator || ReflectNum > 0) )
                {
                    if (bReflective && Other.IsA('xPawn') && xPawn(Other).CheckReflect(HitLocation, RefNormal, DamageMin*100.25))
                    {
                         bDoReflect = true;
                         HitNormal = Vect(0,0,0);
                    }
                    else if ( !Other.bWorldGeometry )
                    {
                         SetNewDamage(BounceNum);
                         NewDamage *= DamageAtten;
    
        		     // Update hit effect except for pawns (blood) other than vehicles.
                         if ( Other.IsA('Vehicle') || (!Other.IsA('Pawn') && !Other.IsA('HitScanBlockingVolume')) )
        			  WeaponAttachment(Weapon.ThirdPersonActor).UpdateHit(Other, HitLocation, HitNormal);
    
                         Other.TakeDamage(NewDamage, Instigator, HitLocation, Momentum*X, Damagetype);
                	if ( (Pawn(Other) != None) && (HitLocation != Start) && AllowMultiHit() )
    				TracePart(HitLocation,End,X,Dir,Pawn(Other));
                         //bHitWithoutBounce = (BounceNum == 0);  
                         //BounceNum = BounceMaxNum + 10;  // Stop Bouncing The beam, it has hit a target.
                         //HitNormal = Vect(0,0,0);
    				
                    }
                    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);
                }
    
                RemainingTrace -= VSize(Start - HitLocation);
    
                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;
                }
            }
            //Bend the beam now
            //Log("New Bounce~~~~~~~~~~~~~~~~");
            if (BounceNum <= BounceMaxNum && HitNormal != Vect(0,0,0))
            {
                Start = HitLocation;
                Dir = Rotator(MirrorVectorByNormal(Vector(Dir), HitNormal));
            }
            else
                Break;
        }
        //Log("End Trace-------------------------------------------------------------------------------------------------------------");
    }
    
    function InitEffects()
    {
    	if ( Level.DetailMode == DM_Low )
    		FlashEmitterClass = None;
        Super.InitEffects();
        if ( FlashEmitter != None )
    		Weapon.AttachToBone(FlashEmitter, 'tip');
    }
    
    function bool AllowMultiHit()
    {
    	return true;
    }
    
    function TracePart(Vector Start, Vector End, Vector X, Rotator Dir, Pawn Ignored)
    {
        local Vector HitLocation, HitNormal;
        local Actor Other;
    
        Other = Ignored.Trace(HitLocation, HitNormal, End, Start, true);
    
        if ( (Other != None) && (Other != Ignored) )
        {
            if ( !Other.bWorldGeometry )
            {
                Other.TakeDamage(DamageMax, Instigator, HitLocation, Momentum*X, DamageType);
                HitNormal = Vect(0,0,0);
                if ( (Pawn(Other) != None) && (HitLocation != Start) && AllowMultiHit() )
    				TracePart(HitLocation,End,X,Dir,Pawn(Other));
            }
        }
        else
        {
            HitLocation = End;
            HitNormal = Vect(0,0,0);
        }
        SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, 0);
    }
    
    // for bot combos
    function Rotator AdjustAim(Vector Start, float InAimError)
    {
    	if ( (SS(Weapon) != None) && (SS(Weapon).ComboTarget != None) )
    		return Rotator(SS(Weapon).ComboTarget.Location - Start);
    
    	return Super.AdjustAim(Start, InAimError);
    }
    
    function SpawnBeamEffect(Vector Start, Rotator Dir, Vector HitLocation, Vector HitNormal, int ReflectNum)
    {
        local SSBeamEffect Beam;
    
        if (Weapon != None)
        {
            //Choose Which beam effect class to spawn, the reflected one, which blocks out something of postnetbeginplay or the original.
    
            if (BounceNum > 0 && bHitWithoutBounce == False)   // is using this when beam has hit something.
                Beam = Weapon.Spawn(ReflectedBeamEffectClass,,,Start, Dir);//ReflectedBeamEffectClass
            else
                Beam = Weapon.Spawn(BeamEffectClass,,,Start, Dir);   //BeamEffectClass
    
            if (ReflectNum != 0) Beam.Instigator = None; // prevents client side repositioning of beam start
    
            Beam.AimAt(HitLocation, HitNormal);
        }
    }
    
    Function SetNewDamage(byte BounceNum)
    {
        NewDamage = Default.DamageMin * ((1-DampeningFactor) ** float(BounceNum));
    }
    
    defaultproperties
    {
         ReflectedBeamEffectClass=Class'SSBeamEffectR'
         DampeningFactor=0.000000
         BounceMaxNum=25
         BeamEffectClass=Class'SSBeamEffect'
         DamageType=Class'DamTypeSSBeam'
         DamageMin=150
         DamageMax=250
         TraceRange=17000.000000
         Momentum=600000.000000
         bReflective=True
         FireSound=SoundGroup'WeaponSounds.ShockRifle.ShockRifleFire'
         FireForce="ShockRifleFire"
         FireRate=0.600000
         AmmoClass=Class'XWeapons.ShockAmmo'
         AmmoPerFire=1
         ShakeRotTime=2.000000
         ShakeOffsetMag=(X=-20.000000)
         ShakeOffsetRate=(X=-600.000000)
         ShakeOffsetTime=3.700000
         BotRefireRate=0.300000
         FlashEmitterClass=Class'XEffects.ShockBeamMuzFlash'
         aimerror=700.000000
         SpreadStyle=SS_Random
    }
    I hope you guys can help

    #2
    Something like this?
    Since you added the TracePart and call it with every Pawn that gets hit, you can just simply increment a variable and reward the player when it reaches a certain level.

    Code:
    var Int HitCount;
     
    function DoFireEffect()
    {
        local Vector StartTrace,X,Y,Z;
        local Rotator R, Aim;
     
        Instigator.MakeNoise(1.0);
        HitCount = 0;
        StartTrace = Instigator.Location + Instigator.EyePosition();
        if ( PlayerController(Instigator.Controller) != None )
        {
            // for combos
           Weapon.GetViewAxes(X,Y,Z);
            StartTrace = StartTrace + X*class'SSaltfire'.Default.ProjSpawnOffset.X;
            if ( !Weapon.WeaponCentered() )
                StartTrace = StartTrace + Weapon.Hand * Y*class'SSaltfire'.Default.ProjSpawnOffset.Y + Z*class'SSaltfire'.Default.ProjSpawnOffset.Z;
        }
     
        Aim = AdjustAim(StartTrace, AimError);
        R = rotator(vector(Aim) + VRand()*FRand()*Spread);
        DoTrace(StartTrace, R);
    }
     
     
    function TracePart(Vector Start, Vector End, Vector X, Rotator Dir, Pawn Ignored)
    {
        local Vector HitLocation, HitNormal;
        local Actor Other;
     
        Other = Ignored.Trace(HitLocation, HitNormal, End, Start, true);
     
        if ( (Other != None) && (Other != Ignored) )
        {
            if ( !Other.bWorldGeometry )
            {
                Other.TakeDamage(DamageMax, Instigator, HitLocation, Momentum*X, DamageType);
                HitCount++;
                if (HitCount == 50) {Instigator.Health += 100;} //Reward player here
                HitNormal = Vect(0,0,0);
                if ( (Pawn(Other) != None) && (HitLocation != Start) && AllowMultiHit() )
                    TracePart(HitLocation,End,X,Dir,Pawn(Other));
            }
        }
        else
        {
            HitLocation = End;
            HitNormal = Vect(0,0,0);
        }
        SpawnBeamEffect(Start, Dir, HitLocation, HitNormal, 0);
    }

    Comment


      #3
      thx that might be very helpful
      but is there a way to announce when a player has killed multiple players with one beamshot, for example: "Player1 vaporized 'X' victims in only one shot!"

      Comment


        #4
        Make your your own custom Local Message.
        http://wiki.beyondunreal.com/wiki/Using_LocalMessages

        I would place the message after the DoTrace(....).

        Comment


          #5
          could use a gamerules and linkedreplicationinfo to keep the stats if u wanted

          Comment


            #6
            Originally posted by pcmods
            Make your your own custom Local Message.
            http://wiki.beyondunreal.com/wiki/Using_LocalMessages

            I would place the message after the DoTrace(....).
            Can't get it to work, I need a little help on this

            Comment

            Working...
            X