您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ trap_Cvar_Update函数代码示例

51自学网 2021-06-03 08:57:35
  C++
这篇教程C++ trap_Cvar_Update函数代码示例写得很实用,希望能帮到您。

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

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

示例1: BotTestAAS

/*==================BotTestAAS==================*/void BotTestAAS(vec3_t origin){    int areanum;    aas_areainfo_t info;    trap_Cvar_Update(&bot_testsolid);    trap_Cvar_Update(&bot_testclusters);    if (bot_testsolid.integer) {        if (!trap_AAS_Initialized())            return;        areanum = BotPointAreaNum(origin);        if (areanum)            BotAI_Print(PRT_MESSAGE, "/remtpy area");        else            BotAI_Print(PRT_MESSAGE, "/r^1SOLID area");    } else if (bot_testclusters.integer) {        if (!trap_AAS_Initialized())            return;        areanum = BotPointAreaNum(origin);        if (!areanum)            BotAI_Print(PRT_MESSAGE, "/r^1Solid!                              ");        else {            trap_AAS_AreaInfo(areanum, &info);            BotAI_Print(PRT_MESSAGE, "/rarea %d, cluster %d       ", areanum, info.cluster);        }    }}
开发者ID:zturtleman,项目名称:reaction,代码行数:32,


示例2: G_InitMapRotations

/*===============G_InitMapRotationsLoad and initialise the map rotations===============*/void G_InitMapRotations( void ){	const char *fileName = "maprotation.cfg";	// Load the file if it exists	if ( trap_FS_FOpenFile( fileName, NULL, FS_READ ) )	{		if ( !G_ParseMapRotationFile( fileName ) )		{			G_Printf( S_COLOR_RED "ERROR: failed to parse %s file/n", fileName );		}	}	else	{		G_Printf( "%s file not found./n", fileName );	}	if ( g_currentMapRotation.integer == NOT_ROTATING )	{		if ( g_initialMapRotation.string[ 0 ] != 0 )		{			G_StartMapRotation( g_initialMapRotation.string, qfalse, qtrue, qfalse, 0 );			trap_Cvar_Set( "g_initialMapRotation", "" );			trap_Cvar_Update( &g_initialMapRotation );		}	}}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:35,


示例3: G_RegisterCvars

/*=================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" );		trap_Cvar_Update( &g_gametype );	}	level.warmupModificationCount = g_warmup.modificationCount;}
开发者ID:kungfooman,项目名称:ioq3,代码行数:34,


示例4: G_PopRotationStack

/*===============G_PopRotationStackPop the rotation stack===============*/static int G_PopRotationStack( void ){	int  value = -1;	char text[ MAX_CVAR_VALUE_STRING ];	char *text_p, *token;	Q_strncpyz( text, g_mapRotationStack.string, sizeof( text ) );	text_p = text;	token = COM_Parse( &text_p );	if ( *token )	{		value = atoi( token );	}	if ( text_p )	{		while ( *text_p == ' ' )		{			text_p++;		}		trap_Cvar_Set( "g_mapRotationStack", text_p );		trap_Cvar_Update( &g_mapRotationStack );	}	else	{		G_ClearRotationStack();	}	return value;}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:40,


示例5: G_StartMapRotation

/*===============G_StartMapRotationSwitch to a new map rotation===============*/qboolean G_StartMapRotation( char *name, qboolean changeMap ){	int i;	for ( i = 0; i < mapRotations.numRotations; i++ )	{		if ( !Q_stricmp( mapRotations.rotations[ i ].name, name ) )		{			trap_Cvar_Set( "g_currentMapRotation", va( "%d", i ) );			trap_Cvar_Update( &g_currentMapRotation );			if ( changeMap )			{				G_IssueMapChange( i );			}			break;		}	}	if ( i == mapRotations.numRotations )	{		return qfalse;	}	else	{		return qtrue;	}}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:36,


示例6: CG_UpdateCvars

/*=================CG_UpdateCvars=================*/void CG_UpdateCvars( void ) {	int			i;	cvarTable_t	*cv;	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {		trap_Cvar_Update( cv->vmCvar );	}	// check for modications here	// If team overlay is on, ask for updates from the server.  If its off,	// let the server know so we don't receive it	if ( drawTeamOverlayModificationCount != cg_drawTeamOverlay.modificationCount ) {		drawTeamOverlayModificationCount = cg_drawTeamOverlay.modificationCount;		if ( cg_drawTeamOverlay.integer > 0 ) {			trap_Cvar_Set( "teamoverlay", "1" );		} else {			trap_Cvar_Set( "teamoverlay", "0" );		}	}	// if force model changed	if ( forceModelModificationCount != cg_forceModel.modificationCount ) {		forceModelModificationCount = cg_forceModel.modificationCount;		CG_ForceModelChange();	}}
开发者ID:kingtiger01,项目名称:OpenMOHAA,代码行数:33,


示例7: G_InitMapRotations

/*===============G_InitMapRotationsLoad and intialise the map rotations===============*/void G_InitMapRotations( void ){  const char    *fileName = "maprotation.cfg";  fileHandle_t  f;  //load the file if it exists  if( trap_FS_FOpenFile( fileName, &f, FS_READ ) > 0 )  {    trap_FS_FCloseFile( f );    if( !G_ParseMapRotationFile( fileName ) )      G_Printf( S_COLOR_RED "ERROR: failed to parse %s file/n", fileName );  }  else    G_Printf( "%s file not found./n", fileName );  if( g_currentMapRotation.integer == NOT_ROTATING )  {    if( g_initialMapRotation.string[ 0 ] != 0 )    {      G_StartMapRotation( g_initialMapRotation.string, false );      trap_Cvar_Set( "g_initialMapRotation", "" );      trap_Cvar_Update( &g_initialMapRotation );    }  }}
开发者ID:TheDushan,项目名称:OpenWolf,代码行数:34,


示例8: G_UpdateCvars

/*=================G_UpdateCvars=================*/void G_UpdateCvars( void ) {	int			i;	cvarTable_t	*cv;	qboolean remapped = qfalse;	for ( i = 0, cv = gameCvarTable ; i < gameCvarTableSize ; i++, cv++ ) {		if ( cv->vmCvar ) {			trap_Cvar_Update( cv->vmCvar );			if ( cv->modificationCount != cv->vmCvar->modificationCount ) {				cv->modificationCount = cv->vmCvar->modificationCount;				if ( cv->trackChange ) {					trap_SendServerCommand( -1, va("print /"Server: %s changed to %s/n/"", 						cv->cvarName, cv->vmCvar->string ) );				}				if (cv->teamShader) {					remapped = qtrue;				}			}		}	}	if (remapped) {		G_RemapTeamShaders();	}}
开发者ID:CarlGammaSagan,项目名称:Quake-3-Android-Port-QIII4A,代码行数:33,


示例9: BotInterbreeding

/*==============BotInterbreeding==============*/void BotInterbreeding(void) {	int i;	trap_Cvar_Update(&bot_interbreedchar);	if (!strlen(bot_interbreedchar.string)) return;	//make sure we are in tournament mode	if (gametype != GT_TOURNAMENT) {		trap_Cvar_SetValue("g_gametype", GT_TOURNAMENT);		ExitLevel();		return;	}	//shutdown all the bots	for (i = 0; i < MAX_CLIENTS; i++) {		if (botstates[i] && botstates[i]->inuse) {			BotAIShutdownPlayer(botstates[i]->playernum, qfalse);		}	}	//make sure all item weight configs are reloaded and Not shared	trap_Cvar_SetValue("bot_reloadcharacters", 1);	//add a number of bots using the desired bot character	for (i = 0; i < bot_interbreedbots.integer; i++) {		trap_Cmd_ExecuteText( EXEC_INSERT, va("addbot %s 4 free %i %s%d/n",						bot_interbreedchar.string, i * 50, bot_interbreedchar.string, i) );	}	//	trap_Cvar_Set("bot_interbreedchar", "");	bot_interbreed = qtrue;}
开发者ID:SilverlineDev,项目名称:mint-arena,代码行数:33,


示例10: UI_UpdateCvars

/*=================UI_UpdateCvars=================*/void UI_UpdateCvars( void ) {	int			i;	cvarTable_t	*cv;	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {		trap_Cvar_Update( cv->vmCvar );	}}
开发者ID:PadWorld-Entertainment,项目名称:wop-gamesource,代码行数:13,


示例11: G_PushRotationStack

/*===============G_PushRotationStackPush the rotation stack===============*/static void G_PushRotationStack( int rotation ){	char text[ MAX_CVAR_VALUE_STRING ];	Com_sprintf( text, sizeof( text ), "%d %s",	             rotation, g_mapRotationStack.string );	trap_Cvar_Set( "g_mapRotationStack", text );	trap_Cvar_Update( &g_mapRotationStack );}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:16,


示例12: CG_UpdateCvars

/*=================CG_UpdateCvars=================*/void CG_UpdateCvars( void ) {	int			i;	cvarTable_t	*cv;	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {		trap_Cvar_Update( cv->vmCvar );	}	// check for modications here}
开发者ID:asl97,项目名称:ZEQ2-Lite-1,代码行数:15,


示例13: Svcmd_AddBot_f

/*===============Svcmd_AddBot_f===============*/void Svcmd_AddBot_f( void ) {	int				skill;	int				delay;	char			name[MAX_TOKEN_CHARS];	char			string[MAX_TOKEN_CHARS];	char			team[MAX_TOKEN_CHARS];	// are bots enabled?	if ( !bot_enable.integer ) {		return;	}	// name	trap_Argv( 1, name, sizeof( name ) );	/// read it just so we can check if it's a name (old method)	if ( name[0] && !Q_stricmp( name, "?" ) ) {		trap_Printf( "Usage: Addbot [skill 1-4] [team (RED/BLUE)] [msec delay]/n" );		return;	}	// CHRUKER: b070 - Was 'wolfbot' but this must match in case	Q_strncpyz( name, "Wolfbot", sizeof( name ) );	// RF, hard code the bots for wolf	if ( !name[0] ) {		trap_Printf( "Usage: Addbot [skill 1-4] [team (RED/BLUE)] [msec delay]/n" );		return;	}	// skill	trap_Argv( 1, string, sizeof( string ) );	if ( !string[0] ) {		trap_Cvar_Update( &bot_defaultskill );		skill = bot_defaultskill.integer;	}	else {		skill = atoi( string );	}	// team	trap_Argv( 2, team, sizeof( team ) );	// delay	trap_Argv( 3, string, sizeof( string ) );	if ( !string[0] ) {		delay = 0;	}	else {		delay = atoi( string );	}	G_AddBot( name, skill, team, NULL, 0, 0, -1, NULL, NULL, -1, NULL, qfalse);	// if this was issued during gameplay and we are playing locally,	// go ahead and load the bot's media immediately	if ( level.time - level.startTime > 1000 &&		trap_Cvar_VariableIntegerValue( "cl_running" ) ) {	}}
开发者ID:thewolfteam,项目名称:Reloaded,代码行数:60,


示例14: G_CheckMinimumPlayers

/*===============G_CheckMinimumPlayers=============== */void G_CheckMinimumPlayers(void) {    int minplayers;    int humanplayers, botplayers;    static int checkminimumplayers_time;    if (level.intermissiontime) return;    //only check once each 10 seconds    if (checkminimumplayers_time > level.time - 10000) {        return;    }    checkminimumplayers_time = level.time;    trap_Cvar_Update(&bot_minplayers);    minplayers = bot_minplayers.integer;    if (minplayers <= 0) return;    if (g_gametype.integer == GT_TEAMSURVIVOR) {        if (minplayers >= g_maxclients.integer / 2) {            minplayers = (g_maxclients.integer / 2) - 1;        }        humanplayers = G_CountHumanPlayers(TEAM_RED);        botplayers = G_CountBotPlayers(TEAM_RED);        //        if (humanplayers + botplayers < minplayers) {            G_AddRandomBot(TEAM_RED);        } else if (humanplayers + botplayers > minplayers && botplayers) {            G_RemoveRandomBot(TEAM_RED);        }        //        humanplayers = G_CountHumanPlayers(TEAM_BLUE);        botplayers = G_CountBotPlayers(TEAM_BLUE);        //        if (humanplayers + botplayers < minplayers) {            G_AddRandomBot(TEAM_BLUE);        } else if (humanplayers + botplayers > minplayers && botplayers) {            G_RemoveRandomBot(TEAM_BLUE);        }    } else if (g_gametype.integer == GT_FFA) {        if (minplayers >= g_maxclients.integer) {            minplayers = g_maxclients.integer - 1;        }        humanplayers = G_CountHumanPlayers(TEAM_FREE);        botplayers = G_CountBotPlayers(TEAM_FREE);        //        if (humanplayers + botplayers < minplayers) {            G_AddRandomBot(TEAM_FREE);        } else if (humanplayers + botplayers > minplayers && botplayers) {            G_RemoveRandomBot(TEAM_FREE);        }    }}
开发者ID:zturtleman,项目名称:q3rain,代码行数:56,


示例15: G_SetCurrentMap

/*===============G_SetCurrentMapSet the current map in some rotation===============*/static void G_SetCurrentMap( int currentMap, int rotation ){  char  text[ MAX_MAP_ROTATIONS * 2 ] = { 0 };  int   *p = G_GetCurrentMapArray( );  int   i;  p[ rotation ] = currentMap;  for( i = 0; i < mapRotations.numRotations; i++ )    Q_strcat( text, sizeof( text ), va( "%d ", p[ i ] ) );  trap_Cvar_Set( "g_currentMap", text );  trap_Cvar_Update( &g_currentMap );}
开发者ID:redrumrobot,项目名称:korx,代码行数:21,


示例16: BotInterbreedEndMatch

/*==============BotInterbreedEndMatchadd link back into ExitLevel?==============*/void BotInterbreedEndMatch(void) {	if (!bot_interbreed) return;	bot_interbreedmatchcount++;	if (bot_interbreedmatchcount >= bot_interbreedcycle.integer) {		bot_interbreedmatchcount = 0;		//		trap_Cvar_Update(&bot_interbreedwrite);		if (strlen(bot_interbreedwrite.string)) {			BotWriteInterbreeded(bot_interbreedwrite.string);			trap_Cvar_Set("bot_interbreedwrite", "");		}		BotInterbreedBots();	}}
开发者ID:SilverlineDev,项目名称:mint-arena,代码行数:22,


示例17: G_SetCurrentNodeByIndex

/*===============G_SetCurrentNodeByIndexSet the current map in some rotation===============*/static void G_SetCurrentNodeByIndex( int currentNode, int rotation ){	char text[ MAX_MAP_ROTATIONS * 4 ] = { 0 };	int  *p = G_CurrentNodeIndexArray();	int  i;	p[ rotation ] = currentNode;	for ( i = 0; i < mapRotations.numRotations; i++ )	{		Q_strcat( text, sizeof( text ), va( "%d ", p[ i ] ) );	}	trap_Cvar_Set( "g_mapRotationNodes", text );	trap_Cvar_Update( &g_mapRotationNodes );}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:23,


示例18: BotAISetup

/*==============BotAISetup==============*/int BotAISetup( int restart ) {	//rww - new bot cvars..	trap_Cvar_Register(&bot_forcepowers, "bot_forcepowers", "1", CVAR_CHEAT);	trap_Cvar_Register(&bot_forgimmick, "bot_forgimmick", "0", CVAR_CHEAT);	trap_Cvar_Register(&bot_honorableduelacceptance, "bot_honorableduelacceptance", "0", CVAR_CHEAT);	trap_Cvar_Register(&bot_pvstype, "bot_pvstype", "1", CVAR_CHEAT);#ifndef FINAL_BUILD	trap_Cvar_Register(&bot_getinthecarrr, "bot_getinthecarrr", "0", 0);#endif#ifdef _DEBUG	trap_Cvar_Register(&bot_nogoals, "bot_nogoals", "0", CVAR_CHEAT);	trap_Cvar_Register(&bot_debugmessages, "bot_debugmessages", "0", CVAR_CHEAT);#endif	trap_Cvar_Register(&bot_attachments, "bot_attachments", "1", 0);	trap_Cvar_Register(&bot_camp, "bot_camp", "1", 0);	trap_Cvar_Register(&bot_wp_info, "bot_wp_info", "1", 0);	trap_Cvar_Register(&bot_wp_edit, "bot_wp_edit", "0", CVAR_CHEAT);	trap_Cvar_Register(&bot_wp_clearweight, "bot_wp_clearweight", "1", 0);	trap_Cvar_Register(&bot_wp_distconnect, "bot_wp_distconnect", "1", 0);	trap_Cvar_Register(&bot_wp_visconnect, "bot_wp_visconnect", "1", 0);	trap_Cvar_Update(&bot_forcepowers);	//end rww	//if the game is restarted for a tournament	if (restart) {		return qtrue;	}	//initialize the bot states	memset( botstates, 0, sizeof(botstates) );	if (!trap_BotLibSetup())	{		return qfalse; //wts?!	}	return qtrue;}
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:47,


示例19: G_CheckMinimumPlayers

/*===============G_CheckMinimumPlayers===============*/void G_CheckMinimumPlayers( void ) {	int minplayers;	int humanplayers, botplayers;	static int checkminimumplayers_time;	if (g_gametype.integer == GT_SIEGE)	{		return;	}	if (level.intermissiontime) return;	//only check once each 10 seconds	if (checkminimumplayers_time > level.time - 10000) {		return;	}	checkminimumplayers_time = level.time;	trap_Cvar_Update(&bot_minplayers);	minplayers = bot_minplayers.integer;	if (minplayers <= 0) return;	if (minplayers > g_maxclients.integer)	{		minplayers = g_maxclients.integer;	}	humanplayers = G_CountHumanPlayers( -1 );	botplayers = G_CountBotPlayers(	-1 );	if ((humanplayers+botplayers) < minplayers)	{		G_AddRandomBot(-1);	}	else if ((humanplayers+botplayers) > minplayers && botplayers)	{		// try to remove spectators first		if (!G_RemoveRandomBot(TEAM_SPECTATOR))		{			// just remove the bot that is playing			G_RemoveRandomBot(-1);		}	}}
开发者ID:Mattman1153,项目名称:jedi-academy,代码行数:47,


示例20: G_StartMapRotation

/*===============G_StartMapRotationSwitch to a new map rotation===============*/qboolean G_StartMapRotation( char *name, qboolean advance,                             qboolean putOnStack, qboolean reset_index, int depth ){	int i;	int currentRotation = g_currentMapRotation.integer;	for ( i = 0; i < mapRotations.numRotations; i++ )	{		if ( !Q_stricmp( mapRotations.rotations[ i ].name, name ) )		{			if ( putOnStack && currentRotation >= 0 )			{				G_PushRotationStack( currentRotation );			}			trap_Cvar_Set( "g_currentMapRotation", va( "%d", i ) );			trap_Cvar_Update( &g_currentMapRotation );			if ( advance )			{				if ( reset_index )				{					G_SetCurrentNodeByIndex( 0, i );				}				G_AdvanceMapRotation( depth );			}			break;		}	}	if ( i == mapRotations.numRotations )	{		return qfalse;	}	else	{		return qtrue;	}}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:48,


示例21: trap_Cvar_Update

voidCvar::trapUpdate(){    trap_Cvar_Update( &_data );    if (!_callback)        return;    if (_callbackModificationCount == modificationCount)        return;    // To prevent an cicular dependency we temporarily remove callback.    void(*tmp)(Cvar&) = _callback;    _callback = 0;    tmp( *this );    _callbackModificationCount = modificationCount;    // Restore callback.    _callback = tmp;}
开发者ID:Dragonji,项目名称:jaymod,代码行数:21,


示例22: CG_UpdateCvars

/*=================CG_UpdateCvars=================*/void CG_UpdateCvars( void ) {	int			i;	cvarTable_t	*cv;	for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {		trap_Cvar_Update( cv->vmCvar );	}	// check for modications here	// If team overlay is on, ask for updates from the server.  If its off,	// let the server know so we don't receive it	if ( drawTeamOverlayModificationCount != cg_drawTeamOverlay.modificationCount ) {		drawTeamOverlayModificationCount = cg_drawTeamOverlay.modificationCount;		if ( cg_drawTeamOverlay.integer > 0 ) {			trap_Cvar_Set( "teamoverlay", "1" );		} else {			trap_Cvar_Set( "teamoverlay", "0" );		}		// FIXME E3 HACK		trap_Cvar_Set( "teamoverlay", "1" );	}	// if force model changed	if ( forceModelModificationCount != cg_forceModel.modificationCount ) {		forceModelModificationCount = cg_forceModel.modificationCount;		CG_ForceModelChange();	}	// if cg_lodScale changed	if ( cgLodScaleValue != cg_lodScale.integer ) {		//copy the value from cg_lodScale to r_lodscale		trap_Cvar_Set("r_lodscale", cg_lodScale.string);		cgLodScaleValue = cg_lodScale.integer;	}}
开发者ID:Clever-Boy,项目名称:entityplus,代码行数:43,


示例23: BotAIStartFrame

/*==================BotAIStartFrame==================*/int BotAIStartFrame(int time) {	int i;	gentity_t	*ent;	bot_entitystate_t state;	int elapsed_time, thinktime;	static int local_time;	static int botlib_residual;	static int lastbotthink_time;	G_CheckBotSpawn();	trap_Cvar_Update(&bot_rocketjump);	trap_Cvar_Update(&bot_grapple);	trap_Cvar_Update(&bot_fastchat);	trap_Cvar_Update(&bot_nochat);	trap_Cvar_Update(&bot_testrchat);	trap_Cvar_Update(&bot_thinktime);	trap_Cvar_Update(&bot_memorydump);	trap_Cvar_Update(&bot_saveroutingcache);	trap_Cvar_Update(&bot_pause);	trap_Cvar_Update(&bot_report);	trap_Cvar_Update(&bot_droppedweight);	trap_Cvar_Update(&bot_offhandgrapple);	trap_Cvar_Update(&bot_shownodechanges);	trap_Cvar_Update(&bot_showteamgoals);	trap_Cvar_Update(&bot_reloadcharacters);	BotUpdateInfoConfigStrings();	if (bot_pause.integer) {		// execute bot user commands every frame		for( i = 0; i < level.maxplayers; i++ ) {			if( !botstates[i] || !botstates[i]->inuse ) {				continue;			}			if( g_entities[i].player->pers.connected != CON_CONNECTED ) {				continue;			}			botstates[i]->lastucmd.forwardmove = 0;			botstates[i]->lastucmd.rightmove = 0;			botstates[i]->lastucmd.upmove = 0;			botstates[i]->lastucmd.buttons = 0;			botstates[i]->lastucmd.serverTime = time;			trap_BotUserCommand(botstates[i]->playernum, &botstates[i]->lastucmd);		}		return qtrue;	}	if (bot_memorydump.integer) {		trap_BotLibVarSet("memorydump", "1");		trap_Cvar_SetValue("bot_memorydump", 0);	}	if (bot_saveroutingcache.integer) {		trap_BotLibVarSet("saveroutingcache", "1");		trap_Cvar_SetValue("bot_saveroutingcache", 0);	}	//check if bot interbreeding is activated	BotInterbreeding();	//cap the bot think time	if (bot_thinktime.integer > 200) {		trap_Cvar_SetValue("bot_thinktime", 200);	}	//if the bot think time changed we should reschedule the bots	if (bot_thinktime.integer != lastbotthink_time) {		lastbotthink_time = bot_thinktime.integer;		BotScheduleBotThink();	}	elapsed_time = time - local_time;	local_time = time;	botlib_residual += elapsed_time;	if (elapsed_time > bot_thinktime.integer) thinktime = elapsed_time;	else thinktime = bot_thinktime.integer;	// update the bot library	if ( botlib_residual >= thinktime ) {		botlib_residual -= thinktime;		trap_BotLibStartFrame((float) time / 1000);		if (!trap_AAS_Initialized()) return qfalse;		//update entities in the botlib		for (i = 0; i < MAX_GENTITIES; i++) {			ent = &g_entities[i];			ent->botvalid = qfalse;			if (!ent->inuse) {				trap_BotLibUpdateEntity(i, NULL);				continue;			}			if (!ent->r.linked) {				trap_BotLibUpdateEntity(i, NULL);				continue;//.........这里部分代码省略.........
开发者ID:SilverlineDev,项目名称:mint-arena,代码行数:101,


示例24: BotAISetupPlayer

/*==============BotAISetupPlayer==============*/int BotAISetupPlayer(int playernum, struct bot_settings_s *settings, qboolean restart) {	char filename[MAX_PATH], name[MAX_PATH], gender[MAX_PATH];	bot_state_t *bs;	int errnum;	if (!botstates[playernum]) botstates[playernum] = trap_Alloc(sizeof(bot_state_t), NULL);	bs = botstates[playernum];	if (!bs) {		return qfalse;	}	if (bs && bs->inuse) {		BotAI_Print(PRT_FATAL, "BotAISetupPlayer: player %d already setup/n", playernum);		return qfalse;	}	if (!trap_AAS_Initialized()) {		BotAI_Print(PRT_FATAL, "AAS not initialized/n");		return qfalse;	}	//load the bot character	bs->character = BotLoadCharacter(settings->characterfile, settings->skill);	if (!bs->character) {		BotAI_Print(PRT_FATAL, "couldn't load skill %f from %s/n", settings->skill, settings->characterfile);		return qfalse;	}	//copy the settings	memcpy(&bs->settings, settings, sizeof(bot_settings_t));	//allocate a goal state	bs->gs = BotAllocGoalState(playernum);	//load the item weights	Characteristic_String(bs->character, CHARACTERISTIC_ITEMWEIGHTS, filename, MAX_PATH);	errnum = BotLoadItemWeights(bs->gs, filename);	if (errnum != BLERR_NOERROR) {		BotFreeGoalState(bs->gs);		BotAI_Print(PRT_FATAL, "BotLoadItemWeights failed/n");		return qfalse;	}	//allocate a weapon state	bs->ws = BotAllocWeaponState(playernum);	//load the weapon weights	Characteristic_String(bs->character, CHARACTERISTIC_WEAPONWEIGHTS, filename, MAX_PATH);	errnum = BotLoadWeaponWeights(bs->ws, filename);	if (errnum != BLERR_NOERROR) {		BotFreeGoalState(bs->gs);		BotFreeWeaponState(bs->ws);		BotAI_Print(PRT_FATAL, "BotLoadWeaponWeights failed/n");		return qfalse;	}	//allocate a chat state	bs->cs = BotAllocChatState();	//load the chat file	Characteristic_String(bs->character, CHARACTERISTIC_CHAT_FILE, filename, MAX_PATH);	Characteristic_String(bs->character, CHARACTERISTIC_CHAT_NAME, name, MAX_PATH);	errnum = BotLoadChatFile(bs->cs, filename, name);	if (errnum != BLERR_NOERROR) {		BotFreeChatState(bs->cs);		BotFreeGoalState(bs->gs);		BotFreeWeaponState(bs->ws);		BotAI_Print(PRT_FATAL, "BotLoadChatFile failed/n");		return qfalse;	}	//get the gender characteristic	Characteristic_String(bs->character, CHARACTERISTIC_GENDER, gender, MAX_PATH);	//set the chat gender	if (*gender == 'f' || *gender == 'F') BotSetChatGender(bs->cs, CHAT_GENDERFEMALE);	else if (*gender == 'm' || *gender == 'M') BotSetChatGender(bs->cs, CHAT_GENDERMALE);	else BotSetChatGender(bs->cs, CHAT_GENDERLESS);	bs->inuse = qtrue;	bs->playernum = playernum;	bs->entitynum = playernum;	bs->setupcount = 4;	bs->entergame_time = FloatTime();	bs->ms = BotAllocMoveState(playernum);	bs->walker = Characteristic_BFloat(bs->character, CHARACTERISTIC_WALKER, 0, 1);	bs->revenge_enemy = -1;	numbots++;	trap_Cvar_Update( &bot_testichat );	if (bot_testichat.integer) {		BotChatTest(bs);	}	//NOTE: reschedule the bot thinking	BotScheduleBotThink();	//if interbreeding start with a mutation	if (bot_interbreed) {		BotMutateGoalFuzzyLogic(bs->gs, 1);	}	// if we kept the bot state	if (restart) {		BotReadSessionData(bs);	}//.........这里部分代码省略.........
开发者ID:SilverlineDev,项目名称:mint-arena,代码行数:101,


示例25: G_CheckMinimumPlayers

/*===============G_CheckMinimumPlayers===============*/void G_CheckMinimumPlayers( void ) {	int minplayers;	int humanplayers, botplayers;	static int checkminimumplayers_time;	if (level.intermissiontime) return;	//only check once each 10 seconds	//if (checkminimumplayers_time > level.time - 10000) {	if (checkminimumplayers_time > level.time - (1000 + (bot_minplayersTime.integer * 100))) { // leilei - faster time		return;	}	checkminimumplayers_time = level.time;	trap_Cvar_Update(&bot_minplayers);	minplayers = bot_minplayers.integer;	if (minplayers <= 0) return;        if (!trap_AAS_Initialized())        {            minplayers = 0;            checkminimumplayers_time = level.time+600*1000;            return; //If no AAS then don't even try        }	if (g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {		if (minplayers >= g_maxclients.integer / 2) {			minplayers = (g_maxclients.integer / 2) -1;		}		humanplayers = G_CountHumanPlayers( TEAM_RED );		botplayers = G_CountBotPlayers(	TEAM_RED );		//		if (humanplayers + botplayers < minplayers) {			G_AddRandomBot( TEAM_RED );		} else if (humanplayers + botplayers > minplayers && botplayers) {			G_RemoveRandomBot( TEAM_RED );		}		//		humanplayers = G_CountHumanPlayers( TEAM_BLUE );		botplayers = G_CountBotPlayers( TEAM_BLUE );		//		if (humanplayers + botplayers < minplayers) {			G_AddRandomBot( TEAM_BLUE );		} else if (humanplayers + botplayers > minplayers && botplayers) {			G_RemoveRandomBot( TEAM_BLUE );		}	}	else if (g_gametype.integer == GT_TOURNAMENT ) {		if (minplayers >= g_maxclients.integer) {			minplayers = g_maxclients.integer-1;		}		humanplayers = G_CountHumanPlayers( -1 );		botplayers = G_CountBotPlayers( -1 );		//		if (humanplayers + botplayers < minplayers) {			G_AddRandomBot( TEAM_FREE );		} else if (humanplayers + botplayers > minplayers && botplayers) {			// try to remove spectators first			if (!G_RemoveRandomBot( TEAM_SPECTATOR )) {				// just remove the bot that is playing				G_RemoveRandomBot( -1 );			}		}	}	else if (g_gametype.integer == GT_FFA || g_gametype.integer == GT_LMS) {		if (minplayers >= g_maxclients.integer) {			minplayers = g_maxclients.integer-1;		}		humanplayers = G_CountHumanPlayers( TEAM_FREE );		botplayers = G_CountBotPlayers( TEAM_FREE );		//		if (humanplayers + botplayers < minplayers) {			G_AddRandomBot( TEAM_FREE );		} else if (humanplayers + botplayers > minplayers && botplayers) {			G_RemoveRandomBot( TEAM_FREE );		}	}}
开发者ID:OpenArena,项目名称:leixperimental,代码行数:84,


示例26: BotAIStartFrame

/*==================BotAIStartFrame==================*/int BotAIStartFrame( int time ) {	int i;	gentity_t   *ent;	bot_entitystate_t state;	//entityState_t entitystate;	//vec3_t mins = {-15, -15, -24}, maxs = {15, 15, 32};	int elapsed_time, thinktime;	static int local_time;	static int botlib_residual;	static int lastbotthink_time;	if ( g_gametype.integer != GT_SINGLE_PLAYER ) {		G_CheckBotSpawn();	}	trap_Cvar_Update( &bot_rocketjump );	trap_Cvar_Update( &bot_grapple );	trap_Cvar_Update( &bot_fastchat );	trap_Cvar_Update( &bot_nochat );	trap_Cvar_Update( &bot_testrchat );	trap_Cvar_Update( &bot_thinktime );	// Ridah, set the default AAS world	trap_AAS_SetCurrentWorld( 0 );	trap_Cvar_Update( &memorydump );	if ( memorydump.integer ) {		trap_BotLibVarSet( "memorydump", "1" );		trap_Cvar_Set( "memorydump", "0" );	}	//if the bot think time changed we should reschedule the bots	if ( bot_thinktime.integer != lastbotthink_time ) {		lastbotthink_time = bot_thinktime.integer;		BotScheduleBotThink();	}	elapsed_time = time - local_time;	local_time = time;	botlib_residual += elapsed_time;	if ( elapsed_time > bot_thinktime.integer ) {		thinktime = elapsed_time;	} else { thinktime = bot_thinktime.integer;}	// update the bot library	if ( botlib_residual >= thinktime ) {		botlib_residual -= thinktime;		trap_BotLibStartFrame( (float) time / 1000 );		// Ridah, only check the default world		trap_AAS_SetCurrentWorld( 0 );		if ( !trap_AAS_Initialized() ) {			return BLERR_NOERROR;		}		//update entities in the botlib		for ( i = 0; i < MAX_GENTITIES; i++ ) {			// Ridah, in single player, we only need client entity information			if ( g_gametype.integer == GT_SINGLE_PLAYER && i > level.maxclients ) {				break;			}			ent = &g_entities[i];			if ( !ent->inuse ) {				continue;			}			if ( !ent->r.linked ) {				continue;			}			if ( ent->r.svFlags & SVF_NOCLIENT ) {				continue;			}			//			memset( &state, 0, sizeof( bot_entitystate_t ) );			//			VectorCopy( ent->r.currentOrigin, state.origin );			VectorCopy( ent->r.currentAngles, state.angles );			VectorCopy( ent->s.origin2, state.old_origin );			VectorCopy( ent->r.mins, state.mins );			VectorCopy( ent->r.maxs, state.maxs );			state.type = ent->s.eType;			state.flags = ent->s.eFlags;			if ( ent->r.bmodel ) {				state.solid = SOLID_BSP;			} else { state.solid = SOLID_BBOX;}			state.groundent = ent->s.groundEntityNum;			state.modelindex = ent->s.modelindex;			state.modelindex2 = ent->s.modelindex2;			state.frame = ent->s.frame;			//state.event = ent->s.event;			//state.eventParm = ent->s.eventParm;//.........这里部分代码省略.........
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,


示例27: AICast_StartServerFrame

/*============AICast_StartServerFrame  Do movements, sighting, etc============*/void AICast_StartServerFrame( int time ) {	int i, elapsed, count, clCount;	cast_state_t    *cs;	int castcount;	static int lasttime;	static vmCvar_t aicast_disable;	gentity_t *ent;	cast_state_t *pcs;//	int		oldLegsTimer;	if ( trap_Cvar_VariableIntegerValue( "savegame_loading" ) ) {		return;	}	if ( g_gametype.integer != GT_SINGLE_PLAYER ) {		return;	}	if ( saveGamePending ) {		return;	}	// if waiting at intermission, don't think	if ( strlen( g_missionStats.string ) > 1 ) {		return;	}	if ( !aicast_disable.handle ) {		trap_Cvar_Register( &aicast_disable, "aicast_disable", "0", CVAR_CHEAT );	} else	{		trap_Cvar_Update( &aicast_disable );		if ( aicast_disable.integer ) {			return;		}	}	trap_Cvar_Update( &aicast_debug );	// no need to think during the intermission	if ( level.intermissiontime ) {		return;	}	//	// make sure the AAS gets updated	trap_BotLibStartFrame( (float) time / 1000 );	//	//	elapsed = time - lasttime;	if ( elapsed == 0 ) {		return;         // no time has elapsed	}	pcs = AICast_GetCastState( 0 );//G_Printf( "AI startserverframe: %i/n", time );	if ( elapsed < 0 ) {		elapsed = 0;		lasttime = time;	}	// don't let the framerate drop below 10	if ( elapsed > 100 ) {		elapsed = 100;	}	//	// process player's current script if it exists	AICast_ScriptRun( AICast_GetCastState( 0 ), qfalse );	//	AICast_SightUpdate( (int)( (float)SIGHT_PER_SEC * ( (float)elapsed / 1000 ) ) );	//	count = 0;	castcount = 0;	clCount = 0;	ent = g_entities;	//	//update the AI characters	// TTimo gcc: left-hand operand of comma expression has no effect	// initial line: for (i = 0; i < aicast_maxclients, clCount < level.numPlayingClients; i++, ent++)	for ( i = 0; ( i < aicast_maxclients ) && ( clCount < level.numPlayingClients ) ; i++, ent++ )	{		if ( ent->client ) {			clCount++;		}		//		cs = AICast_GetCastState( i );		// is this a cast AI?		if ( cs->bs ) {			if ( ent->aiInactive == qfalse && ent->inuse ) {				//				elapsed = level.time - cs->lastMoveThink;				//				// optimization, if they're not in the player's PVS, and they aren't trying to move, then don't bother thinking//.........这里部分代码省略.........
开发者ID:bibendovsky,项目名称:rtcw,代码行数:101,


示例28: AICast_StartFrame

void AICast_StartFrame( int time ) {	int i, elapsed, count, clCount;	cast_state_t    *cs;	int castcount;	static int lasttime;	static vmCvar_t aicast_disable;	gentity_t *ent;	if ( trap_Cvar_VariableIntegerValue( "savegame_loading" ) ) {		return;	}	if ( saveGamePending ) {		return;	}	// if waiting at intermission, don't think	if ( strlen( g_missionStats.string ) > 1 ) {		return;	}	if ( !aicast_disable.handle ) {		trap_Cvar_Register( &aicast_disable, "aicast_disable", "0", CVAR_CHEAT );	} else	{		trap_Cvar_Update( &aicast_disable );		if ( aicast_disable.integer ) {			return;		}	}	trap_Cvar_Update( &aicast_debug );	trap_Cvar_Update( &aicast_debugname );	trap_Cvar_Update( &aicast_scripts );	// no need to think during the intermission	if ( level.intermissiontime ) {		return;	}	//	// make sure the AAS gets updated	trap_BotLibStartFrame( (float) time / 1000 );	//	//	elapsed = time - lasttime;	if ( elapsed == 0 ) {		return;         // no time has elapsed	}//G_Printf( "AI startframe: %i/n", time );	if ( elapsed < 0 ) {		elapsed = 0;		lasttime = time;	}	// don't let the framerate drop below 10	if ( elapsed > 100 ) {		elapsed = 100;	}	//AICast_SightUpdate( (int)((float)SIGHT_PER_SEC * ((float)elapsed / 1000)) );	//	count = 0;	castcount = 0;	clCount = 0;	ent = g_entities;	//	//update the AI characters	// TTimo gcc: left-hand operand of comma expression has no effect	// initial line was: for (i = 0; i < aicast_maxclients, clCount < level.numPlayingClients; i++, ent++)	for ( i = 0; ( i < aicast_maxclients ) && ( clCount < level.numPlayingClients ) ; i++, ent++ )	{		if ( ent->client ) {			clCount++;		}		//		cs = AICast_GetCastState( i );		// is this a cast AI?		if ( cs->bs ) {			if ( ent->inuse ) {				if ( ent->aiInactive == qfalse ) {					//					elapsed = time - cs->lastThink;					//					// if they're moving/firing think every frame					if ( ( elapsed >= 50 ) &&						 (   (   (   ( !VectorCompare( ent->client->ps.velocity, vec3_origin ) ) ||									 ( ent->client->buttons ) ||									 ( elapsed >= aicast_thinktime ) ) &&								 ( count <= aicast_maxthink ) ) ||							 ( elapsed >= aicast_thinktime * 2 ) ) ) {						// make it think now						AICast_Think( i, (float)elapsed / 1000 );						cs->lastThink = time;						//						count++;					}					// check for any debug info updates					AICast_DebugFrame( cs );				} else if ( cs->aiFlags & AIFL_WAITINGTOSPAWN ) {					// check f the space is clear yet//.........这里部分代码省略.........
开发者ID:bibendovsky,项目名称:rtcw,代码行数:101,



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


C++ trap_Cvar_VariableIntegerValue函数代码示例
C++ trap_Cvar_SetValue函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。