AirFist

 

A directly non-lethal true, but useful for pushing people off ledges and into large pits of lava :). This needs tweaking as I havn't been able to cut down the upwards movement enough, it can shove someone upwards to a lethal fall. Maybe thats what you want. It works on monsters too. Anyway, onto the code. Create a file called something like airifst.c. paste this code into it

 
#include "g_local.h"
#include "outerweap.h"
 
 
void airburst(vec3_t origin)
{
edict_t *ent=NULL;
vec3_t start,end;
vec3_t dir;
float radius=200;
int i;
qboolean test=false;
 
 
VectorCopy(origin, start);
// Blow backward ALL ents within 200 units...
while ((ent = findradius(ent, origin, 200)) != NULL)
{
               if (!ent->takedamage)
                       continue;
 
 
 
        VectorCopy(ent->s.origin, end);
        // subtract ent's origin from grenade's origin to get direction..
        VectorSubtract(end, start, dir);
        // Scale new velocity into ent's velocity!
        VectorScale(dir,50,dir);
        VectorAdd(dir,ent->velocity, ent->velocity);
} // end while
}
 
 
 
void fire_airburst (edict_t *self, vec3_t start, vec3_t aimdir)
{
        vec3_t         end,forward;
        trace_t        tr;
        int            mask;
 
VectorMA (start, 8192, aimdir, end);
mask = MASK_SHOT|CONTENTS_SLIME|CONTENTS_LAVA;
tr = gi.trace (start, NULL, NULL, end, self, mask);
if (tr.fraction==1)
        return;
 
if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client))
{       
AngleVectors(self->s.angles, forward, NULL, NULL);
VectorScale(forward, 5000, forward);
VectorAdd(forward, tr.ent->velocity, tr.ent->velocity);
}
else if (tr.ent->solid==(SOLID_BSP|SOLID_BBOX))
{
        PlayerNoise(self, tr.endpos, PNOISE_IMPACT);
        airburst(tr.endpos);
        return;
}              
 
}
 
 
 
void weapon_airfist_fire (edict_t *ent)
{
        vec3_t         start;
        vec3_t         forward, right;
        vec3_t         offset;
 
        
        AngleVectors (ent->client->v_angle, forward, right, NULL);
        
        VectorScale (forward, -3, ent->client->kick_origin);
        ent->client->kick_angles[0] = -3;
        
        VectorSet(offset, 0, 7,  ent->viewheight-8);
        P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
        fire_airburst (ent, start, forward);
 
        ent->client->ps.gunframe++;
        PlayerNoise(ent, start, PNOISE_WEAPON);
}
 
void Weapon_Airfist(edict_t *ent)
{
        static int     pause_frames[] = {56, 0};
        static int     fire_frames[]  = {4, 0};
        
        Weapon_Generic (ent, 3, 18, 56, 61, pause_frames, fire_frames, weapon_airfist_fire);
}
 

Add this to your project (makefile etc). Next create a header file and stick prototypes for the functions here into it (look in the resource section at the bottom). Next you'll have to add the weapon definition in g_items.c

 
        {
        "weapon_airfist",              //  The map entity name.
        Pickup_Weapon,                 // The pickup function
        Use_Weapon,                              //How to use
        Drop_Weapon,           // the drop function
        Weapon_Airfist,                            //What the use function is
        "misc/w_pkup.wav",
        "models/weapons/g_rail/tris.md2",EF_ROTATE,
        "models/weapons/v_rail/tris.md2",      //The models stuff.
        "w_railgun",                                     //Icon to be used. you could create another, you probably should
        "Airfist",                                         //Pickup name. use this to give the item to someone at the start of the game
        0,
        0,
        NULL,
        IT_WEAPON|IT_STAY_COOP,
        WEAP_RAILGUN,                  // the model index, just an integer defined in g_local.h
        NULL,
        0,
        ""
        },
 

Add #include "airfist.h" after #include "g_local.h" at the top of the file.

Now you have the airfist weapon. try it out. Tweak it to your preferences


Resources

 


Skunkworks Tutorials