/* ============== 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; }
bool CDeathMatchMissionMgr::EndGame( ) { // Call base. if( !CServerMissionMgr::EndGame( )) return false; // Can't have custom level or no campaign in deathmatch. if( m_bCustomLevel || m_Campaign.size( ) == 0 ) { ASSERT( !"CDeathMatchMissionMgr::EndGame: Can't have custom level or no campaign in deathmatch." ); return false; } // Start from the beginning. m_nCurrentLevel = 0; m_nCurCampaignIndex = 0; m_nCurrentMission = m_Campaign[m_nCurCampaignIndex]; m_bNewMission = true; // Get the worldname from the mission/level indices. char const* pszFilename = GetLevelFromMission( m_nCurrentMission, m_nCurrentLevel ); if( !pszFilename ) return false; // Exit to the level. if( !ExitLevel( pszFilename, false )) return false; return true; }
/* * BotInterbreeding */ void BotInterbreeding(void) { int i; trap_cvarupdate(&bot_interbreedchar); if(!strlen(bot_interbreedchar.string)) return; /* make sure we are in tournament mode */ if(gametype != GT_TOURNAMENT){ trap_cvarsetstr("g_gametype", va("%d", GT_TOURNAMENT)); ExitLevel(); return; } /* shutdown all the bots */ for(i = 0; i < MAX_CLIENTS; i++) if(botstates[i] && botstates[i]->inuse) BotAIShutdownClient(botstates[i]->client, qfalse); /* make sure all item weight configs are reloaded and Not shared */ trap_BotLibVarSet("bot_reloadcharacters", "1"); /* add a number of bots using the desired bot character */ for(i = 0; i < bot_interbreedbots.integer; i++) trap_SendConsoleCommand(EXEC_INSERT, va("addbot %s 4 free %i %s%d\n", bot_interbreedchar.string, i * 50, bot_interbreedchar.string, i)); trap_cvarsetstr("bot_interbreedchar", ""); bot_interbreed = qtrue; }
/* ============== BotInterbreeding ============== */ void BotInterbreeding(void) { int i; if (!strlen(bot_interbreedchar->string)) return; //make sure we are in tournament mode if (gametype != GT_TOURNAMENT) { Cvar_Set("g_gametype", va("%d", GT_TOURNAMENT)); ExitLevel(); return; } //shutdown all the bots for (i = 0; i < MAX_CLIENTS; i++) { if (botstates[i] && botstates[i]->inuse) { BotAIShutdownClient(botstates[i]->client, qfalse); } } //make sure all item weight configs are reloaded and Not shared botlib_export->BotLibVarSet("bot_reloadcharacters", "1"); //add a number of bots using the desired bot character for (i = 0; i < bot_interbreedbots->integer; i++) { Cbuf_ExecuteText(EXEC_APPEND, va("addbot %s 4 free %i %s%d\n", bot_interbreedchar->string, i * 50, bot_interbreedchar->string, i) ); } // Cvar_Set("bot_interbreedchar", ""); bot_interbreed = qtrue; }
/* ================ G_RunFrame Advances the world by 0.1 seconds ================ */ void G_RunFrame (void) { int i; edict_t *ent; level.framenum++; level.time = level.framenum*FRAMETIME; // choose a client for monsters to target this frame AI_SetSightClient (); // exit intermissions if (level.exitintermission) { ExitLevel (); return; } // // treat each object in turn // even the world gets a chance to think // ent = &g_edicts[0]; for (i=0 ; i<globals.num_edicts ; i++, ent++) { if (!ent->inuse) continue; level.current_entity = ent; VectorCopy (ent->s.origin, ent->s.old_origin); // if the ground entity moved, make sure we are still on it if ((ent->groundentity) && (ent->groundentity->linkcount != ent->groundentity_linkcount)) { ent->groundentity = NULL; if ( !(ent->flags & (FL_SWIM|FL_FLY)) && (ent->svflags & SVF_MONSTER) ) { M_CheckGround (ent); } } if (i > 0 && i <= maxclients->value) { ClientBeginServerFrame (ent); continue; } G_RunEntity (ent); } // see if it is time to end a deathmatch CheckDMRules (); // build the playerstate_t structures for all players ClientEndServerFrames (); }
bool CServerMissionMgr::NextMission( ) { TRACE( "CServerMissionMgr::NextMission\n" ); // Check if we're already exiting a level. if( m_bExitingLevel ) return true; // If this was a custom level, then the game is over. if( m_bCustomLevel ) { // Let the endgame code figure out what we should do. if( !EndGame( )) return false; return true; } // Get the mission. MISSION* pMission = g_pMissionButeMgr->GetMission(m_nCurrentMission); if( !pMission ) { ASSERT( !"CServerMissionMgr::NextMission: Invalid mission." ); return false; } // Start level index over and advance the mission index. m_nCurrentLevel = 0; m_nCurrentRound = 0; m_nCurCampaignIndex++; // See if we reached the end of our campaign. if( m_nCurCampaignIndex >= ( int )m_Campaign.size( )) { // Let the endgame code figure out what we should do. if( !EndGame( )) return false; return true; } // Get the missionid from the campaign. m_nCurrentMission = m_Campaign[m_nCurCampaignIndex]; // Flag that this is a new mission so we can tell everyone else. m_bNewMission = true; // Get the worldname from the mission/level indices. char const* pszFilename = GetLevelFromMission( m_nCurrentMission, m_nCurrentLevel ); if( !pszFilename ) return false; // Do the exit level. if( !ExitLevel( pszFilename, false )) return false; return true; }
bool CServerMissionMgr::ExitLevelToLevel( char const* pszNewLevel ) { TRACE( "CServerMissionMgr::ExitLevelToLevel\n" ); // Check if we're already exiting a level. if( m_bExitingLevel ) return true; // Verify inputs. if( !pszNewLevel ) { ASSERT( !"CServerMissionMgr::ExitLevelToLevel: Invalid inputs." ); return false; } // Default to this not being a mission change. m_bNewMission = false; // Check if the new level is a new mission. int nCurMission = m_nCurrentMission; if( !SetMissionBasedOnLevel( pszNewLevel )) return false; // If we switch to a custom level, then consider it a new mission. if( m_bCustomLevel ) { m_bNewMission = true; m_nCurCampaignIndex = -1; } // If it's not a custom world, check if our mission changed. else { m_bNewMission = ( nCurMission != m_nCurrentMission ); // If we had a mission switch, advance our campaign index. if( m_bNewMission ) { // See if we can find the campaign index from our previous position. m_nCurCampaignIndex = FindNextCampaignIndex( m_nCurCampaignIndex, m_nCurrentMission ); } } // Do the exit level. if( !ExitLevel( pszNewLevel, false )) return false; return true; }
byte PlayALevel(byte map) { int lastTime = 1; byte exitcode = 0; if (!InitLevel(map)) { mapToGoTo = 255; return LEVEL_ABORT; } exitcode = LEVEL_PLAYING; gameMode = GAMEMODE_PLAY; CDMessingTime = 0; garbageTime = 0; UpdateGuys(curMap, &curWorld); // this will force the camera into the right position // it also makes everybody animate by one frame, but no one will // ever notice while (exitcode == LEVEL_PLAYING) { lastTime += TimeLength() - CDMessingTime; StartClock(); if (gameMode == GAMEMODE_PLAY) HandleKeyPresses(); exitcode = LunaticRun(&lastTime); LunaticDraw(); if (lastKey == 27 && gameMode == GAMEMODE_PLAY) { InitPauseMenu(); gameMode = GAMEMODE_MENU; } if (!gamemgl->Process()) { exitcode = LEVEL_ABORT; mapToGoTo = 255; } EndClock(); } ExitLevel(); return exitcode; }
bool CServerMissionMgr::NextRound( ) { TRACE( "CServerMissionMgr::NextRound\n" ); // Check if we're already exiting a level. if( m_bExitingLevel ) return true; // Get the mission... MISSION* pMission = g_pMissionButeMgr->GetMission(m_nCurrentMission); if( !pMission ) { ASSERT( !"CServerMissionMgr::NextMission: Invalid mission." ); return false; } // Advance to the next round... ++m_nCurrentRound; // Default to not a new mission. m_bNewMission = false; // See if we finished the rounds for this level... if( m_nCurrentRound >= m_ServerSettings.m_nRounds ) { // Just go to the next mission... if( !NextMission() ) return false; return true; } if( !ExitLevel( m_sCurrentWorldName, false )) return false; return true; }
bool CServerMissionMgr::ExitLevelTransition( int nNewLevel ) { TRACE( "CServerMissionMgr::ExitLevelTransition\n" ); // Check if we're already exiting a level. if( m_bExitingLevel ) return true; // Default to this not being a mission change. m_bNewMission = false; // Get the next level name. char const* pszFilename = GetLevelFromMission( m_nCurrentMission, nNewLevel ); if( !pszFilename ) return false; // Do the exit level. if( !ExitLevel( pszFilename, true )) return false; return true; }
void VLevelInfo::SecretExitLevel(int Position) { guard(VLevelInfo::SecretExitLevel); if (SecretMap == NAME_None) { // No secret map, use normal exit ExitLevel(Position); return; } LeavePosition = Position; completed = true; NextMap = SecretMap; // go to secret level for (int i = 0; i < MAXPLAYERS; i++) { if (Game->Players[i]) { Game->Players[i]->PlayerFlags |= VBasePlayer::PF_DidSecret; } } unguard; }
/* ================= CheckIntermissionExit The level will stay at the intermission for a minimum of 5 seconds If all players wish to continue, the level will then exit. If one or more players have not acknowledged the continue, the game will wait 10 seconds before going on. ================= */ void CheckIntermissionExit( void ) { int ready, notReady, playerCount; int i; gclient_t *cl; int readyMask; if ( g_gametype.integer == GT_SINGLE_PLAYER ) { return; } // see which players are ready ready = 0; notReady = 0; readyMask = 0; playerCount = 0; for (i=0 ; i< g_maxclients.integer ; i++) { cl = level.clients + i; if ( cl->pers.connected != CON_CONNECTED ) { continue; } if ( g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT ) { continue; } playerCount++; if ( cl->readyToExit ) { ready++; if ( i < 16 ) { readyMask |= 1 << i; } } else { notReady++; } } // copy the readyMask to each player's stats so // it can be displayed on the scoreboard for (i=0 ; i< g_maxclients.integer ; i++) { cl = level.clients + i; if ( cl->pers.connected != CON_CONNECTED ) { continue; } cl->ps.stats[STAT_CLIENTS_READY] = readyMask; } // never exit in less than five seconds if ( level.time < level.intermissiontime + 5000 ) { return; } // only test ready status when there are real players present if ( playerCount > 0 ) { // if nobody wants to go, clear timer if ( !ready ) { level.readyToExit = qfalse; return; } // if everyone wants to go, go now if ( !notReady ) { ExitLevel(); return; } } // the first person to ready starts the ten second timeout if ( !level.readyToExit ) { level.readyToExit = qtrue; level.exitTime = level.time; } // if we have waited ten seconds since at least one player // wanted to exit, go ahead if ( level.time < level.exitTime + 10000 ) { return; } ExitLevel(); }
void G_RunFrame(void) { // Knightmare- dm pause if (paused && deathmatch->value) return; if (level.freeze) { level.freezeframes++; if (level.freezeframes >= sk_stasis_time->value * 10) level.freeze = false; } else { level.framenum++; } level.time = level.framenum*FRAMETIME; // choose a client for monsters to target this frame AI_SetSightClient(); // exit intermissions if (level.exitintermission) { ExitLevel(); return; } if (use_techs->value || (ctf->value && !((int)dmflags->value & DF_CTF_NO_TECH)) ) CheckNumTechs(); // // treat each object in turn // even the world gets a chance to think // edict_t *ent = &g_edicts[0]; for (int i = 0; i < globals.num_edicts; i++, ent++) { if (!ent->inuse) continue; level.current_entity = ent; VectorCopy(ent->s.origin, ent->s.old_origin); // if the ground entity moved, make sure we are still on it if (ent->groundentity && ent->groundentity->linkcount != ent->groundentity_linkcount) { ent->groundentity = NULL; if (!(ent->flags & (FL_SWIM | FL_FLY)) && (ent->svflags & SVF_MONSTER)) M_CheckGround(ent); } if (i > 0 && i <= maxclients->value) { ClientBeginServerFrame(ent); // ACEBOT_ADD if (!ent->is_bot) // Bots need G_RunEntity called continue; // ACEBOT_END } G_RunEntity(ent); } // see if it is time to end a deathmatch CheckDMRules(); // see if needpass needs updated CheckNeedPass(); // build the playerstate_t structures for all players ClientEndServerFrames(); }
/* ================= CheckIntermissionExit The level will stay at the intermission for a minimum of 5 seconds If all players wish to continue, the level will then exit. If one or more players have not acknowledged the continue, the game will wait 10 seconds before going on. ================= */ void CheckIntermissionExit() { if ( g_gametype.integer == GT_SINGLE_PLAYER || g_gametype.integer == GT_MISSION_EDITOR ) return; // see which players are ready int ready = 0; int notReady = 0; int readyMask = 0; int i; for( i=1 ; i<= g_maxclients.integer ; i++) { GameClient *cl = theLevel.getClient(i); if ( !cl || cl->pers_.connected_ != GameClient::ClientPersistant::CON_CONNECTED ) continue; if ( theLevel.getEntity(cl->ps_.clientNum)->r.svFlags & SVF_BOT ) continue; if ( cl->readyToExit_ ) { ready++; if ( i < 16 ) readyMask |= 1 << i; } else { notReady++; } } // copy the readyMask to each player's stats so // it can be displayed on the scoreboard for( i=1 ; i<= g_maxclients.integer ; i++ ) { GameClient* cl = theLevel.getClient(i); if( !cl || cl->pers_.connected_ != GameClient::ClientPersistant::CON_CONNECTED ) continue; cl->ps_.stats[STAT_CLIENTS_READY] = readyMask; } // never exit in less than five seconds if ( theLevel.time_ < theLevel.intermissiontime_ + 5000 ) return; // if nobody wants to go, clear timer if ( !ready ) { theLevel.readyToExit_ = false; return; } // if everyone wants to go, go now if ( !notReady ) { ExitLevel(); return; } // the first person to ready starts the ten second timeout if ( !theLevel.readyToExit_ ) { theLevel.readyToExit_ = true; theLevel.exitTime_ = theLevel.time_; } // if we have waited ten seconds since at least one player // wanted to exit, go ahead if ( theLevel.time_ < theLevel.exitTime_ + 10000 ) return; ExitLevel(); }
/* * ================ G_RunFrame * * Advances the world by 0.1 seconds ================ */ void G_RunFrame(void) { int i; edict_t *ent; #ifdef GAME_MOD Blinky_BeginRunFrame(); #endif level.framenum++; level.time = level.framenum * FRAMETIME; /* choose a client for monsters to target this frame */ AI_SetSightClient(); /* exit intermissions */ if (level.exitintermission) { ExitLevel(); return; } // /* treat each object in turn */ /* even the world gets a chance to think */ // ent = &g_edicts[0]; for (i = 0; i < globals.num_edicts; i++, ent++) { if (!ent->inuse) continue; level.current_entity = ent; VectorCopy(ent->s.origin, ent->s.old_origin); /* if the ground entity moved, make sure we are still on it */ if ((ent->groundentity) && (ent->groundentity->linkcount != ent->groundentity_linkcount)) { ent->groundentity = NULL; if (!(ent->flags & (FL_SWIM | FL_FLY)) && (ent->svflags & SVF_MONSTER)) { M_CheckGround(ent); } } if (i > 0 && i <= maxclients->value) { ClientBeginServerFrame(ent); #ifdef WITH_ACEBOT /* continue; */ #else continue; #endif } G_RunEntity(ent); } /* see if it is time to end a deathmatch */ CheckDMRules(); /* see if needpass needs updated */ CheckNeedPass(); /* build the playerstate_t structures for all players */ ClientEndServerFrames(); }