本文整理汇总了C++中BG_FindItem函数的典型用法代码示例。如果您正苦于以下问题:C++ BG_FindItem函数的具体用法?C++ BG_FindItem怎么用?C++ BG_FindItem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BG_FindItem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
}
}
示例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" ) );
}
示例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;
}
}
示例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
}
示例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);
}
}
}
示例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" ) );
}
}
示例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
}
示例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;
}
示例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" );
}
}
}
示例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;
}
示例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");
}
示例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" ) );
}
示例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" );
}
}
}
示例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;
}
示例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
}