Example #1
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void ) {
	int			i;
	gentity_t	*ent;
	char		*s, *value, *gametypeName;
	static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"};

	// get the next free entity
	ent = G_Spawn();

	for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
	}

	G_SpawnInt( "notep", "0", &i );
	if ( i ) {
		G_FreeEntity( ent );
		return;
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		G_FreeEntity( ent );
	}
}
Example #2
0
void UserSpawn( gentity_t *ent, const char *name )
{
	vec3_t		origin;
	vec3_t		vf;
	vec3_t		angles;
	gentity_t	*ent2;
	
	//Spawn the ent
	ent2 = G_Spawn();
	ent2->classname = G_NewString( name );	//FIXME: This will leave floating memory...

	//TODO: This should ultimately make sure this is a safe spawn!

	//Spawn the entity and place it there
	VectorSet( angles, 0, ent->s.apos.trBase[YAW], 0 );
	AngleVectors( angles, vf, NULL, NULL );
	VectorMA( ent->s.pos.trBase, 96, vf, origin );	//FIXME: Find the radius size of the object, and push out 32 + radius

	origin[2] += 8;
	VectorCopy( origin, ent2->s.pos.trBase );
	VectorCopy( origin, ent2->s.origin );
	VectorCopy( ent->s.apos.trBase, ent2->s.angles );

	gi.linkentity( ent2 );

	//Find a valid spawning spot
	if ( G_CallSpawn( ent2 ) == qfalse )
	{
		gi.SendServerCommand( ent-g_entities, "print \"Failed to spawn '%s'\n\"", name );
		G_FreeEntity( ent2 );
		return;
	}
}
Example #3
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void )
{
	int             i;
	gedict_t       *ent;

	// get the next free entity
	ent = spawn();

	for ( i = 0; i < numSpawnVars; i++ )
	{
		G_ParseField( spawnVars[i][0], spawnVars[i][1], ent );
	}

	if ( ( ( int ) ent->s.v.spawnflags & SPAWNFLAG_NOT_DEATHMATCH ) )
	{
		ent_remove( ent );
		return;
	}

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) )
	{
		ent_remove( ent );
		return;
	}
//      if(!ent->s.v.classname)ent->s.v.classname="";
}
Example #4
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void ) {
	int			i;
	gentity_t	*ent;
	bgEntitySpawnInfo_t spawnInfo;

	// get the next free entity
	ent = G_Spawn();

	for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
	}

	spawnInfo.gametype = g_gametype.integer;
	spawnInfo.spawnInt = G_SpawnInt;
	spawnInfo.spawnString = G_SpawnString;

	// check "notsingle", "notfree", "notteam", etc
	if ( !BG_CheckSpawnEntity( &spawnInfo ) ) {
		ADJUST_AREAPORTAL();
		G_FreeEntity( ent );
		return;
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		G_FreeEntity( ent );
	}
}
Example #5
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void )
{
  int         i;
  gentity_t   *ent;

  // get the next free entity
  ent = G_Spawn( );

  for( i = 0 ; i < level.numSpawnVars ; i++ )
    G_ParseField( level.spawnVars[ i ][ 0 ], level.spawnVars[ i ][ 1 ], ent );

  G_SpawnInt( "notq3a", "0", &i );

  if( i )
  {
    G_FreeEntity( ent );
    return;
  }

  // move editor origin to pos
  VectorCopy( ent->s.origin, ent->s.pos.trBase );
  VectorCopy( ent->s.origin, ent->r.currentOrigin );

  // if we didn't get a classname, don't bother spawning anything
  if( !G_CallSpawn( ent ) )
    G_FreeEntity( ent );
}
Example #6
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
gentity_t *G_SpawnGEntityFromSpawnVars(void)
{
	int       i;
	gentity_t *ent = G_Spawn(); // get the next free entity
	char      *str;

	for (i = 0 ; i < level.numSpawnVars ; i++)
	{
		G_ParseField(level.spawnVars[i][0], level.spawnVars[i][1], ent);
	}

	// check for "notteam" / "notfree" flags
	G_SpawnInt("notteam", "0", &i);
	if (i)
	{
		G_FreeEntity(ent);
		return NULL;
	}

	// allowteams handling
	G_SpawnString("allowteams", "", &str);
	if (str[0])
	{
		str = Q_strlwr(str);
		if (strstr(str, "axis"))
		{
			ent->allowteams |= ALLOW_AXIS_TEAM;
		}
		if (strstr(str, "allies"))
		{
			ent->allowteams |= ALLOW_ALLIED_TEAM;
		}
		if (strstr(str, "cvops"))
		{
			ent->allowteams |= ALLOW_DISGUISED_CVOPS;
		}
	}

	if (ent->targetname && *ent->targetname)
	{
		ent->targetnamehash = BG_StringHashValue(ent->targetname);
	}
	else
	{
		ent->targetnamehash = -1;
	}

	// move editor origin to pos
	VectorCopy(ent->s.origin, ent->s.pos.trBase);
	VectorCopy(ent->s.origin, ent->r.currentOrigin);

	// if we didn't get a classname, don't bother spawning anything
	if (!G_CallSpawn(ent))
	{
		G_FreeEntity(ent);
	}

	return ent;
}
Example #7
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void ) {
	int			i;
	gentity_t	*ent;
	char		*s, *value, *gametypeName;
	static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"};

	// get the next free entity
	ent = G_Spawn();

	for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
	}

	// check for "notsingle" flag
	if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
		G_SpawnInt( "notsingle", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return;
		}
	}
	// check for "notteam" flag (GT_FFA, GT_DUEL, GT_SINGLE_PLAYER)
	if ( g_gametype.integer >= GT_TEAM ) {
		G_SpawnInt( "notteam", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return;
		}
	} else {
		G_SpawnInt( "notfree", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return;
		}
	}

	if( G_SpawnString( "gametype", NULL, &value ) ) {
		if( g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE ) {
			gametypeName = gametypeNames[g_gametype.integer];

			s = strstr( value, gametypeName );
			if( !s ) {
				G_FreeEntity( ent );
				return;
			}
		}
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		G_FreeEntity( ent );
	}
}
Example #8
0
void SpawnCTFItem( char* classname, float x, float y, float z, float angle )
{
	gedict_t *item = spawn();

	item->s.v.classname = classname;
	setorigin( item, x, y, z );
	item->s.v.angles[0] = 0;
	item->s.v.angles[1] = angle;

	G_CallSpawn( item );
}
/*
===============
AICast_DBG_Spawn_f
===============
*/
void AICast_DBG_Spawn_f( gclient_t *client, char *cmd ) {
	extern qboolean G_CallSpawn( gentity_t *ent );
	gentity_t   *ent;
	vec3_t dir;

	ent = G_Spawn();
	ent->classname = G_Alloc( strlen( cmd ) + 1 );
	strcpy( ent->classname, cmd );
	AngleVectors( client->ps.viewangles, dir, NULL, NULL );
	VectorMA( client->ps.origin, 96, dir, ent->s.origin );

	if ( !G_CallSpawn( ent ) ) {
		G_Printf( "Error: unable to spawn \"%s\" entity\n", cmd );
	}
}
Example #10
0
static void use_target_spawner( edict_t *self, edict_t *other, edict_t *activator )
{
	edict_t	*ent;

	ent = G_Spawn();
	ent->classname = self->target;
	VectorCopy( self->s.origin, ent->s.origin );
	VectorCopy( self->s.angles, ent->s.angles );
	G_CallSpawn( ent );
	GClip_UnlinkEntity( ent );
	KillBox( ent );
	GClip_LinkEntity( ent );
	if( self->speed )
		VectorCopy( self->moveinfo.movedir, ent->velocity );
}
Example #11
0
/*
=======================================================================================================================================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
=======================================================================================================================================
*/
void G_SpawnGEntityFromSpawnVars(void) {
	int i;
	gentity_t *ent;
	// get the next free entity
	ent = G_Spawn();

	for (i = 0; i < level.numSpawnVars; i++) {
		G_ParseField(level.spawnVars[i][0], level.spawnVars[i][1], ent);
	}
	// check for "notteam"/"notfree" flags
	if (g_gametype.integer == GT_SINGLE_PLAYER) {
		G_SpawnInt("notsingle", "0", &i);

		if (i) {
			ADJUST_AREAPORTAL();
			G_FreeEntity(ent);
			return;
		}
	}

	if (g_gametype.integer >= GT_TEAM) {
		G_SpawnInt("notteam", "0", &i);

		if (i) {
			ADJUST_AREAPORTAL();
			G_FreeEntity(ent);
			return;
		}
	} else {
		G_SpawnInt("notfree", "0", &i);

		if (i) {
			ADJUST_AREAPORTAL();
			G_FreeEntity(ent);
			return;
		}
	}
	// move editor origin to pos
	VectorCopy(ent->s.origin, ent->s.pos.trBase);
	VectorCopy(ent->s.origin, ent->r.currentOrigin);
	// if we didn't get a classname, don't bother spawning anything
	if (!G_CallSpawn(ent)) {
		ADJUST_AREAPORTAL();
		G_FreeEntity(ent);
	}
}
Example #12
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void ) {
	int i;
	gentity_t   *ent;

	// get the next free entity
	ent = G_Spawn();

	for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
	}

	if ( g_gametype.integer >= GT_TEAM ) {
		G_SpawnInt( "notteam", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return;
		}
	} else {
		G_SpawnInt( "notfree", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return;
		}
	}

	if ( ent->targetname && *ent->targetname ) {
		ent->targetnamehash = BG_StringHashValue( ent->targetname );
	} else {
		ent->targetnamehash = -1;
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		G_FreeEntity( ent );
	}
}
Example #13
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void )
{
	int             i;
	gedict_t       *ent;

	// get the next free entity
	ent = spawn();

	for ( i = 0; i < numSpawnVars; i++ )
	{
		G_ParseField( spawnVars[i][0], spawnVars[i][1], ent );
	}

	if ( deathmatch )
	{
		if ( ( ( int ) ent->s.v.spawnflags & SPAWNFLAG_NOT_DEATHMATCH ) )
		{
//			G_cprint( "%s removed because of SPAWNFLAG_NOT_DEATHMATCH\n", ent->s.v.classname );
			ent_remove( ent );
			return;
		}
	}
	else if (   ( skill == 0 && ((int)ent->s.v.spawnflags & SPAWNFLAG_NOT_EASY) )
			 || ( skill == 1 && ((int)ent->s.v.spawnflags & SPAWNFLAG_NOT_MEDIUM) )
			 || ( skill >= 2 && ((int)ent->s.v.spawnflags & SPAWNFLAG_NOT_HARD) ) 
	   )
	{
//		G_cprint( "%s removed because of SPAWNFLAG_NOT_XXX\n", ent->s.v.classname );
		ent_remove( ent );
		return;
	}

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) )
	{
		ent_remove( ent );
		return;
	}
}
Example #14
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void ) {
	int			i;
	gentity_t	*ent;
	char		*s, *value, *gametypeName;
	static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester"};
	int spawnVarsOffset[MAX_SPAWN_VARS][2];	// key / value pairs offsets

	// Convert to offsets.
	for (i = 0; i < level.numSpawnVars; ++i) {
		spawnVarsOffset[i][0] = level.spawnVars[i][0] - level.spawnVarChars;
		spawnVarsOffset[i][1] = level.spawnVars[i][1] - level.spawnVarChars;
	}

	// Early out if spawn is not required.
	if (!dmlab_update_spawn_vars(
			level.spawnVarChars,
			&level.numSpawnVarChars,
			spawnVarsOffset,
			&level.numSpawnVars)) {
		return;
	}

	// Convert from offsets.
	for (i = 0; i < level.numSpawnVars; ++i) {
		level.spawnVars[i][0] = level.spawnVarChars + spawnVarsOffset[i][0];
		level.spawnVars[i][1] = level.spawnVarChars + spawnVarsOffset[i][1];
	}

	// get the next free entity
	ent = G_Spawn();

	for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
	}

	// check for "notsingle" flag
	if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
		G_SpawnInt( "notsingle", "0", &i );
		if ( i ) {
			ADJUST_AREAPORTAL();
			G_FreeEntity( ent );
			return;
		}
	}
	// check for "notteam" flag (GT_FFA, GT_TOURNAMENT, GT_SINGLE_PLAYER)
	if ( g_gametype.integer >= GT_TEAM ) {
		G_SpawnInt( "notteam", "0", &i );
		if ( i ) {
			ADJUST_AREAPORTAL();
			G_FreeEntity( ent );
			return;
		}
	} else {
		G_SpawnInt( "notfree", "0", &i );
		if ( i ) {
			ADJUST_AREAPORTAL();
			G_FreeEntity( ent );
			return;
		}
	}

#ifdef MISSIONPACK
	G_SpawnInt( "notta", "0", &i );
	if ( i ) {
		ADJUST_AREAPORTAL();
		G_FreeEntity( ent );
		return;
	}
#else
	G_SpawnInt( "notq3a", "0", &i );
	if ( i ) {
		ADJUST_AREAPORTAL();
		G_FreeEntity( ent );
		return;
	}
#endif

	if( G_SpawnString( "gametype", NULL, &value ) ) {
		if( g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE ) {
			gametypeName = gametypeNames[g_gametype.integer];

			s = strstr( value, gametypeName );
			if( !s ) {
				ADJUST_AREAPORTAL();
				G_FreeEntity( ent );
				return;
			}
		}
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		G_FreeEntity( ent );
	}
}
Example #15
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void ) {
	int			i;
	gentity_t	*ent;
	char		*s, *value, *gametypeName;
	static char *gametypeNames[] = { "ffa", "tournament", "single", "team", "ca" /*FIXME "clanarena" */, "ctf", "oneflag", "obelisk", "harvester", "ft", "dom", "ad", "rr", "race" };

	// get the next free entity
	ent = G_Spawn();

	for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
	}

	// check for "notsingle" flag
	if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
		G_SpawnInt( "notsingle", "0", &i );
		if ( i ) {
			ADJUST_AREAPORTAL();
			G_FreeEntity( ent );
			return;
		}
	}
	// check for "notteam" flag (GT_FFA, GT_TOURNAMENT, GT_SINGLE_PLAYER)
	if ( g_gametype.integer >= GT_TEAM ) {
		G_SpawnInt( "notteam", "0", &i );
		if ( i ) {
			ADJUST_AREAPORTAL();
			G_FreeEntity( ent );
			return;
		}
	} else {
		G_SpawnInt( "notfree", "0", &i );
		if ( i ) {
			ADJUST_AREAPORTAL();
			G_FreeEntity( ent );
			return;
		}
	}

	//FIXME this can also be a string in quake live
	if (G_SpawnString("not_gametype", NULL, &value)) {
		//FIXME did quakelive also use ints before ?
		if (isdigit(value[0])) {
			// old check using integer gametype values
			if (g_gametype.integer == i) {
				ADJUST_AREAPORTAL();
				G_FreeEntity(ent);
				return;
			}
		} else {
			if (g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE) {
				gametypeName = gametypeNames[g_gametype.integer];

				s = strstr(value, gametypeName);
				if (!s) {
					// try alternate quake live gametype names
					if (g_gametype.integer == GT_TEAM) {
						s = strstr(value, "tdm");
					} else if (g_gametype.integer == GT_TOURNAMENT) {
						s = strstr(value, "duel");
					} else if (g_gametype.integer == GT_HARVESTER) {
						s = strstr(value, "har");
					} else if (g_gametype.integer == GT_1FCTF) {
						s = strstr(value, "1f");
					} else if (g_gametype.integer == GT_OBELISK) {
						s = strstr(value, "ob");
					}
				}

				if (s) {
					//G_Printf("skipping item, not in gametype string: '%s'\n", value);
					ADJUST_AREAPORTAL();
					G_FreeEntity(ent);
					return;
				}
			}
		}
	}


#if 1  //def MPACK
	G_SpawnInt( "notta", "0", &i );
	if ( i ) {
		ADJUST_AREAPORTAL();
		G_FreeEntity( ent );
		return;
	}
#else
	G_SpawnInt( "notq3a", "0", &i );
	if ( i ) {
		ADJUST_AREAPORTAL();
		G_FreeEntity( ent );
		return;
	}
#endif


	if (G_SpawnString("gametype", NULL, &value)) {
		//Com_Printf("^5gametype: %s\n", value);

		//FIXME gametype as int?  q3 mods?

		if (g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE) {
			gametypeName = gametypeNames[g_gametype.integer];

			s = strstr(value, gametypeName);
			if (!s) {
				// try alternate quake live gametype names
				if (g_gametype.integer == GT_TEAM) {
					s = strstr(value, "tdm");
				} else if (g_gametype.integer == GT_TOURNAMENT) {
					s = strstr(value, "duel");
				} else if (g_gametype.integer == GT_HARVESTER) {
					s = strstr(value, "har");
				} else if (g_gametype.integer == GT_1FCTF) {
					s = strstr(value, "1f");
				} else if (g_gametype.integer == GT_OBELISK) {
					s = strstr(value, "ob");
				}
			}

			if (!s) {
				//G_Printf("skipping item, not in gametype string: '%s'\n", value);
				ADJUST_AREAPORTAL();
				G_FreeEntity(ent);
				return;
			}
		}
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		G_FreeEntity( ent );
	}
}
Example #16
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( bool inSubBSP ) 
{
	gentity_t	*ent;
	char		*value;

	if (inSubBSP)
	{	
		// filter out the unwanted entities
		G_SpawnString("filter", "", &value);
		if (value[0] && strcmp(level.mFilter, value))
		{	
			// we are not matching up to the filter, so no spawney
			return;
		}
	}

	// get the next free entity
	ent = G_Spawn();
	int i;
	for (i = 0 ; i < level.numSpawnVars ; i++ ) 
	{
		G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
	}

	// check for "notteam" flag (GT_DM)
	if ( level.gametypeData->teams ) 
	{
		G_SpawnInt( "notteam", "0", &i );
		if ( i ) 
		{
			G_FreeEntity( ent );
			return;
		}
	} 
	else 
	{
		G_SpawnInt( "notfree", "0", &i );
		if ( i ) 
		{
			G_FreeEntity( ent );
			return;
		}
	}

	// Only spawn this entity in the specified gametype
	if( G_SpawnString( "gametype", NULL, &value ) ) 
	{
		// Has to be a case match
		if ( value && !strstr ( value, level.gametypeData->name ) )
		{
			G_FreeEntity ( ent );
			return;
		}
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) 
	{
		G_FreeEntity( ent );
	}
}
Example #17
0
// Spawn an entity and fill in all of the level fields from level.spawnVars[], then call the class specfic spawn function
gentity_t *G_SpawnGEntityFromSpawnVars( qboolean inSubBSP ) {
	int i;
	gentity_t *ent;
	char *s, *value;
	const char *gametypeName;
	static const char *gametypeNames[] = { "ffa", "holocron", "jedimaster", "duel", "powerduel", "single", "team", "siege", "ctf", "cty" };

	// get the next free entity
	ent = G_Spawn();

	for ( i = 0; i < level.numSpawnVars; i++ ) {
		BG_ParseField( fields, ARRAY_LEN( fields ), level.spawnVars[i][0], level.spawnVars[i][1], (byte *)ent );
	}

	// check for "notsingle" flag
	if ( level.gametype == GT_SINGLE_PLAYER ) {
		G_SpawnInt( "notsingle", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return NULL;
		}
	}
	// check for "notteam" flag (GT_FFA, GT_DUEL, GT_SINGLE_PLAYER)
	if ( level.gametype >= GT_TEAM ) {
		G_SpawnInt( "notteam", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return NULL;
		}
	}
	else {
		G_SpawnInt( "notfree", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return NULL;
		}
	}

	G_SpawnInt( "notta", "0", &i );
	if ( i ) {
		G_FreeEntity( ent );
		return NULL;
	}

	if ( G_SpawnString( "gametype", NULL, &value ) ) {
		if ( level.gametype >= GT_FFA && level.gametype < GT_MAX_GAME_TYPE ) {
			gametypeName = gametypeNames[level.gametype];

			s = strstr( value, gametypeName );
			if ( !s ) {
				G_FreeEntity( ent );
				return NULL;
			}
		}
	}

	// move editor origin to pos
	VectorCopy( &ent->s.origin, &ent->s.pos.trBase );
	VectorCopy( &ent->s.origin, &ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		G_FreeEntity( ent );
		return NULL;
	}

	//Tag on the ICARUS scripting information only to valid recipients
	if ( trap->ICARUS_ValidEnt( (sharedEntity_t *)ent ) ) {
		trap->ICARUS_InitEnt( (sharedEntity_t *)ent );

		if ( ent->classname && ent->classname[0] ) {
			if ( Q_strncmp( "NPC_", ent->classname, 4 ) != 0 ) {//Not an NPC_spawner (rww - probably don't even care for MP, but whatever)
				G_ActivateBehavior( ent, BSET_SPAWN );
			}
		}
	}

	if ( level.manualSpawning ) {
		ent->jpSpawned = qtrue;
	}
	return ent;
}
Example #18
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars( void ) {
    int			i;
    gentity_t	*ent;
    char		*s, *value;

    // get the next free entity
    ent = G_Spawn();

    for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
        G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
    }

    // check for "notsingle" flag
    if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
        G_SpawnInt( "notsingle", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    // check for "notteam" flag (GT_FFA, GT_TOURNAMENT, GT_SINGLE_PLAYER)
    if ( gt[g_gametype.integer].teams ) {
        G_SpawnInt( "notteam", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    } else {
        G_SpawnInt( "notfree", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }

#ifdef MISSIONPACK
    G_SpawnInt( "notta", "0", &i );
    if ( i ) {
        ADJUST_AREAPORTAL();
        G_FreeEntity( ent );
        return;
    }
#else
    G_SpawnInt( "notq3a", "0", &i );
    if ( i ) {
        ADJUST_AREAPORTAL();
        G_FreeEntity( ent );
        return;
    }
#endif
//fnq3
    G_SpawnInt( "notfnq3", "0", &i );
    if ( i ) {
        ADJUST_AREAPORTAL();
        G_FreeEntity( ent );
        return;
    }

    if ( g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE ) {
        if ( G_SpawnString("gametype", NULL, &value) ) {
            s = strstr( value, gt[g_gametype.integer].refName );
            if ( !s ) {
                ADJUST_AREAPORTAL();
                G_FreeEntity( ent );
                return;
            }
        }

        if ( G_SpawnString("not_gametype", NULL, &value) ) {
            s = strstr( value, gt[g_gametype.integer].refName );
            if ( s ) {
                ADJUST_AREAPORTAL();
                G_FreeEntity( ent );
                return;
            }
        }
    }

    if ( gt[g_gametype.integer].arena ) {
        G_SpawnInt( "not_gt_arena", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    if ( gt[g_gametype.integer].ctf ) {
        G_SpawnInt( "not_gt_ctf", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    if ( gt[g_gametype.integer].dom ) {
        G_SpawnInt( "not_gt_dom", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    if ( gt[g_gametype.integer].duel ) {
        G_SpawnInt( "not_gt_duel", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    if ( gt[g_gametype.integer].elimination ) {
        G_SpawnInt( "not_gt_elim", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    if ( gt[g_gametype.integer].freeze ) {
        G_SpawnInt( "not_gt_freeze", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    if ( gt[g_gametype.integer].single ) {
        G_SpawnInt( "not_gt_single", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    if ( gt[g_gametype.integer].tdm ) {
        G_SpawnInt( "not_gt_tdm", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
    if ( gt[g_gametype.integer].teams ) {
        G_SpawnInt( "not_gt_teams", "0", &i );
        if ( i ) {
            ADJUST_AREAPORTAL();
            G_FreeEntity( ent );
            return;
        }
    }
//-fnq3

    // move editor origin to pos
    VectorCopy( ent->s.origin, ent->s.pos.trBase );
    VectorCopy( ent->s.origin, ent->r.currentOrigin );

    // if we didn't get a classname, don't bother spawning anything
    if ( !G_CallSpawn(ent) ) {
        G_FreeEntity( ent );
    }
}
Example #19
0
/*
===================
G_SpawnGEntityFromSpawnVars

Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
void G_SpawnGEntityFromSpawnVars() 
{
	int			i;
//	GameEntity	*ent;
	SpawnFieldHolder sfh;
	memset( &sfh, 0, sizeof(sfh) );

	char		*s, *value, *gametypeName;
	static char *gametypeNames[] = {"ffa", "tournament", "single", "missioneditor", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"};

	// get the next free entity
//	ent = G_Spawn();

	for ( i = 0 ; i < theLevel.numSpawnVars_ ; i++ ) 
	{
//		G_ParseField( theLevel.spawnVars_[i][0], theLevel.spawnVars_[i][1], ent );
		G_ParseField( theLevel.spawnVars_[i][0], theLevel.spawnVars_[i][1], &sfh );
	}

	// check for "notsingle" flag
	if ( g_gametype.integer == GT_SINGLE_PLAYER ) 
	{
		G_SpawnInt( "notsingle", "0", &i );
		if ( i ) 
		{
			//ent->free();
			return;
		}
	}
	// check for "notteam" flag (GT_FFA, GT_TOURNAMENT, GT_SINGLE_PLAYER)
	if ( g_gametype.integer >= GT_TEAM )
	{
		G_SpawnInt( "notteam", "0", &i );
		// MFQ3 special case for flags
		if( (g_gametype.integer != GT_CTF) &&
			(Q_stricmp( sfh.classname_, "team_CTF_redflag" ) == 0 ||
			Q_stricmp( sfh.classname_, "team_CTF_blueflag" ) == 0 ) )
		{
			//ent->free();
			return;
		}
		if ( i ) 
		{
			//ent->free();
			return;
		}
	} 
	else 
	{
		G_SpawnInt( "notfree", "0", &i );
		if ( i )
		{
			//ent->free();
			return;
		}
	}

	if( G_SpawnString( "gametype", NULL, &value ) ) 
	{
		if( g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE ) 
		{
			gametypeName = gametypeNames[g_gametype.integer];

			s = strstr( value, gametypeName );
			if( !s ) {
				//ent->free();
				return;
			}
		}
	}

	// move editor origin to pos
	//VectorCopy( ent->s.origin, ent->s.pos.trBase );
	//VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( &sfh ) ) 
	{
		//ent->free();
	}
}
Example #20
0
// For Maker Mod objects
// combine the two sets of spawnVars. newVars overwrite spawnVars
// we end up with level.spawnVars setup with our final values, the values applied to our ent, 
// and the appropriate spawn function executed.
void G_ApplySpawnVars( gentity_t *ent, char *spawnVars, char *newVars ) {
	int			i;
	char		*token;
	//static char *gametypeNames[] = {"ffa", "holocron", "jedimaster", "duel", "powerduel", "single", "team", "siege", "ctf", "cty"};
	char* p;
	char field[MAX_FIELDNAME_LENGTH + 1];

	level.numSpawnVars = 0;
	level.numSpawnVarChars = 0;
	level.spawnVarChars[0] = '/0';

	p = spawnVars;

	while ( p )
	{
		token = ParseExt( &p, qfalse );  // TODO : make sure it's safe to use this function
		if ( token[0] == 0 )
			break;

		strncpy( field, token, MAX_FIELDNAME_LENGTH  );

		token = ParseExt( &p, qfalse );
		if ( token[0] == 0 )
			break;

		AddSpawnField( field, token );
	}

	p = newVars;

	while ( p )
	{
		token = ParseExt( &p, qfalse );  // TODO : make sure it's safe to use this function
		if ( token[0] == 0 )
			break;

		strncpy( field, token, MAX_FIELDNAME_LENGTH  );

		token = ParseExt( &p, qfalse );
		if ( token[0] == 0 )
			break;

		AddSpawnField( field, token );
	}

	for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		BG_ParseField( fields, level.spawnVars[i][0], level.spawnVars[i][1], (byte *)ent );
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );


	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		//G_FreeEntity( ent );
	}

	//Tag on the ICARUS scripting information only to valid recipients
	if ( trap_ICARUS_ValidEnt( ent ) )
	{
		trap_ICARUS_InitEnt( ent );

		if ( ent->classname && ent->classname[0] )
		{
			if ( Q_strncmp( "NPC_", ent->classname, 4 ) != 0 )
			{//Not an NPC_spawner (rww - probably don't even care for MP, but whatever)
				G_ActivateBehavior( ent, BSET_SPAWN );
			}
		}
	}
}
Example #21
0
/*
* SpawnEntities
* 
* Creates a server's entity / program execution context by
* parsing textual entity definitions out of an ent file.
*/
void G_InitLevel( char *mapname, char *entities, int entstrlen, unsigned int levelTime, unsigned int serverTime, unsigned int realTime )
{
	char *mapString = NULL;
	char name[MAX_CONFIGSTRING_CHARS];
	int i;
	edict_t *ent;
	char *token;
	const gsitem_t *item;

	G_asGarbageCollect( true );

	GT_asCallShutdown();
	G_asCallMapExit();

	G_asShutdownMapScript();
	GT_asShutdownScript();

	G_FreeCallvotes();

	game.serverTime = serverTime;
	game.realtime = realTime;
	game.levelSpawnCount++;

	GClip_ClearWorld(); // clear areas links

	if( !entities )
		G_Error( "G_SpawnLevel: NULL entities string\n" );

	// make a copy of the raw entities string so it's not freed with the pool
	mapString = ( char * )G_Malloc( entstrlen + 1 );
	memcpy( mapString, entities, entstrlen );
	Q_strncpyz( name, mapname, sizeof( name ) );

	// clear old data

	G_LevelInitPool( strlen( mapname ) + 1 + ( entstrlen + 1 ) * 2 + G_LEVELPOOL_BASE_SIZE );

	G_StringPoolInit();

	memset( &level, 0, sizeof( level_locals_t ) );
	memset( &gs.gameState, 0, sizeof( gs.gameState ) );

	level.spawnedTimeStamp = game.realtime;
	level.time = levelTime;
	level.gravity = g_gravity->value;

	// get the strings back
	Q_strncpyz( level.mapname, name, sizeof( level.mapname ) );
	level.mapString = ( char * )G_LevelMalloc( entstrlen + 1 );
	level.mapStrlen = entstrlen;
	memcpy( level.mapString, mapString, entstrlen );
	G_Free( mapString );
	mapString = NULL;

	// make a copy of the raw entities string for parsing
	level.map_parsed_ents = ( char * )G_LevelMalloc( entstrlen + 1 );
	level.map_parsed_ents[0] = 0;

	if( !level.time )
		memset( game.edicts, 0, game.maxentities * sizeof( game.edicts[0] ) );
	else
	{
		G_FreeEdict( world );
		for( i = gs.maxclients + 1; i < game.maxentities; i++ )
		{
			if( game.edicts[i].r.inuse )
				G_FreeEdict( game.edicts + i );
		}
	}

	game.numentities = gs.maxclients + 1;

	// link client fields on player ents
	for( i = 0; i < gs.maxclients; i++ )
	{
		game.edicts[i+1].s.number = i+1;
		game.edicts[i+1].r.client = &game.clients[i];
		game.edicts[i+1].r.inuse = ( trap_GetClientState( i ) >= CS_CONNECTED ) ? true : false;
		memset( &game.clients[i].level, 0, sizeof( game.clients[0].level ) );
		game.clients[i].level.timeStamp = level.time;
	}

	// initialize game subsystems
	trap_ConfigString( CS_MAPNAME, level.mapname );
	trap_ConfigString( CS_SKYBOX, "" );
	trap_ConfigString( CS_AUDIOTRACK, "" );
	trap_ConfigString( CS_STATNUMS, va( "%i %i %i", STAT_SCORE, STAT_HEALTH, STAT_LAST_KILLER ) );
	trap_ConfigString( CS_POWERUPEFFECTS, va( "%i %i %i %i", EF_QUAD, EF_SHELL, EF_CARRIER, EF_REGEN ) );
	trap_ConfigString( CS_SCB_PLAYERTAB_LAYOUT, "" );
	trap_ConfigString( CS_SCB_PLAYERTAB_TITLES, "" );
	trap_ConfigString( CS_MATCHNAME, "" );
	trap_ConfigString( CS_MATCHSCORE, "" );

	// reset map messages
	for( i = 0; i < MAX_HELPMESSAGES; i++ ) {
		trap_ConfigString( CS_HELPMESSAGES + i, "" );
	}

	G_InitGameCommands();
	G_MapLocations_Init();
	G_CallVotes_Init();
	G_SpawnQueue_Init();
	G_Teams_Init();
	// load map script
	G_asLoadMapScript( level.mapname );
	G_Gametype_Init();
	// ch : this would be the location to "transfer ratings"
	G_PrecacheItems(); // set configstrings for items (gametype must be initialized)
	G_PrecacheMedia();
	G_PrecacheGameCommands(); // adding commands after this point won't update them to the client
	AI_InitLevel(); // load navigation file of the current map

	// start spawning entities

	level.canSpawnEntities = true;
	G_InitBodyQueue(); // reserve some spots for dead player bodies

	entities = level.mapString;

	i = 0;
	ent = NULL;
	while( 1 )
	{
		level.spawning_entity = NULL;

		// parse the opening brace
		token = COM_Parse( &entities );
		if( !entities )
			break;
		if( token[0] != '{' )
			G_Error( "G_SpawnMapEntities: found %s when expecting {", token );

		if( !ent )
		{
			ent = world;
			G_InitEdict( world );
		}
		else
			ent = G_Spawn();

		ent->spawnString = entities; // keep track of string definition of this entity

		entities = ED_ParseEdict( entities, ent );
		if( !ent->classname )
		{
			i++;
			// racesow - introducing the freestyle map bug again in
			// order to make some freestyle maps work
			if( !level.gametype.freestyleMapFix )
				G_FreeEdict( ent );
			// !racesow
			G_FreeEdict( ent );
			continue;
		}

		if( !G_CanSpawnEntity( ent ) )
		{
			i++;
			G_FreeEdict( ent );
			continue;
		}

		if( !G_CallSpawn( ent ) )
		{
			i++;
			G_FreeEdict( ent );
			continue;
		}

		// check whether an item is allowed to spawn
		if( ( item = ent->item ) )
		{
			// not pickable items aren't spawnable
			if( item->flags & ITFLAG_PICKABLE )
			{
				if( G_Gametype_CanSpawnItem( item ) )
				{
					// override entity's classname with whatever item specifies
					ent->classname = item->classname;
					PrecacheItem( item );
					continue;
				}
			}

			i++;
			G_FreeEdict( ent );
			continue;
		}
	}

	G_FindTeams();

	// is the parsing string sane?
	assert( (int)level.map_parsed_len < entstrlen );
	level.map_parsed_ents[level.map_parsed_len] = 0;

	// make sure server got the edicts data
	trap_LocateEntities( game.edicts, sizeof( game.edicts[0] ), game.numentities, game.maxentities );

	// items need brush model entities spawned before they are linked
	G_Items_FinishSpawningItems();

	//
	// initialize game subsystems which require entities initialized
	//

	// call gametype specific
	GT_asCallSpawn();

	// call map specific
	G_asCallMapInit();

	AI_InitEntitiesData();

	// always start in warmup match state and let the thinking code
	// revert it to wait state if empty ( so gametype based item masks are setup )
	G_Match_LaunchState( MATCH_STATE_WARMUP );

	G_asGarbageCollect( true );

	// racesow
	RS_Init();
}
Example #22
0
void G_SpawnGEntityFromSpawnVars( qboolean inSubBSP ) {
	int			i;
	gentity_t	*ent;
	char		*s, *value, *gametypeName;
	static char *gametypeNames[] = {"ffa", "holocron", "jedimaster", "duel", "powerduel", "single", "team", "siege", "ctf", "cty"};

	// get the next free entity
	if ( level.entCount > (MAX_GENTITIES - g_objectMargin.integer))
	{
		G_Printf("ERROR :Run out of entities\n");
		return;
	}
	ent = G_Spawn();

	for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
		BG_ParseField( fields, level.spawnVars[i][0], level.spawnVars[i][1], (byte *)ent );
	}

	if ( level.stripping == qtrue )
	{
		// strip out any undesirable object classes.
		if( Q_stricmpn( "item_", ent->classname, 5 ) == 0  ||
			Q_stricmpn( "trigger_", ent->classname, 8 ) == 0 ||
			Q_stricmpn( "target_", ent->classname, 7 ) == 0 ||
			Q_stricmpn( "NPC_", ent->classname, 4 ) == 0 )	
		{
			G_FreeEntity( ent );
			return;
		}

	}

	// check for "notsingle" flag
	if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
		G_SpawnInt( "notsingle", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return;
		}
	}
	// check for "notteam" flag (GT_FFA, GT_DUEL, GT_SINGLE_PLAYER)
	if ( g_gametype.integer >= GT_TEAM ) {
		G_SpawnInt( "notteam", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return;
		}
	} else {
		G_SpawnInt( "notfree", "0", &i );
		if ( i ) {
			G_FreeEntity( ent );
			return;
		}
	}

	G_SpawnInt( "notta", "0", &i );
	if ( i ) {
		G_FreeEntity( ent );
		return;
	}

	if( G_SpawnString( "gametype", NULL, &value ) ) {
		if( g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE ) {
			gametypeName = gametypeNames[g_gametype.integer];

			s = strstr( value, gametypeName );
			if( !s ) {
				G_FreeEntity( ent );
				return;
			}
		}
	}

	// move editor origin to pos
	VectorCopy( ent->s.origin, ent->s.pos.trBase );
	VectorCopy( ent->s.origin, ent->r.currentOrigin );

	// if we didn't get a classname, don't bother spawning anything
	if ( !G_CallSpawn( ent ) ) {
		G_FreeEntity( ent );
	}

	//Tag on the ICARUS scripting information only to valid recipients
	if ( trap_ICARUS_ValidEnt( ent ) )
	{
		trap_ICARUS_InitEnt( ent );

		if ( ent->classname && ent->classname[0] )
		{
			if ( Q_strncmp( "NPC_", ent->classname, 4 ) != 0 )
			{//Not an NPC_spawner (rww - probably don't even care for MP, but whatever)
				G_ActivateBehavior( ent, BSET_SPAWN );
			}
		}
	}
}