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


C++ Add_Ammo函数代码示例

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


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

示例1: Pickup_Weapon

/*
* Pickup_Weapon
*/
bool Pickup_Weapon( edict_t *other, const gsitem_t *item, int flags, int ammo_count )
{
	int ammo_tag;
	gs_weapon_definition_t *weapondef;

	weapondef = GS_GetWeaponDef( item->tag );

	other->r.client->ps.inventory[item->tag]++;

	// never allow the player to carry more than 2 copies of the same weapon
	if( other->r.client->ps.inventory[item->tag] > item->inventory_max )
		other->r.client->ps.inventory[item->tag] = item->inventory_max;

	if( !(flags & DROPPED_ITEM) )
	{
		// give them some ammo with it
		ammo_tag = item->ammo_tag;
		if( ammo_tag )
			Add_Ammo( other->r.client, GS_FindItemByTag( ammo_tag ), weapondef->firedef.weapon_pickup, true );
	}
	else
	{    
		// it's a dropped weapon
		ammo_tag = item->ammo_tag;
		if( ammo_count && ammo_tag )
			Add_Ammo( other->r.client, GS_FindItemByTag( ammo_tag ), ammo_count, true );
	}

	return true;
}
开发者ID:codetwister,项目名称:qfusion,代码行数:33,代码来源:p_weapon.cpp

示例2: Pickup_Weapon

int Pickup_Weapon (gentity_t *ent, gentity_t *other) {
	// add the weapon
	other->client->ps.stats[STAT_WEAPONS] |= ( 1 << ent->item->giTag );

    //Lookup how much ammo we need rather then just giving it quantity
	/*Add_Ammo( other, ent->item->giTag, quantity );*/
//	quantity = ClipAmountForWeapon(ent->item->giTag);
//	if (other->client->clipammo[ent->item->giTag] > 0 )
//		Add_Ammo( other, ent->item->giTag, quantity );
//	else 
	
	if (ent->item->giTag == WP_SHOTGUN) {
		other->client->ammo_in_clip[ent->item->giTag] = 12;
		Add_Ammo( other, ent->item->giTag, 24 );
	} else {
		//Set the number of shots in a clip for that weapon.
		other->client->ammo_in_clip[ent->item->giTag] = G_ClipAmountForWeapon( ent->item->giTag );
		//Add two clips when you pickup a weapon.
		Add_Ammo( other, ent->item->giTag, 2 * G_ClipAmountForWeapon( ent->item->giTag ) );
	}
	switch (ent->item->giTag)
	{
	case WP_C4:
		other->client->ammo_in_clip[ent->item->giTag] = G_ClipAmountForWeapon( ent->item->giTag );
		other->client->ps.ammo[ent->item->giTag] = 0;
	case WP_GRENADE:
		other->client->ammo_in_clip[ent->item->giTag] = G_ClipAmountForWeapon( ent->item->giTag );
		other->client->ps.ammo[ent->item->giTag] = 4;
	}

	if (ent->item->giTag == WP_GRAPPLING_HOOK || ent->item->giTag == WP_GAUNTLET)
		other->client->ps.ammo[ent->item->giTag] = G_MaxTotalAmmo(ent->item->giTag);

	return g_weaponRespawn.integer;
}
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:35,代码来源:g_items.c

示例3: Pickup_Ammo

int Pickup_Ammo (gentity_t *ent, gentity_t *other)
{
	int		quantity;

	if ( ent->count ) {
		quantity = ent->count;
	} else {
		quantity = ent->item->quantity;
	}

	if (!Q_stricmp(ent->item->classname, "ammo_pack")) {
		int i;

		for (i = 0;  i < bg_numItems;  i++) {
			const gitem_t *item;

			item = &bg_itemlist[i];
			if (item->giType != IT_AMMO) {
				// skip
				continue;
			}
			if (!Q_stricmp(item->classname, "ammo_pack")) {
				// skip
				continue;
			}

			Add_Ammo(other, item->giTag, item->quantity);
		}
	} else {
		Add_Ammo (other, ent->item->giTag, quantity);
	}

	return RESPAWN_AMMO;
}
开发者ID:brugal,项目名称:wolfcamql,代码行数:34,代码来源:g_items.c

示例4: Pickup_Weapon

/*
* Pickup_Weapon
*/
qboolean Pickup_Weapon( edict_t *ent, edict_t *other )
{
	int ammo_tag;

	other->r.client->ps.inventory[ent->item->tag]++;

	// never allow the player to carry more than 2 copies of the same weapon
	if( other->r.client->ps.inventory[ent->item->tag] > ent->item->inventory_max )
		other->r.client->ps.inventory[ent->item->tag] = ent->item->inventory_max;

	if( !( ent->spawnflags & DROPPED_ITEM ) )
	{
		// give them some ammo with it
		ammo_tag = ent->item->weakammo_tag;

		if( ammo_tag )
			Add_Ammo( other->r.client, GS_FindItemByTag( ammo_tag ), GS_FindItemByTag( ammo_tag )->quantity, qtrue );
	}
	else
	{    //it's a dropped weapon
		ammo_tag = ent->item->weakammo_tag;
		if( ent->count && ammo_tag )
			Add_Ammo( other->r.client, GS_FindItemByTag( ammo_tag ), ent->count, qtrue );
	}

	return qtrue;
}
开发者ID:TyounanMOTI,项目名称:warsow_mac,代码行数:30,代码来源:p_weapon.c

示例5: Give_Class_Ammo

//this function is for giving the player ammo...
void Give_Class_Ammo(edict_t *ent)
{
	gitem_t *item,*item2;
	
	if (ent->client->resp.team_on->mos[ent->client->resp.mos]->ammo1 )
	{
		if ((mauser_only->value == 1) && !(ent->client->resp.mos == MEDIC))
			item= FindTeamItem(team_list[1]->teamid, LOC_RIFLE);
		else if ((sniper_only->value == 1) && !(ent->client->resp.mos == MEDIC))
			item= FindTeamItem(team_list[(ent->client->resp.team_on->index)]->teamid, LOC_SNIPER);
		else
			item=FindItem(ent->client->resp.team_on->mos[ent->client->resp.mos]->weapon1);

		item2=FindItem(item->ammo);
		Add_Ammo(ent,item2,ent->client->resp.team_on->mos[ent->client->resp.mos]->ammo1);
	}

	if (ent->client->resp.team_on->mos[ent->client->resp.mos]->ammo2 )
	{
		item=FindItem(ent->client->resp.team_on->mos[ent->client->resp.mos]->weapon2);
		item2=FindItem(item->ammo);
		Add_Ammo(ent,item2,ent->client->resp.team_on->mos[ent->client->resp.mos]->ammo2);
	}
	
	
}
开发者ID:basecq,项目名称:q2dos,代码行数:27,代码来源:p_classes.c

示例6: Pickup_Weapon

qboolean Pickup_Weapon (edict_t *ent, edict_t *other)
{
	int			index;
	gitem_t		*ammo;

	index = ITEM_INDEX(ent->item);

	if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) 
		&& other->client->pers.inventory[index])
	{
		if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) )
			return false;	// leave the weapon for others to pickup
	}

	other->client->pers.inventory[index]++;

	//WF
	if(ent->spawnflags & DROPPED_ITEM) {
		ammo = FindItem(ent->item->ammo);
		Add_Ammo(other, ammo, (int)((float)ammo->quantity * dropweapammo->value));
	}
	//WF

	if (!(ent->spawnflags & DROPPED_ITEM) )
	{
		// give them some ammo with it
		ammo = FindItem (ent->item->ammo);
		if ( (int)dmflags->value & DF_INFINITE_AMMO )
			Add_Ammo (other, ammo, 1000);
		else
			Add_Ammo (other, ammo, ammo->quantity);

		if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) )
		{
			if (deathmatch->value)
			{
				if ((int)(dmflags->value) & DF_WEAPONS_STAY)
					ent->flags |= FL_RESPAWN;
				else
					SetRespawn (ent, 30);
			}
			if (coop->value)
				ent->flags |= FL_RESPAWN;
		}
	}

	//WF
	other->safety_time = 0;
	Weapon_PickBest(ent, other);
	/*
	if (other->client->pers.weapon != ent->item && 
		(other->client->pers.inventory[index] == 1) &&
		( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) )
		other->client->newweapon = ent->item;
	*/
	//WF

	return true;
}
开发者ID:mattayres,项目名称:li2mod,代码行数:59,代码来源:p_weapon.c

示例7: Pickup_Ammo

/*
==============
Pickup_Ammo
==============
*/
int Pickup_Ammo (gentity_t *ent, gentity_t *other) {
	// added some ammo pickups, so I'll use ent->item->quantity if no ent->count
	if (ent->count)
	{
		Add_Ammo (other, ent->item->giTag, ent->count, qfalse);
	}
	else
	{
		Add_Ammo (other, ent->item->giTag, ent->item->quantity, qfalse);
	}

	return RESPAWN_AMMO;
}
开发者ID:BackupTheBerlios,项目名称:et-flf-svn,代码行数:18,代码来源:g_items.c

示例8: Pickup_Weapon

qboolean Pickup_Weapon(edict_t *ent, edict_t *other)
{
  int index;
  gitem_t *ammo;

  if (!ent || !other) {
    return false;
  }

  index = ITEM_INDEX(ent->item);

  if ((((int) (dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index]) {
    if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM))) {
      return false; /* leave the weapon for others to pickup */
    }
  }

  other->client->pers.inventory[index]++;

  if (!(ent->spawnflags & DROPPED_ITEM)) {
    /* give them some ammo with it */
    ammo = FindItem(ent->item->ammo);

    if ((int) dmflags->value & DF_INFINITE_AMMO) {
      Add_Ammo(other, ammo, 1000);
    } else {
      Add_Ammo(other, ammo, ammo->quantity);
    }

    if (!(ent->spawnflags & DROPPED_PLAYER_ITEM)) {
      if (deathmatch->value) {
        if ((int) (dmflags->value) & DF_WEAPONS_STAY) {
          ent->flags |= FL_RESPAWN;
        } else {
          SetRespawn(ent, 30);
        }
      }

      if (coop->value) {
        ent->flags |= FL_RESPAWN;
      }
    }
  }

  if ((other->client->pers.weapon != ent->item) && (other->client->pers.inventory[index] == 1) &&
      (!deathmatch->value || (other->client->pers.weapon == FindItem("blaster")))) {
    other->client->newweapon = ent->item;
  }

  return true;
}
开发者ID:greck2908,项目名称:qengine,代码行数:51,代码来源:weapon.c

示例9: Pickup_Weapon

qboolean Pickup_Weapon (edict_t *ent, edict_t *other)
{
	int			index;
	gitem_t		*ammo;

	index = ITEM_INDEX(ent->item);

	if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) 
		&& other->client->pers.inventory[index])
	{
		if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) )
			return false;	// leave the weapon for others to pickup
	}

	other->client->pers.inventory[index]++;

	if (!(ent->spawnflags & DROPPED_ITEM) &&
		(ent->item->ammo != NULL))
	{
		// give them some ammo with it
		ammo = FindItem (ent->item->ammo);
		if ( (int)dmflags->value & DF_INFINITE_AMMO )
			Add_Ammo (other, ammo, 1000);
		else
			Add_Ammo (other, ammo, ammo->quantity);

		if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) )
		{
			if (deathmatch->value)
			{
				if ((int)(dmflags->value) & DF_WEAPONS_STAY)
					ent->flags |= FL_RESPAWN;
				else
					SetRespawn (ent, 30);
			}
			if (coop->value)
				ent->flags |= FL_RESPAWN;
		}
	}

	if (other->client->pers.weapon != ent->item && 
		!(ent->item->hideFlags & HIDE_FROM_SELECTION) && 
		(other->client->pers.inventory[index] == 1) &&
		( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) )
		other->client->newweapon = ent->item;

	return true;
}
开发者ID:yquake2,项目名称:zaero,代码行数:48,代码来源:weapon.c

示例10: Pickup_Ammo

/*
==============
Pickup_Ammo
==============
*/
int Pickup_Ammo( gentity_t *ent, gentity_t *other ) {
	int quantity;

	if ( ent->count ) {
		quantity = ent->count;
	} else {
		// quantity = ent->item->quantity;

		quantity = ent->item->gameskillnumber[( g_gameskill.integer ) - 1];

		// FIXME just for now
		if ( !quantity ) {
			quantity = ent->item->quantity;
		}
	}

	Add_Ammo( other, ent->item->giTag, quantity, qfalse );   //----(SA)	modified

	// single player has no respawns	(SA)
	if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
		return RESPAWN_SP;
	}

	return RESPAWN_AMMO;
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:30,代码来源:g_items.c

示例11: Pickup_Weapon

int Pickup_Weapon (gentity_t *ent, gentity_t *other) {
	int		quantity;

	if ( ent->count < 0 ) {
		quantity = 0; // None for you, sir!
	} else {
		if ( ent->count ) {
			quantity = ent->count;
		} else {
			quantity = ent->item->quantity;
		}

		if (ent->flags & FL_DROPPED_ITEM)
		{
			// TODO: Give the player a second copy of their weapon if applicable.
			// TODO: Set quantity to how ever much was left in the gun (backend stuff likely required for that)
		}
	}

	// add the weapon
	Q_AddWeapon(other->player->ps.weapons, ent->item->giTag);

	Add_Ammo( other, ent->item->giWeaponData.ammoType, quantity ); // LM: Give the ammo this uses.

	// !TODO: Make weapons with infinite ammo use AM_NONE for ammo, then remove this:
	if (ent->item->giWeaponData.ammoType == AM_NONE)
		other->player->ps.ammo[ ent->item->giWeaponData.ammoType ] = -1; // unlimited ammo

	// team deathmatch has slow weapon respawns
	if ( g_gametype.integer == GT_TEAM ) {
		return g_weaponTeamRespawn.integer;
	}

	return g_weaponRespawn.integer;
}
开发者ID:LavenderMoon,项目名称:mint-arena,代码行数:35,代码来源:g_items.c

示例12: Pickup_Weapon

int Pickup_Weapon (gentity_t *ent, gentity_t *other)
{
	int		quantity;

	if (ent->count < 0)
	{
		quantity = 0; // None for you, sir!
	}
	else
	{
		if (ent->flags & FL_DROPPED_ITEM)
			quantity = ent->count;			//Too:
		else
			quantity = ent->item->quantity;
	}

	// add the weapon
	other->client->ps.stats[STAT_WEAPONS] |= (1 << ent->item->giTag);

	Add_Ammo(other, ent->item->giTag, quantity);

	if (ent->item->giTag == WP_GRAPPLING_HOOK)
		other->client->ps.ammo[ent->item->giTag] = -1; // unlimited ammo

	// team deathmatch has slow weapon respawns
	if (g_gametype.integer == GT_TEAM)
	{
		return g_weaponTeamRespawn.integer;
	}

	return g_weaponRespawn.integer;
}
开发者ID:ElderPlayerX,项目名称:Invasion,代码行数:32,代码来源:g_items.c

示例13: Pickup_Ammo

qboolean Pickup_Ammo (edict_t *ent, edict_t *other)
{
	int			oldcount;
	int			count;
	qboolean	weapon;

	weapon = (ent->item->flags & IT_WEAPON);
	if ( (weapon) && ( (int)dmflags->value & DF_INFINITE_AMMO ) )
		count = 1000;
	else if (ent->count)
		count = ent->count;
	else
		count = ent->item->quantity;

	oldcount = other->client->pers.inventory[ITEM_INDEX(ent->item)];

	if (!Add_Ammo (other, ent->item, count))
		return false;

	if (weapon && !oldcount)
	{
		if (other->client->pers.weapon != ent->item && ( !deathmatch->value || other->client->pers.weapon == FindItem("Colt .45") ) )
			other->client->newweapon = ent->item;
	}

	if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)) && (deathmatch->value))
		SetRespawn (ent, 30);

	WeighPlayer(other);
	
	return true;
	
}
开发者ID:basecq,项目名称:q2dos,代码行数:33,代码来源:g_items.c

示例14: Pickup_Weapon

int Pickup_Weapon( gentity_t *ent, gentity_t *other ) {
	int quantity;

	if ( ent->count < 0 )
		quantity = 0; // None for you, sir!
	else {
		if ( ent->count )
			quantity = ent->count;
		else
			quantity = ent->item->quantity;

		// dropped items and teamplay weapons always have full ammo
		if ( !(ent->flags & FL_DROPPED_ITEM) && level.gametype != GT_TEAMBLOOD ) {
			// respawning rules
			// drop the quantity if the already have over the minimum
			if ( other->client->ps.ammo[ent->item->giTag] < quantity )
				quantity = quantity - other->client->ps.ammo[ ent->item->giTag ];
			else
				quantity = 1;		// only add a single shot
		}
	}

	// add the weapon
	other->client->ps.stats[STAT_WEAPONS] |= ( 1 << ent->item->giTag );

	Add_Ammo( other, ent->item->giTag, quantity );

	return g_weaponRespawnTime->integer;
}
开发者ID:Razish,项目名称:QtZ,代码行数:29,代码来源:g_items.c

示例15: Pickup_Weapon

qboolean Pickup_Weapon (edict_t *ent, edict_t *other)
{
	int				index;
	const gitem_t	*ammo;

	index = ITEM_INDEX(ent->item);

	if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY)) 
		&& other->client->inventory[index])
	{
		if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) )
			return false;	// leave the weapon for others to pickup
	}

	other->client->inventory[index]++;

	if (!(ent->spawnflags & DROPPED_ITEM) )
	{
		// give them some ammo with it
		ammo = GETITEM (ent->item->ammoindex);
		if ( (int)dmflags->value & DF_INFINITE_AMMO )
			Add_Ammo (other, ammo, 1000);
		else
			Add_Ammo (other, ammo, ammo->quantity);

		if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) )
		{
			if ((int)(dmflags->value) & DF_WEAPONS_STAY)
				ent->flags |= FL_RESPAWN;
			else
				SetRespawn (ent, 30);
		}
	}

	if (other->client->weapon != ent->item && 
		(other->client->inventory[index] == 1) &&
		other->client->weapon == GETITEM (ITEM_WEAPON_BLASTER))
		other->client->newweapon = ent->item;

	return true;
}
开发者ID:AndreyNazarov,项目名称:opentdm,代码行数:41,代码来源:p_weapon.c


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