本文整理汇总了C++中CASW_Marine::CureInfestation方法的典型用法代码示例。如果您正苦于以下问题:C++ CASW_Marine::CureInfestation方法的具体用法?C++ CASW_Marine::CureInfestation怎么用?C++ CASW_Marine::CureInfestation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CASW_Marine
的用法示例。
在下文中一共展示了CASW_Marine::CureInfestation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoAOE
void CASW_HealGrenade_Projectile::DoAOE( CBaseEntity *pEntity )
{
CASW_Marine *pTargetMarine = static_cast< CASW_Marine* >( pEntity );
if ( !pTargetMarine )
return;
CASW_Marine *pMarine = dynamic_cast< CASW_Marine* >( GetOwnerEntity() ); // Carful! This might be null
float flBaseHealAmount = m_flHealPerSecond * ( gpGlobals->curtime - m_flLastDoAOE );
// At full health... multiplier is 1 + 0. At empty health multiplier is 1 + 3.0.
float fHealthPercent = pTargetMarine->IsInfested() ? 0.0f : static_cast< float >( pTargetMarine->GetHealth() ) / pTargetMarine->GetMaxHealth();
float flLowHealthMultiplier = ( 1.0f + 3.0f * ( 1.0f - fHealthPercent ) );
float flHealAmount = MIN( flBaseHealAmount * flLowHealthMultiplier, pTargetMarine->GetMaxHealth() - ( pTargetMarine->GetHealth() + pTargetMarine->m_iSlowHealAmount ) );
float flHealUsed = flHealAmount;
if ( flHealAmount > 0.0f )
{
bool bHealedBefore = false;
for ( int i = 0; i < m_hHealedEntities.Count(); ++i )
{
if ( m_hHealedEntities[ i ].Get() == pEntity )
{
bHealedBefore = true;
break;
}
}
if ( !bHealedBefore )
{
// Add it to the list of things we've healed at least once
m_hHealedEntities.AddToTail( pEntity );
// Fire event
IGameEvent * event = gameeventmanager->CreateEvent( "player_heal" );
if ( event )
{
CASW_Player *pPlayer = NULL;
if ( pMarine )
{
pPlayer = pMarine->GetCommander();
}
event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) );
event->SetInt( "entindex", pTargetMarine->entindex() );
gameeventmanager->FireEvent( event );
}
if ( pMarine )
{
CASW_Marine_Resource *pMR = pMarine->GetMarineResource();
if ( pMR && !pMR->m_bAwardedHealBeaconAchievement && m_hHealedEntities.Count() >= 4 && pMarine->IsInhabited() && pMarine->GetCommander() )
{
pMR->m_bAwardedHealBeaconAchievement = true;
pMarine->GetCommander()->AwardAchievement( ACHIEVEMENT_ASW_GROUP_HEAL );
}
}
}
pTargetMarine->AddSlowHeal( flHealAmount, 1, pMarine, this );
float flHalfHealTotal = m_flHealAmountTotal / 2.0f;
if ( m_flHealAmountLeft > flHalfHealTotal && ( m_flHealAmountLeft - flHealAmount ) <= flHalfHealTotal )
{
ASWFailAdvice()->OnHealGrenadeUsedWell();
}
m_flHealAmountLeft -= flHealUsed;
if ( m_flHealAmountLeft <= 0.0f )
{
m_flTimeBurnOut = gpGlobals->curtime;
}
if ( ASWGameRules()->GetInfoHeal() && pMarine )
{
ASWGameRules()->GetInfoHeal()->OnMarineHealed( pMarine, pTargetMarine, NULL );
}
}
if ( pTargetMarine->IsInfested() )
{
float fCurePercent = GetInfestationCureAmount();
// cure infestation
if ( fCurePercent > 0.0f )
{
// Cure infestation at 1/20th normal rate per second (the full 20 seconds or amount used does the full cure)
pTargetMarine->CureInfestation( pMarine, 1.0f - ( ( 1.0f - fCurePercent ) * ( flHealUsed / m_flHealAmountTotal ) * ( gpGlobals->curtime - m_flLastDoAOE ) ) );
}
}
}
示例2: SelfHeal
void CASW_Weapon_Medkit::SelfHeal()
{
CASW_Marine *pMarine = GetMarine();
if (pMarine) // firing from a marine
{
if (pMarine->GetHealth() >= pMarine->GetMaxHealth()) // already on full health
return;
if (pMarine->GetHealth() <= 0) // aleady dead!
return;
if (pMarine->m_bSlowHeal) // already healing
return;
if (pMarine->GetFlags() & FL_FROZEN) // don't allow this if the marine is frozen
return;
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(SINGLE);
// sets the animation on the weapon model iteself
SendWeaponAnim( GetPrimaryAttackActivity() );
// sets the animation on the marine holding this weapon
//pMarine->SetAnimation( PLAYER_ATTACK1 );
#ifndef CLIENT_DLL
bool bMedic = (pMarine->GetMarineProfile() && pMarine->GetMarineProfile()->CanUseFirstAid());
// put a slow heal onto the marine, play a particle effect
if (!pMarine->m_bSlowHeal && pMarine->GetHealth() < pMarine->GetMaxHealth())
{
pMarine->AddSlowHeal( GetHealAmount(), 1, pMarine, this );
// Fire event
IGameEvent * event = gameeventmanager->CreateEvent( "player_heal" );
if ( event )
{
CASW_Player *pPlayer = GetCommander();
event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) );
event->SetInt( "entindex", pMarine->entindex() );
gameeventmanager->FireEvent( event );
}
if ( ASWGameRules()->GetInfoHeal() )
{
ASWGameRules()->GetInfoHeal()->OnMarineHealed( pMarine, pMarine, this );
}
pMarine->OnWeaponFired( this, 1 );
}
if (pMarine->IsInfested() && bMedic)
{
float fCure = GetInfestationCureAmount();
// cure infestation
if (fCure < 100)
pMarine->CureInfestation(pMarine, fCure);
}
#endif
// decrement ammo
m_iClip1 -= 1;
#ifndef CLIENT_DLL
DestroyIfEmpty( false );
#endif
}
}