
Heal your teammates with this. I designed this for
a class based mod, for the medic class. I haven't been able to test this yet,
so any feed back is appreciated
put this code below into a file by itself. add it
to your project (makefile)
#include "g_local.h"#include "outerweap.h" void weapon_healgun_fire(edict_t *ent){ vec3_t start; vec3_t end; vec3_t forward, right; vec3_t offset; trace_t tr; AngleVectors (ent->client->v_angle, forward, right, NULL); VectorSet(offset, 0, 7, ent->viewheight-8); P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); VectorMA (start, 100, forward, end); tr = gi.trace (start, NULL, NULL, end, ent, MASK_SHOT); if (tr.fraction < 1.0){ if (tr.ent->client){ if (tr.ent->health<tr.ent->client->pers.max_health){ tr.ent->health+=1; if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) ) ent->client->pers.inventory[ent->client->ammo_index]--;}} else gi.cprintf(ent,PRINT_HIGH,"No-one there\n"); ent->client->ps.gunframe++; } void Weapon_Healgun(edict_t *ent){ static int pause_frames[] = {32, 0}; static int fire_frames[] = {9,11,13, 0}; Weapon_Generic (ent, 8, 13, 49, 53, pause_frames, fire_frames, weapon_healgun_fire); }
Add void Weapon_Healgun (edict_t *ent); at the end
of the weapon function prototypes at the top of g_items.c. Add the code below
to the item list within g_items.c.
{ "weapon_heal", Pickup_Weapon, Use_Weapon, //How to use Drop_Weapon, Weapon_Healgun, //What the function is "misc/w_pkup.wav", "models/weapons/g_flareg/tris.md2",0, "models/weapons/v_flareg/tris.md2", //The models stuff "w_blaster", //Icon to be used "HealGun", //Pickup name 0, 0, "cells", IT_WEAPON, WEAP_HEALGUN, NULL, 0, "" },
Assign the weapon to the player in p_client.c (not
going to go into how to do that here) or use the give command. try it on
another player. You'll need cells