Ejemplo n.º 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;
		}
	}
}
Ejemplo n.º 2
0
void heal_touch(gentity_t *self, gentity_t *other, trace_t *trace)
{
	int       i, j, clientcount = 0;
	gentity_t *touchClients[MAX_CLIENTS];
	int       healvalue;

	memset(touchClients, 0, sizeof(gentity_t *) * MAX_CLIENTS);

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

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

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

		if (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++)
	{
		if (touchClients[i]->client->sess.playerType == PC_MEDIC)
		{
			healvalue = MIN((int)(touchClients[i]->client->ps.stats[STAT_MAX_HEALTH] * 1.12) - touchClients[i]->health, self->damage);
		}
		else
		{
			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_GetItem(ITEM_HEALTH_CABINET) - bg_itemlist);

		if (self->health != -9999)
		{
			self->health -= healvalue;
		}
	}
}