Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Newspaper articles etc: https://crytek.4thdimension.info/forum/mod-database/14846-mod-wreckage.html
- //Wreckage MOD: Suit Deactivation Control
- void CGame::CmdDeactivateSuit(IConsoleCmdArgs* pArgs)
- {
- CryLogAlways("Wreckage Log: NanoSuit disabled!");
- ICVar* suit = gEnv->pConsole->GetCVar("wreckage_isSuitActivated");
- if(suit)
- suit->ForceSet("0");
- //Change Player Arms to Lambert
- IScriptSystem* m_pScriptSystem = g_pGame->GetIGameFramework()->GetISystem()->GetIScriptSystem();
- CActor* pActor = static_cast<CActor*> (g_pGame->GetIGameFramework()->GetClientActor());
- if (pActor)
- {
- SmartScriptTable m_script = pActor->GetEntity()->GetScriptTable();
- if (m_pScriptSystem)
- {
- m_pScriptSystem->BeginCall(m_script, "SetModel"); m_pScriptSystem->PushFuncParam(m_script);
- m_pScriptSystem->PushFuncParam("objects/characters/human/us/nanosuit/nanosuit_us_multiplayer.cdf");
- m_pScriptSystem->PushFuncParam("objects/weapons/arms_lambert/arms_nanosuit_us.chr");
- m_pScriptSystem->PushFuncParam("objects/characters/human/asian/nk_soldier/nk_soldier_frozen_scatter.cgf");
- m_pScriptSystem->PushFuncParam("Characters/Lambert_fp3p.cdf");
- m_pScriptSystem->EndCall();
- pActor->Physicalize();
- }
- //Adjust STANCE_STAND speed values
- CPlayer* pPlayer = static_cast<CPlayer*> (pActor);
- if (pPlayer)
- {
- const SStanceInfo *sInfo = pPlayer->GetStanceInfo(STANCE_STAND);
- SStanceInfo standInfo;
- //Copy old values
- standInfo.heightCollider = sInfo->heightCollider;
- standInfo.heightPivot = sInfo->heightPivot;
- standInfo.leanLeftViewOffset = sInfo->leanLeftViewOffset;
- standInfo.leanLeftWeaponOffset = sInfo->leanLeftWeaponOffset;
- standInfo.leanRightViewOffset = sInfo->leanRightViewOffset;
- standInfo.leanRightWeaponOffset = sInfo->leanRightWeaponOffset;
- standInfo.modelOffset = sInfo->modelOffset;
- strcpy(standInfo.name, sInfo->name);
- standInfo.size = sInfo->size;
- standInfo.useCapsule = sInfo->useCapsule;
- standInfo.viewOffset = sInfo->viewOffset;
- standInfo.weaponOffset = sInfo->weaponOffset;
- //Set new values
- standInfo.normalSpeed = 4;
- standInfo.maxSpeed = 9;
- pPlayer->SetupStance(STANCE_STAND, &standInfo);
- }
- }
- //Set Suit Mode to Armor
- CPlayer *pPlayer = static_cast<CPlayer *>(g_pGame->GetIGameFramework()->GetClientActor());
- if(pPlayer)
- {
- CNanoSuit *m_pNanoSuit = pPlayer->GetNanoSuit();
- m_pNanoSuit->SetMode(NANOMODE_DEFENSE, true);
- }
- //Editor specific
- if (gEnv->pSystem->IsEditor())
- {
- //Select Fists as Default Weapon
- if (pActor && pPlayer)
- pPlayer->SelectFists(true);
- }
- //Custom Health Values
- g_pGame->GetMenu()->SetDifficulty(0);
- /*
- ICVar* HealthValue = gEnv->pConsole->GetCVar("g_playerHealthValue");
- if(HealthValue)
- HealthValue->ForceSet("200");
- ICVar* SuitHealthRegenTime = gEnv->pConsole->GetCVar("g_playerSuitHealthRegenTime");
- if(SuitHealthRegenTime)
- SuitHealthRegenTime->ForceSet("10");
- ICVar* SuitHealthRegenTimeMoving = gEnv->pConsole->GetCVar("g_playerSuitHealthRegenTimeMoving");
- if(SuitHealthRegenTimeMoving)
- SuitHealthRegenTimeMoving->ForceSet("13.5");
- ICVar* SuitArmorModeHealthRegenTime = gEnv->pConsole->GetCVar("g_playerSuitArmorModeHealthRegenTime");
- if(SuitArmorModeHealthRegenTime)
- SuitArmorModeHealthRegenTime->ForceSet("5");
- ICVar* SuitArmorModeHealthRegenTimeMoving = gEnv->pConsole->GetCVar("g_playerSuitArmorModeHealthRegenTimeMoving");
- if(SuitArmorModeHealthRegenTimeMoving)
- SuitArmorModeHealthRegenTimeMoving->ForceSet("7.5");
- ICVar* SuitHealthRegenDelay = gEnv->pConsole->GetCVar("g_playerSuitHealthRegenDelay");
- if(SuitHealthRegenDelay)
- SuitHealthRegenDelay->ForceSet("1.25");
- */
- //Change HUD to Lambert
- g_pGame->GetHUD()->SetLambertHUDEnabled(true);
- }
- //Wreckage MOD: Select Fists void
- void CPlayer::SelectFists(bool active)
- {
- if(active)
- {
- //Select Fists as Default Weapon
- CFists *pFists = static_cast<CFists*>(GetItemByClass(CItem::sFistsClass));
- if(!pFists)
- return;
- COffHand *pOffHand = static_cast<COffHand*>(GetItemByClass(CItem::sOffHandClass));
- //Drop object or NPC
- if (pOffHand)
- {
- if(pOffHand->IsHoldingEntity())
- {
- //Force drop
- if(pOffHand->GetOffHandState()==eOHS_MELEE)
- {
- pOffHand->GetScheduler()->Reset();
- pOffHand->SetOffHandState(eOHS_HOLDING_OBJECT);
- }
- pOffHand->OnAction(GetEntityId(),"use",eAAM_OnPress,0);
- pOffHand->OnAction(GetEntityId(),"use",eAAM_OnRelease,0);
- }
- else if(pOffHand->GetOffHandState()==eOHS_HOLDING_GRENADE)
- pOffHand->FinishAction(eOHA_RESET);
- }
- //Select Fists
- CItem *currentItem = static_cast<CItem*>(GetCurrentItem());
- if(!currentItem)
- {
- //Player has no item selected... just select fists
- pFists->EnableAnimations(false);
- SelectItem(pFists->GetEntityId(),false);
- pFists->EnableAnimations(true);
- }
- else if(pFists->GetEntityId()==currentItem->GetEntityId())
- {
- //Fists already selected
- pFists->Select(false);
- SelectItem(pFists->GetEntityId(),false);
- GetInventory()->SetLastItem(pFists->GetEntityId());
- pFists->Select(true);
- }
- else
- {
- //Deselect current item and select fists
- currentItem->Select(false);
- pFists->EnableAnimations(false);
- SelectItem(pFists->GetEntityId(),false);
- pFists->EnableAnimations(true);
- }
- }
- }
- //Chapter Load Snippet and take screenshot for map transition
- void CFlashMenuObject::OnLoadingStart(ILevelInfo *pLevel)
- {
- //Wreckage MOD: Here is the Loading Start Function: Start Timer for the Subtitles in the Loading Screen
- // and load the right pak files
- string levelname = pLevel->GetName();
- //Wreckage MOD: Crash Fix
- CryLog("Wreckage Log: Reset NanoSuit Status!");
- ICVar* suit = gEnv->pConsole->GetCVar("wreckage_isSuitActivated");
- if(suit)
- suit->ForceSet("1");
- //Wreckage MOD: When Chapter is loaded, prevent loading music from playing
- ICVar* chapter = gEnv->pConsole->GetCVar("wreckage_chapterName");
- if (chapter)
- {
- const char* chapterName = chapter->GetString();
- int result = stricmp(chapterName, "None");
- if (result != 0)
- {
- CryLogAlways("Wreckage: Chapter is loading - NewGame = false; Loading = true");
- m_RainysTimer_IsNewGame = false;
- m_Rainys_IsLoading = true;
- }
- }
- IGameTokenSystem *pGameTokenSystem = gEnv->pGame->GetIGameFramework()->GetIGameTokenSystem();
- string PreviousLevel;
- pGameTokenSystem->GetTokenValueAs("Game.General.Previous_Level", PreviousLevel);
- CryLogAlways("Wreckage: PreviousLevel: %s", PreviousLevel);
- //Wreckage MOD: Play Custom Intro Theme and Set Fade Out Timer if User
- // starts Wreckage from scratch or Part 2
- if (levelname == "Wreckage" && m_Rainys_IsLoading == false)
- {
- if (m_pMusicSystem && !g_pGame->IsReloading())
- {
- m_fMusicFirstTime = -1;
- m_pMusicSystem->EndTheme(EThemeFade_StopAtOnce, 0, true);
- m_pMusicSystem->SetTheme("Wreckage_loading_sounds", true, false);
- m_pMusicSystem->SetMood("intro_map1", true, false);
- m_fRemindOfHarbour = gEnv->pTimer->GetAsyncTime().GetSeconds();
- //Wreckage MOD: Activate the Subtitle System for Loading Screen
- m_RainysTimer_IsNewGame = true;
- }
- }
- if (levelname == "Wreckage_Part2" && m_Rainys_IsLoading == false || levelname == "Wreckage_Part2" && PreviousLevel == "Wreckage")
- {
- if (m_pMusicSystem && !g_pGame->IsReloading())
- {
- m_fMusicFirstTime = -1;
- m_pMusicSystem->EndTheme(EThemeFade_StopAtOnce, 0, true);
- m_pMusicSystem->SetTheme("Wreckage_loading_sounds", true, false);
- m_pMusicSystem->SetMood("intro_map2", true, false);
- m_fRemindOfHarbour = gEnv->pTimer->GetAsyncTime().GetSeconds();
- //Wreckage MOD: Activate the Subtitle System for Loading Screen
- m_RainysTimer_IsNewGame = true;
- }
- }
- //Wreckage MOD: Log a few things...
- if (m_RainysTimer_IsNewGame)
- CryLogAlways("Wreckage: m_WreckageTimer_IsNewGame: True");
- else
- CryLogAlways("Wreckage: m_WreckageTimer_IsNewGame: False");
- if (m_Rainys_IsLoading)
- CryLogAlways("Wreckage: m_Wreckage_IsLoading: True");
- else
- CryLogAlways("Wreckage: m_Wreckage_IsLoading: False");
- if (PreviousLevel == "Wreckage_Part2" && levelname == "Wreckage_Part3")
- {
- CryLog("Wreckage: Starte Part 3!");
- gEnv->pRenderer->ScreenShot("Mods/Wreckage/Game/Levels/Wreckage_Part3/wreckage_03_loading_new.jpg", gEnv->pRenderer->GetWidth());
- OnLoadingStart_Part3(pLevel);
- CryLog("Wreckage: Lade Part 3 eingeleitet!");
- return;
- }
- m_bInLoading = true;
- }
- //Map transition function
- void CFlashMenuObject::OnLoadingStart_Part3(ILevelInfo *pLevel)
- {
- //Wreckage MOD: Here is the Loading Start_Part3 Function
- CryLog("Wreckage: Lade Part 3 Funktion läuft!");
- m_bInLoading = true;
- SAFE_HUD_FUNC(OnLoadingStart(pLevel));
- StopVideo(); //stop background video
- StopTutorialVideo();
- if(m_stateEntryMovies!=eEMS_Done)
- {
- if (m_stateEntryMovies < eEMS_Done)
- SAFE_HARDWARE_MOUSE_FUNC(IncrementCounter());
- m_stateEntryMovies=eEMS_Done;
- }
- if(gEnv->pSystem->IsEditor() || gEnv->pSystem->IsDedicated()) return;
- if(m_bLanQuery)
- {
- gEnv->pGame->GetIGameFramework()->EndCurrentQuery();
- m_bLanQuery = false;
- }
- if(pLevel)
- {
- m_iMaxProgress = pLevel->GetDefaultGameType()->cgfCount;
- }
- else
- {
- m_iMaxProgress = 100;
- }
- if(!m_apFlashMenuScreens[MENUSCREEN_FRONTENDLOADING_PART2]->IsLoaded())
- {
- CryLog("Wreckage: Lade Wechsel Screen!");
- m_apFlashMenuScreens[MENUSCREEN_FRONTENDLOADING_PART2]->Load("Libs/UI/Menus_Loading_Wreckage_Part2.gfx");
- m_apFlashMenuScreens[MENUSCREEN_FRONTENDLOADING_PART2]->GetFlashPlayer()->SetFSCommandHandler(this);
- m_apFlashMenuScreens[MENUSCREEN_FRONTENDLOADING_PART2]->Invoke("SetProgress", 0.0f);
- UpdateMenuColor();
- }
- m_pCurrentFlashMenuScreen = m_apFlashMenuScreens[MENUSCREEN_FRONTENDLOADING_PART2];
- //Prepare Loading Texture
- IRenderer* pRenderer = gEnv->pRenderer;
- assert( pRenderer != NULL );
- if (pRenderer)
- {
- IUIDraw *m_pUiDraw = gEnv->pGame->GetIGameFramework()->GetIUIDraw();
- assert( m_pUiDraw != NULL );
- if (m_pUiDraw)
- {
- char fileName[255];
- sprintf(fileName,"Game/Levels/Wreckage_Part3/wreckage_03_loading_new.jpg");
- m_LoadingTexture = m_pUiDraw->CreateTexture(fileName);
- pRenderer->SetState( GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST );
- m_bIsQuickLevelSwitchLoading = true;
- }
- }
- m_bUpdate = true;
- m_nBlackGraceFrames = 0;
- if(!gEnv->pSystem->IsSerializingFile())
- {
- m_sLastSaveGame = "";
- SetDifficulty(); //set difficulty setting at game/level start
- }
- //remove the hud to be re-created
- if(g_pGame)
- g_pGame->DestroyHUD();
- }
- //Wreckage MOD: Draw Loading Texture if needed
- void CFlashMenuObject::OnPostUpdate(float fDeltaTime)
- {
- if (m_bIsQuickLevelSwitchLoading && m_LoadingTexture != 0)
- {
- IRenderer* pRenderer = gEnv->pRenderer;
- assert( pRenderer != NULL );
- if ( pRenderer == NULL )
- {
- return;
- }
- pRenderer->Draw2dImage(0.0f,-0.5f, 800.0f,600.0f, m_LoadingTexture, 0.0f,1.0f,1.0f,0.0f, 0.0f);
- if (m_bInLoading == false && m_nBlackGraceFrames == 0 && curFrameID >= m_nBlackGraceFrames)
- {
- m_bIsQuickLevelSwitchLoading = false;
- }
- }
- }
- //Load correct player post load and set chapter gametoken (show flowgraph check)
- void CFlashMenuObject::OnLoadingComplete(ILevel *pLevel)
- {
- //Wreckage MOD: Here is The OnLoading Complete Function - Less ToDo here since we moved to 'OnPostUpdate'
- SAFE_HUD_FUNC(OnLoadingComplete(pLevel));
- if(gEnv->pSystem->IsEditor() || gEnv->pSystem->IsDedicated())
- {
- return;
- }
- //Wreckage MOD: Load the correct player model and HUD based of Levelname
- //Load Nomad or Lambert
- string levelname = pLevel->GetLevelInfo()->GetName();
- if (levelname == "Wreckage") //Nomad
- gEnv->pConsole->ExecuteString("wreckage_suit_activate");
- else if (levelname == "Wreckage_Part2" || levelname == "Wreckage_Part3") //Lambert
- gEnv->pConsole->ExecuteString("wreckage_suit_deactivate");
- //Wreckage MOD: Set GameToken for Map SpawnPoint if necessary
- ICVar* chapter = gEnv->pConsole->GetCVar("wreckage_chapterName");
- if (chapter)
- {
- const char* chapterName = chapter->GetString();
- int result = stricmp(chapterName, "None");
- if (result != 0)
- {
- string chapterNameString = chapterName;
- CryLog("Wreckage: Chapter Name: %s", chapterNameString);
- IGameTokenSystem *pGameTokenSystem = gEnv->pGame->GetIGameFramework()->GetIGameTokenSystem();
- if (pGameTokenSystem)
- {
- pGameTokenSystem->SetOrCreateToken("Game.General.Chapter_Name", TFlowInputData(chapterNameString, true));
- string Value;
- pGameTokenSystem->GetTokenValueAs("Game.General.Chapter_Name", Value);
- CryLog("Wreckage: Token Value: %s", Value);
- }
- //Wreckage MOD: Reset CVar for Chapter Name
- chapter->ForceSet("None");
- }
- }
- }
- //Wreckage MOD: Overloaded Memory Callback Function (for Listener) (Critical Emergency Save)
- void CFlashMenuObject::HandleFSCommand(const char *szCommand,const char *szArgs)
- {
- else if(!strcmp(szCommand, "OverloadedMemory"))
- {
- if(szArgs != 0)
- {
- ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager();
- const char* pProfileName;
- string pSaveGameFileName;
- string pCVarString = gEnv->pConsole->GetCVar("g_language")->GetString();
- bool IsEnglish = false;
- if(pCVarString == "English") //Check language: German or English
- IsEnglish = true;
- if(IsEnglish)
- pSaveGameFileName = "Wreckage - Auto Save.CRYSISJMSF"; //English File Name
- else
- pSaveGameFileName = "Wreckage - Auto Speicherung.CRYSISJMSF"; //German File Name
- IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
- pProfileName = pProfile->GetName(); //Get Current User Profile Name
- //pSaveGame = g_pGame->CreateSaveGameName();
- //ESaveGameReason::eSGR_FlowGraph
- CryLog("Wreckage: Save Current Game Status For '%s' As '%s'...", pProfileName, pSaveGameFileName);
- //Save Game
- const bool bSuccess = g_pGame->GetIGameFramework()->SaveGame(pSaveGameFileName, false, true, eSGR_LevelStart, true);
- if(bSuccess)
- {
- CryLog("Wreckage: Game Saving Succeed...");
- CryLog("Wreckage: Restart Wreckage...");
- gEnv->pConsole->ExecuteString("g_loadMod Wreckage"); //Restart Wreckage
- }
- else
- {
- CryLog("Wreckage: Game Saving Failed!");
- ShowMenuMessage("@ui_SYSFatalError");
- }
- }
- }
- }
- //Memory Overloaded Snippet
- void CFlashMenuObject::OnPostUpdate(float fDeltaTime)
- {
- if(gEnv->pSystem->IsEditor() || gEnv->pSystem->IsDedicated()) return;
- //Wreckage MOD: These Function controls our Timer, the Subtitles for the Loading Screen and our new Memory Overload Protection System
- fDeltaTime = gEnv->pTimer->GetFrameTime(ITimer::ETIMER_UI);
- //Wreckage MOD: Check only memory every 5 seconds
- if (m_MemoryListener_LastUpdate == 0.0f)
- m_MemoryListener_LastUpdate = gEnv->pTimer->GetAsyncCurTime();
- if(m_MemoryListener_LastUpdate + 5.0f <= gEnv->pTimer->GetAsyncCurTime())
- {
- m_MemoryListener_LastUpdate = gEnv->pTimer->GetAsyncCurTime();
- //Wreckage MOD: Check only memory if no cutscenes are playing (because in a cutscene you can't save!)
- ISequenceIt* pSeqIt = gEnv->pMovieSystem->GetSequences(true, true);
- IAnimSequence *pSeq=pSeqIt->first();
- if(m_bMemoryListener_Enabled && !gEnv->pMovieSystem->IsPlaying(pSeq))
- {
- CryLog("Wreckage: Used Memory: %i", gEnv->pSystem->GetUsedMemory() /1000000);
- if(gEnv->pSystem->GetUsedMemory() /1000000 >= 1035 && !m_bIs64Bit || gEnv->pSystem->GetUsedMemory() /1000000 >= 2070 && m_bIs64Bit) //Editor: 1400MB ~ GetUsedMemory: 1035MB
- {
- m_bMemoryListener_Enabled = false;
- CryLog("Wreckage: Warning - Memory Overload!");
- ShowInGameMenu(true);
- if(!m_bIs64Bit)
- {
- ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager();
- wstring localizedString, finalString;
- pLocMgr->LocalizeLabel("@ui_overloaded_memory_32", localizedString);
- char status[64];
- sprintf(status, "%d", gEnv->pSystem->GetUsedMemory() /1000000);
- wstring outString;
- outString.resize(strlen(status));
- wchar_t* dst = outString.begin();
- const char* src = status;
- while (const wchar_t c=(wchar_t)(*src++))
- {
- *dst++ = c;
- }
- pLocMgr->FormatStringMessage(finalString, localizedString, outString, 0, 0, 0);
- m_pCurrentFlashMenuScreen->Invoke("showErrorMessageYesNo","overloaded_memory"); //Wreckage MOD: Display our new Error Message in 32 Bit
- m_pCurrentFlashMenuScreen->Invoke("setErrorTextNonLocalized", SFlashVarValue(finalString)); //Wreckage MOD: Set Text
- }
- else
- {
- ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager();
- wstring localizedString, finalString;
- pLocMgr->LocalizeLabel("@ui_overloaded_memory_64", localizedString);
- char status[64];
- sprintf(status, "%d", gEnv->pSystem->GetUsedMemory() /1000000);
- wstring outString;
- outString.resize(strlen(status));
- wchar_t* dst = outString.begin();
- const char* src = status;
- while (const wchar_t c=(wchar_t)(*src++))
- {
- *dst++ = c;
- }
- pLocMgr->FormatStringMessage(finalString, localizedString, outString, 0, 0, 0);
- m_pCurrentFlashMenuScreen->Invoke("showErrorMessageYesNo","overloaded_memory"); //Wreckage MOD: Display our new Error Message in 64 Bit
- m_pCurrentFlashMenuScreen->Invoke("setErrorTextNonLocalized", SFlashVarValue(finalString));
- }
- }
- }
- }
- //Wreckage MOD: 64 Bit Restart if available Callback Function (for Listener)
- void CFlashMenuObject::InitStartMenu()
- {
- //Wreckage MOD: Check if 64 Bit is theoretically available, but not used
- SPlatformInfo pi = gEnv->pi;
- if (m_bIsFirstStart && !m_bIs64Bit && pi.win64Bit)
- {
- m_bIsFirstStart = false;
- ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager();
- wstring localizedString;
- if (gEnv->pCryPak->IsFileExist("../Bin64/Crysis.exe")) //64 Bit is even installed. Request user to use it
- {
- pLocMgr->LocalizeLabel("@ui_menu_wreckage_64bit_available", localizedString);
- m_pCurrentFlashMenuScreen->Invoke("setErrorTextNonLocalized", SFlashVarValue(localizedString));
- m_pCurrentFlashMenuScreen->Invoke("showErrorMessageYesNo","restart_64bit");
- }
- else //64 Bit is not installed. Advice user to install it
- {
- pLocMgr->LocalizeLabel("@ui_menu_wreckage_64bit_detected", localizedString);
- m_pCurrentFlashMenuScreen->Invoke("setErrorTextNonLocalized", SFlashVarValue(localizedString));
- m_pCurrentFlashMenuScreen->Invoke("showErrorMessage","Box1");
- }
- }
- }
- //Wreckage MOD: 64 Bit Restart if available Callback Function (for Listener)
- void CFlashMenuObject::HandleFSCommand(const char *szCommand,const char *szArgs)
- {
- if(!strcmp(szCommand, "Restart64Bit"))
- {
- if(szArgs != 0)
- {
- SPlatformInfo pi = gEnv->pi;
- if (pi.win64Bit)
- {
- if (gEnv->pCryPak->IsFileExist("../Bin64/Crysis.exe"))
- {
- //Prepare launch.bat
- FILE *pFile = gEnv->pCryPak->FOpen("../launch.bat","wb");
- if (pFile)
- {
- const string launchHeader("@echo Please wait...\n@echo off\n\n:start\n\ntasklist /FI \"IMAGENAME eq Crysis.exe\" 2>NUL | find /I /N \"Crysis.exe\">NUL\nif \"%ERRORLEVEL%\"==\"0\" GOTO start\n\n");
- gEnv->pCryPak->FWrite((void*)launchHeader.c_str(), launchHeader.size(), 1, pFile);
- string cmd = "start /WAIT";
- cmd.append(" Bin64\\Crysis.exe");
- if(gEnv->pSystem->IsDevMode())
- {
- cmd.append(" -devmode");
- }
- SModInfo info;
- if(gEnv->pGame->GetIGameFramework()->GetModInfo(&info))
- {
- cmd.append(" -mod ");
- cmd.append(info.m_name);
- }
- cmd.append(" -DX9");
- const string launchBody = cmd;
- gEnv->pCryPak->FWrite((void*)launchBody.c_str(), launchBody.size(), 1, pFile);
- gEnv->pCryPak->FClose(pFile);
- if(gEnv->pGame->GetIGameFramework()->StartProcess("launch.bat"))
- {
- gEnv->pSystem->Quit();
- }
- }
- }
- }
- }
- }
- }
- //Wreckage MOD: New Chapter Selection Screen
- void CFlashMenuObject::UpdateChapterScreen()
- {
- CFlashMenuScreen* pScreen = m_pCurrentFlashMenuScreen;
- if(!pScreen)
- return;
- //*************************************************************************
- pScreen->CheckedInvoke("resetSPChapters");
- // TODO: find a better place for this as it needs to be set only once -- CW
- gEnv->pSystem->SetFlashLoadMovieHandler(this);
- if(!m_pPlayerProfileManager)
- return;
- IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
- if(!pProfile)
- return;
- ICryPak *pCryPak = gEnv->pCryPak;
- ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager();
- //*************************************************************************
- const string szModDir = pCryPak->GetModDir();
- int m_bUnlockedChapterCount;
- // Load Profile
- bool bGotProfile = false;
- string szInfoFile = "..\\";
- szInfoFile += szModDir;
- szInfoFile += "\\Game\\Libs\\UI\\Chapters\\Profile.xml";
- if (XmlNodeRef root = gEnv->pSystem->LoadXmlFile(szInfoFile.c_str()))
- {
- if (strnicmp(root->getTag(), "ChapterSettings", 15) == 0)
- {
- // Get value
- root->getAttr("Unlocked", m_bUnlockedChapterCount);
- if (m_bUnlockedChapterCount < 1)
- bGotProfile = false;
- else
- bGotProfile = true;
- }
- }
- if (false == bGotProfile)
- {
- CryLogAlways("[Error] Wreckage: Chapter System - Failed to load profile. Using default values.");
- m_bUnlockedChapterCount = 1;
- }
- else
- {
- CryLogAlways("Wreckage: Chapter System - Profile file loaded.");
- }
- //Load ChapterList
- bool bGotChapterList = false;
- szInfoFile = "..\\";
- szInfoFile += szModDir;
- szInfoFile += "\\Game\\Libs\\UI\\Chapters\\ChapterNames.xml";
- if (XmlNodeRef root = gEnv->pSystem->LoadXmlFile(szInfoFile.c_str()))
- {
- if (strnicmp(root->getTag(), "ChapterNames", 12) == 0)
- {
- bGotChapterList = true;
- }
- }
- //Create and send chapter list based on UnlockedChapterCount
- if (bGotChapterList)
- {
- if (XmlNodeRef root = gEnv->pSystem->LoadXmlFile(szInfoFile.c_str()))
- {
- if (strnicmp(root->getTag(), "ChapterNames", 12) == 0)
- {
- CFlashMenuScreen* pCurrentScreen = m_pCurrentFlashMenuScreen;
- for(int i = 1; i != m_bUnlockedChapterCount + 1; i++)
- {
- char *key;
- const char *chapterNameDefault;
- const char *chapterNameTranslated;
- sprintf(key, "Chapter_%i", i);
- chapterNameDefault = root->getAttr(key);
- chapterNameTranslated = chapterNameDefault;
- SFlashVarValue args[2] =
- {
- chapterNameDefault,
- chapterNameTranslated
- };
- pCurrentScreen->CheckedInvoke("addChapterToList", args, sizeof(args) / sizeof(args[0]));
- }
- }
- }
- }
- else
- {
- CryLogAlways("[Error] Wreckage: Chapter System - Failed to load chapter list. System disabled!");
- }
- pScreen->CheckedInvoke("updateChapterList");
- }
- //Wreckage MOD: New Chapter Selection Screen
- void CFlashMenuObject::LoadChapter(const char *ChapterName)
- {
- //overwrite the last savegame with the to be loaded one
- //m_sLastSaveGame = ChapterName;
- //gEnv->pGame->GetIGameFramework()->LoadGame(ChapterName, false, true);
- //Find corresponding Level based of ChapterName
- ICryPak *pCryPak = gEnv->pCryPak;
- const string szModDir = pCryPak->GetModDir();
- string levelName;
- bool bGotLevelMapping = false;
- string szInfoFile = "..\\";
- szInfoFile += szModDir;
- szInfoFile += "\\Game\\Libs\\UI\\Chapters\\ChapterLevelMapping.xml";
- if (XmlNodeRef root = gEnv->pSystem->LoadXmlFile(szInfoFile.c_str()))
- {
- if (strnicmp(root->getTag(), "LevelChapterNames", 17) == 0)
- {
- //Get Level Name
- levelName = root->getAttr(ChapterName);
- if (levelName)
- bGotLevelMapping = true;
- else
- bGotLevelMapping = false;
- }
- }
- if (false == bGotLevelMapping)
- {
- CryLogAlways("[Error] Wreckage: Chapter System - Failed to find map. Do nothing.");
- return;
- }
- else
- {
- CryLogAlways("Wreckage: Chapter System - Map found.");
- }
- //Set CVar for Map SpawnPoint
- ICVar* chapter = gEnv->pConsole->GetCVar("wreckage_chapterName");
- if(chapter)
- chapter->ForceSet(ChapterName);
- //Load Map
- string szCmd = "map ";
- szCmd += levelName;
- szCmd += " nonblocking";
- gEnv->pConsole->ExecuteString(szCmd.c_str());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement