Пример #1
0
void heal_touch(gentity_t * self, gentity_t * other, trace_t * trace)
{
	int             i, clientcount = 0;
	gentity_t      *touchClients[MAX_CLIENTS];
	int             healvalue;

	memset(touchClients, 0, sizeof(touchClients));

	if(!other->client)
	{
		return;
	}

	if(self->timestamp > level.time)
	{
		return;
	}
	self->timestamp = level.time + 1000;

	for(i = 0; i < level.numConnectedClients; i++)
	{
		int             j = level.sortedClients[i];

		if(level.clients[j].ps.stats[STAT_MAX_HEALTH] > g_entities[j].health &&
		   trap_EntityContactCapsule(g_entities[j].r.absmin, g_entities[j].r.absmax, self) && G_IsAllowedHeal(&g_entities[j]))
		{
			touchClients[clientcount] = &g_entities[j];
			clientcount++;
		}
	}

	if(clientcount == 0)
	{
		return;
	}

	for(i = 0; i < clientcount; i++)
	{
		healvalue = min(touchClients[i]->client->ps.stats[STAT_MAX_HEALTH] - touchClients[i]->health, self->damage);
		if(self->health != -9999)
		{
			healvalue = min(healvalue, self->health);
		}
		if(healvalue <= 0)
		{
			continue;
		}

		touchClients[i]->health += healvalue;
		// add the medicheal event (to get sound, etc.)
		G_AddPredictableEvent(other, EV_ITEM_PICKUP, BG_FindItemForClassName("item_health_cabinet") - bg_itemlist);

		if(self->health != -9999)
		{
			self->health -= healvalue;
		}
	}
}
Пример #2
0
/*
=================
TossClientItems

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

	// 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 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.

	// (SA) always drop what you were switching to
	if( self->client->ps.weaponstate == WEAPON_DROPPING ) {
		weapon = self->client->pers.cmd.weapon;
	}

	if( !( COM_BitCheck( self->client->ps.weapons, weapon ) ) ) {
		return;
	}

	if((self->client->ps.persistant[PERS_HWEAPON_USE])) {
		return;
	}

	// JPW NERVE don't drop these weapon types
	switch( weapon ) {
		case WP_NONE:
		case WP_KNIFE:
		case WP_DYNAMITE:
		case WP_ARTY:
		case WP_MEDIC_SYRINGE:
		case WP_SMOKETRAIL:
		case WP_MAPMORTAR:
		case VERYBIGEXPLOSION:
		case WP_MEDKIT:
		case WP_BINOCULARS:
		case WP_PLIERS:
		case WP_SMOKE_MARKER:
		case WP_TRIPMINE:
		case WP_SMOKE_BOMB:
		case WP_DUMMY_MG42:
		case WP_LOCKPICK:
		case WP_MEDIC_ADRENALINE:
			return;
		case WP_MORTAR_SET:
			weapon = WP_MORTAR;
			break;
		case WP_K43_SCOPE:
			weapon = WP_K43;
			break;
		case WP_GARAND_SCOPE:
			weapon = WP_GARAND;
			break;
		case WP_FG42SCOPE:
			weapon = WP_FG42;
			break;
		case WP_M7:
			weapon = WP_CARBINE;
			break;
		case WP_GPG40:
			weapon = WP_KAR98;
			break;
		case WP_MOBILE_MG42_SET:
			weapon = WP_MOBILE_MG42;
			break;
	}

	// find the item type for this weapon
	item = BG_FindItemForWeapon( weapon );
	// spawn the item
	
	drop = Drop_Item( self, item, 0, qfalse );
	drop->count = self->client->ps.ammoclip[BG_FindClipForWeapon(weapon)];
	drop->item->quantity = self->client->ps.ammoclip[BG_FindClipForWeapon(weapon)];*/

	weapon_t primaryWeapon;
	gitem_t *item;
	gentity_t *ent;
	int i;

	if( cvars::gameState.ivalue == GS_INTERMISSION ) {
		return;
	}

	primaryWeapon = G_GetPrimaryWeaponForClient( self->client );

	if( primaryWeapon ) {
		// drop our primary weapon
		G_DropWeapon( self, primaryWeapon );
	}

	// Drop binoculars if you have 'em and is set to drop
	if (cvars::bg_weapons.ivalue & SBW_DROPBINOCS && self->client->ps.stats[STAT_KEYS] & ( 1 << INV_BINOCS )) {
		item = BG_FindItemForClassName("weapon_binoculars");
		ent = Drop_Item(self, item, crandom() * 360, qfalse);
		ent->think=MagicSink;
		ent->nextthink = level.time + 60000;
		ent->r.mins[2] -= 8;
	}
	
	// Jaybird - Drop ammo or health on death for respective class
	if (self->client->sess.playerType == PC_MEDIC) {
		for (i = 0; i < g_dropHealth.integer; i++) {
			item = BG_FindItemForClassName("item_health");
			ent = Drop_Item(self, item, crandom() * 360, qfalse);
			ent->think=MagicSink;
			ent->nextthink = level.time + 30000;
		}
	}

	if (self->client->sess.playerType == PC_FIELDOPS) {

		for (i = 0; i < g_dropAmmo.integer; i++) {
			item = BG_FindItemForClassName("weapon_magicammo");
			ent = Drop_Item(self, item, crandom() * 360, qfalse);
			ent->think=MagicSink;
			ent->nextthink = level.time + 30000;
			ent->count = 1;
			ent->s.density = 1;
		}
	}
}