UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 6

163

// Otherwise...
else
{
// Use our default projectile
return WeaponProjectiles[CurrentFireMode];
}
}

If we don't have a SeekingRocketClass class defined, then we just use the
currently defined projectile from our CurrentFireMode array.


  1. The last part of this class involves the defaultproperties block. This is the same
    thing we saw in our Camera class. We're setting our muzzle flash socket, which is
    used for not only firing effects, but also weapon traces, to actually use our muzzle
    flash socket.
    defaultproperties
    {
    // Forces the secondary fire projectile to fire from
    the weapon attachment */
    MuzzleFlashSocket=MuzzleFlashSocket
    }


Our MyWeapon class is complete. We don't want to clog our defaultproperties
block and we have some great base functionality, so from here on out our weapon
classes will generally be only changes to the defaultproperties block. Simplicity!


  1. Create a new class called MyWeapon_HomingRocket. Have it extend from
    MyWeapon.
    class MyWeapon_HomingRocket extends MyWeapon;

  2. In our defaultproperties block, let's add our skeletal and static meshes. We're
    just going to keep using the shock rifle mesh. Although it's not necessary to do this,
    as we're already a child class of (that is, inheriting from) UTWeap_ShockRifle, I
    still want you to see where you would change the mesh if you ever wanted to.
    defaultproperties
    {
    // Weapon SkeletalMesh
    Begin Object class=AnimNodeSequence Name=MeshSequenceA
    End Object


// Weapon SkeletalMesh
Begin Object Name=FirstPersonMesh
SkeletalMesh=
SkeletalMesh'WP_ShockRifle.Mesh.SK_WP_ShockRifle_1P'
AnimSets(0)=
AnimSet'WP_ShockRifle.Anim.K_WP_ShockRifle_1P_Base'
Free download pdf