本文整理汇总了C++中CBaseEntity::GetMaxHealth方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseEntity::GetMaxHealth方法的具体用法?C++ CBaseEntity::GetMaxHealth怎么用?C++ CBaseEntity::GetMaxHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseEntity
的用法示例。
在下文中一共展示了CBaseEntity::GetMaxHealth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NPCThink
void CASW_Shaman::NPCThink( void )
{
BaseClass::NPCThink();
CBaseEntity *pHealTarget = NULL;
if ( GetPrimaryBehavior() == &m_HealOtherBehavior )
{
pHealTarget = m_HealOtherBehavior.GetCurrentHealTarget();
if ( pHealTarget )
{
pHealTarget->TakeHealth( m_HealOtherBehavior.m_flHealAmount * pHealTarget->GetMaxHealth(), DMG_GENERIC );
}
}
SetCurrentHealingTarget( pHealTarget );
}
示例2: FindAndHealTargets
//-----------------------------------------------------------------------------
// Purpose: Returns a pointer to a healable target
//-----------------------------------------------------------------------------
bool CWeaponMedigun::FindAndHealTargets( void )
{
CTFPlayer *pOwner = ToTFPlayer( GetOwnerEntity() );
if ( !pOwner )
return false;
bool bFound = false;
// Maintaining beam to existing target?
CBaseEntity *pTarget = m_hHealingTarget;
if ( pTarget && pTarget->IsAlive() )
{
MaintainTargetInSlot();
}
else
{
FindNewTargetForSlot();
}
CBaseEntity *pNewTarget = m_hHealingTarget;
if ( pNewTarget && pNewTarget->IsAlive() )
{
CTFPlayer *pTFPlayer = ToTFPlayer( pNewTarget );
#ifdef GAME_DLL
// HACK: For now, just deal with players
if ( pTFPlayer )
{
if ( pTarget != pNewTarget && pNewTarget->IsPlayer() )
{
pTFPlayer->m_Shared.Heal( pOwner, GetHealRate() );
}
pTFPlayer->m_Shared.RecalculateChargeEffects( false );
}
if ( m_flReleaseStartedAt && m_flReleaseStartedAt < (gpGlobals->curtime + 0.2) )
{
// When we start the release, everyone we heal rockets to full health
pNewTarget->TakeHealth( pNewTarget->GetMaxHealth(), DMG_GENERIC );
}
#endif
bFound = true;
// Charge up our power if we're not releasing it, and our target
// isn't receiving any benefit from our healing.
if ( !m_bChargeRelease )
{
if ( pTFPlayer )
{
int iBoostMax = floor( pTFPlayer->m_Shared.GetMaxBuffedHealth() * 0.95);
if ( weapon_medigun_charge_rate.GetFloat() )
{
float flChargeAmount = gpGlobals->frametime / weapon_medigun_charge_rate.GetFloat();
// Reduced charge for healing fully healed guys
if ( pNewTarget->GetHealth() >= iBoostMax && ( TFGameRules() && !TFGameRules()->InSetup() ) )
{
flChargeAmount *= 0.5;
}
int iTotalHealers = pTFPlayer->m_Shared.GetNumHealers();
if ( iTotalHealers > 1 )
{
flChargeAmount /= (float)iTotalHealers;
}
float flNewLevel = min( m_flChargeLevel + flChargeAmount, 1.0 );
#ifdef GAME_DLL
if ( flNewLevel >= 1.0 && m_flChargeLevel < 1.0 )
{
pOwner->SpeakConceptIfAllowed( MP_CONCEPT_MEDIC_CHARGEREADY );
if ( pTFPlayer )
{
pTFPlayer->SpeakConceptIfAllowed( MP_CONCEPT_HEALTARGET_CHARGEREADY );
}
}
#endif
m_flChargeLevel = flNewLevel;
}
}
}
}
return bFound;
}