void CWorld :: Precache( void ) { g_pLastSpawn = NULL; CVAR_SET_STRING("sv_gravity", "800"); // 67ft/sec CVAR_SET_STRING("sv_stepsize", "18"); CVAR_SET_STRING("room_type", "0"); // clear DSP // Create all the arenas for (int i = 0; i < MAX_ARENAS; i++) { g_pArenaList[i] = GetClassPtr( ( CDiscArena *)NULL ); g_pArenaList[i]->Spawn(); } // Set up game rules if (g_pGameRules) { delete g_pGameRules; } g_pGameRules = InstallGameRules( ); //!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here ///!!!LATER - do we want a sound ent in deathmatch? (sjb) //pSoundEnt = CBaseEntity::Create( "soundent", g_vecZero, g_vecZero, edict() ); pSoundEnt = GetClassPtr( ( CSoundEnt *)NULL ); pSoundEnt->Spawn(); if ( !pSoundEnt ) { ALERT ( at_console, "**COULD NOT CREATE SOUNDENT**\n" ); } InitBodyQue(); // init sentence group playback stuff from sentences.txt. // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); // init texture type array from materials.txt TEXTURETYPE_Init(); // the area based ambient sounds MUST be the first precache_sounds // player precaches W_Precache (); // get weapon precaches ClientPrecache(); // sounds used from C physics code PRECACHE_SOUND("common/null.wav"); // clears sound channels PRECACHE_SOUND( "items/suitchargeok1.wav" );//!!! temporary sound for respawning weapons. PRECACHE_SOUND( "items/gunpickup2.wav" );// player picks up a gun. PRECACHE_SOUND( "common/bodydrop3.wav" );// dead bodies hitting the ground (animation events) PRECACHE_SOUND( "common/bodydrop4.wav" ); PRECACHE_SOUND( "r_tele1.wav" ); // respawn sound PRECACHE_SOUND( "scream1.wav" ); // falling scream sound PRECACHE_SOUND( "scream2.wav" ); // falling scream sound PRECACHE_SOUND( "scream3.wav" ); // falling scream sound PRECACHE_SOUND( "decap.wav" ); // decapitation sound PRECACHE_SOUND( "shatter.wav" ); // freeze decapitation sound PRECACHE_MODEL( "models/head.mdl" ); // head g_Language = (int)CVAR_GET_FLOAT( "sv_language" ); if ( g_Language == LANGUAGE_GERMAN ) { PRECACHE_MODEL( "models/germangibs.mdl" ); } else { PRECACHE_MODEL( "models/hgibs.mdl" ); PRECACHE_MODEL( "models/agibs.mdl" ); } PRECACHE_SOUND ("weapons/ric1.wav"); PRECACHE_SOUND ("weapons/ric2.wav"); PRECACHE_SOUND ("weapons/ric3.wav"); PRECACHE_SOUND ("weapons/ric4.wav"); PRECACHE_SOUND ("weapons/ric5.wav"); // // Setup light animation tables. 'a' is total darkness, 'z' is maxbright. // // 0 normal LIGHT_STYLE(0, "m"); // 1 FLICKER (first variety) LIGHT_STYLE(1, "mmnmmommommnonmmonqnmmo"); // 2 SLOW STRONG PULSE LIGHT_STYLE(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); // 3 CANDLE (first variety) LIGHT_STYLE(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); // 4 FAST STROBE LIGHT_STYLE(4, "mamamamamama"); // 5 GENTLE PULSE 1 LIGHT_STYLE(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); // 6 FLICKER (second variety) LIGHT_STYLE(6, "nmonqnmomnmomomno"); // 7 CANDLE (second variety) LIGHT_STYLE(7, "mmmaaaabcdefgmmmmaaaammmaamm"); // 8 CANDLE (third variety) LIGHT_STYLE(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); // 9 SLOW STROBE (fourth variety) LIGHT_STYLE(9, "aaaaaaaazzzzzzzz"); // 10 FLUORESCENT FLICKER LIGHT_STYLE(10, "mmamammmmammamamaaamammma"); // 11 SLOW PULSE NOT FADE TO BLACK LIGHT_STYLE(11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); // 12 UNDERWATER LIGHT MUTATION // this light only distorts the lightmap - no contribution // is made to the brightness of affected surfaces LIGHT_STYLE(12, "mmnnmmnnnmmnn"); // styles 32-62 are assigned by the light program for switchable lights // 63 testing LIGHT_STYLE(63, "a"); for ( i = 0; i < ARRAYSIZE(gDecals); i++ ) gDecals[i].index = DECAL_INDEX( gDecals[i].name ); // init the WorldGraph. WorldGraph.InitGraph(); // make sure the .NOD file is newer than the .BSP file. if ( !WorldGraph.CheckNODFile ( ( char * )STRING( gpGlobals->mapname ) ) ) {// NOD file is not present, or is older than the BSP file. WorldGraph.AllocNodes (); } else {// Load the node graph for this level if ( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) {// couldn't load, so alloc and prepare to build a graph. ALERT ( at_console, "*Error opening .NOD file\n" ); WorldGraph.AllocNodes (); } else { ALERT ( at_console, "\n*Graph Loaded!\n" ); } } if ( pev->speed > 0 ) CVAR_SET_FLOAT( "sv_zmax", pev->speed ); else CVAR_SET_FLOAT( "sv_zmax", 4096 ); if ( pev->netname ) { ALERT( at_aiconsole, "Chapter title: %s\n", STRING(pev->netname) ); CBaseEntity *pEntity = CBaseEntity::Create( "env_message", g_vecZero, g_vecZero, NULL ); if ( pEntity ) { pEntity->SetThink( SUB_CallUseToggle ); pEntity->pev->message = pev->netname; pev->netname = 0; pEntity->pev->nextthink = gpGlobals->time + 0.3; pEntity->pev->spawnflags = SF_MESSAGE_ONCE; } } if ( pev->spawnflags & SF_WORLD_DARK ) CVAR_SET_FLOAT( "v_dark", 1.0 ); else CVAR_SET_FLOAT( "v_dark", 0.0 ); if ( pev->spawnflags & SF_WORLD_TITLE ) gDisplayTitle = TRUE; // display the game title if this key is set else gDisplayTitle = FALSE; if ( pev->spawnflags & SF_WORLD_FORCETEAM ) { CVAR_SET_FLOAT( "mp_defaultteam", 1 ); } else { CVAR_SET_FLOAT( "mp_defaultteam", 0 ); } // Discwar if ( g_iPlayersPerTeam < 1 ) g_iPlayersPerTeam = CVAR_GET_FLOAT("rc_playersperteam"); }
void CWorld::Precache( void ) { g_WorldEntity = this; g_fGameOver = false; g_pLastSpawn = NULL; ConVar *gravity = ( ConVar * )cvar->FindVar( "sv_gravity" ); if ( gravity ) { // UNDONE: Disabled this. This makes sv_gravity reset of each level. Is that what we want? // gravity->SetValue( 800 );// 67ft/sec^2 } ConVar *stepsize = ( ConVar * )cvar->FindVar( "sv_stepsize" ); if ( stepsize ) { stepsize->SetValue( 18 ); } ConVar *roomtype = ( ConVar * )cvar->FindVar( "room_type" ); if ( roomtype ) { roomtype->SetValue( 0 ); } // Set up game rules Assert( !g_pGameRules ); if (g_pGameRules) { delete g_pGameRules; } g_pGameRules = InstallGameRules( ); Assert( g_pGameRules ); g_pGameRules->LevelInit(); CSoundEnt::InitSoundEnt(); IGameSystem::LevelInitPreEntityAllSystems( STRING( GetModelName() ) ); // UNDONE: Make most of these things server systems or precache_registers // ================================================= // Activities // ================================================= ActivityList_Free(); RegisterSharedActivities(); InitBodyQue(); // init sentence group playback stuff from sentences.txt. // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); // the area based ambient sounds MUST be the first precache_sounds // player precaches W_Precache (); // get weapon precaches ClientPrecache(); g_pGameRules->Precache(); // precache all temp ent stuff CBaseTempEntity::PrecacheTempEnts(); // sounds used from C physics code enginesound->PrecacheSound("common/null.wav"); // clears sound channels ConVar const *language = cvar->FindVar( "sv_language" ); g_Language = language ? language->GetInt() : LANGUAGE_ENGLISH; if ( g_Language == LANGUAGE_GERMAN ) { engine->PrecacheModel( "models/germangibs.mdl" ); } else { engine->PrecacheModel( "models/gibs/hgibs.mdl" ); } // // Setup light animation tables. 'a' is total darkness, 'z' is maxbright. // // 0 normal engine->LightStyle(0, "m"); // 1 FLICKER (first variety) engine->LightStyle(1, "mmnmmommommnonmmonqnmmo"); // 2 SLOW STRONG PULSE engine->LightStyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); // 3 CANDLE (first variety) engine->LightStyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); // 4 FAST STROBE engine->LightStyle(4, "mamamamamama"); // 5 GENTLE PULSE 1 engine->LightStyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); // 6 FLICKER (second variety) engine->LightStyle(6, "nmonqnmomnmomomno"); // 7 CANDLE (second variety) engine->LightStyle(7, "mmmaaaabcdefgmmmmaaaammmaamm"); // 8 CANDLE (third variety) engine->LightStyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); // 9 SLOW STROBE (fourth variety) engine->LightStyle(9, "aaaaaaaazzzzzzzz"); // 10 FLUORESCENT FLICKER engine->LightStyle(10, "mmamammmmammamamaaamammma"); // 11 SLOW PULSE NOT FADE TO BLACK engine->LightStyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); // 12 UNDERWATER LIGHT MUTATION // this light only distorts the lightmap - no contribution // is made to the brightness of affected surfaces engine->LightStyle(12, "mmnnmmnnnmmnn"); // styles 32-62 are assigned by the light program for switchable lights // 63 testing engine->LightStyle(63, "a"); // ================================================= // Load and Init AI Networks // ================================================= CAI_NetworkManager::InitializeAINetworks(); // ================================================= // Load and Init AI Schedules // ================================================= g_AI_SchedulesManager.LoadAllSchedules(); // ================================================= // Initialize NPC Relationships // ================================================= g_pGameRules->InitDefaultAIRelationships(); CBaseCombatCharacter::InitInteractionSystem(); // Call all registered precachers. CPrecacheRegister::Precache(); if ( m_iszChapterTitle != NULL_STRING ) { DevMsg( 2, "Chapter title: %s\n", STRING(m_iszChapterTitle) ); CMessage *pMessage = (CMessage *)CBaseEntity::Create( "env_message", vec3_origin, vec3_angle, NULL ); if ( pMessage ) { pMessage->SetMessage( m_iszChapterTitle ); m_iszChapterTitle = NULL_STRING; // send the message entity a play message command, delayed by 0.3 seconds pMessage->AddSpawnFlags( SF_MESSAGE_ONCE ); pMessage->SetThink( &CMessage::SUB_CallUseToggle ); pMessage->SetNextThink( gpGlobals->curtime + 0.3 ); } } }
void CWorld::Precache( void ) { COM_TimestampedLog( "CWorld::Precache - Start" ); g_WorldEntity = this; g_fGameOver = false; g_pLastSpawn = NULL; g_Language.SetValue( LANGUAGE_ENGLISH ); // TODO use VGUI to get current language #ifndef INFESTED_DLL ConVarRef stepsize( "sv_stepsize" ); stepsize.SetValue( 24 ); #endif ConVarRef roomtype( "room_type" ); roomtype.SetValue( 0 ); // Set up game rules Assert( !g_pGameRules ); if (g_pGameRules) { delete g_pGameRules; } InstallGameRules(); Assert( g_pGameRules ); g_pGameRules->Init(); CSoundEnt::InitSoundEnt(); // UNDONE: Make most of these things server systems or precache_registers // ================================================= // Activities // ================================================= ActivityList_Free(); RegisterSharedActivities(); EventList_Free(); RegisterSharedEvents(); // Only allow precaching between LevelInitPreEntity and PostEntity CBaseEntity::SetAllowPrecache( true ); COM_TimestampedLog( "IGameSystem::LevelInitPreEntityAllSystems" ); IGameSystem::LevelInitPreEntityAllSystems( STRING( GetModelName() ) ); COM_TimestampedLog( "g_pGameRules->CreateStandardEntities()" ); // Create the player resource g_pGameRules->CreateStandardEntities(); COM_TimestampedLog( "InitBodyQue()" ); InitBodyQue(); COM_TimestampedLog( "SENTENCEG_Init()" ); // init sentence group playback stuff from sentences.txt. // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); COM_TimestampedLog( "PrecacheStandardParticleSystems()" ); // Precache standard particle systems PrecacheStandardParticleSystems( ); // the area based ambient sounds MUST be the first precache_sounds COM_TimestampedLog( "W_Precache()" ); // player precaches W_Precache (); // get weapon precaches COM_TimestampedLog( "ClientPrecache()" ); ClientPrecache(); COM_TimestampedLog( "PrecacheTempEnts()" ); // precache all temp ent stuff CBaseTempEntity::PrecacheTempEnts(); COM_TimestampedLog( "LightStyles" ); // // Setup light animation tables. 'a' is total darkness, 'z' is maxbright. // for ( int i = 0; i < ARRAYSIZE(g_DefaultLightstyles); i++ ) { engine->LightStyle( i, GetDefaultLightstyleString(i) ); } // styles 32-62 are assigned by the light program for switchable lights // 63 testing engine->LightStyle(63, "a"); COM_TimestampedLog( "InitializeAINetworks" ); // ================================================= // Load and Init AI Networks // ================================================= CAI_NetworkManager::InitializeAINetworks(); // ================================================= // Load and Init AI Schedules // ================================================= COM_TimestampedLog( "LoadAllSchedules" ); g_AI_SchedulesManager.LoadAllSchedules(); // ================================================= // Initialize NPC Relationships // ================================================= COM_TimestampedLog( "InitDefaultAIRelationships" ); g_pGameRules->InitDefaultAIRelationships(); COM_TimestampedLog( "InitInteractionSystem" ); CBaseCombatCharacter::InitInteractionSystem(); COM_TimestampedLog( "g_pGameRules->Precache" ); // Call the gamerules precache after the AI precache so that games can precache NPCs that are always loaded g_pGameRules->Precache(); if ( m_iszChapterTitle != NULL_STRING ) { DevMsg( 2, "Chapter title: %s\n", STRING(m_iszChapterTitle) ); CMessage *pMessage = (CMessage *)CBaseEntity::Create( "env_message", vec3_origin, vec3_angle, NULL ); if ( pMessage ) { pMessage->SetMessage( m_iszChapterTitle ); m_iszChapterTitle = NULL_STRING; // send the message entity a play message command, delayed by 1 second pMessage->AddSpawnFlags( SF_MESSAGE_ONCE ); pMessage->SetThink( &CMessage::SUB_CallUseToggle ); pMessage->SetNextThink( gpGlobals->curtime + 1.0f ); } } g_iszFuncBrushClassname = AllocPooledString("func_brush"); if ( m_iszDetailSpriteMaterial.Get() != NULL_STRING ) { PrecacheMaterial( STRING( m_iszDetailSpriteMaterial.Get() ) ); } COM_TimestampedLog( "CWorld::Precache - Finish" ); }
void CWorld :: Precache( void ) { //LRC - set up the world lists g_pWorld = this; m_pAssistLink = NULL; m_pFirstAlias = NULL; // ALERT(at_console, "Clearing AssistList\n"); g_pLastSpawn = NULL; #if 1 CVAR_SET_STRING("sv_gravity", "800"); // 67ft/sec CVAR_SET_STRING("sv_stepsize", "18"); #else CVAR_SET_STRING("sv_gravity", "384"); // 32ft/sec CVAR_SET_STRING("sv_stepsize", "24"); #endif CVAR_SET_STRING("room_type", "0");// clear DSP // Set up game rules if (g_pGameRules) { delete g_pGameRules; } g_pGameRules = InstallGameRules( ); //!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here ///!!!LATER - do we want a sound ent in deathmatch? (sjb) //pSoundEnt = CBaseEntity::Create( "soundent", g_vecZero, g_vecZero, edict() ); pSoundEnt = GetClassPtr( ( CSoundEnt *)NULL ); pSoundEnt->Spawn(); if ( !pSoundEnt ) { ALERT ( at_debug, "**COULD NOT CREATE SOUNDENT**\n" ); } InitBodyQue(); // init sentence group playback stuff from sentences.txt. // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); // init texture type array from materials.txt TEXTURETYPE_Init(); // the area based ambient sounds MUST be the first precache_sounds // player precaches W_Precache (); // get weapon precaches ClientPrecache(); // sounds used from C physics code PRECACHE_SOUND("common/null.wav"); // clears sound channels PRECACHE_SOUND( "items/suitchargeok1.wav" );//!!! temporary sound for respawning weapons. PRECACHE_SOUND( "items/gunpickup2.wav" );// player picks up a gun. PRECACHE_SOUND( "common/bodydrop3.wav" );// dead bodies hitting the ground (animation events) PRECACHE_SOUND( "common/bodydrop4.wav" ); g_Language = (int)CVAR_GET_FLOAT( "sv_language" ); if ( g_Language == LANGUAGE_GERMAN ) { PRECACHE_MODEL( "models/germangibs.mdl" ); } else { PRECACHE_MODEL( "models/hgibs.mdl" ); PRECACHE_MODEL( "models/agibs.mdl" ); } PRECACHE_SOUND ("weapons/ric1.wav"); PRECACHE_SOUND ("weapons/ric2.wav"); PRECACHE_SOUND ("weapons/ric3.wav"); PRECACHE_SOUND ("weapons/ric4.wav"); PRECACHE_SOUND ("weapons/ric5.wav"); PRECACHE_MODEL( "sprites/null.spr" ); //LRC // // Setup light animation tables. 'a' is total darkness, 'z' is maxbright. // int i; // 0 normal for (i = 0; i <= 13; i++) { LIGHT_STYLE(i, (char*)STRING(GetStdLightStyle(i))); } // styles 32-62 are assigned by the light program for switchable lights // 63 testing LIGHT_STYLE(63, "a"); for (i = 0; i < ARRAYSIZE(gDecals); i++ ) gDecals[i].index = DECAL_INDEX( gDecals[i].name ); // init the WorldGraph. WorldGraph.InitGraph(); // make sure the .NOD file is newer than the .BSP file. if ( !WorldGraph.CheckNODFile ( ( char * )STRING( gpGlobals->mapname ) ) ) {// NOD file is not present, or is older than the BSP file. WorldGraph.AllocNodes (); } else {// Load the node graph for this level if ( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) {// couldn't load, so alloc and prepare to build a graph. ALERT ( at_debug, "*Error opening .NOD file\n" ); WorldGraph.AllocNodes (); } else { ALERT ( at_debug, "\n*Graph Loaded!\n" ); } } if ( pev->speed > 0 ) CVAR_SET_FLOAT( "sv_zmax", pev->speed ); else CVAR_SET_FLOAT( "sv_zmax", 4096 ); if ( pev->netname ) { ALERT( at_aiconsole, "Chapter title: %s\n", STRING(pev->netname) ); CBaseEntity *pEntity = CBaseEntity::Create( "env_message", g_vecZero, g_vecZero, NULL ); if ( pEntity ) { pEntity->SetThink(&CWorld::SUB_CallUseToggle ); pEntity->pev->message = pev->netname; pev->netname = 0; pEntity->SetNextThink( 0.3 ); pEntity->pev->spawnflags = SF_MESSAGE_ONCE; } } if ( pev->spawnflags & SF_WORLD_DARK ) CVAR_SET_FLOAT( "v_dark", 1.0 ); else CVAR_SET_FLOAT( "v_dark", 0.0 ); if ( pev->spawnflags & SF_WORLD_TITLE ) gDisplayTitle = TRUE; // display the game title if this key is set else gDisplayTitle = FALSE; if ( pev->spawnflags & SF_WORLD_FORCETEAM ) { CVAR_SET_FLOAT( "mp_defaultteam", 1 ); } else { CVAR_SET_FLOAT( "mp_defaultteam", 0 ); } }