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


C++ GetHealth函数代码示例

本文整理汇总了C++中GetHealth函数的典型用法代码示例。如果您正苦于以下问题:C++ GetHealth函数的具体用法?C++ GetHealth怎么用?C++ GetHealth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetHealth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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