当前位置: 首页>>代码示例>>C++>>正文


C++ Drop_Item函数代码示例

本文整理汇总了C++中Drop_Item函数的典型用法代码示例。如果您正苦于以下问题:C++ Drop_Item函数的具体用法?C++ Drop_Item怎么用?C++ Drop_Item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Drop_Item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TossClientItems

/*
=================
TossClientItems

Toss the weapon and powerups for the killed player
=================
*/
void TossClientItems( gentity_t *self ) {
	gitem_t		*item;
	int			weapon;
	float		angle;
	int			i;
	gentity_t	*drop;

	// drop the weapon if not a gauntlet or machinegun
	weapon = self->s.weapon;

	//Never drop in elimination or last man standing mode!
	if( g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_LMS)
		return;

	// make a special check to see if they are changing to a new
	// weapon that isn't the mg or gauntlet.  Without this, a client
	// can pick up a weapon, be killed, and not drop the weapon because
	// their weapon change hasn't completed yet and they are still holding the MG.
	if ( weapon == WP_MACHINEGUN || weapon == WP_GRAPPLING_HOOK ) {
		if ( self->client->ps.weaponstate == WEAPON_DROPPING ) {
			weapon = self->client->pers.cmd.weapon;
		}
		if ( !( self->client->ps.stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) {
			weapon = WP_NONE;
		}
	}

	if (g_instantgib.integer || g_rockets.integer || g_gametype.integer == GT_CTF_ELIMINATION || g_elimination_allgametypes.integer){
	//Nothing!	
	}
	else
	if ( weapon > WP_MACHINEGUN && weapon != WP_GRAPPLING_HOOK && 
		self->client->ps.ammo[ weapon ] ) {
		// find the item type for this weapon
		item = BG_FindItemForWeapon( weapon );

		// spawn the item
		Drop_Item( self, item, 0 );
	}

	// drop all the powerups if not in teamplay
	if ( g_gametype.integer != GT_TEAM ) {
		angle = 45;
		for ( i = 1 ; i < PW_NUM_POWERUPS ; i++ ) {
			if ( self->client->ps.powerups[ i ] > level.time ) {
				item = BG_FindItemForPowerup( i );
				if ( !item ) {
					continue;
				}
				drop = Drop_Item( self, item, angle );
				// decide how many seconds it has left
				drop->count = ( self->client->ps.powerups[ i ] - level.time ) / 1000;
				if ( drop->count < 1 ) {
					drop->count = 1;
				}
				angle += 45;
			}
		}
	}
}
开发者ID:d00man,项目名称:openarena-vm,代码行数:67,代码来源:g_combat.c

示例2: PortalTouch

static void PortalTouch(gentity_t * self, gentity_t * other, trace_t * trace)
{
	gentity_t      *destination;

	// see if we will even let other try to use it
	if(other->health <= 0)
	{
		return;
	}
	if(!other->client)
	{
		return;
	}
//  if( other->client->ps.persistant[PERS_TEAM] != self->spawnflags ) {
//      return;
//  }

	if(other->client->ps.powerups[PW_NEUTRALFLAG])
	{							// only happens in One Flag CTF
		Drop_Item(other, BG_FindItemForPowerup(PW_NEUTRALFLAG), 0);
		other->client->ps.powerups[PW_NEUTRALFLAG] = 0;
	}
	else if(other->client->ps.powerups[PW_REDFLAG])
	{							// only happens in standard CTF
		Drop_Item(other, BG_FindItemForPowerup(PW_REDFLAG), 0);
		other->client->ps.powerups[PW_REDFLAG] = 0;
	}
	else if(other->client->ps.powerups[PW_BLUEFLAG])
	{							// only happens in standard CTF
		Drop_Item(other, BG_FindItemForPowerup(PW_BLUEFLAG), 0);
		other->client->ps.powerups[PW_BLUEFLAG] = 0;
	}

	// find the destination
	destination = NULL;
	while((destination = G_Find(destination, FOFS(classname), "hi_portal destination")) != NULL)
	{
		if(destination->count == self->count)
		{
			break;
		}
	}

	// if there is not one, die!
	if(!destination)
	{
		if(self->pos1[0] || self->pos1[1] || self->pos1[2])
		{
			TeleportPlayer(other, self->pos1, self->s.angles);
		}
		G_Damage(other, other, other, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);
		return;
	}

	TeleportPlayer(other, destination->s.pos.trBase, destination->s.angles);
}
开发者ID:SinSiXX,项目名称:Rogue-Reborn,代码行数:56,代码来源:g_misc.c

示例3: TossPlayerGametypeItems

/*
===========
TossPlayerGametypeItems

Drop CTF flag and Harvester cubes
===========
*/
void TossPlayerGametypeItems(gentity_t *ent) {
	int j;
	gitem_t *item;
	gentity_t *drop;
	int angle = 0;

	// drop flags in CTF
	item = NULL;
	j = 0;

	if ( ent->player->ps.powerups[ PW_REDFLAG ] ) {
		item = BG_FindItemForPowerup( PW_REDFLAG );
		j = PW_REDFLAG;
	} else if ( ent->player->ps.powerups[ PW_BLUEFLAG ] ) {
		item = BG_FindItemForPowerup( PW_BLUEFLAG );
		j = PW_BLUEFLAG;
	} else if ( ent->player->ps.powerups[ PW_NEUTRALFLAG ] ) {
		item = BG_FindItemForPowerup( PW_NEUTRALFLAG );
		j = PW_NEUTRALFLAG;
	}

	if ( item ) {
		drop = Drop_Item( ent, item, angle );
		angle += 45;
		// decide how many seconds it has left
		drop->count = ( ent->player->ps.powerups[ j ] - level.time ) / 1000;
		if ( drop->count < 1 ) {
			drop->count = 1;
		}
		ent->player->ps.powerups[ j ] = 0;
	}

#ifdef MISSIONPACK
	if ( g_gametype.integer == GT_HARVESTER ) {
		if ( ent->player->ps.tokens > 0 ) {
			if ( ent->player->sess.sessionTeam == TEAM_RED ) {
				item = BG_FindItem( "Blue Cube" );
			} else {
				item = BG_FindItem( "Red Cube" );
			}
			if ( item ) {
				for ( j = 0; j < ent->player->ps.tokens; j++ ) {
					drop = Drop_Item( ent, item, angle );
					if ( ent->player->sess.sessionTeam == TEAM_RED ) {
						drop->s.team = TEAM_BLUE;
					} else {
						drop->s.team = TEAM_RED;
					}
					angle += 45;
				}
			}
			ent->player->ps.tokens = 0;
		}
	}
#endif
}
开发者ID:mecwerks,项目名称:revamp,代码行数:63,代码来源:g_combat.c

示例4: TossPlayerItems

/*
=================
TossPlayerItems

Toss the weapon and powerups for the killed player
=================
*/
void TossPlayerItems( gentity_t *self ) {
	gitem_t		*item;
	int			weapon;
	float		angle;
	int			i;
	gentity_t	*drop;

	// drop the weapon if not a gauntlet or machinegun
	weapon = self->s.weapon;

	// make a special check to see if they are changing to a new
	// weapon that isn't the mg or gauntlet.  Without this, a player
	// can pick up a weapon, be killed, and not drop the weapon because
	// their weapon change hasn't completed yet and they are still holding the MG.
	if ( weapon == WP_MACHINEGUN || weapon == WP_GRAPPLING_HOOK ) {
		if ( self->player->ps.weaponstate == WEAPON_DROPPING ) {
			BG_DecomposeUserCmdValue( self->player->pers.cmd.stateValue, &weapon );
		}
		if ( !( self->player->ps.stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) {
			weapon = WP_NONE;
		}
	}

	if ( weapon > WP_MACHINEGUN && weapon != WP_GRAPPLING_HOOK && 
		self->player->ps.ammo[ weapon ] ) {
		// find the item type for this weapon
		item = BG_FindItemForWeapon( weapon );

		// spawn the item
		Drop_Item( self, item, 0 );
	}

	// drop all the powerups if not in teamplay
	if ( g_gametype.integer != GT_TEAM ) {
		angle = 45;
		for ( i = 1 ; i < PW_NUM_POWERUPS ; i++ ) {
			if ( self->player->ps.powerups[ i ] > level.time ) {
				item = BG_FindItemForPowerup( i );
				if ( !item ) {
					continue;
				}
				drop = Drop_Item( self, item, angle );
				// decide how many seconds it has left
				drop->count = ( self->player->ps.powerups[ i ] - level.time ) / 1000;
				if ( drop->count < 1 ) {
					drop->count = 1;
				}
				angle += 45;
			}
		}
	}
}
开发者ID:mecwerks,项目名称:revamp,代码行数:59,代码来源:g_combat.c

示例5: RestartLevel

//#define rndnum(y,z) ((random()*((z)-((y)+1)))+(y))
void RestartLevel()
{
	edict_t *player;
	int i;
	edict_t *dropped = NULL;
	techspawn = false;
	ResetItems();
	match_nextthink = level.time + 1;
	match_state = STATE_NEEDPLAYERS;
	match_state_end = 1;
	ResetCaps();
	hstime = level.time - 10;
	mapvoteactive = false;
	for_each_player(player, i)
	{
		player->client->resp.score = 0;
		player->client->resp.frags = 0;
		player->client->resp.spree = 0;
		player->client->resp.deaths = 0;
		player->client->pers.db_hud = true;
		if(player->client->pers.pl_state == 2)
			player->client->pers.pl_state = 3;
		player->client->resp.startframe = level.newframenum;
		if (ctf->value)
		{
			if ((!flag1_item || !flag2_item) && ctf->value)
				CTFInit();
			if (player->client->pers.inventory[ITEM_INDEX(flag1_item)])
			{
				dropped = Drop_Item(player, flag1_item);
				player->client->pers.inventory[ITEM_INDEX(flag1_item)] = 0;
				my_bprintf(PRINT_HIGH, "%s lost the %s flag!\n",
					player->client->pers.netname, CTFTeamName(CTF_TEAM1));
			}
			else if (player->client->pers.inventory[ITEM_INDEX(flag2_item)])
			{
				dropped = Drop_Item(player, flag2_item);
				player->client->pers.inventory[ITEM_INDEX(flag2_item)] = 0;
				my_bprintf(PRINT_HIGH, "%s lost the %s flag!\n",
					player->client->pers.netname, CTFTeamName(CTF_TEAM2));
			}
			if (dropped)
			{
				dropped->think = G_FreeEdict;
				dropped->timestamp = level.time;
				dropped->nextthink = level.time + 0.2;
			}
			//JSW - clear flag carrier var
			player->hasflag = 0;
		}
	}
开发者ID:qbism,项目名称:tmg,代码行数:52,代码来源:timer.c

示例6: TossClientWeapon

void TossClientWeapon (edict_t *self)
{
	gitem_t		*item;
	edict_t		*drop;
	qboolean	quad;
	float		spread;

	if (!deathmatch->value)
		return;

	item = self->client->pers.weapon;
	if (! self->client->pers.inventory[self->client->ammo_index] )
		item = NULL;
	if (item && (strcmp (item->pickup_name, "Blaster") == 0))
		item = NULL;

#if defined(_DEBUG) && defined(_Z_TESTMODE)
	if (item && (strcmp (item->pickup_name, "Line Draw") == 0))
		item = NULL;
#endif

	if (!((int)(dmflags->value) & DF_QUAD_DROP))
		quad = false;
	else
		quad = (self->client->quad_framenum > (level.framenum + 10));

	if (item && quad)
		spread = 22.5;
	else
		spread = 0.0;

	if (item)
	{
		self->client->v_angle[YAW] -= spread;
		drop = Drop_Item (self, item);
		self->client->v_angle[YAW] += spread;
		drop->spawnflags = DROPPED_PLAYER_ITEM;
	}

	if (quad)
	{
		self->client->v_angle[YAW] += spread;
		drop = Drop_Item (self, FindItemByClassname ("item_quad"));
		self->client->v_angle[YAW] -= spread;
		drop->spawnflags |= DROPPED_PLAYER_ITEM;

		drop->touch = Touch_Item;
		drop->nextthink = level.time + (self->client->quad_framenum - level.framenum) * FRAMETIME;
		drop->think = G_FreeEdict;
	}
}
开发者ID:ZwS,项目名称:qudos,代码行数:51,代码来源:p_client.c

示例7: monster_death_use

/*
================
monster_death_use

When a monster dies, it fires all of its targets with the current
enemy as activator.
================
*/
void monster_death_use (edict_t *self)
{
	edict_t	*player;
	int		i;

	self->flags &= ~(FL_FLY|FL_SWIM);
	self->monsterinfo.aiflags &= AI_GOOD_GUY;

	// Lazarus: If actor/monster is being used as a camera by a player,
	// turn camera off for that player
	for (i=0,player=g_edicts+1; i<maxclients->value; i++, player++) {
		if(player->client && player->client->spycam == self)
			camera_off(player);
	}

	if (self->item)
	{
		Drop_Item (self, self->item);
		self->item = NULL;
	}

	if (self->deathtarget)
		self->target = self->deathtarget;

	if (!self->target)
		return;

	G_UseTargets (self, self->enemy);
}
开发者ID:qbism,项目名称:qbq2,代码行数:37,代码来源:g_monster.c

示例8: Drop_Ammo

void Drop_Ammo (edict_t *ent, gitem_t *item)
{
	edict_t	*dropped;
	int		index;

	index = ITEM_INDEX(item);
	dropped = Drop_Item (ent, item);
	if (ent->client->pers.inventory[index] >= item->quantity)
		dropped->count = item->quantity;
	else
		dropped->count = ent->client->pers.inventory[index];

	//Wheaty: Only drop ONE grenade
/*	if (item->tag == AMMO_TYPE_GRENADES)
	{
		dropped->count = 1;
	} */

	//Wheaty: Clear inventory of any grenades (even though you only drop 1)
//	if (!item->tag == AMMO_TYPE_GRENADES)
		ent->client->pers.inventory[index] -= dropped->count;
//	else
//		ent->client->pers.inventory[index] = 0;

	ValidateSelectedItem (ent);
	WeighPlayer(ent);
}
开发者ID:basecq,项目名称:q2dos,代码行数:27,代码来源:g_items.c

示例9: RQ3_ResetItem

/*
==============
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;
	}
}
开发者ID:zturtleman,项目名称:reaction,代码行数:42,代码来源:g_items.c

示例10: adminSpawnRune

void adminSpawnRune(edict_t *self, int type, int index)
{
	gitem_t *item;
	edict_t *rune;

	item = FindItem("Rune");		// get the item properties
	rune = Drop_Item(self, item);	// create the entity that holds those properties
	V_ItemClear(&rune->vrxitem);	// initialize the rune
	rune->vrxitem.quantity = 1;
	
	switch(type)
	{
	case ITEM_WEAPON:		spawnNorm(rune, index, ITEM_WEAPON); return;
	case ITEM_ABILITY:		spawnNorm(rune, index, ITEM_ABILITY); return;
	case ITEM_COMBO:		spawnCombo(rune, index); return;
	case ITEM_CLASSRUNE:	spawnClassRune(rune, index); return;
	//Try to spawn a unique (or a random one if it fails to find one at the index)
	case ITEM_UNIQUE:		if (!spawnUnique(rune, index)) spawnNorm(rune, index, 0); return;
	}

	//Randomize id
	strcpy(rune->vrxitem.id, GetRandomString(16));

	//Free the ent (if no rune was spawned)
	G_FreeEdict(rune);
}
开发者ID:mylemans,项目名称:vrxcl,代码行数:26,代码来源:v_items.c

示例11: Drop_Weapon

void
Drop_Weapon(edict_t *ent, gitem_t *item)
{
	int index;

	if (!ent || !item)
	{
		return;
	}

	if ((int)(dmflags->value) & DF_WEAPONS_STAY)
	{
		return;
	}

	index = ITEM_INDEX(item);

	/* see if we're already using it */
	if (((item == ent->client->pers.weapon) ||
		 (item == ent->client->newweapon)) &&
		(ent->client->pers.inventory[index] == 1))
	{
		gi.cprintf(ent, PRINT_HIGH, "Can't drop current weapon\n");
		return;
	}

	Drop_Item(ent, item);
	ent->client->pers.inventory[index]--;
}
开发者ID:phine4s,项目名称:xatrix,代码行数:29,代码来源:weapon.c

示例12: dropWeapon

gentity_s* dropWeapon(int32_t client, int32_t weapon, int32_t camo)
{
	uint16_t tag = scr_const->tag_weapon_right;
	gentity_s* ent = Drop_Item(&g_entities[client], weapon, 20, tag, 0);
	ent->item[0].ammoCount = ent->item[0].clipAmmoCount = 999;
	ent->s.renderOptions = camo;
	Scr_AddEntity(SCRIPTINSTANCE_SERVER, ent);
	return ent;
}
开发者ID:therifboy,项目名称:echelon-bo2,代码行数:9,代码来源:entity.cpp

示例13: Drop_General

void Drop_General (edict_t *ent, gitem_t *item)
{
	if (!item)
		return; // out of ammo, switched before frame?

	Drop_Item (ent, item);
	ent->client->pers.inventory[ITEM_INDEX(item)]--;
	ValidateSelectedItem (ent);
	WeighPlayer(ent);
}
开发者ID:basecq,项目名称:q2dos,代码行数:10,代码来源:g_items.c

示例14: Drop_Item

static edict_t *Drop_General( edict_t *ent, const gsitem_t *item )
{
	edict_t *dropped = Drop_Item( ent, item );
	if( dropped )
	{
		if( ent->r.client && ent->r.client->ps.inventory[item->tag] > 0 )
			ent->r.client->ps.inventory[item->tag]--;
	}
	return dropped;
}
开发者ID:DenMSC,项目名称:qfusion,代码行数:10,代码来源:g_items.cpp

示例15: TossClientItems

/*
=================
TossClientItems

Toss the weapon and powerups for the killed player
=================
*/
void TossClientItems( gentity_t *self ) {
	gitem_t		*item;

	if ( IsBot( self ) )
		return;	//bots don't drop items in single player

	//the player drops a backpack in single player
	item = BG_FindItemForBackpack(); 
	Drop_Item( self, item, 0 );

}
开发者ID:Clever-Boy,项目名称:entityplus,代码行数:18,代码来源:g_combat.c


注:本文中的Drop_Item函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。