TUTORIAL 23 - Anti-Gravity Boots
by Burning
Okay then... This will help you create (not help, but do it)
Anti Gravity Boots. I helped with a few Half-Life tuts, but
i'm going to go make Quake3 tuts from now on i guess. You
don't need much knowledge of C to do this as this took
me about 5 mins.
Anyway... grab a coke, a smoke and if you'd like ... nevermind... !
1. NEW ENTITY FLAG... (IS THE WIND BLOWING?)
Ummm.... let's create a flag... Where ?? Jump
to (without Anti-gravity boots for now)
g_local.h and in line 33 add this :
#define FL_NO_HUMANS 0x00004000 // spawn point just for bots
#define FL_BOOTS 0x00006000 // Anti Gravity Boots
// movers are things like doors, plats, buttons, etc
.
.
.
2. CREATING THE ON/OFF THINGY
Here the code for bending over and turning that
switch on and off on those boots you just bought.
Now open up g_cmds.c and add this in line 1101:
else if (Q_stricmp (cmd, "setviewpos") == 0)
Cmd_SetViewpos_f( ent );
else if (Q_stricmp (cmd, "boots") == 0)
Cmd_Boots_f( ent );
else
trap_SendServerCommand( clientNum, va("print \"unknown cmd %s\n\"", cmd ) );
Yeah... you added the command for typing in the console...
But you still need to create the function Cmd_Boots_f. So now go
to line 1030 (yeah Buddy... same file) and add :
/*
=================
Cmd_Boots_f function for turning boots on/off
=================
*/
void Cmd_Boots_f( gentity_t *ent ) {
char *msg; // message to player
ent->flags ^= FL_BOOTS;
if (!(ent->flags & FL_BOOTS))
msg = "Anti Gravity boots OFF\n";
else msg = "Anti Gravity boots ON\n";
trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
}
Goooooood... now you created the function for actually
turning it on and off... and more... you printed a
shweet little message with it.
3. DOING THE IMPOSSIBLE (IN REAL LIFE I MEAN)
Now we want to change the gravity, right ? .... Right...
Follow me now into the file g_active.c and walk
to line 596... you see it ?... now change it to :
} else {
client->ps.pm_type = PM_NORMAL;
}
client->ps.gravity = g_gravity.value; // Add this,
if (ent->flags & FL_BOOTS) // umm and this,
client->ps.gravity = g_gravity.value * 0.20; // yeah... this too
// set speed
client->ps.speed = g_speed.value;
3. USING IT IN YOUR MOD (IN REAL LIFE I MEAN)
To use this feature all you have to do is type
/boots
in your console or adding
bind b "boots"
to your autoexec.cfg (in your mod dir)
Easy huh ?
N-joy this tutorial...
until next time... mail me for problems and so on.
|