int Pickup_Armor( gentity_t *ent, gentity_t *other ) { other->client->ps.stats[STAT_ARMOR] += ent->item->quantity; if (other->client->ps.stats[STAT_ARMOR] > MaxArmor(&other->client->ps,qfalse)) other->client->ps.stats[STAT_ARMOR] = MaxArmor(&other->client->ps,qfalse); return RESPAWN_ARMOR; }
void CBasePlayerClass::SetArmor( void ) { m_pOwner->pev->armorvalue = MaxArmor(); }
void CBasePlayerClass::SendMaxHealth( void ) { MESSAGE_BEGIN( MSG_ONE, gmsgMaxHealth, NULL, m_pOwner->pev ); WRITE_BYTE( MaxHealth() ); WRITE_BYTE( MaxArmor() ); MESSAGE_END(); }
/* ================ BG_CanItemBeGrabbed Returns false if the item should not be picked up. This needs to be the same for client side prediction and server use. ================ */ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const playerState_t *ps ) { gitem_t *item; #ifdef MISSIONPACK int upperBound; #endif if ( ent->modelindex < 1 || ent->modelindex >= bg_numItems ) { Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: index out of range" ); } item = &bg_itemlist[ent->modelindex]; switch( item->giType ) { case IT_WEAPON: return qtrue; // weapons are always picked up case IT_AMMO: if ( ps->ammo[ item->giTag ] >= 200 ) { return qfalse; // can't hold any more } return qtrue; case IT_ARMOR: //RUNE: Plentiful armor lets you pick up lots more if ( ps->stats[STAT_ARMOR] >= MaxArmor((playerState_t *)ps,qfalse)) { return qfalse; } return qtrue; case IT_HEALTH: // small and mega healths will go over the max, otherwise // don't pick up if already at max if ( item->quantity == 5 || item->quantity == 100 ) { if ( ps->stats[STAT_HEALTH] >= MaxHealth((playerState_t *)ps,qtrue) ) { return qfalse; } return qtrue; } if ( ps->stats[STAT_HEALTH] >= MaxHealth((playerState_t *)ps,qfalse) ) { return qfalse; } return qtrue; case IT_RUNE: return qfalse; case IT_POWERUP: return qtrue; // powerups are always picked up #ifdef MISSIONPACK case IT_PERSISTANT_POWERUP: // can only hold one item at a time if ( ps->stats[STAT_PERSISTANT_POWERUP] ) { return qfalse; } // check team only if( ( ent->generic1 & 2 ) && ( ps->persistant[PERS_TEAM] != TEAM_RED ) ) { return qfalse; } if( ( ent->generic1 & 4 ) && ( ps->persistant[PERS_TEAM] != TEAM_BLUE ) ) { return qfalse; } return qtrue; #endif case IT_TEAM: // team items, such as flags #ifdef MISSIONPACK if( gametype == GT_1FCTF ) { // neutral flag can always be picked up if( item->giTag == PW_NEUTRALFLAG ) { return qtrue; } if (ps->persistant[PERS_TEAM] == TEAM_RED) { if (item->giTag == PW_BLUEFLAG && ps->powerups[PW_NEUTRALFLAG] ) { return qtrue; } } else if (ps->persistant[PERS_TEAM] == TEAM_BLUE) { if (item->giTag == PW_REDFLAG && ps->powerups[PW_NEUTRALFLAG] ) { return qtrue; } } } #endif if( gametype == GT_CTF ) { // ent->modelindex2 is non-zero on items if they are dropped // we need to know this because we can pick up our dropped flag (and return it) // but we can't pick up our flag at base if (ps->persistant[PERS_TEAM] == TEAM_RED) { if (item->giTag == PW_BLUEFLAG || (item->giTag == PW_REDFLAG && ent->modelindex2) || (item->giTag == PW_REDFLAG && ps->powerups[PW_BLUEFLAG]) ) return qtrue; } else if (ps->persistant[PERS_TEAM] == TEAM_BLUE) { if (item->giTag == PW_REDFLAG || (item->giTag == PW_BLUEFLAG && ent->modelindex2) || (item->giTag == PW_BLUEFLAG && ps->powerups[PW_REDFLAG]) ) return qtrue; } } #ifdef MISSIONPACK if( gametype == GT_HARVESTER ) { return qtrue; } #endif return qfalse; case IT_HOLDABLE: // can only hold one item at a time if ( ps->stats[STAT_HOLDABLE_ITEM] ) { return qfalse; } return qtrue; case IT_BAD: Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: IT_BAD" ); default: #ifndef Q3_VM #ifndef NDEBUG // bk0001204 Com_Printf("BG_CanItemBeGrabbed: unknown enum %d\n", item->giType ); #endif #endif break; } return qfalse; }