UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Weapons


158


  1. If we have a possible target, then we note its time mark for locking onto it. If we can
    lock onto it, then start the timer. The timer can be adjusted in the default properties
    and determines how long we need to track our target before we have a solid lock.
    // If we have a "possible" target, note its time mark
    if ( BestTarget != None )
    {
    LastValidTargetTime = WorldInfo.TimeSeconds;


// If we're locked onto our best target
if ( BestTarget == LockedTarget )
{
/** Set the LLOT to the time in seconds since
level began play */

LastLockedOnTime = WorldInfo.TimeSeconds;
}

Once we have a good target, it should turn into our current one, and start
our lock on it. If we've been tracking it for enough time with our crosshair
(PendingLockedTargetTime), then lock onto it.
else
{
if ( LockedTarget != None&&(
(WorldInfo.TimeSeconds - LastLockedOnTime >
LockTolerance)||!CanLockOnTo(LockedTarget)) )
{
// Invalidate the current locked Target
AdjustLockTarget(None);
}

/** We have our best target, see if they should
become our current target Check for a new
pending lock */
if (PendingLockedTarget != BestTarget)

{
PendingLockedTarget = BestTarget;
PendingLockedTargetTime =
((Vehicle(PendingLockedTarget) != None)
&&(UDKPlayerController
(Instigator.Controller)!=None)
&&UDKPlayerController(Instigator.Controller).
bConsolePlayer)
? WorldInfo.TimeSeconds + 0.5*LockAcquireTime
: WorldInfo.TimeSeconds + LockAcquireTime;
}
Free download pdf