Storeable Heal Pack

 

Storeable heal pack. What I mean by this is an item you can pick up and then later use to restore a portion of your health. Not original I know, but it was requested.


insert the code below into the items listing in g_items.c This will set up the item for insertion into maps, and usage.

        {
               "item_healthpack",
               Pickup_Powerup,
               Use_Healthpack,
               Drop_General,
               NULL,
               "items/pkup.wav",
               "models/items/pack/tris.md2", EF_ROTATE,
               NULL,
/* icon */             "i_pack",
/* pickup */   "Health Pack",
/* width */            2,
               180,
               NULL,
               IT_POWERUP,
               0,
               NULL,
               0,
/* precache */ ""
        },

I'm using the Pickup_Powerup function here. this does mean that with some deathmatch settings it will be used imediatly. I might get round to writing a different pickup function for general usage, which would be unaffected

Insert the code below either into a separete file and add a prototype for Use_Healthpack to the begining of g_items.c or just insert the function in at the begining of g_items.c

void Use_Healthpack (edict_t *ent, gitem_t *item)
{
        if (ent->health<200){
               ent->health+=20;
               ent->client->pers.inventory[ITEM_INDEX(item)]--;
               ValidateSelectedItem (ent);
        }
        else
                return;
}

You'll have to add them to a map in someway, or have them in the players inventory at the start. Can I suggest the item placement tutorial ? Enjoy.

Skunkworks Tutorials