TUTORIAL 12 - Grapple
by Matt Ownby
1/15/99, 5:12 AM
Ok the Q3 source code was just released a few hours ago and I have had my eyes pouring
over the contents ever since. Fortunately, much of it is similar to Quake 2. There is also a
lot of new stuff.
As many of you know, the grappling hook was added into the code, but removed later in
development. Therefore, it is just a matter of patching the code a little bit to unlock the
grappling hook for general use < evil grin >. Here is a quick (very quick) tutorial on how to
patch your source code to turn on the grappling hook.
NOTE: Due to my small modifications, line numbers will be different from the stock source. All
my modifications begin with "// start MATT" and "// end MATT".
1. Modify g_client.c (part of the "game" DLL)
Go to about line 939
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GAUNTLET );
// start MATT
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GRAPPLING_HOOK);
// end MATT
client->ps.ammo[WP_GAUNTLET] = -1;
client->ps.ammo[WP_GRAPPLING_HOOK] = -1;
Go to about line 991
// start MATT
for ( i = WP_NUM_WEAPONS - 2 ; i > 0 ; i-- ) {
// changed the -1 to a -2 so the grapple isn't selected by default
// end MATT
if ( client->ps.stats[STAT_WEAPONS] & ( 1 << i ) ) {
client->ps.weapon = i;
break;
}
}
2. Modify ui_controls2.c (part of the "ui" DLL)
Go to about line 105 and insert this value for ID_WEAPON10. The array g_bindings[]
uses these values as an index for all MTYPE_ACTION controls.
If they don't match their order in g_bindings[] then errors will arise.
The remaining values need to be bumped up by one as well, to retain uniqueness.
#define ID_CHAT3 32
#define ID_CHAT4 33
// start MATT
#define ID_WEAPON10 34 // grappling hook
// all others
#define ID_FREELOOK 35
#define ID_INVERTMOUSE 36
#define ID_ALWAYSRUN 37
#define ID_AUTOSWITCH 38
#define ID_MOUSESPEED 39
#define ID_JOYENABLE 40
#define ID_JOYTHRESHOLD 41
#define ID_SMOOTHMOUSE 42
// end MATT
Go to about line 170
menuaction_s bfg;
// start MATT
menuaction_s hook;
// end MATT
menuaction_s attack;
Go to about line 245
{"messagemode4", "chat - attacker", ID_CHAT4, ANIM_CHAT, -1, -1, -1, -1},
// start MATT
{"weapon 10", "grappling hook", ID_WEAPON10, ANIM_WEAPON10, '0', -1, -1, -1},
// stop MATT
{(char*)NULL, (char*)NULL, 0, 0, -1, -1, -1, -1},
Go to about line 299
(menucommon_s *)&s_controls.bfg,
// start MATT
(menucommon_s *)&s_controls.hook,
// end MATT
NULL,
Go to about line 1386
s_controls.bfg.generic.type = MTYPE_ACTION;
s_controls.bfg.generic.flags =
QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.bfg.generic.callback = Controls_ActionEvent;
s_controls.bfg.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.bfg.generic.id = ID_WEAPON9;
// start MATT
s_controls.hook.generic.type = MTYPE_ACTION;
s_controls.hook.generic.flags =
QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.hook.generic.callback = Controls_ActionEvent;
s_controls.hook.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.hook.generic.id = ID_WEAPON10;
// end MATT
s_controls.attack.generic.type = MTYPE_ACTION;
s_controls.attack.generic.flags =
QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN;
s_controls.attack.generic.callback = Controls_ActionEvent;
s_controls.attack.generic.ownerdraw = Controls_DrawKeyBinding;
s_controls.attack.generic.id = ID_ATTACK;
That's it! And yes, this patch _does_ work for CTF (I tested it briefly).
Contact Information:
I can be found on irc.enterthegame.com in #JUN at all times, although sometimes I will
obviously be away. My nick is JB[JUN].
I am not going to post my email address on this page because I am sick of getting spam
every day.
Here are other programming projects I am working on (you can get my email address from
these pages hehe):
http://daphne.rulecity.com/
Balance of Power (look for the Quake 3 version soon muwahaha)
|