UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 6

161

if (NewLockTarget == None)
{
// Clear the lock
if (bLockedOnTarget)
{
// No target
LockedTarget = None;
// Not locked onto a target
bLockedOnTarget = false;
if (LockLostSound != None && Instigator != None &&
Instigator.IsHumanControlled() )
{
// Play the LockLostSound if we lost track of the
target
PlayerController(Instigator.Controller).
ClientPlaySound(LockLostSound);
}
}
}
else
{
// Set the lock
bLockedOnTarget = true;
LockedTarget = NewLockTarget;
LockedTargetPRI = (Pawn(NewLockTarget) != None)?
Pawn(NewLockTarget).PlayerReplicationInfo : None;
if ( LockAcquiredSound != None && Instigator != None &&
Instigator.IsHumanControlled() )
{
PlayerController(Instigator.Controller).
ClientPlaySound(LockAcquiredSound);
}
}
}


  1. Once it looks like everything has checked out we can fire our ammo! We're just setting
    everything back to 0 at this point, as our projectile is seeking our target, so it's time to
    start over and see whether we will use the same target or find another one.
    /****

    • Everything looks good, so fire our ammo!
      ****/
      simulated function FireAmmunition()
      {
      Super.FireAmmunition();
      AdjustLockTarget(None);



Free download pdf