News: SMF - Just Installed!
 
Welcome, Guest. Please login or register.
+  AnthraxBio
|-+  Quake 3
| |-+  Coding Tutorials
| | |-+  Instant PowerUp!
« previous next »
Pages: [1] Print
Author Topic: Instant PowerUp!  (Read 462 times)
SkreamerVirii
Administrator
Full Member
*****
Posts: 133


View Profile
« on: October 01, 2008, 10:14:08 PM »

INSTANT QUAD

Ok in this tutorial I will explain how to make a command for the quad and then be able to call it at any time during gameplay

So lets begin

Open up msvc and make sure you set your active project to that of GAME once you have done this
Go ahead and open up G_CMDS.C

And scroll all the way down to
/*
=================
Cmd_SetViewpos_f
=================
*/
void Cmd_SetViewpos_f( gentity_t *ent ) {
   vec3_t      origin, angles;
   char      buffer[MAX_TOKEN_CHARS];
   int         i;

   if ( !g_cheats.integer ) {
      trap_SendServerCommand( ent-g_entities, va("print \"Cheats are not enabled on this server.\n\""));
      return;
   }
   if ( trap_Argc() != 5 ) {
      trap_SendServerCommand( ent-g_entities, va("print \"usage: setviewpos x y z yaw\n\""));
      return;
   }

   VectorClear( angles );
   for ( i = 0 ; i < 3 ; i++ ) {
      trap_Argv( i + 1, buffer, sizeof( buffer ) );
      origin = atof( buffer );
   }

   trap_Argv( 4, buffer, sizeof( buffer ) );
   angles[YAW] = atof( buffer );

   TeleportPlayer( ent, origin, angles );
}

Now directly underneath it (unless of course you did my first tutorial on setting up msvc and adding player classes if you did then add it directly underneath the chooseclass function)
add this
/*
=================
Cmd_QUAD_f
=================
*/
void Cmd_Quad_f( gentity_t *ent ) {

   char *msg; // message to player

   ent->flags ^= FL_QUAD;

   if (!(ent->flags & FL_QUAD)) {
      msg = "RAGE OFF\n";
      ent->client->ps.powerups[PW_QUAD] = level.time;
      // turns the Quad powerup off
   }       
   else {
      msg = "RAGE ON\n";
      ent->client->ps.powerups[PW_QUAD] = level.time + 1000000000;//ifinite life
      // turns the Quad powerup on
   }

   trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
}

Now down at the bottom of this file will you will see this

if (Q_stricmp (cmd, "give") == 0)
      Cmd_Give_f (ent);
   else if (Q_stricmp (cmd, "god") == 0)
      Cmd_God_f (ent);
   else if (Q_stricmp (cmd, "notarget") == 0)
      Cmd_Notarget_f (ent);
   else if (Q_stricmp (cmd, "noclip") == 0)
      Cmd_Noclip_f (ent);
   else if (Q_stricmp (cmd, "kill") == 0)
      Cmd_Kill_f (ent);
   else if (Q_stricmp (cmd, "levelshot") == 0)
      Cmd_LevelShot_f (ent);
   else if (Q_stricmp (cmd, "follow") == 0)
      Cmd_Follow_f (ent);
   else if (Q_stricmp (cmd, "follownext") == 0)
      Cmd_FollowCycle_f (ent, 1);
   else if (Q_stricmp (cmd, "followprev") == 0)
      Cmd_FollowCycle_f (ent, -1);
   else if (Q_stricmp (cmd, "team") == 0)
      Cmd_Team_f (ent);
   else if (Q_stricmp (cmd, "where") == 0)
      Cmd_Where_f (ent);
   else if (Q_stricmp (cmd, "callvote") == 0)
      Cmd_CallVote_f (ent);
   else if (Q_stricmp (cmd, "vote") == 0)
      Cmd_Vote_f (ent);
   else if (Q_stricmp (cmd, "gc") == 0)
      Cmd_GameCommand_f( ent );
   else if (Q_stricmp (cmd, "setviewpos") == 0)
      Cmd_SetViewpos_f( ent );

Now add this at the end of the list

else if (Q_stricmp (cmd, "quad") == 0)
   Cmd_quad_f( ent );

 (if you have the chooseclass function then add it after that)

ok now lets go and define our flag
open up G_LOCAL.H
if you cant find it then in the fileview on the left hand side scroll down till you find the Headers folder and open it up
then click on G_LOCAL.H

and you should see this
#define   FL_GODMODE               0x00000010
#define   FL_NOTARGET               0x00000020
#define   FL_TEAMSLAVE            0x00000400   // not the first on the team
#define    FL_NO_KNOCKBACK            0x00000800
#define    FL_DROPPED_ITEM            0x00001000
#define    FL_NO_BOTS               0x00002000   // spawn point not for bot use
#define   FL_NO_HUMANS            0x00004000   // spawn point just for bots
at the top of the page

Now directly underneath
#define FL_NO_HUMANS         0x00004000   // spawn point just for bots
(if you have the #define FL_MYGUY  for the player classes just add it above that)
ADD this
#define FL_QUAD               0x00010000
(whenever you make a command like we are now always make sure the 0x00010000 is the same for the all of them the numbers may vary for other commands but I do know that 0x00010000 works for power up commands


Now for me to explain how we can make this work for multple power ups
first off  were going to disect the function below

STEP 1
/*
=================
Cmd_QUAD_f
=================
*/
( you can modify this to whatever you want to call your instant powerup this is the title of the function)
STEP 2
void Cmd_Quad_f( gentity_t *ent ) {

(Now  change this line to match what you want it to be called like with what we did in the title)
STEP 3
   char *msg; // message to player
(Don’t worry about this)
STEP 4
ent->flags ^= FL_QUAD;

   if (!(ent->flags & FL_QUAD)) {
(make sure that if you call thisFL_QUAD then when you define it in G_LOCAL.H you call it the same thing
STEP 5
      msg = "QUAD OFF\n";
(This is what is printed on the screen on in the console when you turn it off you can only change the QUAD OFF to whatever you want it to say leave the rest alone)
STEP 6
      ent->client->ps.powerups[PW_QUAD] = level.time;

      // turns the Quad powerup off
   } 
(this is one of the most important lines in the function )
heres why
   ent->client->ps.powerups[PW_FLIGHT] = level.time;
   ent->client->ps.stats[STAT_ARMOR] = 0;
   ent->client->ps.powerups[PW_BATTLESUIT] = level.time;

and those are just a few 
do a search and see what you can come up with
(some don’t always work tho even if it compiles)
STEP 7
   else {
      msg = "QUAD ON\n";
(same goes here as in STEP 5)
STEP 8
      ent->client->ps.powerups[PW_QUAD] = level.time + 1000000000;//infinite life it will never go away and you will always have quad damage 
      // turns the Quad powerup on
   }
( the same goes here as it does in  STEP 6)

   trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
}
(DON’T MESS WITH THIS)


ok I think I have gotten you started
some of the things that you need to remember is when you create the function you also need to create this

else if (Q_stricmp (cmd, "flight") == 0)
   Cmd_FLIGHT_f( ent );
Cmd_FLIGHT_f( ent );
(just make sure that this reflects what STEP 2 says)

And you also need to define it like this
#define FL_FLIGHT               0x00010000

so go have fun
 compile it and
then just bind it to a key
and BOOOM
instant quad
or anything for that matter
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Free SMF 1.1.5 Forum Theme by Tamuril. © 2008.