Self Catapult Command


Posted by Maj.Bitch (12.145.208.*) at 11:05 AM, 3/6/2001:


Here is a neat command you can add to your mod (particularly useful for CTF players).

What do you need it for and what does it do? Well, did you ever want to get up and over a high wall so you can get behind the enemies lines? Or, did you want to up onto a tall ledge so you can snipe away at the enemy? Well, now you can. When you hit your aliased key you get catapulted up and forward in the direction you are currently facing (and I mean UP and FORWARD!!). Better practice using your new self catapult command else you may end up splattered against some wall or mountain because you misjudged the catapulting height and distance.

Here it is:

Add this new function to your g_cmds.c file right above your ClientCommand() function:


//========================================================
void Cmd_Catapult_f(edict_t *ent) {
vec3_t forward,up;

  // Not available to dead or respawning players!
  if (!G_ClientInGame(ent)) return;

  // Is ent currently airborne?
  if (ent->groundentity==NULL) return;

  if (ent->health <= 10) // cost of 10 health units - OPTIONAL
    gi_centerprintf(ent,"Self Catapult costs 10 health!\n");
  else {
    ent->health -= 10;
    // Physically throw the player up and forward!
    AngleVectors(ent->s.angles, forward, NULL, up);
    VectorCopy(forward, ent->movedir);
    VectorClear(ent->velocity);
    VectorMA(ent->velocity,700,forward,ent->velocity); // forward
    VectorMA(ent->velocity,500,up,ent->velocity); }    // upward
}

Now add this command to your ClientCommand function like so:

  else if (!stricmp(gi.argv(0),"catapult"))
    Cmd_Catapult_f(self);

That's it. Be sure to bind a key to the string "catapult" and you're done!

Have fun!

Maj.Bitch