UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Weapons


156

if ( Instigator.bNoWeaponFiring)
// TRUE indicates that weapon firing is disabled for this
pawn
{
// Used to adjust the LockTarget.
AdjustLockTarget(None);

// "target" is current pending to be locked on to
PendingLockedTarget = None;
return;
}
// We don't have a target
BestTarget = None;
BotController = UDKBot(Instigator.Controller);

// If there is BotController...
if ( BotController != None )
{
// only try locking onto bot's target
if((BotController.Focus != None) &&
CanLockOnTo(BotController.Focus) )
{
// make sure bot can hit it
BotController.GetPlayerViewPoint
( StartTrace, AimRot );
Aim = vector(AimRot);

if((Aim dot Normal(BotController.Focus.Location -
StartTrace)) > LockAim )
{
HitActor = Trace(HitLocation, HitNormal,
BotController.Focus.Location, StartTrace, true,,,
TRACEFLAG_Bullet);
if((HitActor == None)||
(HitActor == BotController.Focus) )
{
// Actor being looked at
BestTarget = BotController.Focus;
}
}
}
}
Free download pdf