本文整理汇总了C++中BG_Buildable函数的典型用法代码示例。如果您正苦于以下问题:C++ BG_Buildable函数的具体用法?C++ BG_Buildable怎么用?C++ BG_Buildable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BG_Buildable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: G_AddMomentumForBuilding
/**
* Adds momentum for building a buildable.
*
* Will save the reward with the buildable.
*/
float G_AddMomentumForBuilding(gentity_t* buildable) {
float value, reward;
team_t team;
gentity_t* builder;
if (!buildable || buildable->s.eType != ET_BUILDABLE) {
return 0.0f;
}
value = BG_Buildable(buildable->s.modelindex)->buildPoints;
team = BG_Buildable(buildable->s.modelindex)->team;
if (buildable->builtBy->slot != -1) {
builder = &g_entities[buildable->builtBy->slot];
} else {
builder = nullptr;
}
reward = AddMomentum(CONF_BUILDING, team, value, builder, false);
// Save reward with buildable so it can be reverted
buildable->momentumEarned = reward;
return reward;
}
示例2: AngleVectors
/*
===============
CG_BuildableInRange
===============
*/
static entityState_t *CG_BuildableInRange( playerState_t *ps, float *healthFraction )
{
vec3_t view, point;
trace_t trace;
entityState_t *es;
int health;
AngleVectors( cg.refdefViewAngles, view, nullptr, nullptr );
VectorMA( cg.refdef.vieworg, 64, view, point );
CG_Trace( &trace, cg.refdef.vieworg, nullptr, nullptr, point, ps->clientNum, MASK_SHOT, 0 );
es = &cg_entities[ trace.entityNum ].currentState;
if ( healthFraction )
{
health = es->generic1;
*healthFraction = ( float ) health / BG_Buildable( es->modelindex )->health;
}
if ( es->eType == ET_BUILDABLE &&
ps->persistant[ PERS_TEAM ] == BG_Buildable( es->modelindex )->team )
{
return es;
}
else
{
return nullptr;
}
}
示例3: CG_Creep
/*
==================
CG_Creep
==================
*/
static void CG_Creep( centity_t *cent )
{
int msec;
float size, frac;
trace_t tr;
vec3_t temp, origin;
int scaleUpTime = BG_Buildable( cent->currentState.modelindex )->buildTime;
int time;
// int creepSize;
time = cent->currentState.time;
//should the creep be growing or receding?
if( time >= 0 )
{
msec = cg.time - time;
if( msec >= 0 && msec < scaleUpTime )
frac = (float)msec / scaleUpTime;
else
frac = 1.0f;
}
else if( time < 0 )
{
msec = cg.time + time;
if( msec >= 0 && msec < CREEP_SCALEDOWN_TIME )
frac = 1.0f - ( (float)msec / CREEP_SCALEDOWN_TIME );
else
frac = 0.0f;
}
VectorCopy( cent->currentState.origin2, temp );
VectorScale( temp, -CREEP_DISTANCE, temp );
VectorAdd( temp, cent->lerpOrigin, temp );
CG_Trace( &tr, cent->lerpOrigin, NULL, NULL, temp, cent->currentState.number, MASK_PLAYERSOLID );
VectorCopy( tr.endpos, origin );
// size = CREEP_SIZE * frac;
size = BG_Buildable( cent->currentState.modelindex )->creepSize * frac;
if( size > 0.0f && tr.fraction < 1.0f )
CG_ImpactMark( cgs.media.creepShader, //qhandle_t markShader
origin, //const vec3_t origin
cent->currentState.origin2, //const vec3_t dir
0.0f, //float orientation
1.0f, //red
1.0f, //green
1.0f, //blue
1.0f, //float alpha
qtrue, //qboolean alphaFade
size, //float radius
qtrue);//qboolean temporary
}
示例4: CG_BuildableParticleEffects
/*
==================
CG_BuildableParticleEffects
==================
*/
static void CG_BuildableParticleEffects( centity_t *cent )
{
entityState_t *es = ¢->currentState;
team_t team = BG_Buildable( es->modelindex )->team;
int health = es->generic1;
float healthFrac = (float)health / BG_Buildable( es->modelindex )->health;
if( !( es->eFlags & EF_B_SPAWNED ) )
return;
//ORGANIC BULB LIGHT / BA_H_LIGHT - VIA PS
if( es->modelindex == BA_A_ORGANIC_BULB )
{
if( !CG_IsParticleSystemValid( ¢->buildablePS ) )
{
cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.organicbulbPS );
if( CG_IsParticleSystemValid( ¢->buildablePS ) )
{
CG_SetAttachmentCent( ¢->buildablePS->attachment, cent );
CG_AttachToCent( ¢->buildablePS->attachment );
}
}
}
else if( team == TEAM_HUMANS )
{
if( healthFrac < 0.33f && !CG_IsParticleSystemValid( ¢->buildablePS ) )
{
cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.humanBuildableDamagedPS );
if( CG_IsParticleSystemValid( ¢->buildablePS ) )
{
CG_SetAttachmentCent( ¢->buildablePS->attachment, cent );
CG_AttachToCent( ¢->buildablePS->attachment );
}
}
else if( healthFrac >= 0.33f && CG_IsParticleSystemValid( ¢->buildablePS ) )
CG_DestroyParticleSystem( ¢->buildablePS );
}
else if( team == TEAM_ALIENS )
{
if( healthFrac < 0.33f && !CG_IsParticleSystemValid( ¢->buildablePS ) )
{
cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.alienBuildableDamagedPS );
if( CG_IsParticleSystemValid( ¢->buildablePS ) )
{
CG_SetAttachmentCent( ¢->buildablePS->attachment, cent );
CG_SetParticleSystemNormal( cent->buildablePS, es->origin2 );
CG_AttachToCent( ¢->buildablePS->attachment );
}
}
else if( healthFrac >= 0.33f && CG_IsParticleSystemValid( ¢->buildablePS ) )
CG_DestroyParticleSystem( ¢->buildablePS );
}
}
示例5: G_Bounce
/*
================
G_Bounce
================
*/
static void G_Bounce( gentity_t *ent, trace_t *trace )
{
vec3_t velocity;
float dot;
int hitTime;
float minNormal;
qboolean invert = qfalse;
// reflect the velocity on the trace plane
hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
dot = DotProduct( velocity, trace->plane.normal );
VectorMA( velocity, -2 * dot, trace->plane.normal, ent->s.pos.trDelta );
if ( ent->s.eType == ET_BUILDABLE )
{
minNormal = BG_Buildable( ent->s.modelindex )->minNormal;
invert = BG_Buildable( ent->s.modelindex )->invertNormal;
}
else
{
minNormal = 0.707f;
}
// cut the velocity to keep from bouncing forever
if ( ( trace->plane.normal[ 2 ] >= minNormal ||
( invert && trace->plane.normal[ 2 ] <= -minNormal ) ) &&
trace->entityNum == ENTITYNUM_WORLD )
{
VectorScale( ent->s.pos.trDelta, ent->physicsBounce, ent->s.pos.trDelta );
}
else
{
VectorScale( ent->s.pos.trDelta, 0.3f, ent->s.pos.trDelta );
}
if ( VectorLength( ent->s.pos.trDelta ) < 10 )
{
VectorMA( trace->endpos, 0.5f, trace->plane.normal, trace->endpos ); // make sure it is off ground
G_SetOrigin( ent, trace->endpos );
ent->s.groundEntityNum = trace->entityNum;
VectorCopy( trace->plane.normal, ent->s.origin2 );
VectorSet( ent->s.pos.trDelta, 0.0f, 0.0f, 0.0f );
return;
}
VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );
VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin );
ent->s.pos.trTime = level.time;
}
示例6: CG_HumanCkitText
/*
===============
CG_HumanCkitText
===============
*/
static void CG_HumanCkitText( char *text, playerState_t *ps )
{
buildable_t buildable = ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT;
entityState_t *es;
if( buildable > BA_NONE )
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to place the %s\n",
CG_KeyNameForCommand( "+attack" ),
BG_Buildable( buildable )->humanName ) );
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to cancel placing the %s\n",
CG_KeyNameForCommand( "+button5" ),
BG_Buildable( buildable )->humanName ) );
}
else
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to build a structure\n",
CG_KeyNameForCommand( "+attack" ) ) );
}
if( ( es = CG_BuildableInRange( ps, NULL ) ) )
{
if( cgs.markDeconstruct )
{
if( es->eFlags & EF_B_MARKED )
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to unmark this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
else
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to mark this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
}
else
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to destroy this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
}
}
示例7: G_RemoveMomentumForDecon
/**
* Removes momentum for deconstructing a buildable.
*/
float G_RemoveMomentumForDecon( gentity_t *buildable, gentity_t *deconner )
{
float value;
team_t team;
// sanity check buildable
if ( !buildable || buildable->s.eType != entityType_t::ET_BUILDABLE )
{
return 0.0f;
}
team = BG_Buildable( buildable->s.modelindex )->team;
if ( buildable->momentumEarned )
{
value = buildable->momentumEarned;
}
else
{
// assume the buildable has just been placed
value = G_PredictMomentumForBuilding( buildable );
}
// Remove only partial momentum as the lost health fraction awards momentum to the enemy.
value *= buildable->entity->Get<HealthComponent>()->HealthFraction();
return AddMomentum( CONF_DECONSTRUCTING, team, -value, deconner, false );
}
示例8: buildFire
/*
===============
buildFire
===============
*/
void buildFire( gentity_t *ent, dynMenu_t menu )
{
//TODO find a solution to move dependency of ent->s.number and &ent->eventTime outside this function
playerState_t *ps=&ent->client->ps;
buildable_t buildable = ( ps->stats[ STAT_BUILDABLE ]
& ~SB_VALID_TOGGLEBIT );
if ( buildable > BA_NONE )
{
if ( ps->stats[ STAT_MISC ] > 0 )
{
G_AddPlayerEvent( ps, EV_BUILD_DELAY, ps->clientNum, ent->s.number, &ent->eventTime );
return;
}
if ( G_BuildIfValid( ent, buildable ) )
{
if ( !g_cheats.integer )
{
ps->stats[ STAT_MISC ] +=
BG_Buildable( buildable )->buildTime;
}
ps->stats[ STAT_BUILDABLE ] = BA_NONE;
}
return;
}
G_TriggerMenu( ps->clientNum, menu );
}
示例9: CG_Rocket_DFCMHumanBuildables
static void CG_Rocket_DFCMHumanBuildables( int handle, const char *data )
{
buildable_t buildable = ( buildable_t ) atoi( Info_ValueForKey( data, "1" ) );
const char *Class = "";
const char *Icon = "";
const char *action = "";
int value, valueMarked;
value = cg.snap->ps.persistant[ PERS_BP ];
valueMarked = cg.snap->ps.persistant[ PERS_MARKEDBP ];
if ( BG_BuildableDisabled( buildable ) || !BG_BuildableUnlocked( buildable ) )
{
Class = "locked";
//Padlock icon. UTF-8 encoding of \uf023
Icon = "<icon>\xEF\x80\xA3</icon>";
}
else if ( BG_Buildable( buildable )->buildPoints > value + valueMarked )
{
Class = "expensive";
//$1 bill icon. UTF-8 encoding of \uf0d6
Icon = "<icon>\xEF\x83\x96</icon>";
}
else
{
Class = "available";
action = va( "onClick='Cmd.exec(\"build %s\") Events.pushevent(\"hide %s\", event)'", BG_Buildable( buildable )->name, rocketInfo.menu[ ROCKETMENU_HUMANBUILD ].id );
}
Rocket_DataFormatterFormattedData( handle, va( "<button class='%s' onMouseover='Events.pushevent(\"setDS humanBuildList default %s\", event)' %s>%s<img src='/%s'/></button>", Class, Info_ValueForKey( data, "2" ), action, Icon, CG_GetShaderNameFromHandle( cg_buildables[ buildable ].buildableIcon ) ), false );
}
示例10: buildFire
/*
===============
buildFire
===============
*/
void buildFire( gentity_t *ent, dynMenu_t menu )
{
buildable_t buildable = ( ent->client->ps.stats[ STAT_BUILDABLE ]
& ~SB_VALID_TOGGLEBIT );
if( buildable > BA_NONE )
{
if( ent->client->ps.stats[ STAT_BUILD_TIMER ] > 0 )
{
G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum );
return;
}
if( G_BuildIfValid( ent, buildable ) )
{
if( !g_cheats.integer )
{
ent->client->ps.stats[ STAT_BUILD_TIMER ] +=
BG_Buildable( buildable )->buildTime;
}
ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE;
}
return;
}
G_TriggerMenu( ent->client->ps.clientNum, menu );
}
示例11: while
/*
================
G_SelectSpawnBuildable
find the nearest buildable of the right type that is
spawned/healthy/unblocked etc.
================
*/
static gentity_t *G_SelectSpawnBuildable( vec3_t preference, buildable_t buildable )
{
gentity_t *search, *spot;
search = spot = NULL;
while( ( search = G_Find( search, FOFS( classname ),
BG_Buildable( buildable )->entityName ) ) != NULL )
{
if( !search->spawned )
continue;
if( search->health <= 0 )
continue;
if( !search->s.groundEntityNum )
continue;
if( search->clientSpawnTime > 0 )
continue;
if( G_CheckSpawnPoint( search->s.number, search->s.origin,
search->s.origin2, buildable, NULL ) != NULL )
continue;
if( !spot || DistanceSquared( preference, search->s.origin ) <
DistanceSquared( preference, spot->s.origin ) )
spot = search;
}
return spot;
}
示例12: G_PredictMomentumForBuilding
/**
* Predicts the momentum reward for building a buildable.
*
* Is used for the buildlog entry, which is written before the actual reward
*happens.
* Also used to calculate the deconstruction penalty for preplaced buildables.
*/
float G_PredictMomentumForBuilding(gentity_t* buildable) {
if (!buildable || buildable->s.eType != ET_BUILDABLE) {
return 0.0f;
}
return BG_Buildable(buildable->s.modelindex)->buildPoints *
MomentumMod(CONF_BUILDING);
}
示例13: G_FindZapChainTargets
/*
===============
G_FindZapChainTargets
===============
*/
static void G_FindZapChainTargets( zap_t *zap )
{
gentity_t *ent = zap->targets[ 0 ]; // the source
int entityList[ MAX_GENTITIES ];
vec3_t range = { LEVEL2_AREAZAP_CHAIN_RANGE,
LEVEL2_AREAZAP_CHAIN_RANGE,
LEVEL2_AREAZAP_CHAIN_RANGE
};
vec3_t mins, maxs;
int i, num;
gentity_t *enemy;
trace_t tr;
float distance;
VectorAdd( ent->s.origin, range, maxs );
VectorSubtract( ent->s.origin, range, mins );
num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
for ( i = 0; i < num; i++ )
{
enemy = &g_entities[ entityList[ i ] ];
// don't chain to self; noclippers can be listed, don't chain to them either
if ( enemy == ent || ( enemy->client && enemy->client->noclip ) )
{
continue;
}
distance = Distance( ent->s.origin, enemy->s.origin );
if ( ( ( enemy->client &&
enemy->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) ||
( enemy->s.eType == ET_BUILDABLE &&
BG_Buildable( enemy->s.modelindex )->team == TEAM_HUMANS ) ) &&
enemy->health > 0 && // only chain to living targets
distance <= LEVEL2_AREAZAP_CHAIN_RANGE )
{
// world-LOS check: trace against the world, ignoring other BODY entities
trap_Trace( &tr, ent->s.origin, NULL, NULL,
enemy->s.origin, ent->s.number, CONTENTS_SOLID );
if ( tr.entityNum == ENTITYNUM_NONE )
{
zap->targets[ zap->numTargets ] = enemy;
zap->distances[ zap->numTargets ] = distance;
if ( ++zap->numTargets >= LEVEL2_AREAZAP_MAX_TARGETS )
{
return;
}
}
}
}
}
示例14: G_BuildableDeconValue
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());
}
示例15: FireBuild
static void FireBuild( gentity_t *self, dynMenu_t menu )
{
buildable_t buildable;
if ( !self->client )
{
return;
}
buildable = (buildable_t) ( self->client->ps.stats[ STAT_BUILDABLE ] & SB_BUILDABLE_MASK );
// open build menu
if ( buildable <= BA_NONE )
{
G_TriggerMenu( self->client->ps.clientNum, menu );
return;
}
// can't build just yet
if ( self->client->ps.stats[ STAT_MISC ] > 0 )
{
G_AddEvent( self, EV_BUILD_DELAY, self->client->ps.clientNum );
return;
}
// build
if ( G_BuildIfValid( self, buildable ) )
{
if ( !g_cheats.integer )
{
int buildTime = BG_Buildable( buildable )->buildTime;
switch ( self->client->ps.persistant[ PERS_TEAM ] )
{
case TEAM_ALIENS:
buildTime *= ALIEN_BUILDDELAY_MOD;
break;
case TEAM_HUMANS:
buildTime *= HUMAN_BUILDDELAY_MOD;
break;
default:
break;
}
self->client->ps.stats[ STAT_MISC ] += buildTime;
}
self->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE;
}
}