本文整理汇总了C++中CActor::GetBodyExplosionDamageMultiplier方法的典型用法代码示例。如果您正苦于以下问题:C++ CActor::GetBodyExplosionDamageMultiplier方法的具体用法?C++ CActor::GetBodyExplosionDamageMultiplier怎么用?C++ CActor::GetBodyExplosionDamageMultiplier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActor
的用法示例。
在下文中一共展示了CActor::GetBodyExplosionDamageMultiplier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SvOnExplosion
//------------------------------------------------------------------------
void CGameRulesMPDamageHandling::SvOnExplosion(const ExplosionInfo &explosionInfo, const CGameRules::TExplosionAffectedEntities& affectedEntities)
{
// SinglePlayer.lua 1721
IActorSystem* pActorSystem = g_pGame->GetIGameFramework()->GetIActorSystem();
float totalDamage = 0.f;
// calculate damage for each entity
CGameRules::TExplosionAffectedEntities::const_iterator it = affectedEntities.begin();
for (; it != affectedEntities.end(); ++it)
{
bool success = false;
IEntity* entity = it->first;
float obstruction = 1.0f - it->second;
bool incone=true;
if (explosionInfo.angle > 0 && explosionInfo.angle < 2*3.1415f)
{
Vec3 explosionEntityPos = entity->GetWorldPos();
Vec3 entitypos = explosionEntityPos;
float ha = explosionInfo.angle * 0.5f;
Vec3 edir = entitypos - explosionInfo.pos;
edir.normalize();
float dot = 1;
if (edir != Vec3(ZERO))
{
dot = edir.dot(explosionInfo.dir);
}
float angle = abs(acos_tpl(dot));
if (angle > ha)
{
incone = false;
}
}
if (incone && gEnv->bServer)
{
float damage = explosionInfo.damage;
damage = floor_tpl(0.5f + CalcExplosionDamage(entity, explosionInfo, obstruction));
bool dead = false;
HitInfo explHit;
Vec3 dir = entity->GetWorldPos() - explosionInfo.pos;
explHit.pos = explosionInfo.pos;
explHit.radius = explosionInfo.radius;
explHit.partId = -1;
dir.Normalize();
explHit.targetId = entity->GetId();
explHit.weaponId = explosionInfo.weaponId;
explHit.shooterId = explosionInfo.shooterId;
explHit.projectileId = explosionInfo.projectileId;
explHit.projectileClassId = explosionInfo.projectileClassId;
uint16 weaponClass = ~uint16(0);
const IEntity* pWeaponEntity = gEnv->pEntitySystem->GetEntity(explosionInfo.weaponId);
if (pWeaponEntity)
{
g_pGame->GetIGameFramework()->GetNetworkSafeClassId(weaponClass, pWeaponEntity->GetClass()->GetName());
}
explHit.weaponClassId = weaponClass;
explHit.material = 0;
explHit.damage = damage;
explHit.type = explosionInfo.type;
explHit.hitViaProxy = explosionInfo.explosionViaProxy;
explHit.dir = dir;
explHit.normal = -dir; //set normal to reverse of direction to avoid backface cull of damage
if (explHit.damage > 0.0f || explosionInfo.damage == 0.f)
{
CActor* pActor = static_cast<CActor*>(pActorSystem->GetActor(entity->GetId()));
if (pActor)
{
const float damageMultiplier = pActor->GetBodyExplosionDamageMultiplier(explHit);
explHit.damage *= damageMultiplier;
// Protect players who are currently shielded
if(pActor->IsPlayer() && static_cast<CPlayer*>(pActor)->ShouldFilterOutExplosion(explHit))
{
explHit.damage = 0.0f;
}
}
else
{
CInteractiveObjectEx* pInteractiveObject = static_cast<CInteractiveObjectEx*>(g_pGame->GetIGameFramework()->QueryGameObjectExtension(entity->GetId(), "InteractiveObjectEx"));
if(pInteractiveObject)
{
pInteractiveObject->OnExploded(explHit.pos);
}
}
//.........这里部分代码省略.........