
# Look for the best target
BestPawn = None
BestLocation = None
for Pawn in PC.DynamicActors ( PawnClass, PC ):
# Check if the pawn is valid
if ( Pawn == PC.Pawn or not self.Damagable ( Pawn ) ): continue
# If it is a team game make sure we are on a different team
if ( not self.FriendlyFire and self.SameTeam ( Pawn ) ): continue
# Setup bones list
BoneList = ( self.BonePrecedence == BONE_Root ) \
and [Pawn****otBone, Pawn.HeadBone] \
or [Pawn.HeadBone, Pawn****otBone]
# Find a visible bone
for bone in BoneList:
# Fetch the bone coords
BoneCoords = Pawn.GetBoneCoords ( bone )
# Calculate the location
BoneLocation = BoneCoords.Origin + BoneCoords.XAxis + BoneCoords.YAxis + BoneCoords.ZAxis
# Conditionally apply latency correction
if ( self.LatencyCorrection ):
BoneLocation += self.Correction ( PC, Pawn, deltatime )
# Adjust according to projectile physics
if ( PC.Pawn.Weapon and PC.Pawn.Weapon.FireMode [ FireMode ] and PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass ):
Projectile = PC.Pawn.Weapon.FireMode [ FireMode ].ProjectileClass.Default
if ( Projectile and Projectile.Speed != 0 and Projectile.Physics != PHYS_Falling ):
BoneLocation += Pawn.Velocity * ( abs ( BoneLocation - CameraLocation ) / Projectile.Speed )
# Calculate angle
Angle = ( CameraRotation.Vector () | ( BoneLocation - CameraLocation ).Normal () ) + 1.0
Angle = ( 1.0 - ( Angle / 2.0 ) ) * 180.0
# Do the check
if ( Angle <= self.AimAngle and Pawn.FastTrace ( BoneLocation, CameraLocation ) ):
# Is this the best one?
if ( not BestPawn or self.Compare ( BestPawn, Pawn ) ):
BestPawn = Pawn
BestLocation = BoneLocation
break
if ( BestPawn ):
# We've found a valid target, so lets set the rotation and fire as required
PC.ClientSetRotation ( ( BestLocation - CameraLocation )****tation () )
if ( self.AutoFire and PC.Pawn.Weapon ): PC.Pawn.Weapon.ClientStartFire ( FireMode )








