// Using Quake2 3.17's built-in support for VWep: // You can figure out how to do 3.17 VWep by reading the 3.15/3.17 Q2 release // notes and looking at the DM2 specs maintained by Uwe Girlich at // http://www.planetquake.com/demospecs/dm2/dm2.html // This code is obviously not the most efficient and there's some // double maintenance, but it's the simplest way to show how things work. // I'm assuming you have Hentai's VWep code patched into your // mod so you already have the calls to ShowGun() in the correct places. // If you don't have Hentai's original VWep code, get it here: // ftp://ftp.telefragged.com/pub/vwep/vwep_src.zip // You can easily rewrite this code to eliminate double maintenance // and make it more much efficient, which is what I've done for L-Fire CTF. // Thanks to NaTS and Thomas (don't know their real/last names) on the // PlanetQuake Q2 Coding list for discussing this with me and helping to // get it working properly. // Questions? // Email: LFire@yyz.com // Web: http://yyz.com/LFire /**************************************************************************/ // In file g_spawn.c void SP_worldspawn (edict_t *ent) { // ... // Old stuff... gi.soundindex ("*pain25_1.wav"); gi.soundindex ("*pain25_2.wav"); gi.soundindex ("*pain50_1.wav"); gi.soundindex ("*pain50_2.wav"); gi.soundindex ("*pain75_1.wav"); gi.soundindex ("*pain75_2.wav"); gi.soundindex ("*pain100_1.wav"); gi.soundindex ("*pain100_2.wav"); // New stuff. // Precache the visible weapon models. // I figured this part out by reading the 3.15/3.17 Q2 release notes. gi.modelindex( "#w_blaster.md2"); gi.modelindex( "#w_shotgun.md2"); gi.modelindex( "#w_sshotgun.md2"); gi.modelindex( "#w_machinegun.md2"); gi.modelindex( "#w_chaingun.md2"); gi.modelindex( "#a_grenades.md2"); gi.modelindex( "#w_glauncher.md2"); gi.modelindex( "#w_rlauncher.md2"); gi.modelindex( "#w_hyperblaster.md2"); gi.modelindex( "#w_railgun.md2"); gi.modelindex( "#w_bfg.md2"); gi.modelindex( "#w_grapple.md2"); // ... } /**************************************************************************/ // In file p_weapon.c // Replace Hentai's ShowGun() with this new version. void ShowGun( edict_t *ent) { int nIndex; char *pszIcon; // No weapon? if ( !ent->client->pers.weapon) { ent->s.modelindex2 = 0; return; } // Determine the weapon's precache index. nIndex = 0; pszIcon = ent->client->pers.weapon->icon; if ( strcmp( pszIcon, "w_blaster") == 0) nIndex = 1; else if ( strcmp( pszIcon, "w_shotgun") == 0) nIndex = 2; else if ( strcmp( pszIcon, "w_sshotgun") == 0) nIndex = 3; else if ( strcmp( pszIcon, "w_machinegun") == 0) nIndex = 4; else if ( strcmp( pszIcon, "w_chaingun") == 0) nIndex = 5; else if ( strcmp( pszIcon, "a_grenades") == 0) nIndex = 6; else if ( strcmp( pszIcon, "w_glauncher") == 0) nIndex = 7; else if ( strcmp( pszIcon, "w_rlauncher") == 0) nIndex = 8; else if ( strcmp( pszIcon, "w_hyperblaster") == 0) nIndex = 9; else if ( strcmp( pszIcon, "w_railgun") == 0) nIndex = 10; else if ( strcmp( pszIcon, "w_bfg") == 0) nIndex = 11; else if ( strcmp( pszIcon, "w_grapple") == 0) nIndex = 12; // Clear previous weapon model. ent->s.skinnum &= 255; // Set new weapon model. ent->s.skinnum |= (nIndex << 8); ent->s.modelindex2 = 255; }