Announcement

Collapse
No announcement yet.

Need help with Log Error

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

    Need help with Log Error

    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

    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
    }

    #2
    I would do it like so:

    var pawn SpearDriver
    Code:
    function KDriverEnter(pawn P)
    {
    SpearDriver = P;
    super.KDriverEnter(p);
    }
    Then Spear Driver should always be the last person to drive the vec (this works for wepaon pawns as well)


    Then you damage call should use SpearDriver...

    Comment


      #3
      OK, That seems like a solid plan, but that code would be in the vehicle, amd I need to get it into the projectile's class where it is needed, and I'm not clear on how to do that. Thanks for the help.

      Comment


        #4
        How 'bout...
        Code:
        VOwner = LightningRod(VehicleBase).SpearDriver

        Comment


          #5
          Except VOwner should still be decalred as a pawn...

          But yeah that shou8ld all work

          Comment


            #6
            This is in my Vehicle Class:
            Code:
            function KDriverEnter(pawn P)
            {
                CDriver = P;
                super.KDriverEnter(p);
            }
            Anth this is in my Projectile Class;
            Code:
            Function PreBeginPlay()
            {
                    VOwner = LightningRod(VehicleBase).CDriver; (<----Line 55)
                    Super.PreBeginPlay();
            }
            And I get this error when compliling:
            c:\UT2004\LightningRod\Classes\LRocket.uc(55) : Error, Bad or missing expression in '='

            Any Ideas? I'm out of my realm here. Thanks.

            Comment


              #7
              I tried it the way you said, Here's the relevant code:

              From My projectile's Class:
              Code:
              Function PreBeginPlay()
              {
              
                  if (Instigator != None)
              	{
                    	TNum = Instigator.GetTeamNum();
                      VHOwner = LightningRod(Instigator);
                      VOwner = (VHOwner.CDriver);
                      }
                      Super.PreBeginPlay();
              }
              Also from My Projectile's Class:
              Code:
              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);
                          ONSPC.TakeDamage( 100, VOwner, OL, Start, DamageType );
              
                      }
                  }
              }
              From My Vehicle's Class:
              Code:
              function KDriverEnter(pawn P)
              {
                  CDriver = P;
                  super.KDriverEnter(p);
              }
              This way of doing things does the same as my origonal code: Damage is not dealt to the powernode until the driver exits the vehicle, and stops once they re-enter. This seems to be unique to the way ONSPowerCore takes damage, because I do not have this problem dealing damage to players, bots or vehicles. Here is the TakeDamage function of ONSPowerCore:

              Code:
              function TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, class<DamageType> damageType)
              {
              	local Controller InstigatorController;
              
              	//if (instigatedBy != None && ScriptedController(instigatedBy.Controller) != None)
              	//	Log("SCRIPTED DAMAGE:"@Damage@"CORESTAGE:"@CoreStage@"HEALTH:"@Health@"POWEREDBYINSTIGATED:"@PoweredBy(instigatedBy.GetTeamNum()));
              
              	if (CoreStage == 4 || CoreStage == 1 || Damage <= 0 || Level.Game.ResetCountdown > 0 || Level.Game.bGameEnded)
              		return;
              
              	if (damageType == None || !damageType.default.bDelayedDamage)
              		DelayedDamageInstigatorController = None;
              	if (instigatedBy != None && instigatedBy.Controller != None)
              		InstigatorController = instigatedBy.Controller;
              	else
              		InstigatorController = DelayedDamageInstigatorController;
              
              	if (InstigatorController == None && damageType != None)
              		return;
              
                  if (damageType != None)
              		Damage *= damageType.default.VehicleDamageScaling;
                  if (instigatedBy != None)
                  {
                  	if (instigatedBy.HasUDamage())
              		Damage *= 2;
              		Damage *= instigatedBy.DamageScaling;
                  }
              
                  if ( InstigatorController == None || (InstigatorController.GetTeamNum() != DefenderTeamIndex && PoweredBy(InstigatorController.GetTeamNum())) )
                  {
              		NetUpdateTime = Level.TimeSeconds - 1;
                  	AccumulatedDamage += Damage;
                  	if ((DamageEventThreshold > 0) && (AccumulatedDamage >= DamageEventThreshold))
                  	{
                  		TriggerEvent(TakeDamageEvent,self, InstigatedBy);
                  		AccumulatedDamage = 0;
                  	}
              	if (InstigatorController != None)
              	{
              		LastDamagedBy = InstigatorController.PlayerReplicationInfo;
              		LastAttacker = instigatedBy;
              		AddScorer(InstigatorController, FMin(Health, Damage) / DamageCapacity);
              	}
              	if ( bFinalCore )
              		NetUpdateTime = Level.TimeSeconds - 1;
                  Health -= Damage;
                  if ( Health < 0 )
                  	DisableObjective(instigatedBy);
              	else if (damageType != None)
              	{
              		//attack notification
              		if (LastAttackMessageTime + 1 < Level.TimeSeconds)
              		{
              			if (bFinalCore)
              			{
              				if (float(Health) / DamageCapacity > 0.55)
              					BroadcastLocalizedMessage(class'ONSOnslaughtMessage', 7 + DefenderTeamIndex,,, self);
              				else if (float(Health) / DamageCapacity > 0.45)
              					BroadcastLocalizedMessage(class'ONSOnslaughtMessage', 25 + DefenderTeamIndex,,, self);
              				else
              					BroadcastLocalizedMessage(class'ONSOnslaughtMessage', 18 + DefenderTeamIndex,,, self);
              			}
              			else
              				BroadcastLocalizedMessage(class'ONSOnslaughtMessage', 9 + DefenderTeamIndex,,, self);
              			UnrealTeamInfo(Level.GRI.Teams[DefenderTeamIndex]).AI.CriticalObjectiveWarning(self, instigatedBy);
              			LastAttackMessageTime = Level.TimeSeconds;
              		}
              		LastAttackTime = Level.TimeSeconds;
              	}
                  }
                  else if (PlayerController(InstigatorController) != None)
                  {
                  	if (InstigatorController.GetTeamNum() != DefenderTeamIndex)
              	        PlayerController(InstigatorController).ReceiveLocalizedMessage(class'ONSOnslaughtMessage', 5);
              		else if (bFinalCore && DamageType == class'DamTypeLinkShaft')
              			PlayerController(InstigatorController).ReceiveLocalizedMessage(class'ONSOnslaughtMessage', 30);
                  }
              }
              Any Ideas?

              Comment


                #8
                What is VOwner declared as? hEre:
                Function PreBeginPlay()
                {
                VOwner = LightningRod(VehicleBase).CDriver; (<----Line 55)
                Super.PreBeginPlay();
                }

                Comment


                  #9
                  A pawn

                  Comment


                    #10
                    Backup your Onslaught.u, and then recompile it with a log statement, see what it's receiving...

                    Comment


                      #11
                      Basically, just for fun, I set this back up as it origonally was, and played a bunch. Seems I either get loads of the error in question, or none at all. This is partially because the error is coming from within a timer loop, and if it happens once, it'll happen repeatedly. Basically, I came to the conclusion that there is some special circumstance where one could end up with VOwner=none, possibly if the player launches the projectile and gets killed while it is active or something. I simply set it up to check and make sure VOwner != None, but if it does, the lance should destroy(). This works for taking the warnings out of the log, and I have yet to see a lance just disapear for no obvious reason (there's no way of telling if it destroy()ed because of this check, or if it just ran out of time). Seems like a simple and clean answer. Thanks for all the help.

                      Comment

                      Working...
                      X