当前位置: 首页>>代码示例>>C++>>正文


C++ CGameRules::GetFriendlyFireRatio方法代码示例

本文整理汇总了C++中CGameRules::GetFriendlyFireRatio方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameRules::GetFriendlyFireRatio方法的具体用法?C++ CGameRules::GetFriendlyFireRatio怎么用?C++ CGameRules::GetFriendlyFireRatio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGameRules的用法示例。


在下文中一共展示了CGameRules::GetFriendlyFireRatio方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CalculateFriendlyFireRatio

float CGameRulesMPDamageHandling::CalculateFriendlyFireRatio(EntityId entityId1, EntityId entityId2)
{
	CGameRules *pGameRules = m_pGameRules;
	if (entityId1 != entityId2 && pGameRules->GetTeamCount() > 1)
	{
		int team1 = pGameRules->GetTeam(entityId1);
		if( team1 ==  pGameRules->GetTeam(entityId2) )
		{
			return pGameRules->GetFriendlyFireRatio();
		}
	}

	//Not on same team so full damage
	return 1.f;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:15,代码来源:GameRulesMPDamageHandling.cpp

示例2: ShouldSpawnBackSideEffect

bool CCannonBall::ShouldSpawnBackSideEffect(IEntity* pHitTarget)
{
	if(m_backSideEffectsDisabled)
		return false;

	if(m_ownerIsPlayer && pHitTarget)
	{
		IActor* pTarget = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pHitTarget->GetId());
		if(pTarget)
		{
			CGameRules* pGameRules = g_pGame->GetGameRules();
			if (pGameRules && pGameRules->GetFriendlyFireRatio() <= 0.f)
			{		
				//if friendly fire is off don't spawn blood effect on teammates
				return !pTarget->IsFriendlyEntity(m_ownerId);
			}
		}
	}

	return true;
}
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:21,代码来源:CannonBall.cpp

示例3: ProcessActorKickedVehicle

float CGameRulesMPDamageHandling::ProcessActorKickedVehicle(IActor* victimActor, EntityId victimId, EntityId kickerId, EntityId vehicleId, float damage, const CGameRules::SCollisionHitInfo& collisionHitInfo)
{
	float angSpeedSq = 0.f;
	const IEntity* pVehicleEntity = gEnv->pEntitySystem->GetEntity(vehicleId);
	if (pVehicleEntity)
	{
		IPhysicalEntity* pent = pVehicleEntity->GetPhysics();
		if (pent)
		{
			pe_status_dynamics psd;
			if (pent->GetStatus(&psd))
			{
				angSpeedSq = psd.w.GetLengthSquared();
			}
		}
	}

	const Vec3& actorVelocity = collisionHitInfo.velocity;
	const Vec3& vehicleVelocity = collisionHitInfo.target_velocity;
	const float vehicleSpeedSq = vehicleVelocity.GetLengthSquared() + angSpeedSq;

	if (vehicleSpeedSq < 1.5f)
		return 0.f;

	float damageScale = 1.f;

	if (g_pGameCVars->g_mpKickableCars)
	{
		if (kickerId==victimId || FindKickableCarRecord(vehicleId, victimId))
			return 0.f;

		CGameRules *pGameRules = g_pGame->GetGameRules();
		if (pGameRules->GetTeamCount() > 1)
		{
			int kickerTeamId = pGameRules->GetTeam(kickerId);
			int victimTeamId = pGameRules->GetTeam(victimId);

			if (kickerTeamId==victimTeamId)	// Friendly fire
			{
				float friendlyFireRatio = pGameRules->GetFriendlyFireRatio();
				if (friendlyFireRatio>0.f)
				{
					damageScale = friendlyFireRatio;
				}
				else
				{
					return 0.f;
				}
			}
		}

		InsertKickableCarRecord(vehicleId, victimId);
	}

	// Damage, for now, is based purely on vehicle speed
	const float vehicleKillSpeed = m_vehicleDamageSettings.killSpeed;
	const float invVehicleKillSpeed = 1.f/(vehicleKillSpeed+0.01f);
	const float maxActorHealth = victimActor->GetMaxHealth();
	damage = 0.1f + sqrtf(vehicleSpeedSq+0.04f) * invVehicleKillSpeed;
	damage = min(damage, 1.f) * maxActorHealth * damageScale;

	return damage;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:63,代码来源:GameRulesMPDamageHandling.cpp


注:本文中的CGameRules::GetFriendlyFireRatio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。