本文整理汇总了C++中GetHealth函数的典型用法代码示例。如果您正苦于以下问题:C++ GetHealth函数的具体用法?C++ GetHealth怎么用?C++ GetHealth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetHealth函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: if
bool CActorCondition::IsLimping() const
{
if(m_fPower< m_fLimpingPowerBegin || GetHealth() < m_fLimpingHealthBegin)
m_bLimping = true;
else if(m_fPower > m_fLimpingPowerEnd && GetHealth() > m_fLimpingHealthEnd)
m_bLimping = false;
return m_bLimping;
}
开发者ID:zcaliptium,项目名称:xray-16,代码行数:8,代码来源:ActorCondition.cpp
示例2: GetActiveWeapon
//=========================================================
// Calcula la nueva velocidad del jugador dependiendo del
// peso de la arma.
//=========================================================
float CIN_Player::CalculateSpeed(CBaseCombatWeapon *pWeapon, float speed)
{
// No se especifico el arma, obtenerla automaticamente.
if ( pWeapon == NULL )
pWeapon = GetActiveWeapon();
ConVarRef hl2_sprintspeed("hl2_sprintspeed");
ConVarRef hl2_walkspeed("hl2_walkspeed");
// Obtenemos la velocidad inicial.
if ( speed == 0 && IsSprinting() )
speed = hl2_sprintspeed.GetFloat();
if ( speed == 0 && !IsSprinting() )
speed = hl2_walkspeed.GetFloat();
float newSpeed = speed;
// Arma válida.
if ( pWeapon )
{
// Obtenemos el peso del arma.
float weaponWeight = pWeapon->GetWpnData().m_WeaponWeight;
// El arma es muy ligera, te da velocidad.
if ( weaponWeight < 0 )
{
weaponWeight = fabs(weaponWeight);
newSpeed = newSpeed + weaponWeight;
}
else
newSpeed = newSpeed - weaponWeight;
}
// Menos de 40% de salud.
if ( GetHealth() <= 40 )
{
// Disminuimos más velocidad entre menos salud tengamos.
if ( GetHealth() <= 5 )
newSpeed = newSpeed - 10;
else if ( GetHealth() <= 10 )
newSpeed = newSpeed - 5;
else if ( GetHealth() <= 20 )
newSpeed = newSpeed - 3;
else if ( GetHealth() <= 40 )
newSpeed = newSpeed - 2;
}
if ( newSpeed < 10 )
newSpeed = 10;
return newSpeed;
}
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:61,代码来源:in_player_shared.cpp
示例3: Update
void Base::Update()
{
//update the health bar to display minion damage
if (GetHealth() > 0)
{
m_HealthBar->setWidth(GetHealth());
}
}
开发者ID:sammut91,项目名称:TDG-DIstinction,代码行数:9,代码来源:Base.cpp
示例4: Assert
//-----------------------------------------------------------------------------
// Purpose: Powerup has just started
//-----------------------------------------------------------------------------
void CBaseCombatCharacter::PowerupStart( int iPowerup, float flAmount, CBaseEntity *pAttacker, CDamageModifier *pDamageModifier )
{
Assert( iPowerup >= 0 && iPowerup < MAX_POWERUPS );
switch( iPowerup )
{
case POWERUP_BOOST:
{
// Players can be boosted over their max
int iMaxBoostedHealth;
if ( IsPlayer() )
{
iMaxBoostedHealth = GetMaxHealth() + GetMaxHealth() / 2;
}
else
{
iMaxBoostedHealth = GetMaxHealth();
}
// Can we boost health further?
if ( GetHealth() < iMaxBoostedHealth )
{
int maxHealthToAdd = iMaxBoostedHealth - GetHealth();
// It uses floating point in here so it doesn't lose the fractional healing part on small frame times.
float flHealthToAdd = flAmount + m_flFractionalBoost;
int nHealthToAdd = (int)flHealthToAdd;
m_flFractionalBoost = flHealthToAdd - nHealthToAdd;
if ( nHealthToAdd )
{
int nHealthAdded = min( nHealthToAdd, maxHealthToAdd );
if ( IsPlayer() )
{
((CBaseTFPlayer*)this)->TakeHealthBoost( nHealthAdded, GetMaxHealth(), 25 );
}
else
{
TakeHealth( nHealthAdded, DMG_GENERIC );
}
TFStats()->IncrementPlayerStat( pAttacker, TF_PLAYER_STAT_HEALTH_GIVEN, nHealthAdded );
}
}
}
break;
case POWERUP_EMP:
{
// EMP removes adrenalin rush
SetPowerup( POWERUP_RUSH, false );
}
break;
default:
break;
}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:60,代码来源:basecombatcharacter_tf2.cpp
示例5: SetHealth
void CBurnBot::TakeDamage(IBaseObject* _pIn)
{
if (_pIn->GetID() == OBJ_TURRET)
{
SetHealth(GetHealth() - ((CTurret*)_pIn)->GetDamage());
SetWasHit(true);
}
if(((CBullet*)_pIn)->GetType() == SPECIALBULLET)
SetHealth(0.0f);
else
SetHealth(GetHealth() - ((CBullet*)_pIn)->GetDamage());
SetWasHit(true);
}
开发者ID:ianalcid08,项目名称:FinalProject,代码行数:13,代码来源:BurnBot.cpp
示例6: GetHealth
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
BuildingHudAlert_t C_BaseObject::GetBuildingAlertLevel( void )
{
float flHealthPercent = GetHealth() / GetMaxHealth();
BuildingHudAlert_t alertLevel = BUILDING_HUD_ALERT_NONE;
if ( HasSapper() )
{
alertLevel = BUILDING_HUD_ALERT_SAPPER;
}
else if ( !IsBuilding() && flHealthPercent < 0.33 )
{
alertLevel = BUILDING_HUD_ALERT_VERY_LOW_HEALTH;
}
else if ( !IsBuilding() && flHealthPercent < 0.66 )
{
alertLevel = BUILDING_HUD_ALERT_LOW_HEALTH;
}
BuildingHudAlert_t iFakeAlert = (BuildingHudAlert_t)cl_obj_fake_alert.GetInt();
if ( iFakeAlert > BUILDING_HUD_ALERT_NONE &&
iFakeAlert < MAX_BUILDING_HUD_ALERT_LEVEL )
{
alertLevel = iFakeAlert;
}
return alertLevel;
}
开发者ID:Deathreus,项目名称:TF2Classic,代码行数:32,代码来源:c_baseobject.cpp
示例7: Tick
void cCreeper::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (!IsTicking())
{
// The base class tick destroyed us
return;
}
if (((GetTarget() == nullptr) || !TargetIsInRange()) && !m_BurnedWithFlintAndSteel)
{
if (m_bIsBlowing)
{
m_ExplodingTimer = 0;
m_bIsBlowing = false;
m_World->BroadcastEntityMetadata(*this);
}
}
else
{
if (m_bIsBlowing)
{
m_ExplodingTimer += 1;
}
if ((m_ExplodingTimer == 30) && (GetHealth() > 0.0)) // only explode when not already dead
{
m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this);
Destroy(); // Just in case we aren't killed by the explosion
}
}
}
开发者ID:lkolbly,项目名称:MCServer,代码行数:32,代码来源:Creeper.cpp
示例8: EquipSuit
void CSDKPlayer::CheatImpulseCommands( int iImpulse )
{
if ( iImpulse != 101 )
{
BaseClass::CheatImpulseCommands( iImpulse );
return ;
}
gEvilImpulse101 = true;
EquipSuit();
GiveNamedItem( "weapon_mp5" );
GiveNamedItem( "weapon_grenade" );
GiveNamedItem( "weapon_shotgun" );
// Give the player everything!
GiveAmmo( 90, AMMO_BULLETS );
GiveAmmo( 3, AMMO_GRENADE );
if ( GetHealth() < 100 )
{
TakeHealth( 25, DMG_GENERIC );
}
gEvilImpulse101 = false;
}
开发者ID:paralin,项目名称:hl2sdk,代码行数:26,代码来源:sdk_player.cpp
示例9: IsValid
bool Entity::IsValid()
{
if( !GetPointer() )
return false;
if( !GetBoneMatrix() )
return false;
if( !GetTeamNum() )
return false;
if( IsDead() )
return false;
if( IsDormant() )
return false;
if( GetOrigin().IsZero() )
return false;
if( GetHealth() < 1 )
return false;
return true;
}
开发者ID:A5-,项目名称:CSGO-External,代码行数:25,代码来源:Entity.cpp
示例10: CEnemy
CGrunt::CGrunt(float fHealthScale) : CEnemy(20)
{
CEntity::m_eType = ENT_ENEMY;
SetEnemyType(Grunt);
AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Walk_Animation.xml");
AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Death_Animation.xml");
AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Attack_Animation.xml");
AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Flinch_Animation.xml");
AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Knocked_Down_Animation.xml");
GetAnimInfo()->SetAnimationName("Grunt_Walk_Animation");
SetBaseAnimations(ENT_ENEMY);
punching = false;
cooldown = 0.0f;
SetHealth((int)(GetHealth()*(1.0f + fHealthScale)));
SetIdleAnim("Grunt_Walk_Animation");
m_bFlipped = false;
m_fMoveAway = 0.0f;
m_bEvadeUp = false;
m_fPosXOld = 0.0f;
m_fPosYOld = 0.0f;
m_fUpdateOldPos = 0.0f;
m_nExpPts = 50;
CSGD_EventSystem::GetInstance()->RegisterClient("New_Player", this);
CSGD_EventSystem::GetInstance()->RegisterClient("ModifyHealth", this);
CSGD_EventSystem::GetInstance()->RegisterClient("Self Destruct", this);
}
开发者ID:kendellm,项目名称:Trials-of-Mastery,代码行数:34,代码来源:Grunt.cpp
示例11: GetPosition
void CClientVehicle::Serialize(CBitStream * pBitStream)
{
// Write the vehicle position
CVector3 vecPosition;
GetPosition(vecPosition);
pBitStream->Write(vecPosition);
// Write the vehicle rotation
CVector3 vecRotation;
GetRotation(vecRotation);
pBitStream->Write(vecRotation);
// Write the vehicle move speed
CVector3 vecMoveSpeed;
GetMoveSpeed(vecMoveSpeed);
pBitStream->Write(vecMoveSpeed);
// Write the vehicle turn speed
CVector3 vecTurnSpeed;
GetTurnSpeed(vecTurnSpeed);
pBitStream->Write(vecTurnSpeed);
// Write the vehicle health
pBitStream->Write(GetHealth());
}
开发者ID:Azon099,项目名称:networked-iv,代码行数:25,代码来源:CClientVehicle.cpp
示例12: GetPosition
void Bullet::Update(float fDeltaTime)
{
if (GetActive())
{
Vector2 position = GetPosition();
Vector2 velocity = GetVelocity();
position += velocity * fDeltaTime;
SetPosition(position);
RecalculateAABB();
GameObject* other = nullptr;
bool collision = CollisionManager::GetSingleton()->IsColliding(this, &other);
if (collision && other->GetCollisionLayer() == ECOLLISIONLAYER_ALL)
{
other->SetHealth(GetHealth() - 30);
SetActive(false);
}
Engine::GetSingleton()->GetSpriteBatch()->GetViewRect(&minX, &minY, &maxX, &maxY);
if (position.x > maxX)
SetActive(false);
else if (position.x < minX)
SetActive(false);
else if (position.y > maxY)
SetActive(false);
else if (position.y < minY)
SetActive(false);
}
return;
}
开发者ID:richard-stern,项目名称:SpaceCowboy,代码行数:31,代码来源:Bullet.cpp
示例13: inputInfoCopy
int CSDKPlayer::OnTakeDamage( const CTakeDamageInfo &info )
{
CTakeDamageInfo inputInfoCopy( info );
// If you shoot yourself, make it hurt but push you less
if ( inputInfoCopy.GetAttacker() == this && inputInfoCopy.GetDamageType() == DMG_BULLET )
{
inputInfoCopy.ScaleDamage( 5.0f );
inputInfoCopy.ScaleDamageForce( 0.05f );
}
int ret = BaseClass::OnTakeDamage( inputInfoCopy );
m_DmgOrigin = info.GetDamagePosition();
#ifdef PLAYER_IGNORE_FALLDAMAGE
// ignore fall damage if instructed to do so by input
if ( ( info.GetDamageType() & DMG_FALL ) )
{
inputInfoCopy.SetDamage(0.0f);
return 0;
}
#endif
#ifdef PLAYER_HEALTH_REGEN
if ( GetHealth() < 100 )
{
m_fTimeLastHurt = gpGlobals->curtime;
}
#endif
return ret;
}
开发者ID:gamenew09,项目名称:SourceSDK2010,代码行数:32,代码来源:sdk_player.cpp
示例14: SendOnFootData
void CLocalPlayer::SendOnFootData()
{
RakNet::BitStream PlayerBitStream_send;
PlayerBitStream_send.Write((MessageID)ID_SEND_PLAYER_DATA);
PlayerBitStream_send.Write(NetworkManager->playerid);
PlayerBitStream_send.Write(GetType());
PlayerBitStream_send.Write(GetModel());
PlayerBitStream_send.Write(GetHealth());
PlayerBitStream_send.Write(GetArmour());
PlayerBitStream_send.Write(GetCoords().x);
PlayerBitStream_send.Write(GetCoords().y);
PlayerBitStream_send.Write(GetCoords().z);
PlayerBitStream_send.Write(GetHeading());
PlayerBitStream_send.Write(GetQuaternion().fX);
PlayerBitStream_send.Write(GetQuaternion().fY);
PlayerBitStream_send.Write(GetQuaternion().fZ);
PlayerBitStream_send.Write(GetQuaternion().fW);
PlayerBitStream_send.Write(AI::GET_PED_DESIRED_MOVE_BLEND_RATIO(playerPed));
PlayerBitStream_send.Write(GetVelocity().x);
PlayerBitStream_send.Write(GetVelocity().y);
PlayerBitStream_send.Write(GetVelocity().z);
PlayerBitStream_send.Write(LocalPlayer->GetVehicle());
PlayerBitStream_send.Write(time(0));
NetworkManager->client->Send(&PlayerBitStream_send, MEDIUM_PRIORITY, RELIABLE_ORDERED, 0, RakNet::UNASSIGNED_SYSTEM_ADDRESS, true);
}
开发者ID:jayr0flmc,项目名称:FiveMP,代码行数:34,代码来源:LocalPlayer.cpp
示例15: ToTFPlayer
//-----------------------------------------------------------------------------
// Purpose: Player has waved his crosshair over this entity. Display appropriate hints.
//-----------------------------------------------------------------------------
void C_BaseObject::DisplayHintTo( C_BasePlayer *pPlayer )
{
bool bHintPlayed = false;
C_TFPlayer *pTFPlayer = ToTFPlayer(pPlayer);
if ( InSameTeam( pPlayer ) )
{
// We're looking at a friendly object.
if ( HasSapper() )
{
bHintPlayed = pPlayer->HintMessage( HINT_OBJECT_HAS_SAPPER, true, true );
}
if ( pTFPlayer->IsPlayerClass( TF_CLASS_ENGINEER ) )
{
// I'm an engineer.
// If I'm looking at a constructing object, let me know I can help build it (but not
// if I built it myself, since I've already got that hint from the wrench).
if ( !bHintPlayed && IsBuilding() && GetBuilder() != pTFPlayer )
{
bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_USE_WRENCH_ONOTHER, false, true );
}
// If it's damaged, I can repair it
if ( !bHintPlayed && !IsBuilding() && GetHealth() < GetMaxHealth() )
{
bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_REPAIR_OBJECT, false, true );
}
}
}
}
开发者ID:Deathreus,项目名称:TF2Classic,代码行数:36,代码来源:c_baseobject.cpp
示例16: GetHealth
void Creature::RegenerateHealth()
{
uint32 curValue = GetHealth();
uint32 maxValue = GetMaxHealth();
if (curValue >= maxValue) return;
float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH);
float Spirit = GetStat(STAT_SPIRIT);
if( HealthIncreaseRate <= 0 ) HealthIncreaseRate = 1;
uint32 addvalue = 0;
if(isPet())
{
if( GetPower(POWER_MANA) > 0 )
addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate);
else
addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate);
}
else
addvalue = maxValue/3;
ModifyHealth(addvalue);
}
开发者ID:chrayn,项目名称:mangos-06,代码行数:27,代码来源:Creature.cpp
示例17: GetPlayerPed
void CLocalPlayer::SendPassengerSync( void )
{
// Are we not connected to the network?
if( !pCore->GetNetworkModule()->IsConnected() )
return;
// Are we dead?
if( IsDead() )
return;
// Get the vehicle instance
CNetworkVehicle * pVehicle = pCore->GetVehicleManager()->GetFromGameGUID( GetPlayerPed()->GetCurrentVehicle()->m_dwGUID );
// Did we fail to find the vehicle?
if( !pVehicle )
return;
// Construct a new bitstream
RakNet::BitStream pBitStream;
// Construct a new passenger sync data structure
InPassengerSync passengerSync;
// Get the player health
passengerSync.m_fHealth = GetHealth ();
// Get the player selected weapon
passengerSync.m_dwSelectedWeapon = GetSelectedWeapon ();
// Write the sync structure to the bitstream
pBitStream.Write( (char *)&passengerSync, sizeof(InPassengerSync) );
// Send the bitstream to the server
pCore->GetNetworkModule()->Call( RPC_PASSENGER_SYNC, &pBitStream, LOW_PRIORITY, UNRELIABLE_SEQUENCED, true );
}
开发者ID:DarkKlo,项目名称:maf2mp,代码行数:35,代码来源:CLocalPlayer.cpp
示例18: WorldSpaceCenter
void C_ASW_Alien::ClientThink()
{
BaseClass::ClientThink();
// asw temp fix demo playback
//ASWUpdateClientSideAnimation();
m_vecLastRenderedPos = WorldSpaceCenter();
m_vecAutoTargetRadiusPos = GetLocalAutoTargetRadiusPos();
if ( GetHealth() > 0 && m_bElectroStunned && m_fNextElectroStunEffect <= gpGlobals->curtime)
{
// apply electro stun effect
HACK_GETLOCALPLAYER_GUARD( "C_ASW_Alien::ClientThink FX_ElectroStun" );
FX_ElectroStun(this);
m_fNextElectroStunEffect = gpGlobals->curtime + RandomFloat( 0.3, 1.0 );
//Msg( "%f - ElectroStunEffect\n", gpGlobals->curtime );
}
UpdateFireEmitters();
C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
if ( pPlayer && pPlayer->IsSniperScopeActive() )
{
m_GlowObject.SetRenderFlags( true, true );
}
else
{
m_GlowObject.SetRenderFlags( false, false );
}
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:31,代码来源:c_asw_alien.cpp
示例19: Msg
int CASW_Simple_Alien::OnTakeDamage( const CTakeDamageInfo &info )
{
// don't get hurt if our attacker is our friend
if (info.GetAttacker() && info.GetAttacker()->Classify() != CLASS_NONE)
{
// Proper way to check, but BCC default relationship array is private :/
//Disposition_t disp = CBaseCombatCharacter::m_DefaultRelationship[Classify()][info.GetAttacker()->Classify()].disposition;
//if (disp == D_LI)
//return 0;
// Hacky way to stop simple aliens getting hurt by other Infested aliens
Class_T c = info.GetAttacker()->Classify();
if ( IsAlienClass( c ) )
return 0;
}
if (asw_debug_alien_damage.GetBool())
{
Msg("%d %s hurt by %f dmg\n", entindex(), GetClassname(), info.GetDamage());
}
int iDamage = BaseClass::OnTakeDamage(info);
if (iDamage > 0 && GetHealth() > 0)
{
PainSound(info);
}
return iDamage;
}
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:30,代码来源:asw_simple_alien.cpp
示例20: SetExperience
void CTurtle::Update(float fElapsedTime)
{
m_vAnimations[m_nCurrAnimation].Update(fElapsedTime);
if(GetExperience() >= (100 * GetLevel()))
{
CBattleMap::GetInstance()->PlaySFX(CAssets::GetInstance()->aBMcowabungaSnd);
SetExperience(0/*GetExperience()-(100* GetLevel())*/);
SetLevel(GetLevel() + 1);
SetHealthMax((int)((float)GetMaxHealth() * 1.25f));
SetHealth((int)((float)GetMaxHealth()));
SetBaseAP(GetBaseAP()+2);
SetStrength( (int)( (float)GetStrength() * 1.2f ) );
SetDefense( (int) ( (float)GetDefense() * 1.2f ) );
SetAccuracy( (int) ( (float)GetAccuracy() * 1.2f ) );
SetSpeed( (int) ( (float)GetSpeed() * 1.2f ) );
}
if( GetHealth() <= 0)
{
if(GetAlive() == true)
{
CBattleMap::GetInstance()->DecrementNumChars();
CBattleMap::GetInstance()->DecrementNumTurtles();
CBattleMap::GetInstance()->SetTurtleDead();
SetAlive(false);
if(GetCurrAnimNum() != 9)
SetCurrAnim(9);
SetPosZ(0.9f);
}
}
}
开发者ID:marvelman610,项目名称:tmntactis,代码行数:30,代码来源:Turtle.cpp
注:本文中的GetHealth函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论