• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ BG_FindItem函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SP_gametype_item

void SP_gametype_item ( gentity_t* ent )
{
	gitem_t *item = NULL;
	char *value;
	int team = -1;

	G_SpawnString("teamfilter", "", &value);

	G_SetOrigin( ent, ent->s.origin );

	// If a team filter is set then override any team settings for the spawns
	if ( level.mTeamFilter[0] )
	{
		if ( Q_stricmp ( level.mTeamFilter, "red") == 0 )
		{
			team = TEAM_RED;
		}
		else if ( Q_stricmp ( level.mTeamFilter, "blue") == 0 )
		{
			team = TEAM_BLUE;
		}
	}

	if (ent->targetname && ent->targetname[0])
	{
		if (team != -1)
		{
			if (strstr(ent->targetname, "flag"))
			{
				if (team == TEAM_RED)
				{
					item = BG_FindItem("team_CTF_redflag");
				}
				else
				{ //blue
					item = BG_FindItem("team_CTF_blueflag");
				}
			}
		}
		else if (strstr(ent->targetname, "red_flag"))
		{
			item = BG_FindItem("team_CTF_redflag");
		}
		else if (strstr(ent->targetname, "blue_flag"))
		{
			item = BG_FindItem("team_CTF_blueflag");
		}
		else
		{
			item = NULL;
		}

		if (item)
		{
			ent->targetname = NULL;
			ent->classname = item->classname;
			G_SpawnItem( ent, item );
		}
	}
}
开发者ID:Camron,项目名称:OpenJK,代码行数:60,代码来源:g_spawn.c


示例2: ClearRegisteredItems

/*
==============
ClearRegisteredItems
==============
*/
void ClearRegisteredItems( void ) {
	memset( itemRegistered, 0, sizeof( itemRegistered ) );

	// players always start with the base weapon
	RegisterItem( BG_FindItemForWeapon( WP_PISTOL ) );
	RegisterItem( BG_FindItemForWeapon( WP_GAUNTLET ) );
	RegisterItem( BG_FindItem("Bag 'O Money" ) );
	RegisterItem( BG_FindItem("Hidden Stash" ) );
}
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:14,代码来源:g_items.c


示例3: value

/*QUAKED worldspawn(0 0 0) ? sun_cameraflare

Every map should have exactly one worldspawn.
"music"     Music wav file
"gravity"   800 is default gravity
"message" Text to print during connection process
"ambient"  Ambient light value(must use '_color')
"_color"    Ambient light color(must be used with 'ambient')
"sun"        Shader to use for 'sun' image
*/
void SP_worldspawn(void) {
	char *s;
	gitem_t *item; // JPW NERVE

	G_SpawnString("classname", "", &s);

	if (Q_stricmp(s, "worldspawn")) {
		G_Error("SP_worldspawn: The first entity isn't 'worldspawn'");
	}
	// make some data visible to connecting client
	trap_SetConfigstring(CS_GAME_VERSION, GAME_VERSION);

	trap_SetConfigstring(CS_LEVEL_START_TIME, va("%i", level.startTime));

	G_SpawnString("music", "", &s);
	trap_SetConfigstring(CS_MUSIC, s);

	G_SpawnString("message", "", &s);
	trap_SetConfigstring(CS_MESSAGE, s);             // map specific message

	trap_SetConfigstring(CS_MOTD, g_motd.string);    // message of the day

	G_SpawnString("gravity", "800", &s);
	trap_Cvar_Set("g_gravity", s);
	// (SA) FIXME: todo: sun shader set for worldspawn

	g_entities[ENTITYNUM_WORLD].s.number = ENTITYNUM_WORLD;
	g_entities[ENTITYNUM_WORLD].r.ownerNum = ENTITYNUM_NONE;
	g_entities[ENTITYNUM_WORLD].classname = "worldspawn";

	g_entities[ENTITYNUM_NONE].s.number = ENTITYNUM_NONE;
	g_entities[ENTITYNUM_NONE].r.ownerNum = ENTITYNUM_NONE;
	g_entities[ENTITYNUM_NONE].classname = "nothing";
	// see if we want a warmup time
	trap_SetConfigstring(CS_WARMUP, "");

	if (g_restarted.integer) {
		trap_Cvar_Set("g_restarted", "0");
		level.warmupTime = 0;
	}

// JPW NERVE change minigun overheat time for single player -- this array gets reloaded every time the server is reset, 
// so this is as good a place as any to do stuff like this
	if (g_gametype.integer != GT_SINGLE_PLAYER) {
		ammoTable[WP_VENOM].maxHeat *= 0.25;
		ammoTable[WP_DYNAMITE].uses = 0; // regens based on recharge time
		// reset ammo for subs to be distinct for multiplayer(so running out of rifle ammo doesn't deplete sidearm)
		// if player runs out of SMG ammunition, it shouldn't *also * deplete pistol ammunition. If you change this, change
		// g_spawn.c as well
		item = BG_FindItem("Thompson");
		item->giAmmoIndex = WP_THOMPSON;
		item = BG_FindItem("Sten");
		item->giAmmoIndex = WP_STEN;
		item = BG_FindItem("MP40");
		item->giAmmoIndex = WP_MP40;
	}
}
开发者ID:ioid3-games,项目名称:ioid3-rtcw,代码行数:67,代码来源:g_spawn.c


示例4: TossPlayerGametypeItems

/*
===========
TossPlayerGametypeItems

Drop CTF flag and Harvester cubes
===========
*/
void TossPlayerGametypeItems(gentity_t *ent) {
	int j;
	gitem_t *item;
	gentity_t *drop;
	int angle = 0;

	// drop flags in CTF
	item = NULL;
	j = 0;

	if ( ent->player->ps.powerups[ PW_REDFLAG ] ) {
		item = BG_FindItemForPowerup( PW_REDFLAG );
		j = PW_REDFLAG;
	} else if ( ent->player->ps.powerups[ PW_BLUEFLAG ] ) {
		item = BG_FindItemForPowerup( PW_BLUEFLAG );
		j = PW_BLUEFLAG;
	} else if ( ent->player->ps.powerups[ PW_NEUTRALFLAG ] ) {
		item = BG_FindItemForPowerup( PW_NEUTRALFLAG );
		j = PW_NEUTRALFLAG;
	}

	if ( item ) {
		drop = Drop_Item( ent, item, angle );
		angle += 45;
		// decide how many seconds it has left
		drop->count = ( ent->player->ps.powerups[ j ] - level.time ) / 1000;
		if ( drop->count < 1 ) {
			drop->count = 1;
		}
		ent->player->ps.powerups[ j ] = 0;
	}

#ifdef MISSIONPACK
	if ( g_gametype.integer == GT_HARVESTER ) {
		if ( ent->player->ps.tokens > 0 ) {
			if ( ent->player->sess.sessionTeam == TEAM_RED ) {
				item = BG_FindItem( "Blue Cube" );
			} else {
				item = BG_FindItem( "Red Cube" );
			}
			if ( item ) {
				for ( j = 0; j < ent->player->ps.tokens; j++ ) {
					drop = Drop_Item( ent, item, angle );
					if ( ent->player->sess.sessionTeam == TEAM_RED ) {
						drop->s.team = TEAM_BLUE;
					} else {
						drop->s.team = TEAM_RED;
					}
					angle += 45;
				}
			}
			ent->player->ps.tokens = 0;
		}
	}
#endif
}
开发者ID:mecwerks,项目名称:revamp,代码行数:63,代码来源:g_combat.c


示例5: G_CheckTeamItems

/*
==================
G_CheckTeamItems
==================
*/
void G_CheckTeamItems(void)
{

	// Set up team stuff
	Team_InitGame();

	if (g_gametype.integer == GT_CTF) {
		gitem_t *item;
		gentity_t *flag, *ent;

		// check for the two flags
		item = BG_FindItem("Silver Case");
		if (!item || !itemRegistered[item - bg_itemlist]) {
			G_Printf(S_COLOR_YELLOW "WARNING: No team_CTF_redflag in map\n");
		}
		item = BG_FindItem("Black Case");
		if (!item || !itemRegistered[item - bg_itemlist]) {
			G_Printf(S_COLOR_YELLOW "WARNING: No team_CTF_blueflag in map\n");
		}

		// NiceAss: Find the red flag
		flag = NULL;
		while ((flag = G_Find(flag, FOFS(classname), "team_CTF_redflag")) != NULL) {
			if (!(flag->flags & FL_DROPPED_ITEM))
				break;
		}
		if (flag) {
			// Red team decal X
			ent = G_Spawn();
			ent->classname = "Decal";
			ent->s.eType = ET_DECAL;
			ent->s.pos.trType = TR_STATIONARY;
			ent->s.modelindex = TEAM_RED;
			G_SetOrigin(ent, flag->s.origin);
			trap_LinkEntity(ent);
		}

		// NiceAss: Find the blue flag
		flag = NULL;
		while ((flag = G_Find(flag, FOFS(classname), "team_CTF_blueflag")) != NULL) {
			if (!(flag->flags & FL_DROPPED_ITEM))
				break;
		}
		if (flag) {
			// Red team decal X
			ent = G_Spawn();
			ent->classname = "Decal";
			ent->s.eType = ET_DECAL;
			ent->s.pos.trType = TR_STATIONARY;
			ent->s.modelindex = TEAM_BLUE;
			G_SetOrigin(ent, flag->s.origin);
			trap_LinkEntity(ent);
		}
	}
}
开发者ID:zturtleman,项目名称:reaction,代码行数:60,代码来源:g_items.c


示例6: ClearRegisteredItems

/*
==============
ClearRegisteredItems
==============
*/
void ClearRegisteredItems( void ) {
	memset( itemRegistered, 0, sizeof( itemRegistered ) );

	// !TODO: Have map determine the base weapons:
	// players always start with the base weapon
	RegisterItem( BG_FindItemForWeapon( WP_MACHINEGUN ) );
	RegisterItem( BG_FindItemForWeapon( WP_GAUNTLET ) );
	if( g_gametype.integer == GT_HARVESTER ) {
		RegisterItem( BG_FindItem( "Red Cube" ) );
		RegisterItem( BG_FindItem( "Blue Cube" ) );
	}
}
开发者ID:LavenderMoon,项目名称:mint-arena,代码行数:17,代码来源:g_items.c


示例7: ClearRegisteredItems

/*
==============
ClearRegisteredItems
==============
*/
void ClearRegisteredItems( void ) {
	memset( itemRegistered, 0, sizeof( itemRegistered ) );

	// players always start with the base weapon
	RegisterItem( BG_FindItemForWeapon( WP_MACHINEGUN ) );
	RegisterItem( BG_FindItemForWeapon( WP_GAUNTLET ) );
#ifdef MISSIONPACK
	if( g_gametype.integer == GT_HARVESTER ) {
		RegisterItem( BG_FindItem( "Red Cube" ) );
		RegisterItem( BG_FindItem( "Blue Cube" ) );
	}
#endif
}
开发者ID:Garey27,项目名称:quake3-brainworks,代码行数:18,代码来源:g_items.c


示例8: TossClientCubes

void TossClientCubes(gentity_t * self)
{
	gitem_t        *item;
	gentity_t      *drop;
	vec3_t          velocity;
	vec3_t          angles;
	vec3_t          origin;

	self->client->ps.generic1 = 0;

	// this should never happen but we should never
	// get the server to crash due to skull being spawned in
	if(!G_EntitiesFree())
	{
		return;
	}

	if(self->client->sess.sessionTeam == TEAM_RED)
	{
		item = BG_FindItem("Red Cube");
	}
	else
	{
		item = BG_FindItem("Blue Cube");
	}

	angles[YAW] = (float)(level.time % 360);
	angles[PITCH] = 0;			// always forward
	angles[ROLL] = 0;

	AngleVectors(angles, velocity, NULL, NULL);
	VectorScale(velocity, 150, velocity);
	velocity[2] += 200 + crandom() * 50;

	if(neutralObelisk)
	{
		VectorCopy(neutralObelisk->s.pos.trBase, origin);
		origin[2] += 44;
	}
	else
	{
		VectorClear(origin);
	}

	drop = LaunchItem(item, origin, velocity);

	drop->nextthink = level.time + g_cubeTimeout.integer * 1000;
	drop->think = G_FreeEntity;
	drop->spawnflags = self->client->sess.sessionTeam;
}
开发者ID:SinSiXX,项目名称:Rogue-Reborn,代码行数:50,代码来源:g_combat.c


示例9: G_CheckTeamItems

/*
==================
G_CheckTeamItems
==================
*/
void G_CheckTeamItems( void ) {
	if ( g_gametype.integer == GT_CTF ) {
		gitem_t *item;

		// make sure we actually have two flags...
		item = BG_FindItem( "Red Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Error( "No team_CTF_redflag in map" );
		}
		item = BG_FindItem( "Blue Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Error( "No team_CTF_blueflag in map" );
		}
	}
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:20,代码来源:g_items.c


示例10: DropPortalDestination

void DropPortalDestination( gentity_t *player ) {
	gentity_t	*ent;
	vec3_t		snapped;

	// create the portal destination
	ent = G_Spawn();
	ent->s.modelindex = G_ModelIndex( "models/powerups/teleporter/tele_exit.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 destination";
	ent->s.pos.trType = TR_STATIONARY;

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

	VectorCopy( player->s.apos.trBase, ent->s.angles );

	ent->think = G_FreeEntity;
	ent->nextthink = level.time + 2 * 60 * 1000;

	trap_LinkEntity( ent );

	player->client->portalID = ++level.portalSequence;
	ent->count = player->client->portalID;

	// give the item back so they can drop the source now
	player->client->ps.stats[STAT_HOLDABLE_ITEM] = BG_FindItem( "Portal" ) - bg_itemlist;
}
开发者ID:d00man,项目名称:openarena-vm,代码行数:35,代码来源:g_misc.c


示例11: BG_FindItem

Gametype_inf::Gametype_inf() {
	// Register the items
	// Boe!Man 11/29/12: Register items per gametype.
	gitem_t *item = BG_FindItem("briefcase");
	if (item){
		item->quantity = ITEM_BRIEFCASE;
	}
	// Boe!Man 11/29/12: Register triggers per gametype.
	gentity_t *find = NULL;
	while (NULL != (find = G_Find(find, FOFS(classname), "gametype_trigger")))
	{
		if (strcmp(find->targetname, (const char*) "briefcase_destination"))
		{
			continue;
		}

		// Assign the id to it.
		find->health = TRIGGER_EXTRACTION;
		find->touch = gametype_trigger_touch;
		trap_LinkEntity(find);
	}

	caseTakenSound = G_SoundIndex("sound/ctf_flag.mp3");
	caseCaptureSound = G_SoundIndex("sound/ctf_win.mp3");
	caseReturnSound = G_SoundIndex("sound/ctf_return.mp3");
}
开发者ID:Jordi1990,项目名称:Sof2MPSDK,代码行数:26,代码来源:gametype_inf.cpp


示例12: ClearRegisteredItems

/*
==============
ClearRegisteredItems
==============
*/
void ClearRegisteredItems() 
{
#pragma message("this should probably be removed!")
	memset( itemRegistered, 0, sizeof( itemRegistered ) );
	// Always load health/ammo/fuel pickups
	RegisterItem( BG_FindItem( "5 Health" ) );
	RegisterItem( BG_FindItem( "25 Health" ) );
	RegisterItem( BG_FindItem( "50 Health" ) );
	RegisterItem( BG_FindItem( "Some Fuel" ) );
	RegisterItem( BG_FindItem( "More Fuel" ) );
	RegisterItem( BG_FindItem( "Shells" ) );
	RegisterItem( BG_FindItem( "Bullets" ) );
	RegisterItem( BG_FindItem( "Slugs" ) );
	RegisterItem( BG_FindItem( "Rockets" ) );
}
开发者ID:MilitaryForces,项目名称:MilitaryForces,代码行数:20,代码来源:g_items.c


示例13: G_CheckTeamItems

/*
==================
G_CheckTeamItems
==================
*/
void G_CheckTeamItems( void ) {

	// Set up team stuff
	Team_InitGame();

	if( g_gametype.integer == GT_CTF ) {
		gitem_t	*item;

		// check for the two flags
		item = BG_FindItem( "red Lolly" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_CTL_redlolly in map" );
		}
		item = BG_FindItem( "blue Lolly" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_CTL_bluelolly in map" );
		}
	}
}
开发者ID:PadWorld-Entertainment,项目名称:wop-gamesource,代码行数:24,代码来源:g_items.c


示例14: G_ParseGametypeItems

/*
===============
G_ParseGametypeItems
===============
*/
bool G_ParseGametypeItems ( TGPGroup* itemsGroup )
{
	TGPGroup	itemGroup;
	int			itemCount;
	char		temp[MAX_QPATH];
	gentity_t	*ent;

	// Handle NULL for convienience
	if ( !itemsGroup )
	{
		return false;
	}

	// Loop over all the items and add each 
	itemGroup = trap_GPG_GetSubGroups ( itemsGroup );
	itemCount = 0;

	while ( itemGroup )
	{	
		gitem_t*   item;
		
		// Parse out the pickup name
		trap_GPG_GetName ( itemGroup, temp );

		item = BG_FindItem ( temp );
		if ( !item )
		{
			item = &bg_itemlist[ MODELINDEX_GAMETYPE_ITEM + itemCount ];
			item->pickup_name = (char *)trap_VM_LocalStringAlloc ( temp );
			itemCount++;
		}

		// Handle the entity specific stuff by finding all matching items that 
		// were spawned.
		ent = NULL;
		while ( NULL != (ent = G_Find ( ent, FOFS(targetname), item->pickup_name ) ) )
		{
			// If not a gametype item then skip it
			if ( strcmp ( ent->classname, "gametype_item" ) )
			{
				continue;
			}

			// Setup the gametype data
			ent->item	   = item;
			ent->nextthink = level.time + 200;
			ent->think     = G_GametypeItemThink;
		}

		// Next sub group
		itemGroup = trap_GPG_GetNext(itemGroup);
	}

	return true;
}
开发者ID:Jordi1990,项目名称:Sof2MPSDK,代码行数:60,代码来源:g_gametype.cpp


示例15: ClearRegisteredItems

/*
==============
ClearRegisteredItems
==============
*/
void ClearRegisteredItems( void ) {
	memset( itemRegistered, 0, sizeof( itemRegistered ) );

	// players always start with the base weapon
	// (SA) Nope, not any more...

//----(SA)	this will be determined by the level or starting position, or the savegame
//			but for now, re-register the MP40 automatically
//	RegisterItem( BG_FindItemForWeapon( WP_MP40 ) );
	RegisterItem( BG_FindItem( "Med Health" ) );           // NERVE - SMF - this is so med packs properly display
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:16,代码来源:g_items.c


示例16: G_CheckTeamItems

/*
==================
G_CheckTeamItems
==================
*/
void G_CheckTeamItems() 
{

	// Set up team stuff
	Team_InitGame();

	if( g_gametype.integer == GT_CTF ) {
		gitem_t	*item;

		// check for the two flags
		item = BG_FindItem( "Red Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			Com_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_redflag in map" );
		}
		item = BG_FindItem( "Blue Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			Com_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_blueflag in map" );
		}
	}
}
开发者ID:MilitaryForces,项目名称:MilitaryForces,代码行数:25,代码来源:g_items.c


示例17: ammo_touch

void ammo_touch( gentity_t *self, gentity_t *other, trace_t *trace ) {
	int i, clientcount = 0, count;
	gentity_t* touchClients[MAX_CLIENTS];

	memset(touchClients, 0, sizeof(touchClients));

	if( other->client == NULL ) {
		return;
	}

	// flags is for the last entity number that got ammo
	if ( self->timestamp > level.time ) {
		return;
	}
	self->timestamp = level.time + 1000;

	for( i = 0; i < level.numConnectedClients; i++ ) {
		int j = level.sortedClients[i];

		if( trap_EntityContactCapsule( g_entities[j].r.absmin, g_entities[j].r.absmax, self ) && G_IsAllowedAmmo( &g_entities[j] ) ) {
			touchClients[clientcount] = &g_entities[j];
			clientcount++;
		}
	}
	
	if(clientcount == 0) {
		return;
	}

	// Gordon: if low, just give out what's left
	if(self->health == -9999) {
		count = clientcount;
	} else {
		count = min(clientcount, self->health / (float)self->damage );
	}

	for( i = 0; i < count; i++) {
		int ammoAdded = qfalse;

		// self->damage contains the amount of ammo to add
		ammoAdded = AddMagicAmmo(touchClients[i], self->damage);

		if (ammoAdded) {
			// add the ammo pack event (to get sound, etc.)
			G_AddPredictableEvent( touchClients[i], EV_ITEM_PICKUP, BG_FindItem("Ammo Pack")-bg_itemlist );
			if (self->health != -9999) {
				// reduce the ammount of available ammo by the added clip number
				self->health -= self->damage;
//				G_Printf("%i clips left\n", self->health );
			}
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:et-flf-svn,代码行数:53,代码来源:g_trigger.c


示例18: G_CheckTeamItems

void G_CheckTeamItems( void ) {

	// Set up team stuff
	Team_InitGame();

	if( level.gametype == GT_FLAGS ) {
		const gitem_t	*item;

		// check for the two flags
		item = BG_FindItem( "team_redflag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			trap->Print( S_COLOR_YELLOW "WARNING: No team_redflag in map\n" );
		}
		item = BG_FindItem( "team_blueflag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			trap->Print( S_COLOR_YELLOW "WARNING: No team_blueflag in map\n" );
		}
	}
	if( level.gametype == GT_TROJAN ) {
		const gitem_t	*item;

		// check for all three flags
		item = BG_FindItem( "team_redflag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			trap->Print( S_COLOR_YELLOW "WARNING: No team_redflag in map\n" );
		}
		item = BG_FindItem( "team_blueflag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			trap->Print( S_COLOR_YELLOW "WARNING: No team_blueflag in map\n" );
		}
		item = BG_FindItem( "team_neutralflag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			trap->Print( S_COLOR_YELLOW "WARNING: No team_neutralflag in map\n" );
		}
	}
}
开发者ID:Razish,项目名称:QtZ,代码行数:36,代码来源:g_items.c


示例19: Cmd_Give_f

/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (gentity_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			i;
	qboolean	give_all;
	gentity_t		*it_ent;
	trace_t		trace;

	if ( !CheatsOk( ent ) ) {
		return;
	}

	name = ConcatArgs( 1 );

	if (Q_stricmp(name, "all") == 0)
		give_all = qtrue;
	else
		give_all = qfalse;

	if (give_all || Q_stricmp( name, "health") == 0)
	{
		ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		ent->client->ps.stats[STAT_WEAPONS] = (1 << WP_NUM_WEAPONS) - 1 - 
			( 1 << WP_GRAPPLING_HOOK ) - ( 1 << WP_NONE );
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for ( i = 0 ; i < MAX_WEAPONS ; i++ ) {
			ent->client->ps.ammo[i] = 999;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "armor") == 0)
	{
		ent->client->ps.stats[STAT_ARMOR] = 200;

		if (!give_all)
			return;
	}

	if (Q_stricmp(name, "excellent") == 0) {
		ent->client->ps.persistant[PERS_EXCELLENT_COUNT]++;
		return;
	}
	if (Q_stricmp(name, "impressive") == 0) {
		ent->client->ps.persistant[PERS_IMPRESSIVE_COUNT]++;
		return;
	}
	if (Q_stricmp(name, "gauntletaward") == 0) {
		ent->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT]++;
		return;
	}
	if (Q_stricmp(name, "defend") == 0) {
		ent->client->ps.persistant[PERS_DEFEND_COUNT]++;
		return;
	}
	if (Q_stricmp(name, "assist") == 0) {
		ent->client->ps.persistant[PERS_ASSIST_COUNT]++;
		return;
	}

	// spawn a specific item right on the player
	if ( !give_all ) {
		it = BG_FindItem (name);
		if (!it) {
			return;
		}

		it_ent = G_Spawn();
		VectorCopy( ent->r.currentOrigin, it_ent->s.origin );
		it_ent->classname = it->classname;
		G_SpawnItem (it_ent, it);
		FinishSpawningItem(it_ent );
		memset( &trace, 0, sizeof( trace ) );
		Touch_Item (it_ent, ent, &trace);
		if (it_ent->inuse) {
			G_FreeEntity( it_ent );
		}
	}
}
开发者ID:MasaMune692,项目名称:alcexamples,代码行数:99,代码来源:g_cmds.c


示例20: G_CheckTeamItems

/*
==================
G_CheckTeamItems
==================
*/
void G_CheckTeamItems( void ) {

	// Set up team stuff
	Team_InitGame();

	if( g_gametype.integer == GT_CTF ) {
		gitem_t	*item;

		// check for the two flags
		item = BG_FindItem( "Red Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_redflag in map" );
		}
		item = BG_FindItem( "Blue Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_blueflag in map" );
		}
	}
#ifdef MISSIONPACK
	if( g_gametype.integer == GT_1FCTF ) {
		gitem_t	*item;

		// check for all three flags
		item = BG_FindItem( "Red Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_redflag in map" );
		}
		item = BG_FindItem( "Blue Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_blueflag in map" );
		}
		item = BG_FindItem( "Neutral Flag" );
		if ( !item || !itemRegistered[ item - bg_itemlist ] ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_CTF_neutralflag in map" );
		}
	}

	if( g_gametype.integer == GT_OBELISK ) {
		gentity_t	*ent;

		// check for the two obelisks
		ent = NULL;
		ent = G_Find( ent, FOFS(classname), "team_redobelisk" );
		if( !ent ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_redobelisk in map" );
		}

		ent = NULL;
		ent = G_Find( ent, FOFS(classname), "team_blueobelisk" );
		if( !ent ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_blueobelisk in map" );
		}
	}

	if( g_gametype.integer == GT_HARVESTER ) {
		gentity_t	*ent;

		// check for all three obelisks
		ent = NULL;
		ent = G_Find( ent, FOFS(classname), "team_redobelisk" );
		if( !ent ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_redobelisk in map" );
		}

		ent = NULL;
		ent = G_Find( ent, FOFS(classname), "team_blueobelisk" );
		if( !ent ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_blueobelisk in map" );
		}

		ent = NULL;
		ent = G_Find( ent, FOFS(classname), "team_neutralobelisk" );
		if( !ent ) {
			G_Printf( S_COLOR_YELLOW "WARNING: No team_neutralobelisk in map" );
		}
	}
#endif
}
开发者ID:Garey27,项目名称:quake3-brainworks,代码行数:83,代码来源:g_items.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BG_FindItemForWeapon函数代码示例发布时间:2022-05-30
下一篇:
C++ BG_EvaluateTrajectoryDelta函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap