UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 6

153

return SocketLocation;
}

/********************************************************
* Overridden from UTWeapon.uc
* @return the location + offset from which to spawn effects
(primarily tracers)
********************************************************/
simulated function vector GetEffectLocation()
{
Local SkeletalMeshComponent AttachedMesh;
local vector SocketLocation;
Local TutorialPawn TutPawn;
TutPawn = TutorialPawn(Owner);
AttachedMesh = TutPawn.CurrentWeaponAttachment.Mesh;
if (TutPawn != none)
{
AttachedMesh.GetSocketWorldLocationAndRotation
(MuzzleFlashSocket, SocketLocation);
}
MuzzleFlashSocket, SocketLocation);
return SocketLocation;
}


  1. Now we're ready to dive into the parts of code that are applicable to the actual
    homing of the weapon. Let's start by adding our debug info, which allows us to
    troubleshoot any issues we may have along the way.


    • Prints debug info for the weapon
      ****/
      simulated function GetWeaponDebug( out Array DebugInfo )
      {
      Super.GetWeaponDebug(DebugInfo);




DebugInfo[DebugInfo.Length] = "Locked:
"@bLockedOnTarget@LockedTarget@LastLockedontime@
(WorldInfo.TimeSeconds-LastLockedOnTime);
DebugInfo[DebugInfo.Length] =
"Pending:"@PendingLockedTarget@PendingLockedTargetTime
@WorldInfo.TimeSeconds;
}

Here we are simply stating which target our weapon is currently locked onto, in
addition to the pending target. It does this by grabbing the variables we've listed
before, after they've returned from their functions, which we'll add in the next part.
Free download pdf