UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 4

101

How to do it...


This is a bit more complicated than our previous recipes. We'll have to create a new pickup
class in our IDE, as well as an archetype in the editor, so that we're able to access the class
and its variables within the editor. This is essential when working with level designers who
are not familiar with code.



  1. Firstly, we want to have a sleek interface when we play with our pickup in the editor,
    so add the following code, beneath your class declaration:
    class Tut_HealthPickup extends UTHealthPickupFactory
    /* Hides categories that we won't be needing from the
    archetype
    /
    HideCategories(Object, Debug, Advanced, Mobile, Physics);

  2. The rest of the code will be going in the defaultproperties block:
    defaultproperties
    {
    /* The value at which an AI bot desires the pickup.
    Higher value = will lean towards this pickup
    /
    MaxDesireability=0.700000
    /* How much this pickup will heal the pawn for /
    HealingAmount=20


/** sound played when the pickup becomes available */
RespawnSound=SoundCue'A_Pickups.Health.Cue.
A_Pickups_Health_Respawn_Cue'
/** Time (seconds) before health pickup respawns */
RespawnTime=10.000000

/** Pickup will rotate */
bRotatingPickup=true
/** Speed of the rotation */
YawRotationRate=16384
/** if true, the pickup mesh floats (bobs) slightly */
bFloatingPickup=true
/** How fast should it bob */
BobSpeed=7.0
/** How far to bob. It will go from +/- this number */
BobOffset=2.5
}

This is the same code from the previous recipe, albeit some of the values have
changed and we've now added a new variable, HealingAmount. This does
exactly what you think it does.
Free download pdf