本文整理汇总了C++中CGameRules::GetDamageHandlingModule方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameRules::GetDamageHandlingModule方法的具体用法?C++ CGameRules::GetDamageHandlingModule怎么用?C++ CGameRules::GetDamageHandlingModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameRules
的用法示例。
在下文中一共展示了CGameRules::GetDamageHandlingModule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EndVerificationSample
//------------------------------------------------------------------------
IMPLEMENT_RMI(CWeapon, SvRequestShoot)
{
CHECK_OWNER_REQUEST();
bool ok=true;
CActor *pActor=GetActorByNetChannel(pNetChannel);
if (!pActor || pActor->IsDead())
ok=false;
if (ok)
{
m_fireCounter++;
m_expended_ammo++;
IActor *pLocalActor=m_pGameFramework->GetClientActor();
bool isLocal = pLocalActor && (pLocalActor->GetChannelId() == pActor->GetChannelId());
#ifdef SERVER_CHECKS
const float fCurrentTime = gEnv->pTimer->GetAsyncCurTime();
const int kOldShotId = m_lastShotId;
if(ShouldEndVerificationSample(fCurrentTime, params.shotId))
{
EndVerificationSample(pActor, kOldShotId);
StartVerificationSample(fCurrentTime);
}
m_fLastSampleTakenTime = fCurrentTime;
m_fSampleNumShots += 1.0f;
CPlayer * pPlayer = static_cast<CPlayer*>(pActor);
pPlayer->GetShotCounter()->RecordShot();
#endif
if (!isLocal)
{
NetShoot(params.hit, 0, params.fireModeId);
}
CHANGED_NETWORK_STATE(this, ASPECT_STREAM);
}
#ifdef SERVER_CHECKS
CGameRules * pGameRules = static_cast<CGameRules*>(g_pGame->GetGameRules());
if(pGameRules) //really we should assert here. I struggle to think of a situation where someone is requesting a shot but there are no GameRules...
{
IGameRulesDamageHandlingModule * pDamageHandler = pGameRules->GetDamageHandlingModule();
assert(pDamageHandler);
pDamageHandler->RegisterShotIdentification(pActor->GetEntityId(), this, params.shotId);
}
#endif
return true;
}
示例2: 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();
}
}