Can't get item to spawn on players at startup


I’ve been trying variations on an idea i had for about six months off and on now. Eventually I got it to actually compile, but it looks like it spawns a small health and when I try to “use item” it says no item to use. I can’t pickup holdables until I use it, but it does nothing. I’ve tried modifying code for the ‘give_all’ cheat, and code from weapon banning tutorials… help?
in g_items.
void ClearRegisteredItems( void ) {
/* int it;
gentity_t it_ent;/
gclient_t *client;

memset( itemRegistered, 0, sizeof( itemRegistered ) );

//it = BG_FindItem (name);

/* it = BG_FindItem (“Medkit”);

		it_ent = G_Spawn();
		VectorCopy( client->r.currentOrigin, it_ent->s.origin );
		it_ent->classname = it->classname;
		G_SpawnItem (it_ent, it);
		FinishSpawningItem(it_ent );
		memset( &trace, 0, sizeof( trace ) );
		Touch_Item (it_ent, ent, &trace);*/

// players always start with the base weapon
//player->client->ps.stats[STAT_HOLDABLE_ITEM] = BG_FindItem( "Portal" ) - bg_itemlist;
client->ps.stats[STAT_HOLDABLE_ITEM] = BG_FindItem( "Medkit" ) - bg_itemlist;

RegisterItem( BG_FindItem( "Medkit" ));
itemRegistered[ BG_FindItem( "Medkit" ) - bg_itemlist ] = qtrue;


Hi there !

I haven’t been modding since a very long time, but I’ll try to help.

The only holdable items in Quake 3 are the teleporter and the medkit. The weapons and the powerups are not holdable items and are handled separately.

So, what do you want to do ? You want to have all players to spawn with a medkit ?

I just checked the code, and maybe you should try to use the ‘Pickup_Holdable’ function (in g_items.c, line 195) ?

I don’t know if you’re allowed to use it in the function that handles player spawning, but let’s check it out :
g_client.c, void ClientSpawn(gentity_t *ent) :
Here’s line 1179 :

	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;

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

// health will count down towards max_health
ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] + 25;

You can investigate and test things around here.

The funny thing about what you’re trying to do, is that’s pretty easy to do from a level designers perspective, there are tutorials to make players spawn with (or without) certain weapons, just by connecting the player spawn entities to weapons or items. But to generalize this you’ll have to add some code :smile:

Good luck !


Man, thank you for your example. I’ll take a look and maybe my luck will change with this. Thanks!


Got it! I’ll be happy to share, as I don’t think anyone has done this before…
In g_client in the void ClientSpawn function, not sure what lines because the changes
are so many in my mod. But there’s these lines.

VectorCopy (playerMaxs, ent->r.maxs);

client->ps.clientNum = index;

client->ps.stats[STAT_HOLDABLE_ITEM] = BG_FindItem( “Medkit” ) - bg_itemlist;

Then in g_items, in void ClearRegisteredItems
this line goes in under the references to the gauntlet and machinegun

itemRegistered[ BG_FindItem( "Medkit" ) - bg_itemlist ] = qtrue; //Clint

That did it. Hope it helps someone else who would like to re-create this type of effect.

Thanks DMEAT!