Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

g_items.c File Reference

#include "g_local.h"

Include dependency graph for g_items.c:

Include dependency graph

Go to the source code of this file.

Defines

#define RESPAWN_AMMO   40
#define RESPAWN_ARMOR   25
#define RESPAWN_HEALTH   35
#define RESPAWN_HOLDABLE   60
#define RESPAWN_MEGAHEALTH   35
#define RESPAWN_POWERUP   120

Functions

void Add_Ammo (gentity_t *ent, int weapon, int count)
void ClearRegisteredItems (void)
gentity_tDrop_Item (gentity_t *ent, gitem_t *item, float angle)
void FinishSpawningItem (gentity_t *ent)
void G_BounceItem (gentity_t *ent, trace_t *trace)
void G_CheckTeamItems (void)
int G_ItemDisabled (gitem_t *item)
void G_RunItem (gentity_t *ent)
void G_SpawnItem (gentity_t *ent, gitem_t *item)
gentity_tLaunchItem (gitem_t *item, vec3_t origin, vec3_t velocity)
int Pickup_Ammo (gentity_t *ent, gentity_t *other)
int Pickup_Armor (gentity_t *ent, gentity_t *other)
int Pickup_Health (gentity_t *ent, gentity_t *other)
int Pickup_Holdable (gentity_t *ent, gentity_t *other)
int Pickup_Powerup (gentity_t *ent, gentity_t *other)
int Pickup_Weapon (gentity_t *ent, gentity_t *other)
void RegisterItem (gitem_t *item)
void RespawnItem (gentity_t *ent)
void SaveRegisteredItems (void)
void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace)
void Use_Item (gentity_t *ent, gentity_t *other, gentity_t *activator)

Variables

qboolean itemRegistered [MAX_ITEMS]


Define Documentation

#define RESPAWN_AMMO   40
 

Definition at line 41 of file g_items.c.

#define RESPAWN_ARMOR   25
 

Definition at line 39 of file g_items.c.

#define RESPAWN_HEALTH   35
 

Definition at line 40 of file g_items.c.

#define RESPAWN_HOLDABLE   60
 

Definition at line 42 of file g_items.c.

#define RESPAWN_MEGAHEALTH   35
 

Definition at line 43 of file g_items.c.

#define RESPAWN_POWERUP   120
 

Definition at line 44 of file g_items.c.


Function Documentation

void Add_Ammo gentity_t ent,
int  weapon,
int  count
 

Definition at line 209 of file g_items.c.

References playerState_s::ammo, gentity_s::client, gentity_t, and gclient_s::ps.

Referenced by Pickup_Ammo(), and Pickup_Weapon().

00210 {
00211     ent->client->ps.ammo[weapon] += count;
00212     if ( ent->client->ps.ammo[weapon] > 200 ) {
00213         ent->client->ps.ammo[weapon] = 200;
00214     }
00215 }

void ClearRegisteredItems void   ) 
 

Definition at line 800 of file g_items.c.

References BG_FindItem(), BG_FindItemForWeapon(), g_gametype, itemRegistered, memset(), RegisterItem(), WP_GAUNTLET, and WP_MACHINEGUN.

Referenced by G_InitGame().

00800                                   {
00801     memset( itemRegistered, 0, sizeof( itemRegistered ) );
00802 
00803     // players always start with the base weapon
00804     RegisterItem( BG_FindItemForWeapon( WP_MACHINEGUN ) );
00805     RegisterItem( BG_FindItemForWeapon( WP_GAUNTLET ) );
00806 #ifdef MISSIONPACK
00807     if( g_gametype.integer == GT_HARVESTER ) {
00808         RegisterItem( BG_FindItem( "Red Cube" ) );
00809         RegisterItem( BG_FindItem( "Blue Cube" ) );
00810     }
00811 #endif
00812 }

Here is the call graph for this function:

gentity_t* Drop_Item gentity_t ent,
gitem_t item,
float  angle
 

Definition at line 613 of file g_items.c.

References AngleVectors(), entityState_s::apos, crandom, gentity_t, gitem_t, LaunchItem(), NULL, entityState_s::pos, gentity_s::s, trajectory_t::trBase, vec3_t, VectorCopy, and VectorScale.

Referenced by ClientEvents(), and TossClientItems().

00613                                                                    {
00614     vec3_t  velocity;
00615     vec3_t  angles;
00616 
00617     VectorCopy( ent->s.apos.trBase, angles );
00618     angles[YAW] += angle;
00619     angles[PITCH] = 0;  // always forward
00620 
00621     AngleVectors( angles, velocity, NULL, NULL );
00622     VectorScale( velocity, 150, velocity );
00623     velocity[2] += 200 + crandom() * 50;
00624     
00625     return LaunchItem( item, ent->s.pos.trBase, velocity );
00626 }

Here is the call graph for this function:

void FinishSpawningItem gentity_t ent  ) 
 

Definition at line 650 of file g_items.c.

References gentity_s::classname, entityShared_t::contents, crandom, entityState_s::eFlags, entityState_s::eType, gentity_s::flags, G_FreeEntity(), G_Printf(), G_SetOrigin(), gentity_t, gitem_s::giType, entityState_s::groundEntityNum, gentity_s::item, ITEM_RADIUS, level, MASK_SOLID, entityShared_t::maxs, entityShared_t::mins, entityState_s::modelindex, entityState_s::modelindex2, gentity_s::nextthink, entityState_s::number, entityState_s::origin, gentity_s::r, respawn(), gentity_s::s, gentity_s::spawnflags, gentity_s::targetname, gentity_s::think, level_locals_t::time, gentity_s::touch, tr, trap_LinkEntity(), trap_Trace(), gentity_s::use, vec3_t, VectorSet, and vtos().

Referenced by Cmd_Give_f().

00650                                           {
00651     trace_t     tr;
00652     vec3_t      dest;
00653 
00654     VectorSet( ent->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS );
00655     VectorSet( ent->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS );
00656 
00657     ent->s.eType = ET_ITEM;
00658     ent->s.modelindex = ent->item - bg_itemlist;        // store item number in modelindex
00659     ent->s.modelindex2 = 0; // zero indicates this isn't a dropped item
00660 
00661     ent->r.contents = CONTENTS_TRIGGER;
00662     ent->touch = Touch_Item;
00663     // useing an item causes it to respawn
00664     ent->use = Use_Item;
00665 
00666     if ( ent->spawnflags & 1 ) {
00667         // suspended
00668         G_SetOrigin( ent, ent->s.origin );
00669     } else {
00670         // drop to floor
00671         VectorSet( dest, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] - 4096 );
00672         trap_Trace( &tr, ent->s.origin, ent->r.mins, ent->r.maxs, dest, ent->s.number, MASK_SOLID );
00673         if ( tr.startsolid ) {
00674             G_Printf ("FinishSpawningItem: %s startsolid at %s\n", ent->classname, vtos(ent->s.origin));
00675             G_FreeEntity( ent );
00676             return;
00677         }
00678 
00679         // allow to ride movers
00680         ent->s.groundEntityNum = tr.entityNum;
00681 
00682         G_SetOrigin( ent, tr.endpos );
00683     }
00684 
00685     // team slaves and targeted items aren't present at start
00686     if ( ( ent->flags & FL_TEAMSLAVE ) || ent->targetname ) {
00687         ent->s.eFlags |= EF_NODRAW;
00688         ent->r.contents = 0;
00689         return;
00690     }
00691 
00692     // powerups don't spawn in for a while
00693     if ( ent->item->giType == IT_POWERUP ) {
00694         float   respawn;
00695 
00696         respawn = 45 + crandom() * 15;
00697         ent->s.eFlags |= EF_NODRAW;
00698         ent->r.contents = 0;
00699         ent->nextthink = level.time + respawn * 1000;
00700         ent->think = RespawnItem;
00701         return;
00702     }
00703 
00704 
00705     trap_LinkEntity (ent);
00706 }

Here is the call graph for this function:

void G_BounceItem gentity_t ent,
trace_t trace
 

Definition at line 915 of file g_items.c.

References BG_EvaluateTrajectoryDelta(), entityShared_t::currentOrigin, DotProduct, trace_t::endpos, trace_t::entityNum, trace_t::fraction, G_SetOrigin(), gentity_t, entityState_s::groundEntityNum, level, cplane_s::normal, gentity_s::physicsBounce, trace_t::plane, entityState_s::pos, level_locals_t::previousTime, gentity_s::r, gentity_s::s, SnapVector, level_locals_t::time, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, vec3_t, VectorAdd, VectorCopy, VectorMA, and VectorScale.

Referenced by G_RunItem().

00915                                                     {
00916     vec3_t  velocity;
00917     float   dot;
00918     int     hitTime;
00919 
00920     // reflect the velocity on the trace plane
00921     hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
00922     BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
00923     dot = DotProduct( velocity, trace->plane.normal );
00924     VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );
00925 
00926     // cut the velocity to keep from bouncing forever
00927     VectorScale( ent->s.pos.trDelta, ent->physicsBounce, ent->s.pos.trDelta );
00928 
00929     // check for stop
00930     if ( trace->plane.normal[2] > 0 && ent->s.pos.trDelta[2] < 40 ) {
00931         trace->endpos[2] += 1.0;    // make sure it is off ground
00932         SnapVector( trace->endpos );
00933         G_SetOrigin( ent, trace->endpos );
00934         ent->s.groundEntityNum = trace->entityNum;
00935         return;
00936     }
00937 
00938     VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin);
00939     VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );
00940     ent->s.pos.trTime = level.time;
00941 }

Here is the call graph for this function:

void G_CheckTeamItems void   ) 
 

Definition at line 716 of file g_items.c.

References BG_FindItem(), FOFS, G_Find(), g_gametype, G_Printf(), gentity_t, gitem_t, itemRegistered, S_COLOR_YELLOW, and Team_InitGame().

Referenced by G_InitGame().

00716                               {
00717 
00718     // Set up team stuff
00719     Team_InitGame();
00720 
00721     if( g_gametype.integer == GT_CTF ) {
00722         gitem_t *item;
00723 
00724         // check for the two flags
00725         item = BG_FindItem( "Red Flag" );
00726         if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
00727             G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_redflag in map" );
00728         }
00729         item = BG_FindItem( "Blue Flag" );
00730         if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
00731             G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_blueflag in map" );
00732         }
00733     }
00734 #ifdef MISSIONPACK
00735     if( g_gametype.integer == GT_1FCTF ) {
00736         gitem_t *item;
00737 
00738         // check for all three flags
00739         item = BG_FindItem( "Red Flag" );
00740         if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
00741             G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_redflag in map" );
00742         }
00743         item = BG_FindItem( "Blue Flag" );
00744         if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
00745             G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_blueflag in map" );
00746         }
00747         item = BG_FindItem( "Neutral Flag" );
00748         if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
00749             G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_neutralflag in map" );
00750         }
00751     }
00752 
00753     if( g_gametype.integer == GT_OBELISK ) {
00754         gentity_t   *ent;
00755 
00756         // check for the two obelisks
00757         ent = NULL;
00758         ent = G_Find( ent, FOFS(classname), "team_redobelisk" );
00759         if( !ent ) {
00760             G_Printf( S_COLOR_YELLOW "WARNING: No team_redobelisk in map" );
00761         }
00762 
00763         ent = NULL;
00764         ent = G_Find( ent, FOFS(classname), "team_blueobelisk" );
00765         if( !ent ) {
00766             G_Printf( S_COLOR_YELLOW "WARNING: No team_blueobelisk in map" );
00767         }
00768     }
00769 
00770     if( g_gametype.integer == GT_HARVESTER ) {
00771         gentity_t   *ent;
00772 
00773         // check for all three obelisks
00774         ent = NULL;
00775         ent = G_Find( ent, FOFS(classname), "team_redobelisk" );
00776         if( !ent ) {
00777             G_Printf( S_COLOR_YELLOW "WARNING: No team_redobelisk in map" );
00778         }
00779 
00780         ent = NULL;
00781         ent = G_Find( ent, FOFS(classname), "team_blueobelisk" );
00782         if( !ent ) {
00783             G_Printf( S_COLOR_YELLOW "WARNING: No team_blueobelisk in map" );
00784         }
00785 
00786         ent = NULL;
00787         ent = G_Find( ent, FOFS(classname), "team_neutralobelisk" );
00788         if( !ent ) {
00789             G_Printf( S_COLOR_YELLOW "WARNING: No team_neutralobelisk in map" );
00790         }
00791     }
00792 #endif
00793 }

Here is the call graph for this function:

int G_ItemDisabled gitem_t item  ) 
 

Definition at line 862 of file g_items.c.

References gitem_s::classname, Com_sprintf(), gitem_t, name, and trap_Cvar_VariableIntegerValue().

Referenced by G_SpawnItem().

00862                                     {
00863 
00864     char name[128];
00865 
00866     Com_sprintf(name, sizeof(name), "disable_%s", item->classname);
00867     return trap_Cvar_VariableIntegerValue( name );
00868 }

Here is the call graph for this function:

void G_RunItem gentity_t ent  ) 
 

Definition at line 950 of file g_items.c.

References BG_EvaluateTrajectory(), gentity_s::clipmask, entityShared_t::currentOrigin, G_BounceItem(), G_FreeEntity(), G_RunThink(), gentity_t, gitem_s::giType, entityState_s::groundEntityNum, gentity_s::item, level, mask, MASK_PLAYERSOLID, entityShared_t::maxs, entityShared_t::mins, entityShared_t::ownerNum, entityState_s::pos, gentity_s::r, gentity_s::s, Team_FreeEntity(), level_locals_t::time, tr, trap_LinkEntity(), trap_PointContents(), trap_Trace(), trajectory_t::trTime, trajectory_t::trType, vec3_t, and VectorCopy.

Referenced by G_RunFrame().

00950                                  {
00951     vec3_t      origin;
00952     trace_t     tr;
00953     int         contents;
00954     int         mask;
00955 
00956     // if groundentity has been set to -1, it may have been pushed off an edge
00957     if ( ent->s.groundEntityNum == -1 ) {
00958         if ( ent->s.pos.trType != TR_GRAVITY ) {
00959             ent->s.pos.trType = TR_GRAVITY;
00960             ent->s.pos.trTime = level.time;
00961         }
00962     }
00963 
00964     if ( ent->s.pos.trType == TR_STATIONARY ) {
00965         // check think function
00966         G_RunThink( ent );
00967         return;
00968     }
00969 
00970     // get current position
00971     BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
00972 
00973     // trace a line from the previous position to the current position
00974     if ( ent->clipmask ) {
00975         mask = ent->clipmask;
00976     } else {
00977         mask = MASK_PLAYERSOLID & ~CONTENTS_BODY;//MASK_SOLID;
00978     }
00979     trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, 
00980         ent->r.ownerNum, mask );
00981 
00982     VectorCopy( tr.endpos, ent->r.currentOrigin );
00983 
00984     if ( tr.startsolid ) {
00985         tr.fraction = 0;
00986     }
00987 
00988     trap_LinkEntity( ent ); // FIXME: avoid this for stationary?
00989 
00990     // check think function
00991     G_RunThink( ent );
00992 
00993     if ( tr.fraction == 1 ) {
00994         return;
00995     }
00996 
00997     // if it is in a nodrop volume, remove it
00998     contents = trap_PointContents( ent->r.currentOrigin, -1 );
00999     if ( contents & CONTENTS_NODROP ) {
01000         if (ent->item && ent->item->giType == IT_TEAM) {
01001             Team_FreeEntity(ent);
01002         } else {
01003             G_FreeEntity( ent );
01004         }
01005         return;
01006     }
01007 
01008     G_BounceItem( ent, &tr );
01009 }

Here is the call graph for this function:

void G_SpawnItem gentity_t ent,
gitem_t item
 

Definition at line 880 of file g_items.c.

References FRAMETIME, G_ItemDisabled(), G_SoundIndex(), G_SpawnFloat(), entityState_s::generic1, gentity_t, gitem_t, gitem_s::giType, gentity_s::item, level, gentity_s::nextthink, gentity_s::physicsBounce, gentity_s::random, RegisterItem(), gentity_s::s, gentity_s::spawnflags, gentity_s::speed, gentity_s::think, level_locals_t::time, and gentity_s::wait.

Referenced by Cmd_Give_f(), and G_CallSpawn().

00880                                                  {
00881     G_SpawnFloat( "random", "0", &ent->random );
00882     G_SpawnFloat( "wait", "0", &ent->wait );
00883 
00884     RegisterItem( item );
00885     if ( G_ItemDisabled(item) )
00886         return;
00887 
00888     ent->item = item;
00889     // some movers spawn on the second frame, so delay item
00890     // spawns until the third frame so they can ride trains
00891     ent->nextthink = level.time + FRAMETIME * 2;
00892     ent->think = FinishSpawningItem;
00893 
00894     ent->physicsBounce = 0.50;      // items are bouncy
00895 
00896     if ( item->giType == IT_POWERUP ) {
00897         G_SoundIndex( "sound/items/poweruprespawn.wav" );
00898         G_SpawnFloat( "noglobalsound", "0", &ent->speed);
00899     }
00900 
00901 #ifdef MISSIONPACK
00902     if ( item->giType == IT_PERSISTANT_POWERUP ) {
00903         ent->s.generic1 = ent->spawnflags;
00904     }
00905 #endif
00906 }

Here is the call graph for this function:

gentity_t* LaunchItem gitem_t item,
vec3_t  origin,
vec3_t  velocity
 

Definition at line 563 of file g_items.c.

References gentity_s::classname, gitem_s::classname, entityShared_t::contents, entityState_s::eFlags, entityState_s::eType, gentity_s::flags, g_gametype, G_SetOrigin(), G_Spawn(), gentity_t, gitem_t, gitem_s::giType, GT_CTF, gentity_s::item, ITEM_RADIUS, level, entityShared_t::maxs, entityShared_t::mins, entityState_s::modelindex, entityState_s::modelindex2, gentity_s::nextthink, entityState_s::pos, gentity_s::r, gentity_s::s, Team_CheckDroppedItem(), gentity_s::think, level_locals_t::time, gentity_s::touch, trap_LinkEntity(), trajectory_t::trDelta, trajectory_t::trTime, trajectory_t::trType, VectorCopy, and VectorSet.

Referenced by Drop_Item().

00563                                                                        {
00564     gentity_t   *dropped;
00565 
00566     dropped = G_Spawn();
00567 
00568     dropped->s.eType = ET_ITEM;
00569     dropped->s.modelindex = item - bg_itemlist; // store item number in modelindex
00570     dropped->s.modelindex2 = 1; // This is non-zero is it's a dropped item
00571 
00572     dropped->classname = item->classname;
00573     dropped->item = item;
00574     VectorSet (dropped->r.mins, -ITEM_RADIUS, -ITEM_RADIUS, -ITEM_RADIUS);
00575     VectorSet (dropped->r.maxs, ITEM_RADIUS, ITEM_RADIUS, ITEM_RADIUS);
00576     dropped->r.contents = CONTENTS_TRIGGER;
00577 
00578     dropped->touch = Touch_Item;
00579 
00580     G_SetOrigin( dropped, origin );
00581     dropped->s.pos.trType = TR_GRAVITY;
00582     dropped->s.pos.trTime = level.time;
00583     VectorCopy( velocity, dropped->s.pos.trDelta );
00584 
00585     dropped->s.eFlags |= EF_BOUNCE_HALF;
00586 #ifdef MISSIONPACK
00587     if ((g_gametype.integer == GT_CTF || g_gametype.integer == GT_1FCTF)            && item->giType == IT_TEAM) { // Special case for CTF flags
00588 #else
00589     if (g_gametype.integer == GT_CTF && item->giType == IT_TEAM) { // Special case for CTF flags
00590 #endif
00591         dropped->think = Team_DroppedFlagThink;
00592         dropped->nextthink = level.time + 30000;
00593         Team_CheckDroppedItem( dropped );
00594     } else { // auto-remove after 30 seconds
00595         dropped->think = G_FreeEntity;
00596         dropped->nextthink = level.time + 30000;
00597     }
00598 
00599     dropped->flags = FL_DROPPED_ITEM;
00600 
00601     trap_LinkEntity (dropped);
00602 
00603     return dropped;
00604 }

Here is the call graph for this function:

int Pickup_Ammo gentity_t ent,
gentity_t other
 

Definition at line 217 of file g_items.c.

References Add_Ammo(), gentity_s::count, gentity_t, gitem_s::giTag, gentity_s::item, and gitem_s::quantity.

Referenced by Touch_Item().

00218 {
00219     int     quantity;
00220 
00221     if ( ent->count ) {
00222         quantity = ent->count;
00223     } else {
00224         quantity = ent->item->quantity;
00225     }
00226 
00227     Add_Ammo (other, ent->item->giTag, quantity);
00228 
00229     return RESPAWN_AMMO;
00230 }

Here is the call graph for this function:

int Pickup_Armor gentity_t ent,
gentity_t other
 

Definition at line 317 of file g_items.c.

References bg_itemlist, gentity_s::client, gentity_t, gitem_s::giTag, gentity_s::item, gclient_s::ps, gitem_s::quantity, and playerState_s::stats.

Referenced by Touch_Item().

00317                                                      {
00318 #ifdef MISSIONPACK
00319     int     upperBound;
00320 
00321     other->client->ps.stats[STAT_ARMOR] += ent->item->quantity;
00322 
00323     if( other->client && bg_itemlist[other->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {
00324         upperBound = other->client->ps.stats[STAT_MAX_HEALTH];
00325     }
00326     else {
00327         upperBound = other->client->ps.stats[STAT_MAX_HEALTH] * 2;
00328     }
00329 
00330     if ( other->client->ps.stats[STAT_ARMOR] > upperBound ) {
00331         other->client->ps.stats[STAT_ARMOR] = upperBound;
00332     }
00333 #else
00334     other->client->ps.stats[STAT_ARMOR] += ent->item->quantity;
00335     if ( other->client->ps.stats[STAT_ARMOR] > other->client->ps.stats[STAT_MAX_HEALTH] * 2 ) {
00336         other->client->ps.stats[STAT_ARMOR] = other->client->ps.stats[STAT_MAX_HEALTH] * 2;
00337     }
00338 #endif
00339 
00340     return RESPAWN_ARMOR;
00341 }

int Pickup_Health gentity_t ent,
gentity_t other
 

Definition at line 278 of file g_items.c.

References bg_itemlist, gentity_s::client, gentity_s::count, gentity_t, gitem_s::giTag, gentity_s::health, gentity_s::item, max, gclient_s::ps, gitem_s::quantity, and playerState_s::stats.

Referenced by Touch_Item().

00278                                                      {
00279     int         max;
00280     int         quantity;
00281 
00282     // small and mega healths will go over the max
00283 #ifdef MISSIONPACK
00284     if( other->client && bg_itemlist[other->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {
00285         max = other->client->ps.stats[STAT_MAX_HEALTH];
00286     }
00287     else
00288 #endif
00289     if ( ent->item->quantity != 5 && ent->item->quantity != 100 ) {
00290         max = other->client->ps.stats[STAT_MAX_HEALTH];
00291     } else {
00292         max = other->client->ps.stats[STAT_MAX_HEALTH] * 2;
00293     }
00294 
00295     if ( ent->count ) {
00296         quantity = ent->count;
00297     } else {
00298         quantity = ent->item->quantity;
00299     }
00300 
00301     other->health += quantity;
00302 
00303     if (other->health > max ) {
00304         other->health = max;
00305     }
00306     other->client->ps.stats[STAT_HEALTH] = other->health;
00307 
00308     if ( ent->item->quantity == 100 ) {     // mega health respawns slow
00309         return RESPAWN_MEGAHEALTH;
00310     }
00311 
00312     return RESPAWN_HEALTH;
00313 }

int Pickup_Holdable gentity_t ent,
gentity_t other
 

Definition at line 195 of file g_items.c.

References gentity_s::client, playerState_s::eFlags, gentity_t, gitem_s::giTag, gentity_s::item, gclient_s::ps, and playerState_s::stats.

Referenced by Touch_Item().

00195                                                         {
00196 
00197     other->client->ps.stats[STAT_HOLDABLE_ITEM] = ent->item - bg_itemlist;
00198 
00199     if( ent->item->giTag == HI_KAMIKAZE ) {
00200         other->client->ps.eFlags |= EF_KAMIKAZE;
00201     }
00202 
00203     return RESPAWN_HOLDABLE;
00204 }

int Pickup_Powerup gentity_t ent,
gentity_t other
 

Definition at line 49 of file g_items.c.

References AngleVectors(), gentity_s::client, level_locals_t::clients, clientPersistant_t::connected, CONTENTS_SOLID, gentity_s::count, DotProduct, ENTITYNUM_NONE, g_gametype, gclient_t, gentity_t, gitem_s::giTag, GT_TEAM, i, gentity_s::item, level, level_locals_t::maxclients, NULL, playerState_s::origin, gclient_s::pers, playerState_s::persistant, entityState_s::pos, playerState_s::powerups, gclient_s::ps, gitem_s::quantity, gentity_s::s, gclient_s::sess, clientSession_t::sessionTeam, playerState_s::stats, level_locals_t::time, tr, trap_Trace(), trajectory_t::trBase, vec3_t, VectorNormalize(), VectorSubtract, and playerState_s::viewangles.

Referenced by Touch_Item().

00049                                                        {
00050     int         quantity;
00051     int         i;
00052     gclient_t   *client;
00053 
00054     if ( !other->client->ps.powerups[ent->item->giTag] ) {
00055         // round timing to seconds to make multiple powerup timers
00056         // count in sync
00057         other->client->ps.powerups[ent->item->giTag] = 
00058             level.time - ( level.time % 1000 );
00059     }
00060 
00061     if ( ent->count ) {
00062         quantity = ent->count;
00063     } else {
00064         quantity = ent->item->quantity;
00065     }
00066 
00067     other->client->ps.powerups[ent->item->giTag] += quantity * 1000;
00068 
00069     // give any nearby players a "denied" anti-reward
00070     for ( i = 0 ; i < level.maxclients ; i++ ) {
00071         vec3_t      delta;
00072         float       len;
00073         vec3_t      forward;
00074         trace_t     tr;
00075 
00076         client = &level.clients[i];
00077         if ( client == other->client ) {
00078             continue;
00079         }
00080         if ( client->pers.connected == CON_DISCONNECTED ) {
00081             continue;
00082         }
00083         if ( client->ps.stats[STAT_HEALTH] <= 0 ) {
00084             continue;
00085         }
00086 
00087     // if same team in team game, no sound
00088     // cannot use OnSameTeam as it expects to g_entities, not clients
00089     if ( g_gametype.integer >= GT_TEAM && other->client->sess.sessionTeam == client->sess.sessionTeam  ) {
00090       continue;
00091     }
00092 
00093         // if too far away, no sound
00094         VectorSubtract( ent->s.pos.trBase, client->ps.origin, delta );
00095         len = VectorNormalize( delta );
00096         if ( len > 192 ) {
00097             continue;
00098         }
00099 
00100         // if not facing, no sound
00101         AngleVectors( client->ps.viewangles, forward, NULL, NULL );
00102         if ( DotProduct( delta, forward ) < 0.4 ) {
00103             continue;
00104         }
00105 
00106         // if not line of sight, no sound
00107         trap_Trace( &tr, client->ps.origin, NULL, NULL, ent->s.pos.trBase, ENTITYNUM_NONE, CONTENTS_SOLID );
00108         if ( tr.fraction != 1.0 ) {
00109             continue;
00110         }
00111 
00112         // anti-reward
00113         client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_DENIEDREWARD;
00114     }
00115     return RESPAWN_POWERUP;
00116 }

Here is the call graph for this function:

int Pickup_Weapon gentity_t ent,
gentity_t other
 

Definition at line 235 of file g_items.c.

References Add_Ammo(), playerState_s::ammo, gentity_s::client, gentity_s::count, gentity_s::flags, g_gametype, g_weaponRespawn, g_weaponTeamRespawn, gentity_t, gitem_s::giTag, vmCvar_t::integer, gentity_s::item, gclient_s::ps, gitem_s::quantity, and playerState_s::stats.

Referenced by Touch_Item().

00235                                                      {
00236     int     quantity;
00237 
00238     if ( ent->count < 0 ) {
00239         quantity = 0; // None for you, sir!
00240     } else {
00241         if ( ent->count ) {
00242             quantity = ent->count;
00243         } else {
00244             quantity = ent->item->quantity;
00245         }
00246 
00247         // dropped items and teamplay weapons always have full ammo
00248         if ( ! (ent->flags & FL_DROPPED_ITEM) && g_gametype.integer != GT_TEAM ) {
00249             // respawning rules
00250             // drop the quantity if the already have over the minimum
00251             if ( other->client->ps.ammo[ ent->item-