With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
Discuss & improve the game engine.

Moderators: Tequila, sparcdr, torhu

nobots/nohumans attributes for items

Postby TheDoctor » Fri Mar 18, 2011 11:01 pm

For info_player_deathmatch entities (=spawnpoints), there exist attributes nobots "1" and nohumans "1", which can be used to exclude bots and humans from using a particular spawn point. Some mappers assume these attributes work also for items such as pickup_money while they actually have no effect at all (for SG1.0 as well as SG1.1b4). To prevent bots from accessing certain items, you currently have to use botclips!

Nevertheless, SG can be changed to add these attributes to items:
In game/g_items.c in void G_SpawnItem(gentity_t, gitem_t), add
Code: Select all
   int      i=0;

   G_SpawnInt( "nobots", "0", &i);
   if ( i ) {
      ent->flags |= FL_NO_BOTS;
   G_SpawnInt( "nohumans", "0", &i );
   if ( i ) {
      ent->flags |= FL_NO_HUMANS;
This will read out the attributes and set appropriate flags.

In game/bg_misc.c in qboolean BG_CanItemBeGrabbed(int, const entityState_t, const playerState_t), add
Code: Select all
   gentity_t   *item_ent;
   gentity_t *player_ent;
   item_ent = &g_entities[ ent->number ];
   player_ent = &g_entities[ ps->clientNum ];

   if ( ( item_ent->flags & FL_NO_BOTS ) && ( player_ent->r.svFlags & SVF_BOT ) ) {
      return qfalse;
   // just to be symmetric, we have a nohumans option...
   if ( ( item_ent->flags & FL_NO_HUMANS ) && !( player_ent->r.svFlags & SVF_BOT ) ) {
      return qfalse;
A problem of the second addition is that one is not supposed to use gentity_t in bg_* files (bg_ files are shared between game and cgame modules). While you might distinguish bots from humans by ping, a variable available in playerState_t, I currently don't know an alternative way to access the FL_NO_* flags.
User avatar
Smokin' Amigo!
Posts: 749
Joined: Sun Jun 06, 2010 3:31 am

Return to Code

Show Sidebar
Show Sidebar

User Control Panel