Navigation

 More Starting Weapons Feature Type: Coding Tutorials     Added: 05/01  
  Author: Corven 

This is a really easy change but could have alot of effect on any mod, were going to make the player start with more weapons.

Gimme more weapons

Code to be Added or Changed

g_client.c

Open up g_client.c and look for the 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;
}

This assigns the player's inventory one machinegun and appropriate ammo, depending on whether or not it's a team game. Now were going to give the player an additional weapon by adding this:

client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_SHOTGUN );
client->ps.ammo[WP_SHOTGUN] = 20;


This will now start him off with the machinegun & the shotgun, but were not finished yet, although we have told it what weapons to start with, we have to get it to also load in the shotgun media, incase it doesn't exist in the map.

g_items.c

We need to precache the shotgun media, so its available in the game.
Find the ClearRegisteredItems( void ) function and add this line to list of weapons:

RegisterItem( BG_FindItemForWeapon( WP_SHOTGUN ) );

While were at it, here's a list of the weapons available:
WP_GAUNTLET, WP_LIGHTNING, WP_SHOTGUN, WP_MACHINEGUN, WP_GRENADE_LAUNCHER, WP_ROCKET_LAUNCHER, WP_PLASMAGUN, WP_RAILGUN, WP_BFG

Comments »



  Page 1

  Comments ( 0 )


  Features Index

  Home

Copyright © 2001 MGON International AB - Privacy statement