Пример #1
0
//====================
//Player::KillEnt
//====================
void Player::KillEnt
	(
   Event * ev
   )

   {
	int num;
	Entity *ent;

	if ( ev->NumArgs() != 1 )
		{
      gi.SendServerCommand( edict-g_entities, "print \"Usage: killent <entity number>\n\"" );
		return;
		}

	num = ev->GetInteger( 1 );
   if ( ( num < 0 ) || ( num >= globals.max_entities ) )
		{
      gi.SendServerCommand( edict-g_entities, "print \"Value out of range.  Possible values range from 0 to %d.\n\"", globals.max_entities );
      return;
		}

	ent = G_GetEntity( num );
   ent->Damage( world, world, ent->max_health + 25, origin, vec_zero, vec_zero, 0, 0, 0 );
   }
Пример #2
0
void Utility::Kill(Entity& entity, Entity* source, meansOfDeath_t meansOfDeath) {
	HealthComponent *healthComponent = entity.Get<HealthComponent>();
	if (healthComponent) {
		entity.Damage(healthComponent->Health(), source ? source->oldEnt : nullptr, {}, {},
		              (DAMAGE_PURE | DAMAGE_NO_PROTECTION), meansOfDeath);
	}
}
Пример #3
0
//====================
//Player::KillClass
//====================
void Player::KillClass
	(
   Event * ev
   )

   {
   int except;
   str classname;
   gentity_t * from;
	Entity *ent;

	if ( ev->NumArgs() < 1 )
		{
      gi.SendServerCommand( edict-g_entities, "print \"Usage: killclass <classname> [except entity number]\n\"" );
		return;
		}

   classname = ev->GetString( 1 );

   except = 0;
   if ( ev->NumArgs() == 2 )
      {
      except = ev->GetInteger( 1 );
      }

   for ( from = this->edict + 1; from < &g_entities[ globals.num_entities ]; from++ )
		{
		if ( !from->inuse )
			{
			continue;
			}

		assert( from->entity );

      ent = from->entity;

      if ( ent->entnum == except )
         {
         continue;
         }

   	if ( ent->inheritsFrom( classname.c_str() ) )
         {
         ent->Damage( world, world, ent->max_health + 25, origin, vec_zero, vec_zero, 0, 0, 0 );
         }
      }
   }
Пример #4
0
void ThrowObject::Touch( Event *ev )
{
	Entity *other;
	
	if ( movetype != MOVETYPE_BOUNCE )
	{
		return;
	}
	
	other = ev->GetEntity( 1 );
	assert( other );
	
	if ( other->isSubclassOf( Teleporter ) )
	{
		return;
	}
	
	if ( other->entnum == owner )
	{
		return;
	}
	
	if ( throw_sound.length() )
	{
		StopLoopSound();
	}
	
	if ( other->takedamage && !hurt_target )
	{
		// other->Damage( this, G_GetEntity( owner ), size.length() * velocity.length() / 400, origin, velocity,
		//    level.impact_trace.plane.normal, 32, 0, MOD_THROWNOBJECT );
		
		other->Damage( this, G_GetEntity( owner ), damage, origin, velocity,
			level.impact_trace.plane.normal, 32, 0, MOD_THROWNOBJECT );
		hurt_target = true;
	}
	
	//Damage( this, this, max_health, origin, velocity, level.impact_trace.plane.normal, 32, 0, MOD_THROWNOBJECT );
	Damage( this, this, 0.0f, origin, velocity, level.impact_trace.plane.normal, 32, 0, MOD_THROWNOBJECT );
}
Пример #5
0
void GooDebris::Touch( Event *ev )
{
	Entity *other;
	Entity *owner;
	Vector ang;
	
	other = ev->GetEntity( 1 );
	
	if ( other == world )
	{
		vectoangles( level.impact_trace.plane.normal, ang );
		setAngles( ang );
	}
	
	if ( level.time < nexttouch )
	{
		return;
	}
	
	nexttouch = level.time + 0.5f;
	
	if ( !other || !other->isSubclassOf( Sentient ) )
	{
		return;
	}
	
	owner = G_GetEntity( this->owner );
	
	if ( !owner )
	{
		owner = world;
	}
	
	if ( !other )
	{
		return;
	}
	
	other->Damage( this, owner, damage, origin, Vector( 0.0f, 0.0f, 0.0f ), Vector( 0.0f, 0.0f, 0.0f ), 0, 0, meansofdeath );
}
void SpawnerComponent::Think(int timeDelta) {
	BuildableComponent *buildableComponent = entity.Get<BuildableComponent>();

	if (buildableComponent && !buildableComponent->Active()) return;

	Entity* blocker = GetBlocker();

	if (blocker) {
		if (!blocker->oldEnt) {
			logger.Warn("Spawn blocking entity has oldEnt == nullptr");
			return;
		}

		// Suicide if blocked by the map.
		if (blocker->oldEnt->s.number == ENTITYNUM_WORLD
		    || blocker->oldEnt->s.eType == entityType_t::ET_MOVER) {
			Entities::Kill(entity, nullptr, MOD_SUICIDE);
		}

		// Free a blocking corpse.
		else if (blocker->oldEnt->s.eType == entityType_t::ET_CORPSE) {
			G_FreeEntity(blocker->oldEnt);
		}

		else if (Entities::OnSameTeam(entity, *blocker)) {
			// Suicide if blocked by own main buildable.
			if (blocker->Get<MainBuildableComponent>()) {
				Entities::Kill(entity, nullptr, MOD_SUICIDE);
			}

			// Kill a friendly blocking buildable.
			else if (blocker->Get<BuildableComponent>()) {
				Entities::Kill(*blocker, nullptr, MOD_SUICIDE);

				// Play an animation so it's clear what destroyed the buildable.
				G_SetBuildableAnim(entity.oldEnt, BANIM_SPAWN1, true);
			}

			// Do periodic damage to a friendly client.
			// TODO: Externalize constants.
			else  if (blocker->Get<ClientComponent>() && g_antiSpawnBlock.integer) {
				blockTime += timeDelta;

				if (blockTime > BLOCKER_GRACE_PERIOD
				    && blockTime - timeDelta <= BLOCKER_GRACE_PERIOD) {
					WarnBlocker(*blocker, false);
				}

				if (blockTime > BLOCKER_GRACE_PERIOD + BLOCKER_WARN_PERIOD) {
					if (blockTime - timeDelta <= BLOCKER_GRACE_PERIOD + BLOCKER_WARN_PERIOD) {
						WarnBlocker(*blocker, true);
					}

					blocker->Damage(
						BLOCKER_DAMAGE * ((float)timeDelta / 1000.0f), entity.oldEnt, {}, {},
						DAMAGE_PURE, MOD_TRIGGER_HURT
					);
				}
			}
		}
	} else if (g_antiSpawnBlock.integer) {
		blockTime = Math::Clamp(blockTime - timeDelta, 0, BLOCKER_GRACE_PERIOD);
	}
}