本文整理汇总了C++中Entity::Damage方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::Damage方法的具体用法?C++ Entity::Damage怎么用?C++ Entity::Damage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::Damage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//====================
//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: Kill
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: Think
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);
}
}