Ejemplo n.º 1
0
/*
==============
BotAISetup
==============
*/
int BotAISetup( int restart ) {
	int errnum;

#ifdef RANDOMIZE
	srand( (unsigned)time( NULL ) );
#endif //RANDOMIZE

	trap_Cvar_Register( &bot_thinktime, "bot_thinktime", "100", 0 );
	trap_Cvar_Register( &memorydump, "memorydump", "0", 0 );

	//if the game is restarted for a tournament
	if ( restart ) {
		return BLERR_NOERROR;
	}

	//initialize the bot states
	memset( botstates, 0, sizeof( botstates ) );

	trap_Cvar_Register( &bot_thinktime, "bot_thinktime", "100", 0 );

	errnum = BotInitLibrary();
	if ( errnum != BLERR_NOERROR ) {
		return qfalse;
	}
	return BLERR_NOERROR;
}
Ejemplo n.º 2
0
/*
=============
AICast_ScriptLoad

  Loads the script for the current level into the buffer
=============
*/
void AICast_ScriptLoad( void ) {
	char filename[MAX_QPATH];
	vmCvar_t mapname;
	fileHandle_t f;
	int len;

	level.scriptAI = NULL;

	trap_Cvar_VariableStringBuffer( "ai_scriptName", filename, sizeof( filename ) );
	if ( strlen( filename ) > 0 ) {
		trap_Cvar_Register( &mapname, "ai_scriptName", "", CVAR_ROM );
	} else {
		trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );
	}
	Q_strncpyz( filename, "maps/", sizeof( filename ) );
	Q_strcat( filename, sizeof( filename ), mapname.string );
	Q_strcat( filename, sizeof( filename ), ".ai" );

	len = trap_FS_FOpenFile( filename, &f, FS_READ );

	// make sure we clear out the temporary scriptname
	trap_Cvar_Set( "ai_scriptName", "" );

	if ( len < 0 ) {
		return;
	}

	level.scriptAI = G_Alloc( len );
	trap_FS_Read( level.scriptAI, len, f );

	trap_FS_FCloseFile( f );

	return;
}
Ejemplo n.º 3
0
/*
===============
G_InitBots
===============
*/
void G_InitBots( qboolean restart ) {
	int			fragLimit;
	int			timeLimit;
	const char	*arenainfo;
	char		*strValue;
	int			basedelay;
	char		map[MAX_QPATH];
	char		serverinfo[MAX_INFO_STRING];

	G_LoadBots();
	G_LoadArenas();

	trap_Cvar_Register( &bot_minplayers, "bot_minplayers", "0", CVAR_SERVERINFO );


	// leilei - additional ones
	trap_Cvar_Register( &bot_minplayersTime, "bot_minplayersTime", "10", CVAR_SERVERINFO );

	if( g_gametype.integer == GT_SINGLE_PLAYER ) {
		trap_GetServerinfo( serverinfo, sizeof(serverinfo) );
		Q_strncpyz( map, Info_ValueForKey( serverinfo, "mapname" ), sizeof(map) );
		arenainfo = G_GetArenaInfoByMap( map );
		if ( !arenainfo ) {
			return;
		}

		strValue = Info_ValueForKey( arenainfo, "fraglimit" );
		fragLimit = atoi( strValue );
		if ( fragLimit ) {
			trap_Cvar_Set( "fraglimit", strValue );
		}
		else {
			trap_Cvar_Set( "fraglimit", "0" );
		}

		strValue = Info_ValueForKey( arenainfo, "timelimit" );
		timeLimit = atoi( strValue );
		if ( timeLimit ) {
			trap_Cvar_Set( "timelimit", strValue );
		}
		else {
			trap_Cvar_Set( "timelimit", "0" );
		}

		if ( !fragLimit && !timeLimit ) {
			trap_Cvar_Set( "fraglimit", "10" );
			trap_Cvar_Set( "timelimit", "0" );
		}

		basedelay = BOT_BEGIN_DELAY_BASE;
		strValue = Info_ValueForKey( arenainfo, "special" );
		if( Q_stricmp( strValue, "training" ) == 0 ) {
			basedelay += 10000;
		}

		if( !restart ) {
			G_SpawnBots( Info_ValueForKey( arenainfo, "bots" ), basedelay );
		}
	}
}
Ejemplo n.º 4
0
/*
=============
G_Script_ScriptLoad

  Loads the script for the current level into the buffer
=============
*/
void G_Script_ScriptLoad(void)
{
	char         filename[MAX_QPATH];
	vmCvar_t     mapname;
	fileHandle_t f;
	int          len;

	trap_Cvar_Register(&g_scriptDebug, "g_scriptDebug", "0", 0);

	level.scriptEntity = NULL;

	trap_Cvar_VariableStringBuffer("g_scriptName", filename, sizeof(filename));
	if (strlen(filename) > 0)
	{
		trap_Cvar_Register(&mapname, "g_scriptName", "", CVAR_CHEAT);
	}
	else
	{
		trap_Cvar_Register(&mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM);
	}
	Q_strncpyz(filename, "maps/", sizeof(filename));
	Q_strcat(filename, sizeof(filename), mapname.string);

	if (g_gametype.integer == GT_WOLF_LMS)
	{
		Q_strcat(filename, sizeof(filename), "_lms");
	}

	Q_strcat(filename, sizeof(filename), ".script");

	len = trap_FS_FOpenFile(filename, &f, FS_READ);

	// make sure we clear out the temporary scriptname
	trap_Cvar_Set("g_scriptName", "");

	if (len < 0)
	{
		return;
	}

	// END Mad Doc - TDF
	// Arnout: make sure we terminate the script with a '\0' to prevent parser from choking
	//level.scriptEntity = G_Alloc( len );
	//trap_FS_Read( level.scriptEntity, len, f );
	level.scriptEntity = G_Alloc(len + 1);
	trap_FS_Read(level.scriptEntity, len, f);
	*(level.scriptEntity + len) = '\0';

	// Gordon: and make sure ppl haven't put stuff with uppercase in the string table..
	G_Script_EventStringInit();

	// Gordon: discard all the comments NOW, so we dont deal with them inside scripts
	// Gordon: disabling for a sec, wanna check if i can get proper line numbers from error output
//	COM_Compress( level.scriptEntity );

	trap_FS_FCloseFile(f);
}
/*
	direct call by ui-init
	... used by wopSP_initGame
*/
void wopSP_init(void) {
    //NOTE: addCommand only exists in cg -.- (so can't add this cmds in game/ui)

    trap_Cvar_Register(NULL, WOPSP_STORY_CVAR	, "", CVAR_SERVERINFO|CVAR_ROM );
    trap_Cvar_Register(NULL, WOPSP_SELEMENT_CVAR, "", CVAR_SERVERINFO|CVAR_ROM );

    trap_Cvar_Register(NULL, WOPSP_SAVENAME_CVAR, "default", CVAR_ARCHIVE );

    trap_Cvar_Register(NULL, WOPSP_BOTSKILL		, "2", CVAR_ARCHIVE|CVAR_LATCH ); //like g_spSkill and the addbot-parameter 1-5
}
Ejemplo n.º 6
0
void LoadDynamicMusic(void)
{//Tries to load dynamic music data for this map.
	int				len = 0;
	fileHandle_t	f;
	char			buffer[DMS_INFO_SIZE];
	vmCvar_t	mapname;

	//Open up the dynamic music file
	len = trap_FS_FOpenFile("ext_data/dms.dat", &f, FS_READ);

	if (!f)
	{//file open error
		G_Printf("LoadDynamicMusic() Error: Couldn't open ext_data/dms.dat\n");
		return;
	}

	if(len >= DMS_INFO_SIZE)
	{//file too large for buffer
		G_Printf("LoadDynamicMusic() Error: dms.dat too big.\n");
		return;
	}

	trap_FS_Read(buffer, len, f);	//read data in buffer

	trap_FS_FCloseFile(f);	//close file

	trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );
	
	LoadDynamicMusicGroup(mapname.string, buffer);
}
/*
=================
G_RegisterCvars
=================
*/
void G_RegisterCvars( void ) {
	int			i;
	cvarTable_t	*cv;
	qboolean remapped = qfalse;

	for ( i = 0, cv = gameCvarTable ; i < gameCvarTableSize ; i++, cv++ ) {
		trap_Cvar_Register( cv->vmCvar, cv->cvarName,
			cv->defaultString, cv->cvarFlags );
		if ( cv->vmCvar )
			cv->modificationCount = cv->vmCvar->modificationCount;

		if (cv->teamShader) {
			remapped = qtrue;
		}
	}

	if (remapped) {
		G_RemapTeamShaders();
	}

	// check some things
	if ( g_gametype.integer < 0 || g_gametype.integer >= GT_MAX_GAME_TYPE ) {
		G_Printf( "g_gametype %i is out of range, defaulting to 0\n", g_gametype.integer );
		trap_Cvar_Set( "g_gametype", "0" );
	}

	level.warmupModificationCount = g_warmup.modificationCount;
}
/*
=================
UI_RegisterCvars
=================
*/
void UI_RegisterCvars( void ) {
	int			i;
	cvarTable_t	*cv;

	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
		trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
	}

	// cvars die mehr als 256 Zeich aufnehmen sollen (256-limit ist nur im gamecode)
//spray anfang
	trap_Cvar_Register( NULL, "logolist", "", CVAR_INIT|CVAR_ROM );
//spray ende
//lens anfang
	trap_Cvar_Register( NULL, "lensflarelist", "", CVAR_INIT|CVAR_ROM );
//lens ende
}
Ejemplo n.º 9
0
/*
===============
G_LoadArenas
===============
*/
static void G_LoadArenas( void ) {
	int			numdirs;
	vmCvar_t	arenasFile;
	char		filename[128];
	char		dirlist[1024];
	char*		dirptr;
	int			i, n;
	int			dirlen;

	g_numArenas = 0;

	trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM );
	if( *arenasFile.string ) {
		G_LoadArenasFromFile(arenasFile.string);
	}
	else {
		G_LoadArenasFromFile("scripts/arenas.txt");
	}

	// get all arenas from .arena files
	numdirs = trap_FS_GetFileList("scripts", ".arena", dirlist, 1024 );
	dirptr  = dirlist;
	for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/");
		strcat(filename, dirptr);
		G_LoadArenasFromFile(filename);
	}
	trap_Printf( va( "%i arenas parsed\n", g_numArenas ) );
	
	for( n = 0; n < g_numArenas; n++ ) {
		Info_SetValueForKey( g_arenaInfos[n], "num", va( "%i", n ) );
	}
}
Ejemplo n.º 10
0
/*
===============
G_LoadBots
===============
*/
static void G_LoadBots( void ) {
	vmCvar_t	botsFile;
	int			numdirs;
	char		filename[128];
	char		dirlist[1024];
	char*		dirptr;
	int			i;
	int			dirlen;

	if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
		return;
	}

	g_numBots = 0;

	trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM );
	if( *botsFile.string ) {
		G_LoadBotsFromFile(botsFile.string);
	}
	else {
		G_LoadBotsFromFile("scripts/bots.txt");
	}

	// get all bots from .bot files
	numdirs = trap_FS_GetFileList("scripts", ".bot", dirlist, 1024 );
	dirptr  = dirlist;
	for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/");
		strcat(filename, dirptr);
		G_LoadBotsFromFile(filename);
	}
	trap_Printf( va( "%i bots parsed\n", g_numBots ) );
}
Ejemplo n.º 11
0
/*
==============
BotAILoadMap
==============
*/
int BotAILoadMap( int restart ) {
	int			i;
	vmCvar_t	mapname;

	if (!restart) {
		trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );
		trap_BotLibLoadMap( mapname.string );
	}

	//initialize physics
	BotInitPhysicsSettings();	//ai_move.h
	//initialize the items in the level
	BotInitLevelItems();		//ai_goal.h
	BotSetBrushModelTypes();	//ai_move.h

	for (i = 0; i < MAX_CLIENTS; i++) {
		if (botstates[i] && botstates[i]->inuse) {
			BotResetState( botstates[i] );
			botstates[i]->setupcount = 4;
		}
	}

	BotSetupDeathmatchAI();

	return qtrue;
}
Ejemplo n.º 12
0
void G_DebugOpenSkillLog(void)
{
	vmCvar_t        mapname;
	qtime_t         ct;
	char           *s;

	if (g_debugSkills.integer < 2)
	{
		return;
	}

	trap_Cvar_Register(&mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM);

	trap_RealTime(&ct);

	if (trap_FS_FOpenFile(va("skills-%d-%02d-%02d-%02d%02d%02d-%s.log",
	                         1900 + ct.tm_year, ct.tm_mon + 1, ct.tm_mday,
	                         ct.tm_hour, ct.tm_min, ct.tm_sec, mapname.string), &skillDebugLog, FS_APPEND_SYNC) < 0)
	{
		return;
	}

	s = va("%02d:%02d:%02d : Logfile opened.\n", ct.tm_hour, ct.tm_min, ct.tm_sec);

	trap_FS_Write(s, strlen(s), skillDebugLog);
}
Ejemplo n.º 13
0
/*
===============
UI_LoadBots
===============
*/
void UI_LoadBots( void ) {
	vmCvar_t botsFile;
	int numdirs;
	char filename[128];
	char dirlist[1024];
	char*       dirptr;
	int i;
	int dirlen;

	ui_numBots = 0;

	trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT | CVAR_ROM );
	if ( *botsFile.string ) {
		UI_LoadBotsFromFile( botsFile.string );
	} else {
		UI_LoadBotsFromFile( "scripts/bots.txt" );
	}

	// get all bots from .bot files
	numdirs = trap_FS_GetFileList( "scripts", ".bot", dirlist, 1024 );
	dirptr  = dirlist;
	for ( i = 0; i < numdirs; i++, dirptr += dirlen + 1 ) {
		dirlen = strlen( dirptr );
		strcpy( filename, "scripts/" );
		strcat( filename, dirptr );
		UI_LoadBotsFromFile( filename );
	}
	trap_Print( va( "%i bots parsed\n", ui_numBots ) );
}
Ejemplo n.º 14
0
/*
=================
CG_RegisterCvars
=================
*/
void CG_RegisterCvars( void ) {
	int			i;
	cvarTable_t	*cv;
	char		var[MAX_TOKEN_CHARS];

	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
		trap_Cvar_Register( cv->vmCvar, cv->cvarName,
			cv->defaultString, cv->cvarFlags );
	}

	// see if we are also running the server on this machine
	trap_Cvar_VariableStringBuffer( "sv_running", var, sizeof( var ) );
	cgs.localServer = atoi( var );


	trap_Cvar_Register(NULL, "cg_wombat", "1", CVAR_ARCHIVE );
}
Ejemplo n.º 15
0
/*
=================
UI_RegisterCvars
=================
*/
void UI_RegisterCvars( void ) {
	int			i;
	cvarTable_t	*cv;

	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
		trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
	}
}
Ejemplo n.º 16
0
/*
=================
CG_RegisterCvars
=================
*/
void CG_RegisterCvars( void ) {
	int			i;
	cvarTable_t	*cv;
	char		var[MAX_TOKEN_CHARS];

	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
		trap_Cvar_Register( cv->vmCvar, cv->cvarName,
			cv->defaultString, cv->cvarFlags );
	}

	// see if we are also running the server on this machine
	trap_Cvar_VariableStringBuffer( "sv_running", var, sizeof( var ) );
	cgs.localServer = atoi( var );

	forceModelModificationCount = cg_forceModel.modificationCount;

	trap_Cvar_Register(NULL, "model", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
}
Ejemplo n.º 17
0
/*
===============
G_InitBots
===============
*/
void G_InitBots( qboolean restart ) {
	G_LoadBots();
	G_LoadArenas();

	trap_Cvar_Register( &bot_minplayers, "bot_minplayers", "0", CVAR_SERVERINFO );
	//rww - new bot route stuff
	LoadPath_ThisLevel();
	//end rww
}
Ejemplo n.º 18
0
void AICast_Init (void)
{
	vmCvar_t	cvar;
	int	i;

	numSecrets = 0;
	numcast = 0;
	numSpawningCast = 0;
	saveGamePending = qtrue;

	trap_Cvar_Register( &aicast_debug, "aicast_debug", "0", 0 );
	trap_Cvar_Register( &aicast_debugname, "aicast_debugname", "", 0 );
	trap_Cvar_Register( &aicast_scripts, "aicast_scripts", "1", 0 );

	// (aicast_thinktime / sv_fps) * aicast_maxthink = number of cast's to think between each aicast frame
	// so..
	// (100 / 20) * 6 = 30
	//
	// so if the level has more than 30 AI cast's, they could start to bunch up, resulting in slower thinks

	trap_Cvar_Register( &cvar, "aicast_thinktime", "50", 0 );
	aicast_thinktime = trap_Cvar_VariableIntegerValue( "aicast_thinktime" );

	trap_Cvar_Register( &cvar, "aicast_maxthink", "12", 0 );
	aicast_maxthink = trap_Cvar_VariableIntegerValue( "aicast_maxthink" );

	aicast_maxclients = trap_Cvar_VariableIntegerValue( "sv_maxclients" );

	aicast_skillscale = (float)trap_Cvar_VariableIntegerValue( "g_gameSkill" ) / (float)GSKILL_MAX;

	caststates = G_Alloc( aicast_maxclients * sizeof(cast_state_t) );
	memset( caststates, 0, sizeof(caststates) );
	for (i=0; i<MAX_CLIENTS; i++) {
		caststates[i].entityNum = i;
	}

	// try and load in the AAS now, so we can interact with it during spawning of entities
	i = 0;
	trap_AAS_SetCurrentWorld(0);
	while (!trap_AAS_Initialized() && (i++ < 10)) {
		trap_BotLibStartFrame((float) level.time / 1000);
	}
}
Ejemplo n.º 19
0
/*
=================
UI_RegisterCvars
=================
*/
void UI_RegisterCvars( void ) {
	int			i;
	cvarTable_t	*cv;
	
	//RPG-X: RedTechie - Keep no class default
	//RPG-X: TiM - just commented this out for now to see if I can add class support to the main UI
//	trap_Cvar_Set( "ui_playerclass", "NOCLASS" );
	
	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
		trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
	}
}
Ejemplo n.º 20
0
//===========================================================================
// Routine      : AOTCTC_Holocron_Savepositions
// Description  : Saves holocron positions to a .hpf file on disk
void AOTCTC_Holocron_Savepositions( void )
{
	fileHandle_t	f;
	char			*fileString;
	//[DynamicMemoryTweaks]
	char			savePath[MAX_QPATH];
	//[/DynamicMemoryTweaks]
	//[RawMapName]
	vmCvar_t		mapname;
	//[/RawMapName]
	char			lineout[MAX_INFO_STRING];
	int				loop = 0;

	number_of_holocronpositions--;

	G_Printf("^7Saving holocron position table.\n");

	fileString = NULL;

	//savePath = (char *)B_TempAlloc(1024*4);
	trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );

	Com_sprintf(savePath, 1024*4, "holocron_positions/%s.hpf", mapname.string);

	trap_FS_FOpenFile(savePath, &f, FS_WRITE);

	if ( !f )
	{
		return;
	}

	Com_sprintf( lineout, sizeof(lineout), "%i ", number_of_holocronpositions);
	trap_FS_Write( lineout, strlen(lineout), f);

	while (loop < number_of_holocronpositions)
	{
		char lineout[MAX_INFO_STRING];

		Com_sprintf( lineout, sizeof(lineout), "%f %f %f ", 
				holocrons[loop].origin[0],
				holocrons[loop].origin[1],
				holocrons[loop].origin[2] );
		
		trap_FS_Write( lineout, strlen(lineout), f);

		loop++;
	}

	G_Printf("^7Holocron Position table saved %i holocron positions to file %s.\n", number_of_holocronpositions, savePath);

	trap_FS_FCloseFile( f );
}
Ejemplo n.º 21
0
/*
=============
G_Script_ScriptLoad

  Loads the script for the current level into the buffer
=============
*/
void G_Script_ScriptLoad( void ) {
	char filename[MAX_QPATH];
	vmCvar_t mapname;
	fileHandle_t f;
	int len;

	trap_Cvar_Register( &g_scriptDebug, "g_scriptDebug", "0", 0 );

	level.scriptEntity = NULL;

	trap_Cvar_VariableStringBuffer( "g_scriptName", filename, sizeof( filename ) );
	if ( strlen( filename ) > 0 ) {
		trap_Cvar_Register( &mapname, "g_scriptName", "", CVAR_ROM );
	} else {
		trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );
	}
	Q_strncpyz( filename, "maps/", sizeof( filename ) );
	Q_strcat( filename, sizeof( filename ), mapname.string );
	// DHM - Nerve :: Support capture mode by loading appropriate script
	if ( ( g_gametype.integer == GT_WOLF_CP ) || ( g_gametype.integer == GT_WOLF_CPH ) ) { // JPW NERVE added capture & hold
		Q_strcat( filename, sizeof( filename ), "_cp" );
	}
	// dhm - Nerve
	Q_strcat( filename, sizeof( filename ), ".script" );

	len = trap_FS_FOpenFile( filename, &f, FS_READ );

	// make sure we clear out the temporary scriptname
	trap_Cvar_Set( "g_scriptName", "" );

	if ( len < 0 ) {
		return;
	}

	level.scriptEntity = G_Alloc( len );
	trap_FS_Read( level.scriptEntity, len, f );

	trap_FS_FCloseFile( f );
}
Ejemplo n.º 22
0
Archivo: g_bot.c Proyecto: GenaSG/ET
/*
===============
G_InitBots
===============
*/
void G_InitBots( qboolean restart ) {
	G_LoadBots();

	trap_Cvar_Register( &bot_debug, "bot_debug", "0", 0 );

	// the static entity cache is not ready yet
	level.initStaticEnts = qfalse;

	// determine which team is attacking
	level.captureFlagMode = qfalse;

	return;
}
qboolean AIMOD_LoadCoverPoints ( void )
{
	//FILE			*pIn;
	int				i = 0;
	fileHandle_t	f;
	int				num_map_waypoints = 0;
	vmCvar_t		mapname;

	// Init...
	num_cover_spots = 0;

	trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );

	trap_FS_FOpenFile( va( "nodes/%s.cpw", mapname.string), &f, FS_READ );

	if (!f)
	{
		G_Printf( "^1ERROR: Reading coverpoints from /nodes/%s.cpw failed\n", mapname.string );
		return qfalse;
	}

	trap_FS_Read( &num_map_waypoints, sizeof(int), f );

	if (num_map_waypoints != gWPNum)
	{// Is an old file! We need to make a new one!
		G_Printf( "^1*** ^3%s^5: Reading coverpoints from ^7/nodes/%s.cpw^3 failed ^5(old coverpoint file)^5!!!\n", GAME_VERSION, mapname.string );
		trap_FS_FCloseFile( f );
		return qfalse;
	}

	trap_FS_Read( &num_cover_spots, sizeof(int), f );	

	for ( i = 0; i < num_cover_spots; i++ )
	{
		int j = 0;

		trap_FS_Read( &(cover_nodes[i]), sizeof(int), f );

		if (!(gWPArray[cover_nodes[i]]->flags & WPFLAG_COVER))
			gWPArray[cover_nodes[i]]->flags |= WPFLAG_COVER;

		//CG_Printf("Cover spot #%i (node %i) is at %f %f %f.\n", i, cover_nodes[i], nodes[cover_nodes[i]].origin[0], nodes[cover_nodes[i]].origin[1], nodes[cover_nodes[i]].origin[2]);
	}

	trap_FS_FCloseFile( f );

	G_Printf( "^1*** ^3%s^5: Successfully loaded %i cover points from file ^7/nodes/%s.cpw^5.\n", GAME_VERSION, num_cover_spots, mapname.string);

	return qtrue;
}
Ejemplo n.º 24
0
/*
===============
G_LoadBots
===============
*/
static void G_LoadBots(void)
{
	int          len;
	char         *filename;
	vmCvar_t     botsFile;
	fileHandle_t f;
	char         buf[MAX_BOTS_TEXT];

	if (!bot_enable.integer)
	{
		return;
	}

	trap_Cvar_Register(&botsFile, "g_botsFile", "", CVAR_INIT | CVAR_ROM);
	if (*botsFile.string)
	{
		filename = botsFile.string;
	}
	else
	{
		filename = "scripts/bots.txt";
	}

	len = trap_FS_FOpenFile(filename, &f, FS_READ);
	if (!f)
	{
		trap_Printf(va(S_COLOR_RED "file not found: %s\n", filename));
		return;
	}
	if (len >= MAX_BOTS_TEXT)
	{
		trap_Printf(va(S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_BOTS_TEXT));
		trap_FS_FCloseFile(f);
		return;
	}

	trap_FS_Read(buf, len, f);
	buf[len] = 0;
	trap_FS_FCloseFile(f);

	g_numBots = Com_ParseInfos(buf, MAX_BOTS, g_botInfos);
	trap_Printf(va("%i bots parsed\n", g_numBots));

	// load bot script
	Bot_ScriptLoad();
}
Ejemplo n.º 25
0
/*
===============
G_LoadArenas
===============
*/
static void G_LoadArenas(void)
{
#ifdef QUAKESTUFF
	int          len;
	char         *filename;
	vmCvar_t     arenasFile;
	fileHandle_t f;
	int          n;
	char         buf[MAX_ARENAS_TEXT];

	trap_Cvar_Register(&arenasFile, "g_arenasFile", "", CVAR_INIT | CVAR_ROM);
	if (*arenasFile.string)
	{
		filename = arenasFile.string;
	}
	else
	{
		filename = "scripts/arenas.txt";
	}

	len = trap_FS_FOpenFile(filename, &f, FS_READ);
	if (!f)
	{
		trap_Printf(va(S_COLOR_RED "file not found: %s\n", filename));
		return;
	}
	if (len >= MAX_ARENAS_TEXT)
	{
		trap_Printf(va(S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_ARENAS_TEXT));
		trap_FS_FCloseFile(f);
		return;
	}

	trap_FS_Read(buf, len, f);
	buf[len] = 0;
	trap_FS_FCloseFile(f);

	g_numArenas = Com_ParseInfos(buf, MAX_ARENAS, g_arenaInfos);
	trap_Printf(va("%i arenas parsed\n", g_numArenas));

	for (n = 0; n < g_numArenas; n++)
	{
		Info_SetValueForKey(g_arenaInfos[n], "num", va("%i", n));
	}
#endif
}
Ejemplo n.º 26
0
/*
=================
G_ScriptAction_MissionSuccess

  syntax: missionsuccess <mission_level>
=================
*/
qboolean G_ScriptAction_MissionSuccess( gentity_t *ent, const char* params ) {
	gentity_t   *player;
	vmCvar_t cvar;
	int lvl;
    const char* pString;
    char* token;

	pString = params;

	token = COM_ParseExt( &pString, qfalse );
	if ( !token[0] ) {
		G_Error( "AI Scripting: missionsuccess requires a mission_level identifier\n" );
	}

	player = AICast_FindEntityForName( "player" );
	// double check that they are still alive
	if ( player->health <= 0 ) {
		return qfalse;  // hold the script here

	}
	lvl = atoi( token );

// if you've already got it, just return.  don't need to set 'yougotmail'
	if ( player->missionObjectives & ( 1 << ( lvl - 1 ) ) ) {
		return qtrue;
	}

	player->missionObjectives |= ( 1 << ( lvl - 1 ) );  // make this bitwise

	//set g_objective<n> cvar
	trap_Cvar_Register( &cvar, va( "g_objective%i", lvl ), "1", CVAR_ROM );
	// set it to make sure
	trap_Cvar_Set( va( "g_objective%i", lvl ), "1" );

	token = COM_ParseExt( &pString, qfalse );
	if ( token[0] ) {
		if ( Q_strcasecmp( token,"nodisplay" ) ) {   // unknown command
			G_Error( "AI Scripting: missionsuccess with unknown parameter: %s\n", token );
		}
	} else {    // show on-screen information
		trap_Cvar_Set( "cg_youGotMail", "2" ); // set flag to draw icon
	}

	return qtrue;
}
Ejemplo n.º 27
0
void Cmd_NewJail_f(gentity_t *ent)
{
	if (!HasPermission(ent, PERMISSION_JAIL))
		return;

	if (trap_Argc() != 1)
	{
		MM_SendMessage(ent - g_entities, va("print \"Command usage: mnewjail\n\""));
		return;
	}

	if(jails_add(ent->client->ps.origin, ent->client->ps.viewangles))
		MM_SendMessage(ent - g_entities, va("print \"New jail spot created.\n\""));
	else
		MM_SendMessage(ent - g_entities, va("print \"Error creating new jail spot.\n\""));

	vmCvar_t mapname;
	trap_Cvar_Register(&mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM);
	MM_WriteData(va("jails\\%s.json", mapname.string), MM_WriteJails);
}
Ejemplo n.º 28
0
/*
==============
BotAILoadMap
==============
*/
int BotAILoadMap( int restart ) {
	int i;
	vmCvar_t mapname;

	if ( !restart ) {
		trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );
		trap_BotLibLoadMap( mapname.string );
	}

	for ( i = 0; i < MAX_CLIENTS; i++ ) {
		if ( botstates[i] && botstates[i]->inuse ) {
			BotResetState( botstates[i] );
			botstates[i]->setupcount = 4;
		}
	}

	BotSetupDeathmatchAI();

	return BLERR_NOERROR;
}
/*
===============
UI_LoadBots
===============
*/
static void UI_LoadBots( void ) {
	vmCvar_t	botsFile;
	int			numdirs;
	char		filename[128];
	char		dirlist[1024];
	char*		dirptr;
	int			i;
	int			dirlen;
	char		info[MAX_INFO_STRING];

	ui_numBots = 0;

	// setup random bot option
	memset(info, 0, MAX_INFO_STRING);
	Info_SetValueForKey(info, "name", "Random");
	Info_SetValueForKey(info, "model", "random");
	ui_botInfos[ui_numBots] = UI_Alloc(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1);
	if (ui_botInfos[ui_numBots]) {
		strcpy(ui_botInfos[ui_numBots], info);
	}
	ui_numBots++;

	trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM );
	if( *botsFile.string ) {
		UI_LoadBotsFromFile(botsFile.string);
	}
	else {
		UI_LoadBotsFromFile("scripts/bots.txt");
	}

	// get all bots from .bot files
	numdirs = trap_FS_GetFileList("scripts", ".bot", dirlist, 1024 );
	dirptr  = dirlist;
	for (i = 0; i < numdirs; i++, dirptr += dirlen+1) {
		dirlen = strlen(dirptr);
		strcpy(filename, "scripts/");
		strcat(filename, dirptr);
		UI_LoadBotsFromFile(filename);
	}
	Com_DPrintf("%i bots parsed\n", ui_numBots);
}
Ejemplo n.º 30
0
void Cmd_DelJail_f(gentity_t *ent)
{
	char buffer[MAX_TOKEN_CHARS];
	if (!HasPermission(ent, PERMISSION_JAIL))
		return;

	if (trap_Argc() != 2)
	{
		MM_SendMessage(ent - g_entities, va("print \"Command usage: mdeljail <id>\n\""));
		return;
	}

	trap_Argv(1, buffer, sizeof(buffer));

	int id = atoi(buffer);
	jail_t *root = jails.next;

	for (int i = 0; i < id; i++)
		if (root == NULL) break;
		else
			root = root->next;

	if (root)
	{
		if(root->prev) root->prev->next = root->next;
		if(root->next) root->next->prev = root->prev;
		free(root);
		jails.count--;
		MM_SendMessage(ent - g_entities, va("print \"Jail spot removed.\n\""));
	}
	else
		MM_SendMessage(ent - g_entities, va("print \"Error removing jail spot.\n\""));

	vmCvar_t mapname;
	trap_Cvar_Register(&mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM);
	MM_WriteData(va("jails\\%s.json", mapname.string), MM_WriteJails);
}