本文整理汇总了C++中FOFS函数的典型用法代码示例。如果您正苦于以下问题:C++ FOFS函数的具体用法?C++ FOFS怎么用?C++ FOFS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FOFS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: target_script_trigger_use
/*QUAKED target_script_trigger (1 .7 .2) (-8 -8 -8) (8 8 8)
must have an aiName
must have a target
when used it will fire its targets
*/
void target_script_trigger_use(gentity_t *ent, gentity_t *other, gentity_t *activator)
{
// START Mad Doctor I changes, 8/16/2002
qboolean found = qfalse;
// for all entities/bots with this ainame
gentity_t *trent = NULL;
// Are we using ainame to find another ent instead of using scriptname for this one?
if (ent->aiName)
{
// Find the first entity with this name
trent = G_Find(trent, FOFS(scriptName), ent->aiName);
// Was there one?
if (trent)
{
// We found it
found = qtrue;
// Play the script
G_Script_ScriptEvent(trent, "trigger", ent->target);
} // if (trent)...
} // if (ent->aiName)...
// Use the old method if we didn't find an entity with the ainame
if (!found)
{
if (ent->scriptName)
{
G_Script_ScriptEvent(ent, "trigger", ent->target);
}
}
G_UseTargets(ent, other);
}
示例2: SP_FixCoopSpots
/*
* The ugly as hell coop spawnpoint fixup function.
* While coop was planed by id, it wasn't part of
* the initial release and added later with patch
* to version 2.00. The spawnpoints in some maps
* were SNAFU, some have wrong targets and some
* no name at all. Fix this by matching the coop
* spawnpoint target names to the nearest named
* single player spot.
*/
void
SP_FixCoopSpots(edict_t *self)
{
edict_t *spot;
vec3_t d;
if (!self)
{
return;
}
spot = NULL;
while (1)
{
spot = G_Find(spot, FOFS(classname), "info_player_start");
if (!spot)
{
return;
}
if (!spot->targetname)
{
continue;
}
VectorSubtract(self->s.origin, spot->s.origin, d);
if (VectorLength(d) < 550)
{
if ((!self->targetname) || (Q_stricmp(self->targetname, spot->targetname) != 0))
{
self->targetname = spot->targetname;
}
return;
}
}
}
示例3: WP_FireDetPack
//---------------------------------------------------------
void WP_FireDetPack( gentity_t *ent, qboolean alt_fire )
//---------------------------------------------------------
{
if ( !ent || !ent->client )
{
return;
}
if ( alt_fire )
{
if ( ent->client->ps.eFlags & EF_PLANTED_CHARGE )
{
gentity_t *found = NULL;
// loop through all ents and blow the crap out of them!
while (( found = G_Find( found, FOFS( classname ), "detpack" )) != NULL )
{
if ( found->activator == ent )
{
VectorCopy( found->currentOrigin, found->s.origin );
found->e_ThinkFunc = thinkF_WP_Explode;
found->nextthink = level.time + 100 + random() * 100;
G_Sound( found, G_SoundIndex( "sound/weapons/detpack/warning.wav" ));
// would be nice if this actually worked?
AddSoundEvent( NULL, found->currentOrigin, found->splashRadius*2, AEL_DANGER, qfalse, qtrue );//FIXME: are we on ground or not?
AddSightEvent( NULL, found->currentOrigin, found->splashRadius*2, AEL_DISCOVERED, 100 );
}
}
ent->client->ps.eFlags &= ~EF_PLANTED_CHARGE;
}
}
else
{
WP_DropDetPack( ent, muzzle, forwardVec );
ent->client->ps.eFlags |= EF_PLANTED_CHARGE;
}
}
示例4: while
/*
================
G_SelectHumanSpawnPoint
go to a random point that doesn't telefrag
================
*/
gentity_t *G_SelectHumanSpawnPoint( vec3_t preference )
{
gentity_t *spot;
int count;
gentity_t *spots[ MAX_SPAWN_POINTS ];
if( level.numHumanSpawns <= 0 )
return NULL;
count = 0;
spot = NULL;
while( ( spot = G_Find( spot, FOFS( classname ),
BG_Buildable( BA_H_SPAWN )->entityName ) ) != NULL )
{
if( !spot->spawned )
continue;
if( spot->health <= 0 )
continue;
if( !spot->s.groundEntityNum )
continue;
if( spot->clientSpawnTime > 0 )
continue;
if( G_CheckSpawnPoint( spot->s.number, spot->s.origin,
spot->s.origin2, BA_H_SPAWN, NULL ) != NULL )
continue;
spots[ count ] = spot;
count++;
}
if( !count )
return NULL;
return G_ClosestEnt( preference, spots, count );
}
示例5: GetNextTrack
void GetNextTrack( gentity_t *ent ) {
gentity_t *track = NULL;
gentity_t *next;
gentity_t *choice[MAXCHOICES];
int num_choices = 0;
int rval;
next = ent->nextTrain;
if ( !( next->track ) ) {
G_Printf( "NULL track name for %s on %s\n", ent->classname, next->targetname );
return;
}
while ( 1 )
{
track = G_Find( track, FOFS( targetname ), next->track );
if ( !track ) {
break;
}
choice[num_choices++] = track;
if ( num_choices == MAXCHOICES ) {
break;
}
}
if ( !num_choices ) {
G_Printf( "GetNextTrack didnt find a track\n" );
return;
}
rval = rand() % num_choices;
ent->nextTrain = NULL;
ent->target = choice[rval]->targetname;
}
示例6: misc_weapon_shooter_aim
void misc_weapon_shooter_aim( gentity_t *self )
{
//update my aim
if ( self->target )
{
gentity_t *targ = G_Find( NULL, FOFS(targetname), self->target );
if ( targ )
{
self->enemy = targ;
VectorSubtract( targ->currentOrigin, self->currentOrigin, self->client->renderInfo.muzzleDir );
VectorCopy( targ->currentOrigin, self->pos1 );
vectoangles( self->client->renderInfo.muzzleDir, self->client->ps.viewangles );
SetClientViewAngle( self, self->client->ps.viewangles );
//FIXME: don't keep doing this unless target is a moving target?
self->nextthink = level.time + FRAMETIME;
}
else
{
self->enemy = NULL;
}
}
}
示例7: BFIXED
gentity_t *SelectNearestDeathmatchSpawnPoint( bvec3_t from ) {
gentity_t *spot;
bvec3_t delta;
bfixed dist, nearestDist;
gentity_t *nearestSpot;
nearestDist = BFIXED(999999,0);
nearestSpot = NULL;
spot = NULL;
while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
VectorSubtract( spot->s.origin, from, delta );
dist = FIXED_VEC3LEN( delta );
if ( dist < nearestDist ) {
nearestDist = dist;
nearestSpot = spot;
}
}
return nearestSpot;
}
示例8: BotFrame
void BotFrame( void )
{
gedict_t *te, *oself;
oself = self;
for ( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "player" ) ); )
{
if ( te->has_disconnected )
continue;
if ( !te->isBot )
continue;
self = te;
if( !tf_data.enable_bot )
{
botDisconnect( self );
continue;
}
self->old_button0 = self->s.v.button0;
self->old_button2 = self->s.v.button2;
self->old_keys = self->keys;
self->s.v.button0 = 0;
self->s.v.button2 = 0;
self->s.v.impulse = 0;
self->keys = 0;
if( self->team_no && self->team_no != 1)
{
G_bprint(3,"%s: i'm dont know how to play for team 2\n",self->s.v.netname);
botDisconnect(self);
continue;
}
Bot_AI( );
Bot_CL_KeyMove( );
}
self = oself;
}
示例9: for
/*
==============================
G_UseTargets
"activator" should be set to the entity that initiated the firing.
Search for (string)targetname in all entities that
match (string)self.target and call their .use function
==============================
*/
void G_UseTargets( gentity_t *ent, gentity_t *activator )
{
gentity_t *t;
if ( ent->targetShaderName && ent->targetShaderNewName )
{
float f = level.time * 0.001;
AddRemap( ent->targetShaderName, ent->targetShaderNewName, f );
trap_SetConfigstring( CS_SHADERSTATE, BuildShaderStateConfig() );
}
if ( !ent->target )
{
return;
}
t = NULL;
while ( ( t = G_Find( t, FOFS( targetname ), ent->target ) ) != NULL )
{
if ( t == ent )
{
G_Printf( "WARNING: Entity used itself.\n" );
}
else
{
if ( t->use )
{
t->use( t, ent, activator );
}
}
if ( !ent->inuse )
{
G_Printf( "entity was removed while using targets\n" );
return;
}
}
}
示例10: Eng_DispUnload
void Eng_DispUnload( )
{
gedict_t *disp;
float power;
for ( disp = world; (disp = trap_find( disp, FOFS( s.v.classname ), "building_dispenser" )); )
{
disp->s.v.ammo_cells = disp->s.v.ammo_cells - 20;
disp->s.v.ammo_rockets = disp->s.v.ammo_rockets - 15;
if ( disp->s.v.ammo_rockets < 0 )
disp->s.v.ammo_rockets = 0;
if ( disp->s.v.ammo_cells < 0 )
disp->s.v.ammo_cells = 0;
self->hook_out = 0;
power = ceil( 25 + disp->s.v.ammo_rockets * 1.5 + disp->s.v.ammo_cells );
if ( power > 250 )
power = 250;
G_bprint( 2, "maximum detdispenser damage - %.0f\n", power );
return;
}
G_sprint( self, 2, "no disp\n" );
}
示例11: while
gentity_t *SelectNearestDeathmatchSpawnPoint( vec3_t from ) {
gentity_t *spot;
vec3_t delta;
float dist, nearestDist;
gentity_t *nearestSpot;
nearestDist = 999999;
nearestSpot = NULL;
spot = NULL;
while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
VectorSubtract( spot->s.origin, from, delta );
dist = VectorLength( delta );
if ( dist < nearestDist ) {
nearestDist = dist;
nearestSpot = spot;
}
}
return nearestSpot;
}
示例12: SP_FixCoopSpots
static void SP_FixCoopSpots(edict_t *self){
edict_t *spot;
vec3_t d;
spot = NULL;
while(1){
spot = G_Find(spot, FOFS(classname), "info_player_start");
if(!spot)
return;
if(!spot->targetname)
continue;
VectorSubtract(self->s.origin, spot->s.origin, d);
if(VectorLength(d) < 384){
if((!self->targetname) || Q_stricmp(self->targetname, spot->targetname) != 0){
// gi.dprintf("FixCoopSpots changed %s at %s targetname from %s to %s\n", self->classname, vtos(self->s.origin), self->targetname, spot->targetname);
self->targetname = spot->targetname;
}
return;
}
}
}
示例13: ClassIsRestricted
int ClassIsRestricted( int tno, int pc )
{
int max, num = 0;
gedict_t *te;
if ( pc <= 0 || pc > 10 )
return 0;
if ( !tno )
return 0;
max = GetSVInfokeyInt( li_classrestricted[pc-1][0], li_classrestricted[pc-1][1], 0 );
if ( max > 0 )
{
for ( te = world; ( te = trap_find( te, FOFS( s.v.classname ), "player" ) ); )
{
if ( te->team_no == tno )
{
if ( pc == 10 )
{
if ( te->tfstate & TFSTATE_RANDOMPC )
num++;
} else
{
if ( te->playerclass == pc || te->nextpc == pc )
{
if ( !( te->tfstate & TFSTATE_RANDOMPC ) )
num++;
}
}
}
}
if ( num >= max )
return 1;
}
if ( max == -1 )
return 1;
return 0;
}
示例14: drawhline
static void drawhline(int x,int y,int w,GrxColor color) {
int copr, pl;
GR_int32u offs;
GRX_ENTER();
copr = C_OPER(color);
offs = FOFS(x,y,CURC->gc_line_offset);
for (pl=0; pl < 3; ++pl) {
if(DOCOLOR8(color,copr)) {
GR_repl cval = freplicate_b(color);
char *pp = &GRX_FRAME_MEMORY_PLANE(&CURC->gc_base_address,pl)[offs];
int ww = w;
switch(copr) {
case C_XOR: repfill_b_xor(pp,cval,ww); break;
case C_OR: repfill_b_or( pp,cval,ww); break;
case C_AND: repfill_b_and(pp,cval,ww); break;
default: repfill_b( pp,cval,ww); break;
}
}
color >>= 8;
}
GRX_LEAVE();
}
示例15: EAVYSpawnTeamNearFlag
void EAVYSpawnTeamNearFlag(edict_t *flag)
{
edict_t *spot = NULL;
float dist;
vec3_t v;
while(spot = G_Find (spot, FOFS(classname), "info_player_deathmatch"))
{
VectorSubtract (spot->s.origin, flag->s.origin, v);
dist = VectorLength (v);
if (EAVY_RESTRICTED_RADIUS > dist)
{
if (!strcmp(flag->classname, "item_flag_team1"))
spot->classname = "info_player_team1";
if (!strcmp(flag->classname, "item_flag_team2"))
spot->classname = "info_player_team2";
spot->svflags |= SVF_NOCLIENT;
spot->solid = SOLID_NOT;
ED_CallSpawn (spot);
}
}
}