UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Weapons


162

LastValidTargetTime = 0;
PendingLockedTarget = None;
LastLockedOnTime = 0;
PendingLockedTargetTime = 0;
}


  1. With all of that out of the way, we can finally work on firing our projectile, or in our
    case, our missile. ProjectileFile() tells our missile to go after our currently
    locked target, by setting the SeekTarget variable to our currently locked target.
    /****

    • If locked on, we need to set the Seeking projectile's

    • LockedTarget.
      ****/
      simulated function Projectile ProjectileFire()
      {
      local Projectile SpawnedProjectile;




SpawnedProjectile = super.ProjectileFire();
if (bLockedOnTarget &&
UTProj_SeekingRocket(SpawnedProjectile) != None)
{
/** Go after the target we are currently locked
onto */
UTProj_SeekingRocket(SpawnedProjectile).SeekTarget =
LockedTarget;
}
return SpawnedProjectile;
}


  1. Really though, our projectile could be anything at this point. We need to tell our
    weapon to actually use our missile (or rocket, they are used interchangeably) which
    we will define in our defaultproperties block.
    /****

    • We override GetProjectileClass to swap in a Seeking Rocket if we
      are

    • locked on.
      ****/
      function class GetProjectileClass()
      {
      // if we're locked on...
      if (bLockedOnTarget)
      {
      // use our homing rocket
      return SeekingRocketClass;
      }



Free download pdf