The following is the code for my LightingRod vehicle's LRocket Projectile. Basically, It's a lance that sticks in the ground for a while and zaps things nearby. Notice the 'NodeZap' function. You'll notice it's a little weird. The basics of it is that if I set it up as:
ONSPC.TakeDamage( 10, Instigator, OL, Start, DamageType );
No damage is given to the powernode if the player gets out of the vehicle (but does if they stay in), and if I set it up as:
ONSPC.TakeDamage( 10, VOwner, OL, Start, DamageType );
Then no damage is given to the powernode if the player stays in the vehicle (But does if they get out of the vehicle). The problem is that I was palying a game with some bots, and got a log full of these warnings:
Warning: LRocket ONS-Torlan.LRocket (Function LightningRod.LRocket.NodeZap:0101) Accessed None 'VOwner'
Can anyone think of a reason that I should end up with VOwner of None? The idea in PrebeginPlay is that VHOwner stores the vehicle of the projectile's instigator, and VOwner stores the driver of that vehicle (I think, it's been a while since I wrote that code.)
Let me know if you see anything too weird or something that could have been done easier or better. Thanks
ONSPC.TakeDamage( 10, Instigator, OL, Start, DamageType );
No damage is given to the powernode if the player gets out of the vehicle (but does if they stay in), and if I set it up as:
ONSPC.TakeDamage( 10, VOwner, OL, Start, DamageType );
Then no damage is given to the powernode if the player stays in the vehicle (But does if they get out of the vehicle). The problem is that I was palying a game with some bots, and got a log full of these warnings:
Warning: LRocket ONS-Torlan.LRocket (Function LightningRod.LRocket.NodeZap:0101) Accessed None 'VOwner'
Can anyone think of a reason that I should end up with VOwner of None? The idea in PrebeginPlay is that VHOwner stores the vehicle of the projectile's instigator, and VOwner stores the driver of that vehicle (I think, it's been a while since I wrote that code.)
Let me know if you see anything too weird or something that could have been done easier or better. Thanks
Code:
Class LRocket extends RocketProj; Var Rotator LastDir; var float PEffectRange; var float VEffectRange; var float LEffectRange; var float ONSPCEffectRange; var xPawn InstigatorPawn; var vector Start; var vector StartA; var Rotator OtherDir; var() class<NewLightningBolt> BeamEffectClass; var class<DamageType> DamageType; Var Float TakenDamage; Var Float DamageTake; Var int Health; Var int Tloops; var int TNum; Var xPawn P; Var Vehicle V; Var Vehicle VT; Var LRocket L; Var ONSPowerCore ONSPC; Var vector PL; Var vector VL; Var vector OL; Var vector LL; Var vector SL; Var NewLightningBolt Beam; Var Pawn VOwner; Var Vehicle VHOwner; Var Bool VTouch; Replication { reliable if ( Role == ROLE_Authority ) TakenDamage, DamageTake, LastDir; } Simulated function Destroyed() { Super.Destroyed(); } Function PreBeginPlay() { if (Instigator != None) { TNum = Instigator.GetTeamNum(); VHOwner = vehicle(Instigator); VOwner = (VHOwner.Driver); } Super.PreBeginPlay(); } Simulated function PostBeginPlay() { if (PhysicsVolume.bWaterVolume) { EndPlay(Location,( vector(Rotation))); } SetCollision(True,True,True); Super.PostBeginPlay(); } Simulated singular function HitWall(vector HitNormal, actor Wall) { } simulated function ProcessTouch(Actor Other, Vector HitLocation) { } Simulated function Explode(vector HitLocation, vector HitNormal) { SetTimer(0.1,True); if ( SmokeTrail != None ) SmokeTrail.mRegen = False; if ( Corona != None ) Corona.Destroy(); If (VOwner == None) Destroy(); } Simulated function Landed( vector HitNormal ) { bOrientToVelocity=False; Explode(Location,HitNormal); } Simulated Function EndPlay( vector HitLocation, vector HitNormal) { local PlayerController PC; PlaySound(sound'WeaponSounds.BExplosion3',,2.5*TransientSoundVolume); if ( EffectIsRelevant(Location,false) ) { Spawn(class'NewExplosionA',,,HitLocation - HitNormal*20,rotator(HitNormal)); PC = Level.GetLocalPlayerController(); if ( (PC.ViewTarget != None) && VSize(PC.ViewTarget.Location - Location) < 5000 ) Spawn(class'LRSpark',,, HitLocation + HitNormal*20, (RotRand())); Spawn(class'LRSpark',,, HitLocation + HitNormal*20, (RotRand())); Spawn(class'LRSpark',,, HitLocation + HitNormal*20, (RotRand())); Spawn(class'LRSpark',,, HitLocation + HitNormal*20, (RotRand())); Spawn(class'LRSpark',,, HitLocation + HitNormal*20, (RotRand())); Spawn(class'LRSpark',,, HitLocation + HitNormal*20, (RotRand())); Spawn(class'ExplosionCrap',,, HitLocation + HitNormal*20, rotator(HitNormal)); } Destroy(); } Simulated Function CheckTouch() { Foreach TouchingActors(class'Vehicle', VT) { If (VT != None) { VTouch = True; } Else if (VTouch == True) { EndPlay(Location,( vector(Rotation))); } } } Simulated Function Timer() { TLoops++; CheckTouch(); If ((TLoops)%3 == 0) { If (TLoops > 300) { SetTimer (0.0,False); EndPlay(Location,( vector(Rotation))); } IdleSpark(); VehicleZap(); LRocketZap(); NodeZap(); if((TLoops)%6 >= 1) { PlayerZap(); } } } Function IdleSpark() { Start = (location - 138 * (vector(Rotation)) ); StartA = (location - 198 * (vector(Rotation)) ); OtherDir = rotator(StartA - Start); SL = StartA; Beam = Spawn(BeamEffectClass ,,, Start, OtherDir); Beam.mSpawnVecA = SL; Beam.SetLocation(Start); PlaySound(Sound'WeaponSounds.LightningGun.LightningGunImpact', SLOT_Misc,,,,,true); } Function PlayerZap() { Foreach VisibleCollidingActors(class'xPawn', P, PEffectRange, Location) { if ( P.Health > 0 && P.Controller != None && (P.Controller.GetTeamNum() != (TNum))) { Start = (location - 158 * (vector(Rotation)) ); PL = P.Location; OtherDir = rotator(PL - Start); Beam = Spawn(BeamEffectClass ,,, Start, OtherDir); Beam.mSpawnVecA = PL; Beam.SetLocation(Start); P.TakeDamage( 5, Vowner, PL, Start, DamageType); } } } Function VehicleZap() { Foreach VisibleCollidingActors(class'Vehicle', V, VEffectRange, Location) { Start = (location - 158 * (vector(Rotation)) ); VL = V.Location; If ((VSize(Start - VL)) < 400) { HurtRadius(0, 300, DamageType, 130000.000000, Location ); HurtRadius(0, 600, DamageType, 60000.000000, Location ); } if (V.Health > 0 && (V.Controller != None) && (V.Controller.GetTeamNum() != (TNum))) { OtherDir = rotator(VL - Start); Beam = Spawn(BeamEffectClass ,,, Start, OtherDir); Beam.mSpawnVecA = VL; Beam.SetLocation(Start); V.TakeDamage( 7, VOwner, VL, Start, DamageType ); } } } Function LRocketZap() { Foreach VisibleCollidingActors(class'LRocket', L, LEffectRange, Location) { if (L != Self) { Start = (location - 158 * (vector(Rotation)) ); LL = L.Location; OtherDir = rotator(LL - Start); Beam = Spawn(BeamEffectClass ,,, Start, OtherDir); Beam.mSpawnVecA = LL; Beam.SetLocation(Start); L.TakeDamage( 10, VOwner, LL, Start, DamageType ); } } } Function NodeZap() { Foreach VisibleCollidingActors(class'ONSPowerCore', ONSPC, ONSPCEffectRange, Location) { if ((TNum != ONSPC.DefenderTeamIndex) && ((TNum == 0 && ONSPC.bPoweredByRed) || (TNum == 1 && ONSPC.bPoweredByBlue))) { Start = (location - 158 * (vector(Rotation)) ); OL = ONSPC.Location; OtherDir = rotator(OL - Start); Beam = Spawn(BeamEffectClass ,,, Start, OtherDir); Beam.mSpawnVecA = OL; Beam.SetLocation(Start); if (VOwner.Controller == None) //Nodes will not accept damage from pawn without controller (when pawn is in vehicle) { ONSPC.TakeDamage( 10, Instigator, OL, Start, DamageType ); } Else { ONSPC.TakeDamage( 10, VOwner, OL, Start, DamageType ); } } } } Simulated Function CheckHealth() { If (TakenDamage > Health) { PlaySound(sound'LightningRod.Electric',,4.5*TransientSoundVolume); Spawn(class'LRCore',,, Location + (Vector(Rotation))*20, Rotation); SetCollision(false,false,false); EndPlay(Location, (vector(Rotation))); } } Simulated function TakeDamage( int DamageTake, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType) { if (DamageTake >0) { TakenDamage = TakenDamage + DamageTake; } CheckHealth(); } DefaultProperties { VTouch=False TakenDamage=0.0 bGameRelevant=True AmbientSound=None Health=60 TLoops=0 DamageType=Class'LightningRod.DamTypeLR' VEffectRange=2800.000000 PEffectRange=2200.000000 LEffectRange=1200.000000 ONSPCEffectRange=1200.000000 BeamEffectClass=Class'LightningRod.LightningBolt' bOrientToVelocity=True Physics=PHYS_Falling Speed=10550.000000 MaxSpeed=10850.000000 StaticMesh=StaticMesh'LRMesh.Lance' LifeSpan=38.000000 DrawScale=2.0 bCanBeDamaged=True CollisionRadius=15.000000 CollisionHeight=25.000000 bUseCylinderCollision=True bProjTarget=True TossZ=2.000000 bNetTemporary=False }
Comment