Quake Style - Quake 3
Tutorials Newbie Tutorials - Grappling Hook How to enable Zoid's grappling
hook (the infamous "weapon 10") for Q3!
|
I was
going over the source and noticed that Quake 3 already has a grappling hook
programmed by our lovely friend Zoid! It's not offhand (as far as I know, only
been looking at the source for an hour), but the models, icons, and effects are
all in the Q3 PK3 file. As of now, the model is just gray - unskinned, and the
beam effect and sound come from the lightning gun (hint hint....new ability for
lightning gun?). I'll show you how to give the player starting weapons by using
the grappling hook as an example.
First make sure you're using the game
project, then open up g_client.c. Go to the void ClientSpawn(gentity_t *ent)
function and find these lines:
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MACHINEGUN );
if ( g_gametype.integer == GT_TEAM ) {
client->ps.ammo[WP_MACHINEGUN] = 50;
} else {
client->ps.ammo[WP_MACHINEGUN] = 100;
}
These essentially assign the player's inventory to one
machinegun and some bullets, depending on whether or not it's teamplay.
Now to give the player additional weapons you'll use something like
this:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GRAPPLING_HOOK );
Put the above line just under the ones having to do with the
machinegun. Notice that I'm using |= instead of just = as done in the original
code above for the machinegun. Since the machinegun is the FIRST weapon
assigned, you can use the assignment operator, but additional weapons need to
use the |= in order to add them to the inventory, without overwriting the first
one. If you look a few lines down in the code you'll see that the gauntlet is
added to the player's inventory in the same way as I showed you with the
grappling hook above. The above line will let you give players any weapon at
spawning, just by changing the WP_ enumeration.
Now open up g_items.c.
Since we're going to be using some of the models and effects for the grappling
hook, and no maps have the actual weapon, we need to precache it. We also need
to precache the lightning gun so the grappling rope is also loaded. Find the
void ClearRegisteredItems( void ) function and add these to the existing list of
weapons to be registered:
// Willi - Grappling Hook
RegisterItem( BG_FindItemForWeapon( WP_LIGHTNING ) );
RegisterItem( BG_FindItemForWeapon( WP_GRAPPLING_HOOK ) );
Here's the complete list of weapon names you can use in
g_client.c:
WP_GAUNTLET
WP_LIGHTNING
WP_SHOTGUN
WP_MACHINEGUN
WP_GRENADE_LAUNCHER
WP_ROCKET_LAUNCHER
WP_PLASMAGUN
WP_RAILGUN
WP_BFG
WP_GRAPPLING_HOOK
I hope you enjoy and use the grappling hook, which is activated
by pressing 0 (or if that doesn't work, try /weapon 10 at the console) and the
assignment of weapons.
--
Credits:
Tutorial by Willi
Return to QS Tutorials
-- Important:
If you
do use something from QuakeStyle in your mod, please give us credit.
Our code is copyrighted, but we give permission to everyone to
use it in any way they see fit, as long as we are recognized.