Ejemplo n.º 1
0
void sensor_support_think( gentity_t *self )
{
	if(!self->enabled)
	{
		self->nextthink = level.time + SENSOR_POLL_PERIOD * 5;
		return;
	}

	switch (self->conditions.team) {
		case TEAM_HUMANS:
			self->powered = G_FindPower( self, qfalse );
			break;
		case TEAM_ALIENS:
			self->powered = G_FindCreep( self );
			break;
		case TEAM_ALL:
			self->powered = G_FindPower( self, qfalse );
			if(!self->powered)
				self->powered = G_FindCreep( self );
			break;
		default:
			G_Printf(S_ERROR "missing team field for %s\n", etos( self ));
			G_FreeEntity( self );
			break;
	}

	if(self->powered)
		G_FireEntity( self, self->powerSource );

	self->nextthink = level.time + SENSOR_POLL_PERIOD;
}
Ejemplo n.º 2
0
void sensor_creep_think( gentity_t *self )
{
	if(!self->enabled)
	{
		self->nextthink = level.time + SENSOR_POLL_PERIOD * 5;
		return;
	}

	self->powered = G_FindCreep( self );

	if(self->powered)
		G_FireEntity( self, self->powerSource );

	self->nextthink = level.time + SENSOR_POLL_PERIOD;
}
void AlienBuildableComponent::Think(int timeDelta) {
	// TODO: Port gentity_t.powered.
	entity.oldEnt->powered = (G_ActiveOvermind() != nullptr);

	// Suicide if creep is gone.
	if (BG_Buildable(entity.oldEnt->s.modelindex)->creepTest && !G_FindCreep(entity.oldEnt)) {
		G_Kill(entity.oldEnt, entity.oldEnt->powerSource ? &g_entities[entity.oldEnt->powerSource->killedBy] : nullptr, MOD_NOCREEP);
	}

	// TODO: Find an elegant way to access per-buildable configuration.
	float creepSize = (float)BG_Buildable((buildable_t)entity.oldEnt->s.modelindex)->creepSize;

	// Slow close humans.
	ForEntities<HumanClassComponent>([&] (Entity& other, HumanClassComponent& humanClassComponent) {
		// TODO: Add LocationComponent.
		if (G_Distance(entity.oldEnt, other.oldEnt) > creepSize) return;

		// TODO: Send (Creep)Slow message instead.
		if (other.oldEnt->flags & FL_NOTARGET) return;
		if (other.oldEnt->client->ps.groundEntityNum == ENTITYNUM_NONE) return;
		other.oldEnt->client->ps.stats[STAT_STATE] |= SS_CREEPSLOWED;
		other.oldEnt->client->lastCreepSlowTime = level.time;
	});
}