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


C++ IAIObject::Event方法代码示例

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


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

示例1: UpdatePlayerLowHealthStatus

void CLocalPlayerComponent::UpdatePlayerLowHealthStatus( const float oldHealth )
{
	const float healthThrLow = g_pGameCVars->g_playerLowHealthThreshold;
	const float healthThrMid = g_pGameCVars->g_playerMidHealthThreshold;

	const float maxHealth = (float)m_rPlayer.GetMaxHealth();
	const float minHealth = 0; 
	const float currentHealth = m_rPlayer.m_health.GetHealth();
	const bool isDead = m_rPlayer.m_health.IsDead();
	
	CRY_ASSERT( maxHealth > minHealth );

	//Extra 'mid-low' health sound hint
	if ((currentHealth <= healthThrMid) && (oldHealth > healthThrMid))
	{
		m_rPlayer.PlaySound(CPlayer::ESound_EnterMidHealth);
		m_playedMidHealthSound = true;
	}
	else if ((oldHealth <= healthThrMid) && (currentHealth > healthThrMid) && m_playedMidHealthSound)
	{
		m_rPlayer.PlaySound(CPlayer::ESound_EnterMidHealth, false);
		m_rPlayer.PlaySound(CPlayer::ESound_ExitMidHealth);
		m_playedMidHealthSound = false;
	}

	if((currentHealth <= healthThrLow) && (oldHealth > healthThrLow))
	{
		if(!isDead)
		{
			m_rPlayer.SetClientSoundmood(CPlayer::ESoundmood_LowHealth);
		}

		IAIObject* pAI = m_rPlayer.GetEntity()->GetAI();
		if (pAI)
		{
			float mercyTimeScale = 1.0f;
			
			SAIEVENT aiEvent;
			aiEvent.fThreat = mercyTimeScale;
			pAI->Event(AIEVENT_LOWHEALTH, &aiEvent);

			CGameRules* pGameRules = g_pGame->GetGameRules();
			if(pGameRules != NULL)
			{
				IGameRulesDamageHandlingModule* pDamageHandling = pGameRules->GetDamageHandlingModule();
				if(pDamageHandling != NULL)
				{
					pDamageHandling->OnGameEvent(IGameRulesDamageHandlingModule::eGameEvent_LocalPlayerEnteredMercyTime);
				}
			}
		}
	}
	else if((currentHealth > healthThrLow) && (oldHealth <= healthThrLow))
	{
		m_rPlayer.SetClientSoundmood(CPlayer::ESoundmood_Alive);
	}

	const float k_minDamageForHit = 10.0f;	//this is partly to deal with small differences in health over the network
	if(!isDead && (currentHealth < oldHealth - k_minDamageForHit))
	{
		m_rPlayer.SendMusicLogicEvent(eMUSICLOGICEVENT_PLAYER_WOUNDED);
	}

	const float defiantSkillKillLowHealth = maxHealth * g_pGameCVars->g_defiant_lowHealthFraction;

	if(currentHealth > defiantSkillKillLowHealth)
	{
		m_timeEnteredLowHealth = 0.f;
	}
	else if(m_timeEnteredLowHealth <= 0.f)
	{
		m_timeEnteredLowHealth = gEnv->pTimer->GetFrameStartTime();
	}
}
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:74,代码来源:LocalPlayerComponent.cpp


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