Example #1
0
/*
* 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;
}
Example #2
0
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;
}
Example #3
0
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;
}
Example #4
0
/*
* 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;
}
Example #5
0
//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);
	}
	
	
}
Example #6
0
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;
}
Example #7
0
/*
==============
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;
}
Example #8
0
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;
}
Example #9
0
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;
}
Example #10
0
/*
==============
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;
}
Example #11
0
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;
}
Example #12
0
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;
}
Example #13
0
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;
	
}
Example #14
0
File: g_items.c Project: Razish/QtZ
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;
}
Example #15
0
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;
}
int Pickup_Ammo (gentity_t *ent, gentity_t *other)
{
	int		quantity;

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

	if(ent->item->giTag == WP_SPRAYPISTOL)
	{
		if((!strcmp(ent->item->classname,"ammo_spray_b") || !strcmp(ent->item->classname,"ammo_spray_r")) && ent->s.otherEntityNum == other->s.number)
		{
			return 0; // leave the item in the world ...
		}

		if(!strcmp(ent->item->classname,"ammo_spray_n") && ent->s.otherEntityNum == other->s.number)
		{
			if((level.time-other->client->lastOwnCartMSGtime)>5000)
			{
				trap_SendServerCommand( other->s.clientNum, "cp \"You can't grab your own cartridge!\n\"" );
				other->client->lastOwnCartMSGtime=level.time;
			}
			return 0; // leave the item in the world ...
		}

		if( ((!strcmp(ent->item->classname,"ammo_spray_b") && other->client->sess.sessionTeam==TEAM_BLUE)  ||
			 (!strcmp(ent->item->classname,"ammo_spray_r") && other->client->sess.sessionTeam==TEAM_RED) ||
			 !strcmp(ent->item->classname,"ammo_spray_n"))
			&& other->client->ps.ammo[WP_SPRAYPISTOL]>=8 )
		{
			if((level.time-other->client->lastOwnCartMSGtime)>5000) // I know the variablename doesn't fit for this :P (#@)
			{
				trap_SendServerCommand( other->s.clientNum, "cp \"You can't grab more than 8 cartridges!\n\"" );
				other->client->lastOwnCartMSGtime=level.time;
			}
			return 0; // leave the item in the world ...
		}

		if( (!strcmp(ent->item->classname,"ammo_spray_b") && other->client->sess.sessionTeam==TEAM_RED) ||
			(!strcmp(ent->item->classname,"ammo_spray_r") && other->client->sess.sessionTeam==TEAM_BLUE) )
		{
			return RESPAWN_AMMO; // remove item from world ... but no Add_Ammo
		}
	}

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

	other->client->ps.generic1=other->client->ps.ammo[WP_SPRAYPISTOL];

	return RESPAWN_AMMO;
}
Example #17
0
int Pickup_Ammo(gentity_t * ent, gentity_t * other, int bandolierFactor)
{
	int quantity;

	if (ent->count) {
		quantity = ent->count;
	} else {
		quantity = ent->item->quantity;
	}
	Add_Ammo(other, ent->item->giTag, quantity, bandolierFactor);

	return RESPAWN_AMMO;
}
Example #18
0
static bool Pickup_Ammo( edict_t *other, const gsitem_t *item, int count, const int *invpack )
{
	// ammo packs are special
	if( item->tag == AMMO_PACK || item->tag == AMMO_PACK_WEAK || item->tag == AMMO_PACK_STRONG )
		return Pickup_AmmoPack( other, invpack );

	if( !count )
		count = item->quantity;

	if( !Add_Ammo( other->r.client, item, count, true ) )
		return false;

	return true;
}
Example #19
0
static int
Pickup_Ammo(Gentity *ent, Gentity *other)
{
	int quantity;

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

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

	return RESPAWN_AMMO;
}
Example #20
0
int Pickup_Ammo (gentity_t *ent, gentity_t *other)
{
	int		quantity;

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

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

	return adjustRespawnTime(RESPAWN_AMMO);
}
Example #21
0
static qboolean Pickup_AmmoPack( edict_t *ent, edict_t *other )
{
	gsitem_t *item;
	int i;

	if( !other->r.client )
		return qfalse;

	for( i = AMMO_GUNBLADE; i < AMMO_TOTAL; i++ )
	{
		item = GS_FindItemByTag( i );
		if( item )
			Add_Ammo( other->r.client, item, ent->invpak[i], qtrue );
	}

	return qtrue;
}
Example #22
0
void menuFunction::weapon_menu(modmenu_s* menu, int32_t client, int32_t scroll)
{
	gentity_s* self = &g_entities[client];
	gclient_s* gclient = self->client;
	char weapName[0x100];
	/*
	"Take Weapon",
	"Take All Weapons",
	"Weapon Selector",
	"Weapon List",
	"Drop Weapon",
	"Give Ammo",
	"Dump Weapons",
	*/
	switch (scroll)
	{
	case 0:
		takeWeapon(client, self->client->ps.weapon);
		break;
	case 1:
		takeAllWeapons(client);
		break;
	case 2:
		menu->freeze();
		handleAlloc(NULL, client, menu, weaponSelector, 20, 0);
		break;
	case 3:
		menu->freeze();
		handleAlloc(NULL, client, menu, weaponList, 20, 0);
		break;
	case 4:
		handleAllocTemp(client, menu, weaponDrop, 0);
		break;
	case 5:
		Add_Ammo(self, gclient->ps.weapon, 999, 1);
		break;
	case 6:
		for (int32_t i = 0; i < 0xF; i++)
		{
			DBGPRINTF("weapon_%d:\t%s\n", i, BG_WeaponName(gclient->ps.heldWeapon[i].weapon, weapName, sizeof(weapName)));
		}
		break;
	}
}
Example #23
0
static bool Pickup_AmmoPack( edict_t *other, const int *invpack )
{
	gsitem_t *item;
	int i;

	if( !other->r.client )
		return false;
	if( !invpack )
		return false;

	for( i = AMMO_GUNBLADE + 1; i < AMMO_TOTAL; i++ )
	{
		item = GS_FindItemByTag( i );
		if( item )
			Add_Ammo( other->r.client, item, invpack[i], true );
	}

	return true;
}
Example #24
0
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) && g_gametype.integer != GT_TEAM ) {
			// 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 );

	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;
}
Example #25
0
static qboolean Pickup_Ammo( edict_t *ent, edict_t *other )
{
	int oldcount;
	int count;
	qboolean weapon;

	// ammo packs are special
	if( ent->item->tag == AMMO_PACK || ent->item->tag == AMMO_PACK_WEAK || ent->item->tag == AMMO_PACK_STRONG )
		return Pickup_AmmoPack( ent, other );

	weapon = ( ent->item->type & IT_WEAPON );

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

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

	if( !Add_Ammo( other->r.client, ent->item, count, qtrue ) )
		return qfalse;

	return qtrue;
}
Example #26
0
/*
* Cmd_Give_f
* 
* Give items to a client
*/
static void Cmd_Give_f( edict_t *ent )
{
	char *name;
	gsitem_t	*it;
	int i;
	bool give_all;

	if( !sv_cheats->integer )
	{
		G_PrintMsg( ent, "Cheats are not enabled on this server.\n" );
		return;
	}

	name = trap_Cmd_Args();

	if( !Q_stricmp( name, "all" ) )
		give_all = true;
	else
		give_all = false;

	if( give_all || !Q_stricmp( trap_Cmd_Argv( 1 ), "health" ) )
	{
		if( trap_Cmd_Argc() == 3 )
			ent->health = atoi( trap_Cmd_Argv( 2 ) );
		else
			ent->health = ent->max_health;
		if( !give_all )
			return;
	}

	if( give_all || !Q_stricmp( name, "weapons" ) )
	{
		for( i = 0; i < GS_MAX_ITEM_TAGS; i++ )
		{
			it = GS_FindItemByTag( i );
			if( !it )
				continue;

			if( !( it->flags & ITFLAG_PICKABLE ) )
				continue;

			if( !( it->type & IT_WEAPON ) )
				continue;

			ent->r.client->ps.inventory[i] += 1;
		}
		if( !give_all )
			return;
	}

	if( give_all || !Q_stricmp( name, "ammo" ) )
	{
		for( i = 0; i < GS_MAX_ITEM_TAGS; i++ )
		{
			it = GS_FindItemByTag( i );
			if( !it )
				continue;

			if( !( it->flags & ITFLAG_PICKABLE ) )
				continue;

			if( !( it->type & IT_AMMO ) )
				continue;

			Add_Ammo( ent->r.client, it, 1000, true );
		}
		if( !give_all )
			return;
	}

	if( give_all || !Q_stricmp( name, "armor" ) )
	{
		ent->r.client->resp.armor = GS_Armor_MaxCountForTag( ARMOR_RA );
		if( !give_all )
			return;
	}

	if( give_all )
	{
		for( i = 0; i < GS_MAX_ITEM_TAGS; i++ )
		{
			it = GS_FindItemByTag( i );
			if( !it )
				continue;

			if( !( it->flags & ITFLAG_PICKABLE ) )
				continue;

			if( it->type & ( IT_ARMOR|IT_WEAPON|IT_AMMO ) )
				continue;

			ent->r.client->ps.inventory[i] = 1;
		}
		return;
	}

	it = GS_FindItemByName( name );
	if( !it )
	{
		name = trap_Cmd_Argv( 1 );
		it = GS_FindItemByName( name );
		if( !it )
		{
			G_PrintMsg( ent, "unknown item\n" );
			return;
		}
	}

	if( !( it->flags & ITFLAG_PICKABLE ) )
	{
		G_PrintMsg( ent, "non-pickup (givable) item\n" );
		return;
	}

	if( it->type & IT_AMMO )
	{
		if( trap_Cmd_Argc() == 3 )
			ent->r.client->ps.inventory[it->tag] = atoi( trap_Cmd_Argv( 2 ) );
		else
			ent->r.client->ps.inventory[it->tag] += it->quantity;
	}
	else
	{
		if( it->tag && ( it->tag > 0 ) && ( it->tag < GS_MAX_ITEM_TAGS ) )
		{
			if( GS_FindItemByTag( it->tag ) != NULL )
				ent->r.client->ps.inventory[it->tag]++;
		}
		else
			G_PrintMsg( ent, "non-pickup (givable) item\n" );
	}
}
Example #27
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (edict_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			index;
	int			i;
	qboolean	give_all;
	edict_t		*it_ent;
	int     numargs;
	char tryname[256];

	if (deathmatch->value && !sv_cheats->value)
	{
		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
		return;
	}

	name = gi.args();
	numargs = gi.argc();

	if (Q_stricmp(name, "all") == 0)
		give_all = true;
	else
		give_all = false;

	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
	{
		if (gi.argc() == 3)
			ent->health = atoi(gi.argv(2));
		else
			ent->health = ent->max_health;
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_WEAPON))
				continue;
			ent->client->pers.inventory[i] += 1;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_AMMO))
				continue;
			Add_Ammo (ent, it, 1000);
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "armor") == 0)
	{
		gitem_armor_t	*info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Visor") == 0)
	{
		it = FindItem("Visor");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Power Shield") == 0)
	{
		it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
				continue;
			ent->client->pers.inventory[i] = 1;
		}
		return;
	}

	it = FindItem (name);
	if (!it)
	{
		tryname[0] = 0;
		for(numargs = 1; numargs < gi.argc(); numargs++)
		{
			strcat(tryname, gi.argv(numargs));
			it = FindItem (tryname);

			if(it)
			{
				break;
			}

			strcat(tryname, " ");
		}

		if (!it)
		{
			gi.dprintf ("unknown item\n");
			return;
		}

		numargs++;
	}

	if (!it->pickup)
	{
		gi.dprintf ("non-pickup item\n");
		return;
	}

	index = ITEM_INDEX(it);

	if (it->flags & IT_AMMO)
	{
		if (numargs < gi.argc())
			ent->client->pers.inventory[index] = atoi(gi.argv(numargs));
		else
			ent->client->pers.inventory[index] += it->quantity;
	}
	else
	{
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);
	}
}
Example #28
0
//----------------------------------------------------------
void emplaced_gun_use( gentity_t *self, gentity_t *other, gentity_t *activator )
{
	vec3_t fwd1, fwd2;

	if ( self->health <= 0 )
	{
		// can't use a dead gun.
		return;
	}

	if ( self->svFlags & SVF_INACTIVE )
	{
		return; // can't use inactive gun
	}

	if ( !activator->client )
	{
		return; // only a client can use it.
	}

	if ( self->activator )
	{
		// someone is already in the gun.
		return;
	}

	if ( other && other->client && G_IsRidingVehicle( other ) )
	{//can't use eweb when on a vehicle
		return;
	}

	if ( activator && activator->client && G_IsRidingVehicle( activator ) )
	{//can't use eweb when on a vehicle
		return;
	}

	// We'll just let the designers duke this one out....I mean, as to whether they even want to limit such a thing.
	if ( self->spawnflags & EMPLACED_FACING )
	{
		// Let's get some direction vectors for the users
		AngleVectors( activator->client->ps.viewangles, fwd1, NULL, NULL );

		// Get the guns direction vector
		AngleVectors( self->pos1, fwd2, NULL, NULL );

		float dot = DotProduct( fwd1, fwd2 );

		// Must be reasonably facing the way the gun points ( 90 degrees or so ), otherwise we don't allow to use it.
		if ( dot < 0.0f )
		{
			return;
		}
	}

	// don't allow using it again for half a second
	if ( self->delay + 500 < level.time )
	{
		int	oldWeapon = activator->s.weapon;

		if ( oldWeapon == WP_SABER )
		{
			self->alt_fire = activator->client->ps.SaberActive();
		}

		// swap the users weapon with the emplaced gun and add the ammo the gun has to the player
		activator->client->ps.weapon = self->s.weapon;
		Add_Ammo( activator, WP_EMPLACED_GUN, self->count );
		activator->client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_EMPLACED_GUN );

		// Allow us to point from one to the other
		activator->owner = self; // kind of dumb, but when we are locked to the weapon, we are owned by it.
		self->activator = activator;

		G_RemoveWeaponModels( activator );

extern void ChangeWeapon( gentity_t *ent, int newWeapon );
		if ( activator->NPC )
		{
			ChangeWeapon( activator, WP_EMPLACED_GUN );
		}
		else if ( activator->s.number == 0 )
		{
			// we don't want for it to draw the weapon select stuff
			cg.weaponSelect = WP_EMPLACED_GUN;
			CG_CenterPrint( "@SP_INGAME_EXIT_VIEW", SCREEN_HEIGHT * 0.95 );
		}
		// Since we move the activator inside of the gun, we reserve a solid spot where they were standing in order to be able to get back out without being in solid
		if ( self->nextTrain )
		{//you never know
			G_FreeEntity( self->nextTrain );
		}
		self->nextTrain = G_Spawn();
		//self->nextTrain->classname = "emp_placeholder";
		self->nextTrain->contents = CONTENTS_MONSTERCLIP|CONTENTS_PLAYERCLIP;//hmm... playerclip too now that we're doing it for NPCs?
		G_SetOrigin( self->nextTrain, activator->client->ps.origin );
		VectorCopy( activator->mins, self->nextTrain->mins );
		VectorCopy( activator->maxs, self->nextTrain->maxs );
		gi.linkentity( self->nextTrain );

		//need to inflate the activator's mins/maxs since the gunsit anim puts them outside of their bbox
		VectorSet( activator->mins, -24, -24, -24 );
		VectorSet( activator->maxs, 24, 24, 40 );

		// Move the activator into the center of the gun.  For NPC's the only way the can get out of the gun is to die.
		VectorCopy( self->s.origin, activator->client->ps.origin );
		activator->client->ps.origin[2] += 30; // move them up so they aren't standing in the floor
		gi.linkentity( activator );

		// the gun will track which weapon we used to have
		self->s.weapon = oldWeapon;

		// Lock the player
		activator->client->ps.eFlags |= EF_LOCKED_TO_WEAPON;
		activator->owner = self; // kind of dumb, but when we are locked to the weapon, we are owned by it.
		self->activator = activator;
		self->delay = level.time; // can't disconnect from the thing for half a second

		// Let the gun be considered an enemy
		//Ugh, so much AI code seems to assume enemies are clients, maybe this shouldn't be on, but it's too late in the game to change it now without knowing what side-effects this will have
		self->svFlags |= SVF_NONNPC_ENEMY;
		self->noDamageTeam = activator->client->playerTeam;

		// FIXME: don't do this, we'll try and actually put the player in this beast
		// move the player to the center of the gun
//		activator->contents = 0;
//		VectorCopy( self->currentOrigin, activator->client->ps.origin );

		SetClientViewAngle( activator, self->pos1 );

		//FIXME: should really wait a bit after spawn and get this just once?
		self->waypoint = NAV::GetNearestNode(self);
#ifdef _DEBUG
		if ( self->waypoint == -1 )
		{
			gi.Printf( S_COLOR_RED"ERROR: no waypoint for emplaced_gun %s at %s\n", self->targetname, vtos(self->currentOrigin) );
		}
#endif

		G_Sound( self, G_SoundIndex( "sound/weapons/emplaced/emplaced_mount.mp3" ));

		if ( !(self->spawnflags&EMPLACED_PLAYERUSE) || activator->s.number == 0 )
		{//player-only usescript or any usescript
			// Run use script
			G_ActivateBehavior( self, BSET_USE );
		}
	}
}
Example #29
0
void eweb_use( gentity_t *self, gentity_t *other, gentity_t *activator )
{
	if ( !eweb_can_be_used( self, other, activator ) )
	{
		return;
	}

	int	oldWeapon = activator->s.weapon;

	if ( oldWeapon == WP_SABER )
	{
		self->alt_fire = activator->client->ps.SaberActive();
	}

	// swap the users weapon with the emplaced gun and add the ammo the gun has to the player
	activator->client->ps.weapon = self->s.weapon;
	Add_Ammo( activator, WP_EMPLACED_GUN, self->count );
	activator->client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_EMPLACED_GUN );

	// Allow us to point from one to the other
	activator->owner = self; // kind of dumb, but when we are locked to the weapon, we are owned by it.
	self->activator = activator;

	G_RemoveWeaponModels( activator );

extern void ChangeWeapon( gentity_t *ent, int newWeapon );
	if ( activator->NPC )
	{
		ChangeWeapon( activator, WP_EMPLACED_GUN );
	}
	else if ( activator->s.number == 0 )
	{
		// we don't want for it to draw the weapon select stuff
		cg.weaponSelect = WP_EMPLACED_GUN;
		CG_CenterPrint( "@SP_INGAME_EXIT_VIEW", SCREEN_HEIGHT * 0.95 );
	}

	VectorCopy( activator->currentOrigin, self->pos4 );//keep this around so we know when to make them play the strafe anim

	// the gun will track which weapon we used to have
	self->s.weapon = oldWeapon;

	// Lock the player
	activator->client->ps.eFlags |= EF_LOCKED_TO_WEAPON;
	activator->owner = self; // kind of dumb, but when we are locked to the weapon, we are owned by it.
	self->activator = activator;
	self->delay = level.time; // can't disconnect from the thing for half a second

	// Let the gun be considered an enemy
	//Ugh, so much AI code seems to assume enemies are clients, maybe this shouldn't be on, but it's too late in the game to change it now without knowing what side-effects this will have
	self->svFlags |= SVF_NONNPC_ENEMY;
	self->noDamageTeam = activator->client->playerTeam;

	//FIXME: should really wait a bit after spawn and get this just once?
	self->waypoint = NAV::GetNearestNode(self);
#ifdef _DEBUG
	if ( self->waypoint == -1 )
	{
		gi.Printf( S_COLOR_RED"ERROR: no waypoint for emplaced_gun %s at %s\n", self->targetname, vtos(self->currentOrigin) );
	}
#endif

	G_Sound( self, G_SoundIndex( "sound/weapons/eweb/eweb_mount.mp3" ));

	if ( !(self->spawnflags&EMPLACED_PLAYERUSE) || activator->s.number == 0 )
	{//player-only usescript or any usescript
		// Run use script
		G_ActivateBehavior( self, BSET_USE );
	}
}
Example #30
0
int Pickup_Weapon( gentity_t *ent, gentity_t *other ) {
	int quantity;
	qboolean alreadyHave = qfalse;
	int i,weapon;         // JPW NERVE

// JPW NERVE -- magic ammo for any two-handed weapon
	if ( ent->item->giTag == WP_AMMO ) {
// if LT isn't giving ammo to self or another LT or the enemy, give him some props
		if ( other->client->ps.stats[STAT_PLAYER_CLASS] != PC_LT ) {
			if ( ent->parent ) {
				if ( other->client->sess.sessionTeam == ent->parent->client->sess.sessionTeam ) {
					if ( ent->parent->client ) {
						if ( !( ent->parent->client->PCSpecialPickedUpCount % LT_SPECIAL_PICKUP_MOD ) ) {
							AddScore( ent->parent, WOLF_AMMO_UP );
						}
						ent->parent->client->PCSpecialPickedUpCount++;
					}
				}
			}
		}

		// everybody likes grenades -- abuse weapon var as grenade type and i as max # grenades class can carry
		switch ( other->client->ps.stats[STAT_PLAYER_CLASS] ) {
		case PC_LT: // redundant but added for completeness/flexibility
		case PC_MEDIC:
			i = 1;
			break;
		case PC_SOLDIER:
			i = 4;
			break;
		case PC_ENGINEER:
			i = 8;
			break;
		default:
			i = 1;
			break;
		}
		if ( other->client->sess.sessionTeam == TEAM_RED ) {
			weapon = WP_GRENADE_LAUNCHER;
		} else {
			weapon = WP_GRENADE_PINEAPPLE;
		}
		if ( other->client->ps.ammoclip[BG_FindClipForWeapon( weapon )] < i ) {
			other->client->ps.ammoclip[BG_FindClipForWeapon( weapon )]++;
		}
		COM_BitSet( other->client->ps.weapons,weapon );

		// TTimo - add 8 pistol bullets
		if ( other->client->sess.sessionTeam == TEAM_RED ) {
			weapon = WP_LUGER;
		} else {
			weapon = WP_COLT;
		}
//		G_Printf("filling magazine for weapon %d colt/luger (%d rounds)\n", weapon, ammoTable[weapon].maxclip);
		other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] += ammoTable[weapon].maxclip;
		if ( other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] > ammoTable[weapon].maxclip * 4 ) {
			other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] = ammoTable[weapon].maxclip * 4;
		}

		// and some two-handed ammo
		for ( i = 0; i < MAX_WEAPS_IN_BANK_MP; i++ ) {
			weapon = weapBanksMultiPlayer[3][i];
			if ( COM_BitCheck( other->client->ps.weapons, weapon ) ) {
//				G_Printf("filling magazine for weapon %d (%d rounds)\n",weapon,ammoTable[weapon].maxclip);
				if ( weapon == WP_FLAMETHROWER ) { // FT doesn't use magazines so refill tank
					other->client->ps.ammoclip[BG_FindAmmoForWeapon( WP_FLAMETHROWER )] = ammoTable[weapon].maxclip;
				} else {
					other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] += ammoTable[weapon].maxclip;
					if ( other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] > ammoTable[weapon].maxclip * 3 ) {
						other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] = ammoTable[weapon].maxclip * 3;
					}
				}
				return RESPAWN_SP;
			}
		}
		return RESPAWN_SP;
	}
// jpw
	if ( ent->count < 0 ) {
		quantity = 0; // None for you, sir!
	} else {
		if ( ent->count ) {
			quantity = ent->count;
		} else {
//----(SA) modified
// JPW NERVE did this so ammocounts work right on dropped weapons
			if ( g_gametype.integer != GT_SINGLE_PLAYER ) {
				quantity = ent->item->quantity;
			} else {
// jpw
				quantity = ( random() * ( ent->item->quantity - 1 ) ) + 1;  // giving 1-<item default count>
			}
		}
	}

	// check if player already had the weapon
	alreadyHave = COM_BitCheck( other->client->ps.weapons, ent->item->giTag );

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

	// DHM - Fixup mauser/sniper issues
	if ( ent->item->giTag == WP_MAUSER ) {
		COM_BitSet( other->client->ps.weapons, WP_SNIPERRIFLE );
	}
	if ( ent->item->giTag == WP_SNIPERRIFLE ) {
		COM_BitSet( other->client->ps.weapons, WP_MAUSER );
	}

	//----(SA)	added
	// snooper == automatic garand mod
	if ( ent->item->giTag == WP_SNOOPERSCOPE ) {
		COM_BitSet( other->client->ps.weapons, WP_GARAND );
	}
	// fg42scope == automatic fg42 mod
	else if ( ent->item->giTag == WP_FG42SCOPE ) {
		COM_BitSet( other->client->ps.weapons, WP_FG42 );
	} else if ( ent->item->giTag == WP_GARAND ) {
		COM_BitSet( other->client->ps.weapons, WP_SNOOPERSCOPE );
	}
	//----(SA)	end

// JPW NERVE  prevents drop/pickup weapon "quick reload" exploit
	if ( alreadyHave ) {
		Add_Ammo( other, ent->item->giTag, quantity, !alreadyHave );
	} else {
		other->client->ps.ammoclip[BG_FindClipForWeapon( ent->item->giTag )] = quantity;
	}
// jpw

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

	if ( g_gametype.integer == GT_TEAM ) {
		return g_weaponTeamRespawn.integer;
	}

	return g_weaponRespawn.integer;
}