Example #1
0
/*
==============
RQ3_ResetItem

Added by Elder
Items respawn themselves after a period of time
Based on the AQ2 item code which was based off Q2 CTF techs
This can be called directly when a player dies in a CONTENTS_NODROP area
==============
*/
void RQ3_ResetItem(int itemTag)
{
	gitem_t *rq3_item;
	gentity_t *rq3_temp;
	float angle = rand() % 360;

// JBravo: no resetting items in TP or CTB
	if (g_gametype.integer == GT_TEAMPLAY || g_gametype.integer == GT_CTF)
		return;
	if (g_gametype.integer == GT_TEAM && !g_RQ3_tdmMode.integer)
		return;

	switch (itemTag) {
	case HI_KEVLAR:
	case HI_LASER:
	case HI_SILENCER:
	case HI_BANDOLIER:
	case HI_SLIPPERS:
	case HI_HELMET:
		//Free entity and reset position in unique item array
		//level.uniqueItemsUsed &= ~(1 << ent->item->giTag);
		rq3_item = BG_FindItemForHoldable(itemTag);
		rq3_temp = (gentity_t *) SelectRandomDeathmatchSpawnPoint();
		Drop_Item(rq3_temp, rq3_item, angle);
		//G_Printf("RQ3_DroppedItemThink: Freeing item entity + respawning\n");
		break;
	default:
		//Elder: shouldn't have to come here
		G_Printf("RQ3_ResetItem: Out of range or invalid item %d\n", itemTag);
		break;
	}
}
Example #2
0
//go through all classes on a team and register their
//weapons and items for precaching.
void G_SiegeRegisterWeaponsAndHoldables( int team ) {
	siegeTeam_t *stm = BG_SiegeFindThemeForTeam( team );

	if ( stm ) {
		int i = 0;
		siegeClass_t *scl;
		while ( i < stm->numClasses ) {
			scl = stm->classes[i];

			if ( scl ) {
				int j = 0;
				while ( j < WP_NUM_WEAPONS ) {
					if ( scl->weapons & (1 << j) ) { //we use this weapon so register it.
						RegisterItem( BG_FindItemForWeapon( j ) );
					}
					j++;
				}
				j = 0;
				while ( j < HI_NUM_HOLDABLE ) {
					if ( scl->invenItems & (1 << j) ) { //we use this item so register it.
						RegisterItem( BG_FindItemForHoldable( j ) );
					}
					j++;
				}
			}
			i++;
		}
	}
}
Example #3
0
/*
===============
CG_UseItem
===============
*/
static void CG_UseItem( centity_t *cent ) {
	playerInfo_t *pi;
	int			itemNum, playerNum;
	gitem_t		*item;
	entityState_t *es;
	int			i;

	es = &cent->currentState;
	
	itemNum = (es->event & ~EV_EVENT_BITS) - EV_USE_ITEM0;
	if ( itemNum < 0 || itemNum > HI_NUM_HOLDABLE ) {
		itemNum = 0;
	}

	// print a message if the local player
	for (i = 0; i < CG_MaxSplitView(); i++) {
		if ( es->number != cg.snap->pss[i].playerNum ) {
			continue;
		}

		if ( !itemNum ) {
			CG_CenterPrint( i, "No item to use", SCREEN_HEIGHT * 0.30, 0.5 );
		} else {
			item = BG_FindItemForHoldable( itemNum );
			CG_CenterPrint( i, va("Use %s", item->pickup_name), SCREEN_HEIGHT * 0.30, 0.5 );
		}
	}

	switch ( itemNum ) {
	default:
	case HI_NONE:
		trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useNothingSound );
		break;

	case HI_TELEPORTER:
		break;

	case HI_MEDKIT:
		playerNum = cent->currentState.playerNum;
		if ( playerNum >= 0 && playerNum < MAX_CLIENTS ) {
			pi = &cgs.playerinfo[ playerNum ];
			pi->medkitUsageTime = cg.time;
		}
		trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.medkitSound );
		break;

#ifdef MISSIONPACK
	case HI_KAMIKAZE:
		break;

	case HI_PORTAL:
		break;
	case HI_INVULNERABILITY:
		trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useInvulnerabilitySound );
		break;
#endif
	}

}
Example #4
0
/*
==============
BG_FindClassnameForHoldable
==============
*/
char *BG_FindClassnameForHoldable(holdable_t pw)
{
	gitem_t *item = BG_FindItemForHoldable(pw);

	if (item)
	{
		return item->classname;
	}
	return NULL;
}
Example #5
0
/*
===============
CG_UseItem
===============
*/
static void CG_UseItem( centity_t *cent ) {
	clientInfo_t *ci;
	int			itemNum, clientNum;
	gitem_t		*item;
	entityState_t *es;

	es = &cent->currentState;
	
	itemNum = (es->event & ~EV_EVENT_BITS) - EV_USE_ITEM0;
	if ( itemNum < 0 || itemNum > HI_NUM_HOLDABLE ) {
		itemNum = 0;
	}

	// print a message if the local player
	if ( es->number == cg.snap->ps.clientNum ) {
		if ( !itemNum ) {
			CG_CenterPrint( "No item to use", SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
		} else {
			item = BG_FindItemForHoldable( itemNum );
			CG_CenterPrint( va("Use %s", item->pickup_name), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
		}
	}

	switch ( itemNum ) {
	default:
	case HI_NONE:
		trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useNothingSound );
		break;

	case HI_TELEPORTER:
		break;

	case HI_MEDKIT:
		clientNum = cent->currentState.clientNum;
		if ( clientNum >= 0 && clientNum < MAX_CLIENTS ) {
			ci = &cgs.clientinfo[ clientNum ];
			ci->medkitUsageTime = cg.time;
		}
		trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.medkitSound );
		break;

#ifdef MISSIONPACK
	case HI_KAMIKAZE:
		break;

	case HI_PORTAL:
		break;
	case HI_INVULNERABILITY:
		trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useInvulnerabilitySound );
		break;
#endif
	}

}
Example #6
0
/*
==============
ClearRegisteredItems
==============
*/
void ClearRegisteredItems(void)
{
	memset(itemRegistered, 0, sizeof(itemRegistered));

	// players always start with the base weapon
	//Blaze: Changed WP_MACHINEGUN to WP_PISTOL and WP_GAUNTLET to WP_KNIFE
	RegisterItem(BG_FindItemForWeapon(WP_PISTOL));
	RegisterItem(BG_FindItemForWeapon(WP_KNIFE));
	//Elder: add unique items here
	RegisterItem(BG_FindItemForHoldable(HI_KEVLAR));
	RegisterItem(BG_FindItemForHoldable(HI_SLIPPERS));
	RegisterItem(BG_FindItemForHoldable(HI_SILENCER));
	RegisterItem(BG_FindItemForHoldable(HI_BANDOLIER));
	RegisterItem(BG_FindItemForHoldable(HI_LASER));
	// JBravo: adding the helmet
	if (g_RQ3_haveHelmet.integer)
		RegisterItem(BG_FindItemForHoldable(HI_HELMET));
	//Makro - all weapons should be loaded in teamplay
	//JBravo: and CTF
	if (g_gametype.integer == GT_TEAMPLAY || g_gametype.integer == GT_CTF || g_gametype.integer == GT_TEAM) {
		RegisterItem(BG_FindItemForWeapon(WP_M3));
		RegisterItem(BG_FindItemForWeapon(WP_MP5));
		RegisterItem(BG_FindItemForWeapon(WP_HANDCANNON));
		RegisterItem(BG_FindItemForWeapon(WP_SSG3000));
		RegisterItem(BG_FindItemForWeapon(WP_M4));
		RegisterItem(BG_FindItemForWeapon(WP_AKIMBO));
		RegisterItem(BG_FindItemForWeapon(WP_GRENADE));
	}
}
Example #7
0
/*
===============
CG_UseItem
===============
*/
static void CG_UseItem( centity_t *cent ) {
	clientInfo_t *ci = 0;
	int			itemNum;
	gitem_t		*item;
	entityState_t *es;

	es = &cent->currentState;
	
	itemNum = (es->event & ~EV_EVENT_BITS) - EV_USE_ITEM0;
	if ( itemNum < 0 || itemNum > HI_NUM_HOLDABLE ) {
		itemNum = 0;
	}

	// print a message if the local player
	if ( es->number == cg.snap->ps.clientNum ) {
		if ( !itemNum ) {
			CG_CenterPrint( "No item to use" );
		} else {
			item = BG_FindItemForHoldable( itemNum );
			CG_CenterPrint( va("Use %s", item->pickup_name) );
		}
	}

	switch ( itemNum ) {
	default:
	case HI_NONE:
		trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useNothingSound );
		break;

	case HI_TELEPORTER:
		break;

	case HI_MEDKIT:
		trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.medkitSound );
		break;

	}

}
Example #8
0
void ThrowItem(gentity_t * ent)
{
	gclient_t *client;
	gitem_t *xr_item;
	gentity_t *xr_drop;
//	int item;

	client = ent->client;

	//itemonTime > 0 or itemonState == itemon_dropping?  Or both?
	//item = 0;

	// JBravo: New drop item code for multiple items.
	if (client->uniqueItems > 0) {
		if (g_gametype.integer >= GT_TEAM) {
			if (client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << client->teamplayItem)) {
				xr_item = BG_FindItemForHoldable(client->teamplayItem);
				xr_drop = dropWeapon(ent, xr_item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM);
				xr_drop->count = -1;
				client->ps.stats[STAT_HOLDABLE_ITEM] &= ~(1 << client->teamplayItem);
				client->uniqueItems--;
				return;
			}
		}
		if (client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_BANDOLIER)) {
			xr_item = BG_FindItemForHoldable(HI_BANDOLIER);
			xr_drop = dropWeapon(ent, xr_item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM);
			xr_drop->count = -1;
			client->ps.stats[STAT_HOLDABLE_ITEM] &= ~(1 << HI_BANDOLIER);
			client->uniqueItems--;
			return;
		} else if (client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_SLIPPERS)) {
			xr_item = BG_FindItemForHoldable(HI_SLIPPERS);
			xr_drop = dropWeapon(ent, xr_item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM);
			xr_drop->count = -1;
			client->ps.stats[STAT_HOLDABLE_ITEM] &= ~(1 << HI_SLIPPERS);
			client->uniqueItems--;
			return;
		} else if (client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_SILENCER)) {
			xr_item = BG_FindItemForHoldable(HI_SILENCER);
			xr_drop = dropWeapon(ent, xr_item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM);
			xr_drop->count = -1;
			client->ps.stats[STAT_HOLDABLE_ITEM] &= ~(1 << HI_SILENCER);
			client->uniqueItems--;
			return;
		// JBravo: adding the helmet :)
		} else if (client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_HELMET)) {
			xr_item = BG_FindItemForHoldable(HI_HELMET);
			xr_drop = dropWeapon(ent, xr_item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM);
			xr_drop->count = -1;
			client->ps.stats[STAT_HOLDABLE_ITEM] &= ~(1 << HI_HELMET);
			client->uniqueItems--;
			return;
		} else if (client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_LASER)) {
			xr_item = BG_FindItemForHoldable(HI_LASER);
			xr_drop = dropWeapon(ent, xr_item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM);
			xr_drop->count = -1;
			client->ps.stats[STAT_HOLDABLE_ITEM] &= ~(1 << HI_LASER);
			client->uniqueItems--;
			return;
		} else if (client->ps.stats[STAT_HOLDABLE_ITEM] & (1 << HI_KEVLAR)) {
			xr_item = BG_FindItemForHoldable(HI_KEVLAR);
			xr_drop = dropWeapon(ent, xr_item, 0, FL_DROPPED_ITEM | FL_THROWN_ITEM);
			xr_drop->count = -1;
			client->ps.stats[STAT_HOLDABLE_ITEM] &= ~(1 << HI_KEVLAR);
			client->uniqueItems--;
			return;
		}
	}
}