int G_BuildableDeconValue(gentity_t *ent) { HealthComponent* healthComponent = ent->entity->Get<HealthComponent>(); if (!healthComponent->Alive()) { return 0; } return (int)roundf((float)BG_Buildable(ent->s.modelindex)->buildPoints * healthComponent->HealthFraction()); }
static AIValue_t percentHealth( gentity_t *self, const AIValue_t *params ) { AIEntity_t e = ( AIEntity_t ) AIUnBoxInt( params[ 0 ] ); botEntityAndDistance_t et = AIEntityToGentity( self, e ); float healthFraction; HealthComponent *healthComponent; if (et.ent && (healthComponent = et.ent->entity->Get<HealthComponent>())) { healthFraction = healthComponent->HealthFraction(); } else { healthFraction = 0.0f; } return AIBoxFloat( healthFraction ); }