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


C++ G_Find函数代码示例

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


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

示例1: CheckAlmostCapture

/*
==================
CheckAlmostCapture
==================
*/
void CheckAlmostCapture( gentity_t *self, gentity_t *attacker ) {
	gentity_t	*ent;
	vec3_t		dir;
	char		*classname;

	// if this player was carrying a flag
	if ( self->player->ps.powerups[PW_REDFLAG] ||
		self->player->ps.powerups[PW_BLUEFLAG] ||
		self->player->ps.powerups[PW_NEUTRALFLAG] ) {
		// get the goal flag this player should have been going for
		if ( g_gametype.integer == GT_CTF ) {
			if ( self->player->sess.sessionTeam == TEAM_BLUE ) {
				classname = "team_CTF_blueflag";
			}
			else {
				classname = "team_CTF_redflag";
			}
		}
		else {
			if ( self->player->sess.sessionTeam == TEAM_BLUE ) {
				classname = "team_CTF_redflag";
			}
			else {
				classname = "team_CTF_blueflag";
			}
		}
		ent = NULL;
		do
		{
			ent = G_Find(ent, FOFS(classname), classname);
		} while (ent && (ent->flags & FL_DROPPED_ITEM));
		// if we found the destination flag and it's not picked up
		if (ent && !(ent->r.svFlags & SVF_NOCLIENT) ) {
			// if the player was *very* close
			VectorSubtract( self->player->ps.origin, ent->s.origin, dir );
			if ( VectorLength(dir) < 200 ) {
				self->player->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
				if ( attacker->player ) {
					attacker->player->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
				}
			}
		}
	}
}
开发者ID:mecwerks,项目名称:revamp,代码行数:49,代码来源:g_combat.c

示例2: fx_target_beam_link

//------------------------------------------
void fx_target_beam_link( gentity_t *ent )
{
	gentity_t	*target = NULL;
	vec3_t		dir;

	target = G_Find( target, FOFS(targetname), ent->target );

	if ( !target )
	{
		Com_Printf( "bolt_link: unable to find target %s\n", ent->target );
		G_FreeEntity( ent );
		return;
	}

	ent->attackDebounceTime = level.time;

	if ( !target->classname || Q_stricmp( "info_null", target->classname ) )
	{//don't want to set enemy to something that's going to free itself... actually, this could be bad in other ways, too... ent pointer could be freed up and re-used by the time we check it next
		G_SetEnemy( ent, target );
	}
	VectorSubtract( target->s.origin, ent->s.origin, dir );//er, does it ever use dir?
	VectorNormalize( dir );//er, does it use len or dir?
	vectoangles( dir, ent->s.angles );//er, does it use s.angles?

	VectorCopy( target->s.origin, ent->s.origin2 );

	if ( ent->spawnflags & 1 )
	{
		// Do nothing
		ent->e_ThinkFunc	= thinkF_NULL;
	}
	else
	{
		if ( !(ent->spawnflags & 8 )) // one_shot, only calls when used
		{
			// switch think functions to avoid doing the bolt_link every time
			ent->e_ThinkFunc = thinkF_fx_target_beam_think;
			ent->nextthink	= level.time + FRAMETIME;
		}
	}

	ent->e_UseFunc = useF_fx_target_beam_use;
	gi.linkentity( ent );
}
开发者ID:BSzili,项目名称:OpenJK,代码行数:45,代码来源:g_fx.cpp

示例3: Use_Target_Lock

/*
==============
Use_Target_Lock
==============
*/
void Use_Target_Lock(gentity_t *ent, gentity_t *other, gentity_t *activator)
{
	gentity_t *t = 0;

	while ((t = G_Find(t, FOFS(targetname), ent->target)) != NULL)
	{
//		G_Printf("target_lock locking entity with key: %d\n", ent->count);
		t->key = ent->key;
		if (t->key)
		{
			G_SetAASBlockingEntity(t, AAS_AREA_DISABLED);
		}
		else
		{
			G_SetAASBlockingEntity(t, AAS_AREA_ENABLED);
		}
	}

}
开发者ID:morsik,项目名称:war-territory,代码行数:24,代码来源:g_target.c

示例4: G_ScriptAction_Trigger

/*
=================
G_ScriptAction_Trigger

  syntax: trigger <aiName/scriptName> <trigger>

  Calls the specified trigger for the given ai character or script entity
=================
*/
qboolean G_ScriptAction_Trigger( gentity_t *ent, char *params )
{
	gentity_t *trent;
	char *pString, name[MAX_QPATH], trigger[MAX_QPATH], *token;
	int oldId;

	// get the cast name
	pString = params;
	token = COM_ParseExt( &pString, qfalse );
	Q_strncpyz( name, token, sizeof(name) );
	if (!name[0])
	{
		G_Error( "G_Scripting: trigger must have a name and an identifier\n" );
	}

	token = COM_ParseExt( &pString, qfalse );
	Q_strncpyz( trigger, token, sizeof(trigger) );
	if (!trigger[0])
	{
		G_Error( "G_Scripting: trigger must have a name and an identifier\n" );
	}

//	trent = AICast_FindEntityForName( name );
		trent = NULL;
	if (trent)
	{	// we are triggering an AI
		//oldId = trent->scriptStatus.scriptId;
//		AICast_ScriptEvent( AICast_GetCastState( trent->s.number ), "trigger", trigger );
		return qtrue;
	}

	// look for an entity
	trent = G_Find( &g_entities[MAX_CLIENTS], FOFS(scriptName), name );
	if (trent) {
		oldId = trent->scriptStatus.scriptId;
		G_Script_ScriptEvent( trent, "trigger", trigger );
		// if the script changed, return false so we don't muck with it's variables
		return ((trent != ent) || (oldId == trent->scriptStatus.scriptId));
	}

	G_Error( "G_Scripting: trigger has unknown name: %s\n", name );
	return qfalse;	// shutup the compiler
}
开发者ID:nobowned,项目名称:rtcw-2.3,代码行数:52,代码来源:g_script_actions.c

示例5: misc_viper_bomb_use

void misc_viper_bomb_use (edict_t *self, edict_t *other, edict_t *activator)
{
	edict_t	*viper;

	self->solid = SOLID_BBOX;
	self->svflags &= ~SVF_NOCLIENT;
	self->s.effects |= EF_ROCKET;
	self->use = NULL;
	self->movetype = MOVETYPE_TOSS;
	self->prethink = misc_viper_bomb_prethink;
	self->touch = misc_viper_bomb_touch;
	self->activator = activator;

	viper = G_Find (NULL, FOFS(classname), "misc_viper");
	VectorScale (viper->moveinfo.dir, viper->moveinfo.speed, self->velocity);

	self->timestamp = level.time;
	VectorCopy (viper->moveinfo.dir, self->moveinfo.dir);
}
开发者ID:AJenbo,项目名称:Quake-2,代码行数:19,代码来源:g_misc.c

示例6: Tag_PostInitSetup

//=================
//=================
void Tag_PostInitSetup (void)
{
	edict_t		*e;
	vec3_t		origin, angles;

	// automatic spawning of tag token if one is not present on map.
	e = G_Find (NULL, FOFS(classname), "dm_tag_token");
	if(e == NULL)
	{
		e = G_Spawn();
		e->classname = "dm_tag_token";

		SelectSpawnPoint (e, origin, angles);
		VectorCopy(origin, e->s.origin);
		VectorCopy(origin, e->s.old_origin);
		VectorCopy(angles, e->s.angles);
		SP_dm_tag_token (e);
	}
}
开发者ID:MaddTheSane,项目名称:Quake2-Rogue,代码行数:21,代码来源:dm_tag.c

示例7: CreateTargetChangeLevel

/*
* G_ChooseNextMap
*/
static edict_t *G_ChooseNextMap( void )
{
	edict_t	*ent = NULL;
	const char *next;

	if( *level.forcemap )
	{
		return CreateTargetChangeLevel( level.forcemap );
	}

	if( !( *g_maplist->string ) || g_maplist->string[0] == '\0' || g_maprotation->integer == 0 )
	{
		// same map again
		return CreateTargetChangeLevel( level.mapname );
	}
	else if( g_maprotation->integer == 1 )
	{
		next = G_MapRotationNormal();

		// not in the list, we go for the first one
		ent = CreateTargetChangeLevel( next ? next : level.mapname );
		return ent;
	}
	else if( g_maprotation->integer == 2 )
	{
		next = G_MapRotationRandom();
		ent = CreateTargetChangeLevel( next ? next : level.mapname );
		return ent;
	}

	if( level.nextmap[0] )  // go to a specific map
		return CreateTargetChangeLevel( level.nextmap );

	// search for a changelevel
	ent = G_Find( NULL, FOFS( classname ), "target_changelevel" );
	if( !ent )
	{
		// the map designer didn't include a changelevel,
		// so create a fake ent that goes back to the same level
		return CreateTargetChangeLevel( level.mapname );
	}
	return ent;
}
开发者ID:DenMSC,项目名称:racemod_2.1,代码行数:46,代码来源:g_main.cpp

示例8: target_speaker_multiple

void target_speaker_multiple (gentity_t *ent)
{
	gentity_t *vis_dummy = NULL;

	if (!(ent->target))
	{
		G_Error( "target_speaker missing target at pos %s", vtos( ent->s.origin ) );	
	}

	vis_dummy = G_Find (NULL, FOFS(targetname), ent->target);

	if(vis_dummy)
	{
		ent->s.otherEntityNum = vis_dummy->s.number;
	}
	else
		G_Error( "target_speaker cant find vis_dummy_multiple %s", vtos( ent->s.origin ) );	
	
}
开发者ID:nobowned,项目名称:rtcw,代码行数:19,代码来源:g_target.c

示例9: teleporter_touch

void teleporter_touch(edict_t * self, edict_t * other, cplane_t * plane, csurface_t * surf)
{
    edict_t * dest;
    int i;

    if (!other->client)
        return;
    dest = G_Find(NULL, FOFS(targetname), self->target);
    if (!dest)
    {
        gi.dprintf("Couldn't find destination\n");
        return;
    }

    // unlink to make sure it can't possibly interfere with KillBox
    gi.unlinkentity(other);

    VectorCopy(dest->s.origin, other->s.origin);
    VectorCopy(dest->s.origin, other->s.old_origin);
    other->s.origin[2] += 10;

    // clear the velocity and hold them in place briefly
    VectorClear(other->velocity);
    other->client->ps.pmove.pm_time = 160 >> 3; // hold time
    other->client->ps.pmove.pm_flags |= PMF_TIME_TELEPORT;

    // draw the teleport splash at source and on the player
    self->owner->s.event = EV_PLAYER_TELEPORT;
    other->s.event = EV_PLAYER_TELEPORT;

    // set angles
    for (i = 0; i < 3; i++)
        other->client->ps.pmove.delta_angles[i] = ANGLE2SHORT(dest->s.angles[i] - other->client->resp.cmd_angles[i]);

    VectorClear(other->s.angles);
    VectorClear(other->client->ps.viewangles);
    VectorClear(other->client->v_angle);

    // kill anything at the destination
    KillBox(other);

    gi.linkentity(other);
}
开发者ID:glampert,项目名称:quake2-for-ps2,代码行数:43,代码来源:g_misc.c

示例10: DropPortalSource

void DropPortalSource( gentity_t *player ) {
	gentity_t	*ent;
	gentity_t	*destination;
	vec3_t		snapped;

	// create the portal source
	ent = G_Spawn();
	ent->s.modelindex = G_ModelIndex( "models/powerups/teleporter/tele_enter.md3" );

	VectorCopy( player->s.pos.trBase, snapped );
	SnapVector( snapped );
	G_SetOrigin( ent, snapped );
	VectorCopy( player->r.mins, ent->r.mins );
	VectorCopy( player->r.maxs, ent->r.maxs );

	ent->classname = "hi_portal source";
	ent->s.pos.trType = TR_STATIONARY;

	ent->r.contents = CONTENTS_CORPSE | CONTENTS_TRIGGER;
	ent->takedamage = qtrue;
	ent->health = 200;
	ent->die = PortalDie;

	trap_LinkEntity( ent );

	ent->count = player->client->portalID;
	player->client->portalID = 0;

//	ent->spawnflags = player->client->ps.persistant[PERS_TEAM];

	ent->nextthink = level.time + 1000;
	ent->think = PortalEnable;

	// find the destination
	destination = NULL;
	while( (destination = G_Find(destination, FOFS(classname), "hi_portal destination")) != NULL ) {
		if( destination->count == ent->count ) {
			VectorCopy( destination->s.pos.trBase, ent->pos1 );
			break;
		}
	}

}
开发者ID:d00man,项目名称:openarena-vm,代码行数:43,代码来源:g_misc.c

示例11: DBall_SelectSpawnPoint

//==================
void DBall_SelectSpawnPoint (edict_t *ent, vec3_t origin, vec3_t angles)
{
	edict_t	*bestspot;
	float	bestdistance, bestplayerdistance;
	edict_t	*spot;
	char	*spottype;
	char	skin[512];

	strcpy(skin, Info_ValueForKey (ent->client->pers.userinfo, "skin"));
	if(!strcmp(dball_team1_skin->string, skin))
		spottype = "dm_dball_team1_start";
	else if(!strcmp(dball_team2_skin->string, skin))
		spottype = "dm_dball_team2_start";
	else
		spottype = "info_player_deathmatch";

	spot = NULL;
	bestspot = NULL;
	bestdistance = 0;
	while ((spot = G_Find (spot, FOFS(classname), spottype)) != NULL)
	{
		bestplayerdistance = PlayersRangeFromSpot (spot);

		if (bestplayerdistance > bestdistance)
		{
			bestspot = spot;
			bestdistance = bestplayerdistance;
		}
	}

	if (bestspot)
	{
		VectorCopy (bestspot->s.origin, origin);
		origin[2] += 9;
		VectorCopy (bestspot->s.angles, angles);
		return;
	}

	// if we didn't find an appropriate spawnpoint, just
	// call the standard one.
	SelectSpawnPoint(ent, origin, angles);
}
开发者ID:DrItanium,项目名称:rogue,代码行数:43,代码来源:ball.c

示例12: camTrack_touch

void camTrack_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
	edict_t *player;
	edict_t *nextTarget;

	if (!plane)
		return;
	
	player = &g_edicts[1];	// Gotta be, since this is SP only

	//delete bullet model.
	G_FreeEdict(self->child);


	
	

	//hit wall.

	//if no next target, then abort.
	if (!self->owner->target)
	{
		camera_off(player);
		//fire targets.
		FireTarget2(self->owner);
		return;
	}

	//fire targets.
	FireTarget2(self->owner);

	nextTarget = G_Find(NULL,FOFS(targetname), self->owner->target);

	if (!nextTarget)
	{
		camera_off(player);
		return;
	}	

	FirePathTarget(nextTarget);
	WarpToNextPoint(self, nextTarget);
}
开发者ID:AimHere,项目名称:thirty-flights-of-linux,代码行数:42,代码来源:g_abel_camshoot.c

示例13: camera_cam_firstthink

void camera_cam_firstthink( gentity_t *ent ) {
	gentity_t   *target = NULL;
	vec3_t dang;
	vec3_t vec;

	if ( ent->track ) {
		target = G_Find( NULL, FOFS( targetname ), ent->track );
	}

	if ( target ) {
		VectorSubtract( target->s.origin, ent->r.currentOrigin, vec );
		vectoangles( vec, dang );
		G_SetAngle( ent, dang );
	}

	if ( ent->target ) {
		ent->nextthink = level.time + ( FRAMETIME / 2 );
		ent->think = Think_SetupTrainTargets;
	}
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:20,代码来源:g_tramcar.c

示例14: while

/*
===========
SelectInitialSpawnPoint

Try to find a spawn point marked 'initial', otherwise
use normal spawn selection.
============
*/
gentity_t *SelectInitialSpawnPoint( vec3_t origin, vec3_t angles ) {
	gentity_t	*spot;

	spot = NULL;
	while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
		if ( spot->spawnflags & 1 ) {
			break;
		}
	}

	if ( !spot || SpotWouldTelefrag( spot ) ) {
		return SelectSpawnPoint( vec3_origin, origin, angles );
	}

	VectorCopy (spot->s.origin, origin);
	origin[2] += 9;
	VectorCopy (spot->s.angles, angles);

	return spot;
}
开发者ID:zturtleman,项目名称:swarmedq3,代码行数:28,代码来源:g_client.c

示例15: AI_AddNode_Teleporter

//==========================================
// AI_AddNode_Teleporter
// Drop two nodes, one at trigger and other
// at target entity
//==========================================
int AI_AddNode_Teleporter( edict_t *ent )
{
	vec3_t		v1,v2;
	edict_t		*dest;

	if (nav.num_nodes + 1 > MAX_NODES)
		return INVALID;

	dest = G_Find ( NULL, FOFS(targetname), ent->target );
	if (!dest)
		return INVALID;
	
	//NODE_TELEPORTER_IN
	nodes[nav.num_nodes].flags = (NODEFLAGS_TELEPORTER_IN|NODEFLAGS_SERVERLINK);
	
	VectorCopy( ent->maxs, v1 );
	VectorCopy( ent->mins, v2 );
	nodes[nav.num_nodes].origin[0] = (v1[0] - v2[0]) / 2 + v2[0];
	nodes[nav.num_nodes].origin[1] = (v1[1] - v2[1]) / 2 + v2[1];
	nodes[nav.num_nodes].origin[2] = ent->mins[2]+32;

	nodes[nav.num_nodes].flags |= AI_FlagsForNode( nodes[nav.num_nodes].origin, ent );
	
	nav.num_nodes++;
	
	//NODE_TELEPORTER_OUT
	nodes[nav.num_nodes].flags = (NODEFLAGS_TELEPORTER_OUT|NODEFLAGS_SERVERLINK);
	VectorCopy( dest->s.origin, nodes[nav.num_nodes].origin );
	if ( ent->spawnflags & 1 ) // droptofloor
		nodes[nav.num_nodes].flags |= NODEFLAGS_FLOAT;
	else
		AI_DropNodeOriginToFloor( nodes[nav.num_nodes].origin, NULL );

	nodes[nav.num_nodes].flags |= AI_FlagsForNode( nodes[nav.num_nodes].origin, ent );
	
	// link from teleport_in
	AI_AddLink( nav.num_nodes-1, nav.num_nodes, LINK_TELEPORT );
	
	nav.num_nodes++;
	return nav.num_nodes -1;
}
开发者ID:mylemans,项目名称:vrxcl,代码行数:46,代码来源:ai_nodes.c


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