# Homing Missiles

By Postal

Intermediate

I am quite sure we all like having a lock on someone with the eightball, it is always fun to know you are going to hit someone with a little package of pain. But perhaps you are sick of having to keep aiming at the stupid bots as they run around like headless chickens. Well now I shall tell you what to do about it. We are going to make a subclass or RocketMK2. We are going to modify the code used in the seeking missiles to find a target them by themselves. So to go over quick idea, the eightball finds the target you are looking at, and tell the rocket that, we are going to make the rocket find its own target.

So lets look at the seeking rocket code:

simulated function Timer()

This is timer so it is called upon constantly to keep updating the course of the missile towards the target

{

local ut_SpriteSmokePuff b;

local vector SeekingDir;

local float MagnitudeVel;

if ( InitialDir == vect(0,0,0) ) InitialDir = Normal(Velocity);

if ( (Seeking != None) && (Seeking != Instigator) )

{

If the guy we are aiming at is not you or if that guys doesn’t exist

SeekingDir = Normal(Seeking.Location - Location);

if ( (SeekingDir Dot InitialDir) > 0 )

{

This code makes it home in on its target

MagnitudeVel = VSize(Velocity);

SeekingDir = Normal(SeekingDir * 0.5 * MagnitudeVel + Velocity);

Velocity = MagnitudeVel * SeekingDir;

Acceleration = 25 * SeekingDir;

SetRotation(rotator(Velocity));

}

}

And this makes the smoke behind the missile.

if ( bHitWater || (Level.NetMode == NM_DedicatedServer) ) Return;

if ( (Level.bHighDetailMode && !Level.bDropDetail) || (FRand() < 0.5) )

{

b = Spawn(class'ut_SpriteSmokePuff');

B.DrawScale = 0.5;

b.RemoteRole = ROLE_None;

}

}

So what we need to do is have the rocket find its own target.

foreach visiblecollidingactors(class'Pawn', I, 2000,, true)

That will find all pawns in the visible area for 2000 unreal units and refers to them as I for reference.

So I ended up with this:

simulated function Timer()

{

local ut_SpriteSmokePuff b;

local vector SeekingDir;

local float MagnitudeVel;

Local Pawn i;

Reference term for the pawns we find.

if ( InitialDir == vect(0,0,0) ) InitialDir = Normal(Velocity);

If ( (Seeking == None) || (Seeking == Instigator) )

{

If we havent got a target or if that target is you.

foreach visiblecollidingactors(class'Pawn', I, 2000,, true)

{

If (i != Instigator && I.Health >0)

{

If the target is not dead or you.

Seeking = I;

New target.

}

}

}

Else if ( (Seeking != None) && (Seeking != Instigator) )

{

SeekingDir = Normal(Seeking.Location - Location);

if ( (SeekingDir Dot InitialDir) > 0 )

{

MagnitudeVel = VSize(Velocity);

SeekingDir = Normal(SeekingDir * 0.5 * MagnitudeVel + Velocity);

Velocity = MagnitudeVel * SeekingDir;

Acceleration = 25 * SeekingDir;

SetRotation(rotator(Velocity));

}

}

if ( bHitWater || (Level.NetMode == NM_DedicatedServer) ) Return;

if ( (Level.bHighDetailMode && !Level.bDropDetail) || (FRand() < 0.5) )

{

b = Spawn(class'ut_SpriteSmokePuff');

B.DrawScale = 0.5;

b.RemoteRole = ROLE_None;

}

}

And that all we need for a self guided missle

Visitors Since December 26, 2000