示例#1
0
/*
* Touch_Item
*/
void Touch_Item( edict_t *ent, edict_t *other, cplane_t *plane, int surfFlags )
{
	bool taken;
	const gsitem_t *item = ent->item;

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

	if( !( other->r.client->ps.pmove.stats[PM_STAT_FEATURES] & PMFEAT_ITEMPICK ) )
		return;

	if( !item || !( item->flags & ITFLAG_PICKABLE ) )
		return; // not a grabbable item

	if( !G_Gametype_CanPickUpItem( item ) )
		return;

	taken = G_PickupItem( other, item, ent->spawnflags, ent->count, ent->invpak );

	if( !( ent->spawnflags & ITEM_TARGETS_USED ) )
	{
		G_UseTargets( ent, other );
		ent->spawnflags |= ITEM_TARGETS_USED;
	}

	if( !taken )
		return;

	if( ent->spawnflags & ITEM_TIMED )
		ent->r.owner = other;

	// flash the screen
	G_AddPlayerStateEvent( other->r.client, PSEV_PICKUP, ( item->flags & IT_WEAPON ? item->tag : 0 ) );

	G_AwardPlayerPickup( other, ent );

	// for messages
	other->r.client->teamstate.last_pickup = ent;

	// show icon and name on status bar
	other->r.client->ps.stats[STAT_PICKUP_ITEM] = item->tag;
	other->r.client->resp.pickup_msg_time = level.time + 3000;

	if( ent->attenuation )
		Touch_ItemSound( other, item );

	if( !( ent->spawnflags & DROPPED_ITEM ) && G_Gametype_CanRespawnItem( item ) )
	{
		if( (item->type & IT_WEAPON ) && GS_RaceGametype() )
			return; // weapons stay in race
		SetRespawn( ent, G_Gametype_RespawnTimeForItem( item ) );
		return;
	}
	G_FreeEdict( ent );
}
示例#2
0
/*
* G_ClientDamageFeedback
* 
* Adds color blends, hitsounds, etc
*/
void G_ClientDamageFeedback( edict_t *ent )
{
	if( ent->r.client->resp.snap.damageTaken )
	{
		int damage = ent->r.client->resp.snap.damageTaken;
		int byteDir = DirToByte( ent->r.client->resp.snap.damageTakenDir );

		if( damage <= 20 )
			G_AddPlayerStateEvent( ent->r.client, PSEV_DAMAGE_20, byteDir );
		else if( damage <= 40 )
			G_AddPlayerStateEvent( ent->r.client, PSEV_DAMAGE_40, byteDir );
		else if( damage <= 60 )
			G_AddPlayerStateEvent( ent->r.client, PSEV_DAMAGE_60, byteDir );
		else
			G_AddPlayerStateEvent( ent->r.client, PSEV_DAMAGE_80, byteDir );
	}

	// add hitsounds from given damage
	if( ent->snap.damage_given || ent->snap.damageteam_given || ent->snap.kill || ent->snap.teamkill )
	{
		// we can't make team damage hit sound at the same time as we do damage hit sound
		// let's determine what's more relevant
		if( ent->snap.teamkill || ent->snap.damageteam_given > 50 ||
			( ent->snap.damageteam_given > 2 * ent->snap.damage_given && !ent->snap.kill ) )
		{
			G_AddPlayerStateEvent( ent->r.client, PSEV_HIT, 5 );
		}
		else
		{
			if( ent->snap.kill )
				G_AddPlayerStateEvent( ent->r.client, PSEV_HIT, 4 );
			else if( ent->snap.damage_given >= 75 )
				G_AddPlayerStateEvent( ent->r.client, PSEV_HIT, 0 );
			else if( ent->snap.damage_given >= 45 )
				G_AddPlayerStateEvent( ent->r.client, PSEV_HIT, 1 );
			else if( ent->snap.damage_given >= 20 )
				G_AddPlayerStateEvent( ent->r.client, PSEV_HIT, 2 );
			else
				G_AddPlayerStateEvent( ent->r.client, PSEV_HIT, 3 );
		}
	}
}
示例#3
0
文件: g_items.c 项目: hettoo/racesow
/*
* Touch_Item
*/
void Touch_Item( edict_t *ent, edict_t *other, cplane_t *plane, int surfFlags )
{
	qboolean taken;

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

	if( !( other->r.client->ps.pmove.stats[PM_STAT_FEATURES] & PMFEAT_ITEMPICK ) )
		return;

	if( !ent->item || !( ent->item->flags & ITFLAG_PICKABLE ) )
		return; // not a grabbable item

	if( !G_Gametype_CanPickUpItem( ent->item ) )
		return;

	taken = G_PickupItem( ent, other );

	if( !( ent->spawnflags & ITEM_TARGETS_USED ) )
	{
		G_UseTargets( ent, other );
		ent->spawnflags |= ITEM_TARGETS_USED;
	}

	if( !taken )
		return;

	// flash the screen
	G_AddPlayerStateEvent( other->r.client, PSEV_PICKUP, ( ent->item->flags & IT_WEAPON ? ent->item->tag : 0 ) );

	G_AwardPlayerPickup( other, ent );

	// for messages
	other->r.client->teamstate.last_pickup = ent;

	// show icon and name on status bar
	other->r.client->ps.stats[STAT_PICKUP_ITEM] = ent->item->tag;
	other->r.client->resp.pickup_msg_time = level.time + 3000;

	if( ent->attenuation )
		Touch_ItemSound( other, ent->item );

	if( !( ent->spawnflags & ( DROPPED_ITEM | DROPPED_PLAYER_ITEM ) ) && G_Gametype_CanRespawnItem( ent->item ) )
		SetRespawn( ent, G_Gametype_RespawnTimeForItem( ent->item ) );
	else
		G_FreeEdict( ent );
}