Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 60.03 KB | None | 0 0
  1. /***********************************************************************/
  2. /**     © 2015 CD PROJEKT S.A. All rights reserved.
  3. /**     THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /**     The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6.  
  7.  
  8.  
  9.  
  10. import struct SSavegameInfo
  11. {
  12.     import var filename : string;          
  13.     import var slotType : ESaveGameType;   
  14.     import var slotIndex : int;            
  15.                                            
  16. };
  17.  
  18.  
  19. enum Platform
  20. {
  21.     Platform_PC = 0,
  22.     Platform_Xbox1 = 1,
  23.     Platform_PS4 = 2,
  24.     Platform_Unknown = 3
  25. }
  26.  
  27. struct SPostponedPreAttackEvent
  28. {
  29.     var entity      : CGameplayEntity;
  30.     var eventName   : name;
  31.     var eventType   : EAnimationEventType;
  32.     var data        : CPreAttackEventData;
  33.     var animInfo    : SAnimationEventAnimInfo;
  34. };
  35.  
  36. import class CR4Game extends CCommonGame
  37. {
  38.     saved var zoneName : EZoneName;    
  39.     private var gamerProfile : W3GamerProfile;
  40.     private var isDialogOrCutscenePlaying : bool;                  
  41.     private saved var recentDialogOrCutsceneEndGameTime : GameTime;    
  42.     public var isCutscenePlaying : bool;
  43.     public var isDialogDisplayDisabled : bool;
  44.     default isDialogDisplayDisabled = false;
  45.     public var witcherLog : W3GameLog;
  46.     public var deathSaveLockId : int;
  47.     private var currentPresence : name;
  48.     private var restoreUsableItemL : bool;
  49.    
  50.     private saved var savedEnchanterFunds           : int;
  51.     private saved var gameplayFactsForRemoval       : array<SGameplayFactRemoval>;
  52.     private saved var gameplayFacts                 : array<SGameplayFact>;
  53.     private saved var tutorialManagerHandle         : EntityHandle;        
  54.     private saved var diffChangePostponed           : EDifficultyMode;     
  55.     private saved var dynamicallySpawnedBoats       : array<EntityHandle>;     
  56.     private saved var dynamicallySpawnedBoatsToDestroy : array<EntityHandle>;  
  57.    
  58.     private saved var uberMovement : bool;  default uberMovement = false;
  59.    
  60.     function EnableUberMovement( flag : bool )
  61.     {
  62.         uberMovement = flag;
  63.     }
  64.    
  65.     public function IsUberMovementEnabled() : bool
  66.     {
  67.         return uberMovement;
  68.     }  
  69.    
  70.         default diffChangePostponed = EDM_NotSet;
  71.    
  72.    
  73.     import final function ShowSteamControllerBindingPanel() : bool;
  74.    
  75.     import final function ActivateHorseCamera( activate : bool, blendTime : float, optional instantMount : bool );
  76.    
  77.     import final function GetFocusModeController() : CFocusModeController;
  78.    
  79.     public var isRespawningInLastCheckpoint : bool;
  80.     default isRespawningInLastCheckpoint = false;
  81.     private var environmentID : int;
  82.    
  83.     public function SetIsRespawningInLastCheckpoint()
  84.     {
  85.         isRespawningInLastCheckpoint = true;
  86.     }
  87.    
  88.     event  OnGameSaveListUpdated()
  89.     {
  90.         var menuBase    : CR4MenuBase;
  91.         var ingameMenu  : CR4IngameMenu;
  92.        
  93.         menuBase = (CR4MenuBase)(theGame.GetGuiManager().GetRootMenu());
  94.        
  95.         if (menuBase)
  96.         {
  97.             ingameMenu = (CR4IngameMenu)(menuBase.GetSubMenu());
  98.            
  99.             if (ingameMenu)
  100.             {
  101.                 ingameMenu.HandleSaveListUpdate();
  102.             }
  103.         }
  104.     }
  105.    
  106.     event  OnGameLoadInitFinished()
  107.     {
  108.         var requiredContent : array< name >;
  109.         var blockedContentTag : name;
  110.         var i : int;
  111.         var progress : float;
  112.         var loadResult : ELoadGameResult;
  113.         var ingameMenu : CR4IngameMenu;
  114.         var menuBase : CR4MenuBase;
  115.    
  116.         loadResult = GetLoadGameProgress();
  117.         blockedContentTag = 'launch0';
  118.        
  119.         if ( loadResult != LOAD_MissingContent && loadResult != LOAD_Error )
  120.         {
  121.             theSound.SoundEvent("stop_music");
  122.             theSound.SoundEvent("gui_global_game_start");
  123.             theGame.GetGuiManager().RequestMouseCursor(false);
  124.         }
  125.        
  126.         if ( loadResult == LOAD_NotInitialized || loadResult == LOAD_Initializing || loadResult == LOAD_Loading )
  127.         {
  128.             LogChannel( 'Save', "Event OnGameLoadInitFinished() called, but load not initialized / not ready / already loading. DEBUG THIS!" );
  129.             isRespawningInLastCheckpoint = false;
  130.             return true;
  131.         }
  132.        
  133.         if ( loadResult == LOAD_MissingContent )
  134.         {
  135.             GetContentRequiredByLastSave( requiredContent );
  136.            
  137.             theSound.SoundEvent("gui_global_denied");
  138.            
  139.             for ( i = ( requiredContent.Size() - 1 ); i >= 0; i -= 1 )
  140.             {
  141.                 if ( !IsContentAvailable( requiredContent[ i ] ) )
  142.                 {
  143.                     blockedContentTag = requiredContent[ i ];
  144.                     break;
  145.                 }
  146.             }
  147.            
  148.             progress = ProgressToContentAvailable( blockedContentTag );
  149.             GetGuiManager().ShowProgressDialog( UMID_MissingContentOnLoadError, "", "error_message_new_game_not_ready", true, UDB_Ok, progress, UMPT_Content, blockedContentTag );
  150.             isRespawningInLastCheckpoint = false;
  151.            
  152.             menuBase = (CR4MenuBase)(theGame.GetGuiManager().GetRootMenu());
  153.             if (menuBase)
  154.             {
  155.                 ingameMenu = (CR4IngameMenu)(menuBase.GetSubMenu());
  156.                
  157.                 if (ingameMenu)
  158.                 {
  159.                     ingameMenu.HandleLoadGameFailed();
  160.                 }
  161.             }
  162.            
  163.             return true;
  164.         }
  165.        
  166.         if ( loadResult == LOAD_Error )
  167.         {
  168.             menuBase = (CR4MenuBase)(theGame.GetGuiManager().GetRootMenu());
  169.            
  170.             theSound.SoundEvent("gui_global_denied");
  171.            
  172.             if (menuBase)
  173.             {
  174.                 ingameMenu = (CR4IngameMenu)(menuBase.GetSubMenu());
  175.                
  176.                 if (ingameMenu)
  177.                 {
  178.                     ingameMenu.HandleLoadGameFailed();
  179.                 }
  180.             }
  181.         }
  182.  
  183.         if ( loadResult != LOAD_MissingContent && loadResult != LOAD_Error && isRespawningInLastCheckpoint )
  184.         {
  185.             ReleaseNoSaveLock( deathSaveLockId );
  186.             theInput.RestoreContext( 'Exploration', true );
  187.             isRespawningInLastCheckpoint = false;
  188.         }
  189.     }
  190.    
  191.     event  OnGameLoadInitFinishedSuccess()
  192.     {
  193.         GetGuiManager().GetRootMenu().CloseMenu();
  194.     }
  195.    
  196.     public function IsFocusModeActive() : bool
  197.     {
  198.         var focusModeController : CFocusModeController;
  199.         focusModeController = GetFocusModeController();
  200.         if ( focusModeController )
  201.         {
  202.             return focusModeController.IsActive();
  203.         }
  204.         return false;
  205.     }
  206.    
  207.     var logEnabled  : bool;
  208.     default logEnabled = true;
  209.    
  210.     public function EnableLog( enable : bool )
  211.     {
  212.         logEnabled = enable;
  213.     }
  214.    
  215.     public function CanLog() : bool
  216.     {
  217.         return logEnabled && !IsFinalBuild();
  218.     }
  219.        
  220.     import final function GetSurfacePostFX() : CGameplayFXSurfacePost;
  221.    
  222.     import final function GetCommonMapManager() : CCommonMapManager;
  223.  
  224.     import final function GetJournalManager() : CWitcherJournalManager;
  225.  
  226.     import final function GetLootManager() : CR4LootManager;
  227.    
  228.     import final function GetInteractionsManager() : CInteractionsManager;
  229.    
  230.     import final function GetCityLightManager() : CCityLightManager;   
  231.    
  232.     import final function GetSecondScreenManager() : CR4SecondScreenManagerScriptProxy;
  233.        
  234.     import final function GetGuiManager() : CR4GuiManager;
  235.  
  236.     import final function GetGlobalEventsScriptsDispatcher() : CR4GlobalEventsScriptsDispatcher;
  237.    
  238.     import final function GetFastForwardSystem() : CGameFastForwardSystem;
  239.    
  240.     import final function NotifyOpeningJournalEntry( jorunalEntry : CJournalBase );
  241.    
  242.     var globalEventsScriptsDispatcherInternal : CR4GlobalEventsScriptsDispatcher;
  243.     public function GetGlobalEventsManager() : CR4GlobalEventsScriptsDispatcher
  244.     {
  245.         if ( !globalEventsScriptsDispatcherInternal )
  246.         {
  247.             globalEventsScriptsDispatcherInternal = GetGlobalEventsScriptsDispatcher();
  248.         }
  249.         return globalEventsScriptsDispatcherInternal;
  250.     }
  251.        
  252.    
  253.     import final function StartSepiaEffect( fadeInTime: float ) : bool;
  254.    
  255.    
  256.     import final function StopSepiaEffect( fadeOutTime: float ) : bool;
  257.    
  258.    
  259.     import final function GetWindAtPoint( point : Vector ) : Vector;
  260.    
  261.     import final function GetWindAtPointForVisuals( point : Vector ) : Vector;
  262.    
  263.     import final function GetGameCamera() : CCustomCamera;
  264.    
  265.    
  266.     import final function GetBuffImmunitiesForActor( actor : CActor ) : CBuffImmunity;
  267.     import final function GetMonsterParamsForActor( actor : CActor, out monsterCategory : EMonsterCategory, out soundMonsterName : CName, out isTeleporting : bool, out canBeTargeted : bool, out canBeHitByFists : bool ) : bool;
  268.     import final function GetMonsterParamForActor( actor : CActor, out val : CMonsterParam ) : bool;
  269.    
  270.    
  271.     import final function GetVolumePathManager() : CVolumePathManager;
  272.    
  273.    
  274.     import final function SummonPlayerHorse( teleportToSafeSpot : bool, createEntityHelper : CR4CreateEntityHelper );
  275.  
  276.    
  277.     import final function ToggleMenus();
  278.     import final function ToggleInput();
  279.    
  280.     import final function GetResourceAliases( out aliases : array< string > );
  281.    
  282.    
  283.     import final function GetKinectSpeechRecognizer() : CR4KinectSpeechRecognizerListenerScriptProxy;
  284.    
  285.    
  286.     import final function GetTutorialSystem() : CR4TutorialSystem;
  287.    
  288.    
  289.     import final function DisplaySystemHelp();
  290.     import final function DisplayStore();
  291.     import final function DisplayUserProfileSystemDialog();
  292.     import final function SetRichPresence( presence : name );
  293.  
  294.    
  295.     import final function OnUserDialogCallback( message, action : int );
  296.    
  297.    
  298.     import final function SaveUserSettings();
  299.    
  300.    
  301.    
  302.     //modSigns
  303.     public final function gmUserSettingsScaling()
  304.     {
  305.         var i : int;
  306.         var all : array<CActor>;
  307.        
  308.         all = GetActorsInRange(thePlayer, 10000.f, 10000, '', true);
  309.         for(i = 0; i < all.Size(); i += 1)
  310.         {
  311.             if((CNewNPC)all[i])
  312.                 ((CNewNPC)all[i]).ResetLevel();
  313.         }
  314.     }
  315.  
  316.     //modSigns
  317.     public final function gmUserSettingsQuestLevels()
  318.     {
  319.         LoadQuestLevels( "gameplay\globals\quest_levels.csv" );
  320.         if(theGame.GetDLCManager().IsEP1Enabled())
  321.             LoadQuestLevels( "dlc\ep1\data\gameplay\globals\quest_levels.csv" );
  322.         if(theGame.GetDLCManager().IsEP2Enabled())
  323.             LoadQuestLevels( "dlc\bob\data\gameplay\globals\quest_levels.csv" );
  324.     }
  325.  
  326.     //modSigns
  327.     public final function gmUserSettingsGameplay()
  328.     {
  329.         params.gmResetCachedValuesGameplay();
  330.         gmUpdateRegenEffects();
  331.     }
  332.  
  333.     //modSigns
  334.     public final function gmUserSettingsQoL()
  335.     {
  336.         params.gmResetCachedValuesQoL();
  337.         thePlayer.StopLowStaminaSFX();
  338.         thePlayer.CheckForLowStamina();
  339.     }
  340.    
  341.    
  342.    
  343.     public final function UpdateRichPresence(presence : name)
  344.     {
  345.         SetRichPresence(presence);
  346.         currentPresence = presence;
  347.     }
  348.    
  349.     public final function ClearRichPresence(presence : name)
  350.     {
  351.         var manager: CCommonMapManager;
  352.         var currentArea : EAreaName;
  353.        
  354.        
  355.         if(currentPresence == presence)
  356.         {
  357.             manager = theGame.GetCommonMapManager();
  358.             currentArea = manager.GetCurrentJournalArea();
  359.             currentPresence =  manager.GetLocalisationNameFromAreaType( currentArea );
  360.             SetRichPresence(currentPresence);
  361.            
  362.         }
  363.     }
  364.    
  365.    
  366.     import var params : W3GameParams;
  367.  
  368.     private var minimapSettings : C2dArray;
  369.     public var playerStatisticsSettings : C2dArray;
  370.     public var hudSettings : C2dArray;
  371.  
  372.    
  373.     public var damageMgr : W3DamageManager;
  374.  
  375.    
  376.     public var effectMgr : W3GameEffectManager;
  377.    
  378.    
  379.     private var timescaleSources : array<STimescaleSource>;
  380.  
  381.    
  382.     public saved var envMgr : W3EnvironmentManager;
  383.    
  384.     public var runewordMgr : W3RunewordManager;
  385.    
  386.     private var questLevelsFilePaths : array<string>;
  387.     public var questLevelsContainer : array<C2dArray>;
  388.     public var expGlobalModifiers : C2dArray;
  389.     public var expGlobalMod_kills : float;
  390.     public var expGlobalMod_quests : float;
  391.    
  392.    
  393.     private var syncAnimManager : W3SyncAnimationManager;
  394.     public function GetSyncAnimManager() : W3SyncAnimationManager
  395.     {
  396.         if( !syncAnimManager )
  397.         {
  398.             syncAnimManager = new W3SyncAnimationManager in this;
  399.         }
  400.        
  401.         return syncAnimManager;
  402.     }
  403.    
  404.    
  405.    
  406.    
  407.     public function SetEnvironmentID( id : int )
  408.     {
  409.         environmentID = id;
  410.     }
  411.    
  412.     private function SetTimescaleSources()
  413.     {
  414.         timescaleSources.Clear();
  415.         timescaleSources.Grow( EnumGetMax('ETimescaleSource') + 1 );
  416.  
  417.        
  418.         timescaleSources[ ETS_PotionBlizzard ].sourceType = ETS_PotionBlizzard;
  419.         timescaleSources[ ETS_PotionBlizzard ].sourceName = 'PotionBlizzard';
  420.         timescaleSources[ ETS_PotionBlizzard ].sourcePriority = 10;
  421.        
  422.        
  423.         timescaleSources[ ETS_SlowMoTask ].sourceType = ETS_SlowMoTask;
  424.         timescaleSources[ ETS_SlowMoTask ].sourceName = 'SlowMotionTask';
  425.         timescaleSources[ ETS_SlowMoTask ].sourcePriority = 15;
  426.        
  427.        
  428.         timescaleSources[ ETS_HeavyAttack ].sourceType = ETS_HeavyAttack;
  429.         timescaleSources[ ETS_HeavyAttack ].sourceName = 'HeavyAttack';
  430.         timescaleSources[ ETS_HeavyAttack ].sourcePriority = 15;
  431.        
  432.        
  433.         timescaleSources[ ETS_ThrowingAim ].sourceType = ETS_ThrowingAim;
  434.         timescaleSources[ ETS_ThrowingAim ].sourceName = 'ThrowingAim';
  435.         timescaleSources[ ETS_ThrowingAim ].sourcePriority = 15;
  436.        
  437.        
  438.         timescaleSources[ ETS_RaceSlowMo ].sourceType = ETS_RaceSlowMo;
  439.         timescaleSources[ ETS_RaceSlowMo ].sourceName = 'RaceSlowMo';
  440.         timescaleSources[ ETS_RaceSlowMo ].sourcePriority = 10;
  441.        
  442.        
  443.         timescaleSources[ ETS_RadialMenu ].sourceType = ETS_RadialMenu;
  444.         timescaleSources[ ETS_RadialMenu ].sourceName = 'RadialMenu';
  445.         timescaleSources[ ETS_RadialMenu ].sourcePriority = 20;
  446.        
  447.        
  448.         timescaleSources[ ETS_CFM_PlayAnim ].sourceType = ETS_CFM_PlayAnim;
  449.         timescaleSources[ ETS_CFM_PlayAnim ].sourceName = 'CFM_PlayAnim';
  450.         timescaleSources[ ETS_CFM_PlayAnim ].sourcePriority = 25;
  451.        
  452.        
  453.         timescaleSources[ ETS_CFM_On ].sourceType = ETS_CFM_On;
  454.         timescaleSources[ ETS_CFM_On ].sourceName = 'CFM_On';
  455.         timescaleSources[ ETS_CFM_On ].sourcePriority = 20;
  456.        
  457.        
  458.         timescaleSources[ ETS_DebugInput ].sourceType = ETS_DebugInput;
  459.         timescaleSources[ ETS_DebugInput ].sourceName = 'debug_input';
  460.         timescaleSources[ ETS_DebugInput ].sourcePriority = 30;
  461.        
  462.        
  463.         timescaleSources[ ETS_SkillFrenzy ].sourceType = ETS_SkillFrenzy;
  464.         timescaleSources[ ETS_SkillFrenzy ].sourceName = 'skill_frenzy';
  465.         timescaleSources[ ETS_SkillFrenzy ].sourcePriority = 15;
  466.        
  467.        
  468.         timescaleSources[ ETS_HorseMelee ].sourceType = ETS_HorseMelee;
  469.         timescaleSources[ ETS_HorseMelee ].sourceName = 'horse_melee';
  470.         timescaleSources[ ETS_HorseMelee ].sourcePriority = 15;
  471.        
  472.        
  473.         timescaleSources[ ETS_FinisherInput ].sourceType = ETS_FinisherInput;
  474.         timescaleSources[ ETS_FinisherInput ].sourceName = 'finisher_input';
  475.         timescaleSources[ ETS_FinisherInput ].sourcePriority = 15;
  476.        
  477.        
  478.         timescaleSources[ ETS_TutorialFight ].sourceType = ETS_TutorialFight;
  479.         timescaleSources[ ETS_TutorialFight ].sourceName = 'tutorial_fight';
  480.         timescaleSources[ ETS_TutorialFight ].sourcePriority = 25;
  481.        
  482.        
  483.         timescaleSources[ ETS_InstantKill ].sourceType = ETS_InstantKill;
  484.         timescaleSources[ ETS_InstantKill ].sourceName = 'instant_kill';
  485.         timescaleSources[ ETS_InstantKill ].sourcePriority = 5;
  486.     }
  487.    
  488.     public function GetTimescaleSource(src : ETimescaleSource) : name
  489.     {
  490.         return timescaleSources[src].sourceName;
  491.     }
  492.    
  493.     public function GetTimescalePriority(src : ETimescaleSource) : int
  494.     {
  495.         return timescaleSources[src].sourcePriority;
  496.     }
  497.    
  498.     private function UpdateSecondScreen()
  499.     {
  500.         var areaMapPins             : array< SAreaMapPinInfo >;
  501.         var areaMapPinsCount        : int;
  502.         var index_areas             : int;
  503.         var worldPath               : string;
  504.         var localMapPins            : array< SCommonMapPinInstance >;
  505.         var globalMapPins           : array< SCommonMapPinInstance >;
  506.         var mapPin                  : SCommonMapPinInstance;
  507.    
  508.         areaMapPins         = GetCommonMapManager().GetAreaMapPins();
  509.         areaMapPinsCount    = areaMapPins.Size();
  510.         for ( index_areas = 0; index_areas < areaMapPinsCount; index_areas += 1 )
  511.         {      
  512.             mapPin.id = areaMapPins[ index_areas ].areaType;
  513.             mapPin.tag = '0';
  514.             mapPin.type = 'WorldMap';
  515.             mapPin.position = areaMapPins[ index_areas ].position;
  516.             mapPin.isDiscovered = true;
  517.             globalMapPins.PushBack( mapPin );
  518.            
  519.             localMapPins    = GetCommonMapManager().GetMapPinInstances( areaMapPins[ index_areas ].worldPath );
  520.             GetSecondScreenManager().SendAreaMapPins( areaMapPins[ index_areas ].areaType, localMapPins );         
  521.         }      
  522.        
  523.         GetSecondScreenManager().SendGlobalMapPins( globalMapPins );   
  524.     }
  525.    
  526.    
  527.     import final function GetPlatform():int;
  528.    
  529.     private var isSignedIn:bool;
  530.     default isSignedIn = false;
  531.    
  532.     public function isUserSignedIn():bool
  533.     {
  534.         if (GetPlatform() == Platform_PC)
  535.         {
  536.             return true;
  537.         }
  538.         else
  539.         {
  540.             return isSignedIn;
  541.         }
  542.     }
  543.    
  544.     event OnUserSignedIn()
  545.     {
  546.         isSignedIn = true;
  547.        
  548.         GetGuiManager().OnSignIn();
  549.     }
  550.    
  551.     event OnUserSignedOut()
  552.     {
  553.         isSignedIn = false;
  554.        
  555.         GetGuiManager().OnSignOut();
  556.     }
  557.    
  558.     event OnSignInStarted()
  559.     {
  560.         GetGuiManager().OnSignInStarted();
  561.     }
  562.    
  563.     event OnSignInCancelled()
  564.     {
  565.         GetGuiManager().OnSignInCancelled();
  566.     }
  567.    
  568.     import final function SetActiveUserPromiscuous();
  569.    
  570.     import final function ChangeActiveUser();
  571.    
  572.     import final function GetActiveUserDisplayName() : string;
  573.    
  574.    
  575.     import final function IsContentAvailable( content : name ) : bool;
  576.    
  577.    
  578.     import final function ProgressToContentAvailable( content : name ) : int;
  579.    
  580.     import final function ShouldForceInstallVideo() : bool;
  581.    
  582.     import final function IsDebugQuestMenuEnabled() : bool;
  583.    
  584.    
  585.     import final function EnableNewGamePlus( enable : bool );
  586.    
  587.    
  588.     import final function StartNewGamePlus( save : SSavegameInfo ) : ENewGamePlusStatus;
  589.    
  590.     public function OnConfigValueChanged( varName : name, value : string ) : void
  591.     {
  592.         var kinect : CR4KinectSpeechRecognizerListenerScriptProxy;
  593.         kinect = GetKinectSpeechRecognizer();
  594.        
  595.         if ( varName == 'Kinect' )
  596.         {
  597.             if ( value == "true" )
  598.                 kinect.SetEnabled( true );
  599.             else
  600.                 kinect.SetEnabled( false );
  601.         }
  602.     }
  603.    
  604.     public function LoadQuestLevels( filePath: string ) : void
  605.     {  
  606.         var index : int;   
  607.        
  608.         //modSigns: no quest levels option
  609.         if( theGame.params.GetNoQuestLevels() )
  610.         {
  611.             questLevelsFilePaths.Clear();
  612.             questLevelsContainer.Clear();
  613.             return;
  614.         }
  615.        
  616.         index = questLevelsFilePaths.FindFirst( filePath );    
  617.         if( index == -1 )
  618.         {      
  619.             questLevelsFilePaths.PushBack( filePath ); 
  620.             questLevelsContainer.PushBack( LoadCSV( filePath ) );
  621.         }
  622.     }
  623.    
  624.     public function UnloadQuestLevels( filePath: string ) : void
  625.     {  
  626.         var index : int;   
  627.         index = questLevelsFilePaths.FindFirst( filePath );    
  628.         if( index != -1 )
  629.         {
  630.             questLevelsFilePaths.Erase( index );   
  631.             questLevelsContainer.Erase( index );
  632.         }        
  633.     }
  634.    
  635.     event OnGameStarting(restored : bool )
  636.     {
  637.         var diff : int;
  638.    
  639.         if(!restored)
  640.         {
  641.            
  642.             gameplayFacts.Clear();
  643.             gameplayFactsForRemoval.Clear();
  644.         }
  645.        
  646.         if (!FactsDoesExist("lowest_difficulty_used") || GetLowestDifficultyUsed() == EDM_NotSet)
  647.         {
  648.             SetLowestDifficultyUsed(GetDifficultyLevel());
  649.         }
  650.            
  651.         SetHoursPerMinute(0.25);   
  652.         SetTimescaleSources();
  653.        
  654.        
  655.         isDialogOrCutscenePlaying = false;
  656.    
  657.        
  658.         params.Init();
  659.        
  660.        
  661.         witcherLog = new W3GameLog in this;
  662.                
  663.         InitGamerProfile();
  664.            
  665.        
  666.         damageMgr = new W3DamageManager in this;
  667.  
  668.         tooltipSettings = LoadCSV("gameplay\globals\tooltip_settings.csv");
  669.         minimapSettings = LoadCSV("gameplay\globals\minimap_settings.csv");
  670.         LoadHudSettings();
  671.         playerStatisticsSettings = LoadCSV("gameplay\globals\player_statistics_settings.csv");
  672.                    
  673.         LoadQuestLevels( "gameplay\globals\quest_levels.csv" );      
  674.        
  675.         expGlobalModifiers = LoadCSV("gameplay\globals\exp_mods.csv");
  676.         expGlobalMod_kills = StringToFloat( expGlobalModifiers.GetValueAt(0,0) );
  677.         expGlobalMod_quests = StringToFloat( expGlobalModifiers.GetValueAt(1,0) );
  678.        
  679.         InitializeEffectManager();
  680.  
  681.         envMgr = new W3EnvironmentManager in this;
  682.         envMgr.Initialize();
  683.        
  684.         runewordMgr = new W3RunewordManager in this;
  685.         runewordMgr.Init();
  686.        
  687.         theGame.RequestPopup( 'OverlayPopup' );
  688.        
  689.         theSound.Initialize(); 
  690.         if(IsLoadingScreenVideoPlaying())
  691.         {
  692.             theSound.EnterGameState(ESGS_Movie);
  693.         }
  694.     }
  695.        
  696.     private function InitGamerProfile()
  697.     {
  698.         gamerProfile = new W3GamerProfile in this;
  699.         gamerProfile.Init();
  700.     }
  701.    
  702.     public function GetGamerProfile() : W3GamerProfile
  703.     {
  704.        
  705.         if(!gamerProfile)
  706.             InitGamerProfile();
  707.        
  708.         return gamerProfile;
  709.     }
  710.    
  711.     public function OnTick()
  712.     {
  713.         if(envMgr)
  714.             envMgr.Update();
  715.            
  716.        
  717.         if(diffChangePostponed != EDM_NotSet && thePlayer)
  718.         {
  719.             OnDifficultyChanged(diffChangePostponed);
  720.             diffChangePostponed = EDM_NotSet;
  721.         }
  722.        
  723.         FirePostponedPreAttackEvents();
  724.     }  
  725.    
  726.     event OnGameStarted(restored : bool)
  727.     {
  728.         var focusModeController : CFocusModeController;
  729.        
  730.         focusModeController = GetFocusModeController();
  731.        
  732.         if( !restored )
  733.         {
  734.            
  735.             if(FactsQuerySum("started_new_game") <= 0)
  736.             {
  737.                 thePlayer.displayedQuestsGUID.Clear();
  738.  
  739.                 dynamicallySpawnedBoats.Clear();
  740.                 FactsAdd("started_new_game", 1);
  741.             }
  742.         }
  743.        
  744.         if ( FactsQuerySum( "q704_long_night_starts" ) == 0 )
  745.         {
  746.             GetWorld().HideLayerGroup( "quests\main_quests\q704_the_truth\q704_vampires\custom_land_borders" );
  747.         }
  748.        
  749.         if ( focusModeController )
  750.         {
  751.             focusModeController.OnGameStarted();
  752.         }
  753.    
  754.         GetCommonMapManager().OnGameStarted();
  755.        
  756.        
  757.         ClearRichPresence(currentPresence);    
  758.  
  759.         theSound.InitializeAreaMusic( GetCommonMapManager().GetCurrentArea() );
  760.         UpdateSecondScreen();
  761.        
  762.         if( thePlayer && thePlayer.teleportedOnBoatToOtherHUB )
  763.         {
  764.             thePlayer.SetTeleportedOnBoatToOtherHUB( false );
  765.             thePlayer.AddTimer( 'DelayedSpawnAndMountBoat', 0.001f, false );
  766.         }
  767.     }
  768.    
  769.     event OnHandleWorldChange()
  770.     {
  771.         thePlayer.SetTeleportedOnBoatToOtherHUB( true );
  772.     }
  773.  
  774.    
  775.     event OnBeforeWorldChange( worldName : string )
  776.     {
  777.        
  778.         var manager : CCommonMapManager = theGame.GetCommonMapManager();
  779.         if ( manager )
  780.         {
  781.             manager.CacheMapPins();
  782.             manager.ForceSettingLoadingScreenVideoForWorld( worldName );
  783.         }
  784.  
  785.        
  786.         thePlayer.SetUsedVehicle( NULL );
  787.     }
  788.    
  789.     event OnAfterLoadingScreenGameStart()
  790.     {
  791.         var tut : STutorialMessage;
  792.        
  793.        
  794.         theSound.LeaveGameState(ESGS_Movie);
  795.        
  796.        
  797.         theSound.SoundEvent("system_resume");
  798.        
  799.        
  800.         if(ShouldProcessTutorial('TutorialStash') && FactsQuerySum("tut_stash_fresh_playthrough") <= 0)
  801.         {          
  802.            
  803.             tut.type = ETMT_Message;
  804.             tut.tutorialScriptTag = 'TutorialStash';
  805.             tut.canBeShownInMenus = false;
  806.             tut.glossaryLink = false;
  807.             tut.markAsSeenOnShow = true;
  808.            
  809.            
  810.             theGame.GetTutorialSystem().DisplayTutorial(tut);
  811.         }
  812.     }
  813.    
  814.     event  OnSaveStarted( type : ESaveGameType )
  815.     {
  816.         LogChannel( 'Savegame', "OnSaveStarted " + type );
  817.        
  818.     }
  819.  
  820.     event  OnSaveCompleted( type : ESaveGameType, succeeded : bool )
  821.     {
  822.         var hud : CR4ScriptedHud;
  823.         var text : string;
  824.  
  825.         LogChannel( 'Savegame', "OnSaveCompleted " + type + " " + succeeded );
  826.        
  827.         if ( succeeded )
  828.         {
  829.             theGame.GetGuiManager().ShowSavingIndicator();
  830.             theGame.GetGuiManager().HideSavingIndicator();
  831.        
  832.             if (theGame.GetPlatform() == Platform_Xbox1)
  833.             {
  834.                 text = "panel_hud_message_gamesaved_X1";
  835.             }
  836.             else if (theGame.GetPlatform() == Platform_PS4)
  837.             {
  838.                 text = "panel_hud_message_gamesaved_PS4";
  839.             }
  840.             else
  841.             {
  842.                 text = "panel_hud_message_gamesaved";
  843.             }
  844.            
  845.             if ( type == SGT_AutoSave || type == SGT_CheckPoint || type == SGT_ForcedCheckPoint )
  846.             {
  847.                 hud = ( CR4ScriptedHud )GetHud();
  848.                 if ( hud )
  849.                 {
  850.                     hud.HudConsoleMsg( GetLocStringByKeyExt(text) );
  851.                 }
  852.             }
  853.             else
  854.             {
  855.                 thePlayer.DisplayHudMessage( text );
  856.             }
  857.         }
  858.         else if ( type == SGT_QuickSave || type == SGT_Manual )
  859.         {
  860.             if (theGame.GetPlatform() == Platform_Xbox1)
  861.             {
  862.                 text = "panel_hud_message_gamesavedfailed_X1"; 
  863.             }
  864.             else if (theGame.GetPlatform() == Platform_PS4)
  865.             {
  866.                 text = "panel_hud_message_gamesavedfailed_PS4";
  867.             }
  868.             else
  869.             {
  870.                 text = "panel_hud_message_gamesavedfailed";
  871.             }
  872.            
  873.             theGame.GetGuiManager().ShowUserDialog(0, "", text, UDB_Ok);
  874.         }
  875.     }
  876.  
  877.     event OnControllerReconnected()
  878.     {
  879.         if(!theGame.IsBlackscreen() && theGame.IsActive())
  880.         {
  881.             if(theGame.GetGuiManager().IsAnyMenu())
  882.             {
  883.                 theSound.SoundEvent("system_resume_music_only");
  884.             }
  885.             else
  886.             {
  887.                 theSound.SoundEvent("system_resume");
  888.             }
  889.         }
  890.        
  891.         GetGuiManager().OnControllerReconnected();
  892.     }
  893.    
  894.     event OnControllerDisconnected()
  895.     {
  896.         if(!theGame.IsBlackscreen() && theGame.IsActive() && !theGame.GetGuiManager().IsAnyMenu())
  897.         {
  898.            
  899.             theSound.SoundEvent("system_pause");
  900.         }
  901.        
  902.         GetGuiManager().OnControllerDisconnected();
  903.     }
  904.    
  905.     //modSigns: reworked
  906.     event OnGiveReward( target : CEntity, rewardName : name, rewrd : SReward )
  907.     {
  908.         var i                       : int;
  909.         var itemCount               : int;
  910.         var gameplayEntity          : CGameplayEntity;
  911.         var inv                     : CInventoryComponent;
  912.         var goldMultiplier          : float;
  913.         var itemMultiplier          : float;
  914.         var itemsCount              : int;
  915.         var ids                     : array<SItemUniqueId>;
  916.         var itemCategory            : name;
  917.         var moneyWon                : int;
  918.         var rewardMultData          : SRewardMultiplier;
  919.         var lvlDiff                 : int;
  920.         var playerLevel, rewardLevel: int;
  921.         var expModifier             : float;
  922.         var expPoints               : int;
  923.        
  924.         if ( target == thePlayer )
  925.         {
  926.             // exp
  927.             if ( rewrd.experience > 0 && GetWitcherPlayer())
  928.             {
  929.                 expModifier = 1.f; //start with 100% exp
  930.                 playerLevel = thePlayer.GetLevel();
  931.                 if(FactsQuerySum("NewGamePlus") > 0) //reward levels are set for base game
  932.                     playerLevel -= params.GetNewGamePlusLevel(); //decrease player level for NG+
  933.                 if(theGame.params.GetNoQuestLevels()) //no quest levels option
  934.                     rewardLevel = 0;
  935.                 else
  936.                     rewardLevel = rewrd.level;
  937.                 if(theGame.params.GetFixedExp() == false && rewardLevel > 0) //default exp option
  938.                 {
  939.                     lvlDiff = rewardLevel - playerLevel; //level difference: negative for low level quests, positive for hight level quests
  940.                     //lower lever quests give increasingly less exp and higher level quests give more
  941.                     expModifier += lvlDiff * theGame.params.LEVEL_DIFF_XP_MOD;
  942.                     //0% min, 150% max
  943.                     expModifier = ClampF(expModifier, 0, theGame.params.MAX_XP_MOD);
  944.             }
  945.                 //calculate exp
  946.                 expPoints = RoundMath(rewrd.experience * expGlobalMod_quests * expModifier);
  947.                 //always get at least 5 exp
  948.                 expPoints = Max(5, expPoints);
  949.                 //final exp modifier
  950.                 if( theGame.params.GetQuestExpModifier() != 0 )
  951.                     expPoints = RoundMath(expPoints * (1 + theGame.params.GetQuestExpModifier()));
  952.                 GetWitcherPlayer().AddPoints(EExperiencePoint, expPoints, true);
  953.            
  954.             if ( rewrd.achievement > 0 )
  955.             {
  956.                 theGame.GetGamerProfile().AddAchievement( rewrd.achievement );
  957.             }
  958.         }
  959.        
  960.         gameplayEntity = (CGameplayEntity)target;
  961.         if ( gameplayEntity )
  962.         {
  963.             inv = gameplayEntity.GetInventory();
  964.             if ( inv )
  965.             {
  966.                 rewardMultData = thePlayer.GetRewardMultiplierData( rewardName );
  967.                 //modSigns: debug
  968.                 //theGame.witcherLog.AddMessage("rewardName = " + rewardMultData.rewardName);
  969.                
  970.                 if( rewardMultData.isItemMultiplier )
  971.                 {
  972.                     goldMultiplier = 1.0;
  973.                     itemMultiplier = rewardMultData.rewardMultiplier;
  974.                     //modSigns: debug
  975.                     //theGame.witcherLog.AddMessage("itemMultiplier = " + rewardMultData.rewardMultiplier);
  976.                 }
  977.                 else
  978.                 {
  979.                     goldMultiplier = rewardMultData.rewardMultiplier;
  980.                     itemMultiplier = 1.0;
  981.                     //modSigns: debug
  982.                     //theGame.witcherLog.AddMessage("goldMultiplier = " + rewardMultData.rewardMultiplier);
  983.                 }
  984.                
  985.                
  986.                 if ( rewrd.gold > 0 )
  987.                 {
  988.                     inv.AddMoney( (int)(rewrd.gold * goldMultiplier) );
  989.                     thePlayer.RemoveRewardMultiplier(rewardName);      
  990.                     if( target == thePlayer )
  991.                     {
  992.                         moneyWon = (int)(rewrd.gold * goldMultiplier);
  993.                        
  994.                         if ( moneyWon > 0 )
  995.                             thePlayer.DisplayItemRewardNotification('Crowns', moneyWon );
  996.                     }
  997.                 }
  998.                
  999.                
  1000.                
  1001.                 for ( i = 0; i < rewrd.items.Size(); i += 1 )
  1002.                 {
  1003.                     itemsCount = RoundF( rewrd.items[ i ].amount * itemMultiplier );
  1004.                    
  1005.                     if( itemsCount > 0 )
  1006.                     {
  1007.                         ids = inv.AddAnItem( rewrd.items[ i ].item, itemsCount );
  1008.                        
  1009.                         for ( itemCount = 0; itemCount < ids.Size(); itemCount += 1 )
  1010.                         {
  1011.                            
  1012.                             if ( inv.ItemHasTag( ids[i], 'Autogen' ) && GetWitcherPlayer().GetLevel() - 1 > 1 )
  1013.                             {
  1014.                                 inv.GenerateItemLevel( ids[i], true );
  1015.                             }
  1016.                         }
  1017.                        
  1018.                         itemCategory = inv.GetItemCategory( ids[0] );
  1019.                         if ( itemCategory == 'alchemy_recipe' ||  itemCategory == 'crafting_schematic' )
  1020.                         {
  1021.                             inv.ReadSchematicsAndRecipes( ids[0] );
  1022.                         }                      
  1023.                        
  1024.                         if(target == thePlayer)
  1025.                         {
  1026.                            
  1027.                             if( !inv.ItemHasTag( ids[0], 'GwintCard') )
  1028.                             {
  1029.                                 thePlayer.DisplayItemRewardNotification(rewrd.items[ i ].item, RoundF( rewrd.items[ i ].amount * itemMultiplier ) );
  1030.                             }
  1031.                         }
  1032.                     }
  1033.                 }
  1034.             }
  1035.         }
  1036.     }
  1037.  
  1038.     public function IsEffectManagerInitialized() : bool
  1039.     {
  1040.         if(!effectMgr)
  1041.             return false;
  1042.        
  1043.         return effectMgr.IsReady();
  1044.     }
  1045.    
  1046.     public function InitializeEffectManager()
  1047.     {
  1048.         effectMgr = new W3GameEffectManager in this;
  1049.         effectMgr.Initialize();
  1050.     }
  1051.    
  1052.     public function GetLowestDifficultyUsed() : EDifficultyMode
  1053.     {
  1054.         return FactsQuerySum("lowest_difficulty_used");
  1055.     }
  1056.    
  1057.     public function SetLowestDifficultyUsed(d : EDifficultyMode)
  1058.     {
  1059.         FactsSet("lowest_difficulty_used", (int)d);
  1060.     }
  1061.    
  1062.    
  1063.     event OnGameEnded()
  1064.     {  
  1065.         var focusModeController : CFocusModeController;
  1066.        
  1067.         if ( runewordMgr )
  1068.         {
  1069.             delete runewordMgr;
  1070.             runewordMgr = NULL;
  1071.         }
  1072.        
  1073.         focusModeController = GetFocusModeController();
  1074.         if ( focusModeController )
  1075.         {
  1076.             focusModeController.OnGameEnded();
  1077.         }
  1078.        
  1079.         DeactivateEnvironment( environmentID, 0 );
  1080.            
  1081.         if(effectMgr)
  1082.         {
  1083.             delete effectMgr;
  1084.             effectMgr = NULL;
  1085.         }
  1086.        
  1087.         if(envMgr)
  1088.         {
  1089.             delete envMgr;
  1090.             envMgr = NULL;
  1091.         }
  1092.        
  1093.         if( syncAnimManager )
  1094.         {
  1095.             delete syncAnimManager;
  1096.             syncAnimManager = NULL;
  1097.         }
  1098.        
  1099.         RemoveTimeScale( GetTimescaleSource(ETS_RadialMenu) );
  1100.  
  1101.        
  1102.         theSound.Finalize();
  1103.        
  1104.        
  1105.         LogChannel( 'HUD', "GUI Closed" );
  1106.     }
  1107.        
  1108.     public var m_runReactionSceneDialog : bool;
  1109.     public function SetRunReactionSceneDialog( val : bool ){ m_runReactionSceneDialog = val; }
  1110.    
  1111.     public function SetIsDialogOrCutscenePlaying(b : bool)
  1112.     {
  1113.         var witcher         : W3PlayerWitcher;
  1114.         var activePoster    : W3Poster;
  1115.         var hud             : CR4ScriptedHud;
  1116.         var radialModule    : CR4HudModuleRadialMenu;
  1117.         var lootPopup       : CR4LootPopup;
  1118.         var bolts           : SItemUniqueId;
  1119.        
  1120.         isDialogOrCutscenePlaying = b;
  1121.         recentDialogOrCutsceneEndGameTime = GetGameTime();
  1122.        
  1123.         if ( b)
  1124.         {
  1125.             hud = (CR4ScriptedHud)GetHud();
  1126.    
  1127.             if( hud )
  1128.             {
  1129.                 radialModule = (CR4HudModuleRadialMenu)hud.GetHudModule("RadialMenuModule");
  1130.                 if (radialModule && radialModule.IsRadialMenuOpened())
  1131.                 {
  1132.                     radialModule.HideRadialMenu();
  1133.                 }
  1134.             }
  1135.            
  1136.             lootPopup = (CR4LootPopup)GetGuiManager().GetPopup('LootPopup');
  1137.            
  1138.             if (lootPopup)
  1139.             {
  1140.                 lootPopup.ClosePopup();
  1141.             }
  1142.         }
  1143.        
  1144.         if(theGame.GetTutorialSystem() && theGame.GetTutorialSystem().IsRunning())
  1145.         {
  1146.             theGame.GetTutorialSystem().OnCutsceneOrDialogChange(b);
  1147.            
  1148.             if(b)
  1149.             {
  1150.                 FactsAdd("tut_dialog_started", 1, CeilF(ConvertRealTimeSecondsToGameSeconds(1)));
  1151.             }
  1152.         }
  1153.        
  1154.        
  1155.         witcher = GetWitcherPlayer();
  1156.         if(b && witcher && witcher.IsAnyQuenActive())
  1157.         {
  1158.             witcher.FinishQuen( true, true );          
  1159.         }
  1160.        
  1161.         activePoster = thePlayer.GetActivePoster ();
  1162.        
  1163.         if ( activePoster )
  1164.         {
  1165.             CloseMenu('PosterMenu');
  1166.             activePoster.OnEndedObservingPoster();
  1167.         }
  1168.        
  1169.         if ( b && thePlayer.IsHoldingItemInLHand ())
  1170.         {
  1171.             thePlayer.HideUsableItem( true );
  1172.             restoreUsableItemL = true;
  1173.         }
  1174.         if ( !b && restoreUsableItemL )
  1175.         {
  1176.             restoreUsableItemL = false;
  1177.            
  1178.             if ( !thePlayer.IsInCombat() )
  1179.             {
  1180.                 thePlayer.OnUseSelectedItem();
  1181.             }
  1182.         }
  1183.        
  1184.        
  1185.        
  1186.         if(!b && witcher)
  1187.         {
  1188.            
  1189.             if(!witcher.GetItemEquippedOnSlot(EES_Bolt, bolts) || witcher.inv.ItemHasTag(bolts, theGame.params.TAG_INFINITE_AMMO))         
  1190.                 witcher.AddAndEquipInfiniteBolt();
  1191.         }
  1192.     }
  1193.    
  1194.     public final function IsDialogOrCutscenePlaying() : bool
  1195.     {
  1196.         return isDialogOrCutscenePlaying;
  1197.     }
  1198.    
  1199.     public final function GetRecentDialogOrCutsceneEndGameTime() : GameTime
  1200.     {
  1201.         return recentDialogOrCutsceneEndGameTime;
  1202.     }
  1203.    
  1204.     public final function GetSavedEnchanterFunds() : int
  1205.     {
  1206.         return savedEnchanterFunds;
  1207.     }
  1208.  
  1209.     public final function SetSavedEnchanterFunds( value : int )
  1210.     {
  1211.         savedEnchanterFunds = value;
  1212.     }
  1213.  
  1214.    
  1215.     public function SetIsCutscenePlaying(b : bool)
  1216.     {
  1217.         isCutscenePlaying = b;
  1218.     }
  1219.    
  1220.    
  1221.    
  1222.    
  1223.    
  1224.      public function PopulateMenuQueueStartupOnce( out menus : array< name > )
  1225.     {
  1226.         menus.PushBack( 'StartupMoviesMenu' );
  1227.     }
  1228.    
  1229.      public function PopulateMenuQueueStartupAlways( out menus : array< name > )
  1230.     {
  1231.         var menuType : int;
  1232.        
  1233.         menuType = ChooseRandomMainMenuIfNotChosenYet();
  1234.         if (GetPlatform() != Platform_PC)
  1235.         {
  1236.             switch ( menuType )
  1237.             {
  1238.                 case 1:
  1239.                     menus.PushBack( 'StartScreenMenuEP1' );
  1240.                     break;
  1241.                 case 2:
  1242.                     menus.PushBack( 'StartScreenMenuEP2' );
  1243.                     break;
  1244.                 case 0:
  1245.                 default:
  1246.                     menus.PushBack( 'StartScreenMenu' );
  1247.                     break;
  1248.             }
  1249.         }
  1250.     }
  1251.    
  1252.      public function PopulateMenuQueueConfig( out menus : array< name > )
  1253.     {
  1254.         var inGameConfigWrapper : CInGameConfigWrapper;
  1255.         inGameConfigWrapper = (CInGameConfigWrapper)theGame.GetInGameConfigWrapper();
  1256.        
  1257.         if( GetPlatform() != Platform_PC )
  1258.         {
  1259.             menus.PushBack( 'RescaleMenu' );
  1260.             menus.PushBack( 'MainGammaMenu' );
  1261.         }
  1262.     }
  1263.  
  1264.      public function PopulateMenuQueueMainOnce( out menus : array< name > )
  1265.     {
  1266.         if (GetPlatform() != Platform_PC)
  1267.         {
  1268.             menus.PushBack( 'AutosaveWarningMenu' );
  1269.         }
  1270.         menus.PushBack( 'RecapMoviesMenu' );
  1271.     }
  1272.    
  1273.      public function PopulateMenuQueueMainAlways( out menus : array< name > )
  1274.     {
  1275.         var menuType : int;
  1276.        
  1277.         menuType = ChooseRandomMainMenuIfNotChosenYet();
  1278.         switch ( menuType )
  1279.         {
  1280.             case 1:
  1281.                 menus.PushBack( 'CommonMainMenuEP1' );
  1282.                 break;
  1283.             case 2:
  1284.                 menus.PushBack( 'CommonMainMenuEP2' );
  1285.                 break;
  1286.             case 0:
  1287.             default:
  1288.                 menus.PushBack( 'CommonMainMenu' );
  1289.                 break;
  1290.         }
  1291.     }
  1292.  
  1293.     private var _mainMenuType : int; default _mainMenuType = -1;
  1294.  
  1295.     public function GetChosenMainMenuType() : int
  1296.     {
  1297.         return _mainMenuType;
  1298.     }
  1299.    
  1300.     private function ChooseRandomMainMenuIfNotChosenYet() : int
  1301.     {
  1302.         var availableMainMenuTypes : array< int >;
  1303.         var seed : int;
  1304.         var index : int;
  1305.        
  1306.         if ( _mainMenuType > -1 )
  1307.         {
  1308.             return _mainMenuType;
  1309.         }
  1310.        
  1311.         availableMainMenuTypes.PushBack( 0 );
  1312.        
  1313.         if (theGame.GetDLCManager().IsEP1Available())
  1314.         {
  1315.             availableMainMenuTypes.PushBack( 1 );
  1316.         }
  1317.         if (theGame.GetDLCManager().IsEP2Available())
  1318.         {
  1319.             availableMainMenuTypes.PushBack( 2 );
  1320.         }
  1321.  
  1322.         seed = CalcSeed( theGame );
  1323.         index = (int)RandNoiseF( seed, availableMainMenuTypes.Size() );
  1324.  
  1325.         _mainMenuType = availableMainMenuTypes[ index ];
  1326.         LogChannel('asd', "RAND " + seed + "   " + index + "   " + _mainMenuType );
  1327.  
  1328.         return _mainMenuType;
  1329.  
  1330.         return _mainMenuType;
  1331.     }
  1332.  
  1333.     public function GetNewGameDefinitionFilename() : string
  1334.     {
  1335.         return "game/witcher3.redgame";
  1336.     }
  1337.    
  1338.    
  1339.    
  1340.    
  1341.    
  1342.     public function GetCurrentZone() : EZoneName
  1343.     {
  1344.         return zoneName;
  1345.     }
  1346.    
  1347.     public function SetCurrentZone( tag : name )
  1348.     {
  1349.         zoneName = ZoneNameToType( tag );
  1350.     }
  1351.        
  1352.    
  1353.    
  1354.    
  1355.    
  1356.     private var uiHorizontalFrameScale : float; default uiHorizontalFrameScale              = 1.0;
  1357.     private var uiVerticalFrameScale : float;   default uiVerticalFrameScale                = 1.0;
  1358.     private var uiScale : float;                default uiScale                             = 1.0; 
  1359.     private var uiGamepadScaleGain : float;     default uiGamepadScaleGain                  = 0.0;
  1360.     private var uiOpacity : float;              default uiOpacity                           = 0.8;
  1361.    
  1362.    
  1363.     protected var isColorBlindMode:bool;
  1364.     public function getColorBlindMode():bool
  1365.     {
  1366.         return isColorBlindMode;
  1367.     }
  1368.     public function setColorBlindMode(value:bool)
  1369.     {
  1370.         isColorBlindMode = value;
  1371.     }
  1372.    
  1373.    
  1374.     private var menuToOpen : name;
  1375.     public function GetMenuToOpen() : name
  1376.     {
  1377.         return menuToOpen;
  1378.     }
  1379.     public function SetMenuToOpen( menu : name )
  1380.     {
  1381.         menuToOpen = menu;
  1382.     }
  1383.    
  1384.     public function RequestMenuWithBackground( menu : name, backgroundMenu : name, optional initData : IScriptable )
  1385.     {
  1386.         var commonMenu : CR4CommonMenu;
  1387.         var guiManager : CR4GuiManager;
  1388.        
  1389.         guiManager = GetGuiManager();
  1390.         commonMenu = (CR4CommonMenu)guiManager.GetRootMenu();
  1391.         if( commonMenu )
  1392.         {
  1393.             commonMenu.SwitchToSubMenu(menu,"");
  1394.         }
  1395.         else
  1396.         {
  1397.             if ( guiManager.IsAnyMenu() )
  1398.             {
  1399.                 guiManager.GetRootMenu().CloseMenu();
  1400.             }
  1401.            
  1402.             SetMenuToOpen( menu );
  1403.             theGame.RequestMenu( backgroundMenu, initData );
  1404.         }
  1405.     }
  1406.    
  1407.     public function OpenPopup(DataObject : W3PopupData) : void
  1408.     {
  1409.         theGame.RequestMenu('PopupMenu', DataObject);
  1410.     }
  1411.  
  1412.     public function SetUIVerticalFrameScale( value : float )
  1413.     {
  1414.         uiVerticalFrameScale = value;
  1415.     }
  1416.  
  1417.     public function GetUIVerticalFrameScale() : float
  1418.     {
  1419.         return uiVerticalFrameScale;
  1420.     }
  1421.  
  1422.     public function SetUIHorizontalFrameScale( value : float )
  1423.     {
  1424.         var horizontalPlusFrameScale : float;
  1425.         uiHorizontalFrameScale = value;
  1426.         horizontalPlusFrameScale = theGame.GetUIHorizontalPlusFrameScale();
  1427.         uiHorizontalFrameScale = uiHorizontalFrameScale * horizontalPlusFrameScale;
  1428.     }
  1429.    
  1430.     public function GetUIHorizontalFrameScale() : float
  1431.     {
  1432.         return uiHorizontalFrameScale;
  1433.     }
  1434.    
  1435.     public function SetUIScale( value : float )
  1436.     {
  1437.         uiScale = value;
  1438.     }
  1439.  
  1440.     public function GetUIScale() : float
  1441.     {
  1442.         return uiScale;
  1443.     }
  1444.  
  1445.     public function SetUIGamepadScaleGain( value : float )
  1446.     {
  1447.         uiGamepadScaleGain = value;
  1448.     }
  1449.  
  1450.     public function GetUIGamepadScaleGain() : float
  1451.     {
  1452.         return uiGamepadScaleGain;
  1453.     }
  1454.  
  1455.     public function SetDeathSaveLockId(i : int)
  1456.     {
  1457.         deathSaveLockId = i;
  1458.     }
  1459.    
  1460.     public function SetUIOpacity( value : float )
  1461.     {
  1462.         uiOpacity = value;
  1463.     }
  1464.  
  1465.     public function GetUIOpacity() : float
  1466.     {
  1467.         return uiOpacity;
  1468.     }
  1469.    
  1470.     public function setDialogDisplayDisabled( value : bool )
  1471.     {
  1472.         isDialogDisplayDisabled = value;
  1473.     }
  1474.  
  1475.     public function LoadHudSettings()
  1476.     {
  1477.         var inGameConfigWrapper : CInGameConfigWrapper;
  1478.        
  1479.         hudSettings = LoadCSV("gameplay\globals\hud_settings.csv");
  1480.            
  1481.         inGameConfigWrapper = (CInGameConfigWrapper)theGame.GetInGameConfigWrapper();
  1482.            
  1483.         isDialogDisplayDisabled = inGameConfigWrapper.GetVarValue('Localization', 'Subtitles') == "false";
  1484.            
  1485.         SetUIVerticalFrameScale( StringToFloat(inGameConfigWrapper.GetVarValue('Hidden', 'uiVerticalFrameScale')) );
  1486.         SetUIHorizontalFrameScale( StringToFloat(inGameConfigWrapper.GetVarValue('Hidden', 'uiHorizontalFrameScale')) );
  1487.            
  1488.         uiScale = StringToFloat(theGame.hudSettings.GetValueAt(1,theGame.hudSettings.GetRowIndexAt( 0, "uiScale" )));  
  1489.         uiOpacity = StringToFloat(theGame.hudSettings.GetValueAt(1,theGame.hudSettings.GetRowIndexAt( 0, "uiOpacity" )));  
  1490.     }
  1491.    
  1492.     event OnRefreshUIScaling()
  1493.     {
  1494.         var inGameConfigWrapper : CInGameConfigWrapper;
  1495.         inGameConfigWrapper = (CInGameConfigWrapper)theGame.GetInGameConfigWrapper();
  1496.         SetUIVerticalFrameScale( StringToFloat(inGameConfigWrapper.GetVarValue('Hidden', 'uiVerticalFrameScale')) );
  1497.         SetUIHorizontalFrameScale( StringToFloat(inGameConfigWrapper.GetVarValue('Hidden', 'uiHorizontalFrameScale')) );
  1498.     }
  1499.    
  1500.     event OnSpawnPlayerHorse( )
  1501.     {
  1502.         var createEntityHelper              : CR4CreateEntityHelper;
  1503.        
  1504.         thePlayer.RaiseEvent('HorseSummon');
  1505.        
  1506.         if( !thePlayer.GetHorseWithInventory()
  1507.             ||  !thePlayer.GetHorseWithInventory().IsAlive()
  1508.             ||  ( !thePlayer.WasVisibleInScaledFrame( thePlayer.GetHorseWithInventory(), 1.5f, 1.5f ) && VecDistanceSquared( thePlayer.GetWorldPosition(), thePlayer.GetHorseWithInventory().GetWorldPosition() ) > 900 )
  1509.             ||  VecDistanceSquared( thePlayer.GetWorldPosition(), thePlayer.GetHorseWithInventory().GetWorldPosition() ) > 1600 )
  1510.         {
  1511.             createEntityHelper = new CR4CreateEntityHelper in this;
  1512.             createEntityHelper.SetPostAttachedCallback( this, 'OnPlayerHorseSummoned' );
  1513.             theGame.SummonPlayerHorse( true, createEntityHelper );
  1514.         }
  1515.         else
  1516.         {
  1517.            
  1518.             thePlayer.GetHorseWithInventory().SignalGameplayEventParamObject( 'HorseSummon', thePlayer );
  1519.         }
  1520.        
  1521.         thePlayer.OnSpawnHorse();
  1522.     }
  1523.  
  1524.     private function OnPlayerHorseSummoned( horseEntity : CEntity )
  1525.     {
  1526.         var saddle          : SItemUniqueId;
  1527.         var horseManager    : W3HorseManager;
  1528.         var horse           : CActor;
  1529.  
  1530.        
  1531.         horseManager = GetWitcherPlayer().GetHorseManager();
  1532.         saddle = horseManager.GetItemInSlot(EES_HorseSaddle);
  1533.         if ( horseManager.GetInventoryComponent().GetItemName(saddle) == 'Devil Saddle' )
  1534.         {
  1535.            
  1536.             horse = (CActor)horseEntity;
  1537.             horse.AddEffectDefault(EET_WeakeningAura, horse, 'horse saddle', false);
  1538.         }
  1539.        
  1540.         thePlayer.GetHorseWithInventory().SignalGameplayEventParamObject( 'HorseSummon', thePlayer );
  1541.        
  1542.         GetWitcherPlayer().GetHorseManager().ApplyHorseUpdateOnSpawn();
  1543.     }
  1544.    
  1545.    
  1546.     event OnTutorialMessageForChoiceLines( flags : int )
  1547.     {
  1548.        
  1549.        
  1550.        
  1551.         GameplayFactsSet('dialog_choice_flags', flags);
  1552.         GameplayFactsAdd('dialog_choice_is_set', 1, 1);
  1553.     }
  1554.    
  1555.     event OnTutorialMessageForChoiceLineChosen( flags : int )
  1556.     {
  1557.         GameplayFactsSet('dialog_used_choice_flags', flags);
  1558.         GameplayFactsAdd('dialog_used_choice_is_set', 1, 1);
  1559.     }  
  1560.    
  1561.    
  1562.    
  1563.    
  1564.    
  1565.    
  1566.    
  1567.  
  1568.     public function GameplayFactsAdd(factName : string, optional value : int, optional realtimeSecsValidFor : int)
  1569.     {
  1570.         var idx : int;
  1571.         var newFact : SGameplayFact;
  1572.         var newFactRemoval : SGameplayFactRemoval;
  1573.        
  1574.         if(value < 0)
  1575.             return;
  1576.         else if(value == 0)
  1577.             value = 1;
  1578.            
  1579.         idx = GetGameplayFactIndex(factName);
  1580.         if(idx >= 0)
  1581.         {
  1582.             gameplayFacts[idx].value += value;
  1583.         }
  1584.         else
  1585.         {
  1586.             newFact.factName = factName;
  1587.             newFact.value = value;
  1588.             gameplayFacts.PushBack(newFact);
  1589.         }
  1590.        
  1591.         if(realtimeSecsValidFor > 0)
  1592.         {
  1593.             newFactRemoval.factName = factName;
  1594.             newFactRemoval.value = value;
  1595.             newFactRemoval.timerID = thePlayer.AddTimer('GameplayFactRemove', realtimeSecsValidFor, , , , true, false);
  1596.            
  1597.             gameplayFactsForRemoval.PushBack(newFactRemoval);
  1598.         }
  1599.     }
  1600.    
  1601.     public function GameplayFactsSet(factName : string, value : int)
  1602.     {
  1603.         var idx : int;
  1604.         var newFact : SGameplayFact;
  1605.        
  1606.         idx = GetGameplayFactIndex(factName);
  1607.         if(idx >= 0)
  1608.         {
  1609.             gameplayFacts[idx].value = value;
  1610.         }
  1611.         else
  1612.         {
  1613.             newFact.factName = factName;
  1614.             newFact.value = value;
  1615.             gameplayFacts.PushBack(newFact);
  1616.         }
  1617.     }
  1618.    
  1619.     public function GameplayFactsRemove(factName : string)
  1620.     {
  1621.         var i : int;
  1622.        
  1623.         for(i=0; i<gameplayFacts.Size(); i+=1)
  1624.         {
  1625.             if(gameplayFacts[i].factName == factName)
  1626.             {
  1627.                 gameplayFacts.EraseFast(i);
  1628.                 return;
  1629.             }
  1630.         }
  1631.     }
  1632.    
  1633.    
  1634.     public function GameplayFactRemoveFromTimer(timerID : int)
  1635.     {
  1636.         var idx, factIdx : int;
  1637.        
  1638.         idx = GetGameplayFactsForRemovalIndex(timerID);
  1639.         if(idx < 0)
  1640.         {
  1641.             LogAssert(false, "CR4Game.GameplayFactRemoveFromTimer: trying to process non-existant timer <<" + timerID + ">>");
  1642.             return;
  1643.         }
  1644.        
  1645.         factIdx = GetGameplayFactIndex(gameplayFactsForRemoval[idx].factName);
  1646.         if(factIdx < 0)                
  1647.             return;
  1648.        
  1649.         gameplayFacts[factIdx].value -= gameplayFactsForRemoval[idx].value;
  1650.         if(gameplayFacts[factIdx].value <= 0)
  1651.             gameplayFacts.EraseFast(factIdx);
  1652.            
  1653.         gameplayFactsForRemoval.EraseFast(idx);
  1654.     }
  1655.  
  1656.     public function GameplayFactsQuerySum(factName : string) : int
  1657.     {
  1658.         var idx : int;
  1659.        
  1660.         idx = GetGameplayFactIndex(factName);
  1661.         if(idx >= 0)       
  1662.             return gameplayFacts[idx].value;
  1663.            
  1664.         return 0;
  1665.     }
  1666.    
  1667.     private function GetGameplayFactIndex(factName : string) : int
  1668.     {
  1669.         var i : int;
  1670.        
  1671.         for(i=0; i<gameplayFacts.Size(); i+=1)
  1672.         {
  1673.             if(gameplayFacts[i].factName == factName)
  1674.                 return i;          
  1675.         }
  1676.        
  1677.         return -1;
  1678.     }
  1679.    
  1680.     private function GetGameplayFactsForRemovalIndex(timerID : int) : int
  1681.     {
  1682.         var i : int;
  1683.        
  1684.         for(i=0; i<gameplayFactsForRemoval.Size(); i+=1)
  1685.         {
  1686.             if(gameplayFactsForRemoval[i].timerID == timerID)
  1687.                 return i;          
  1688.         }
  1689.        
  1690.         return -1;
  1691.     }
  1692.    
  1693.     public function GetR4ReactionManager() : CR4ReactionManager
  1694.     {
  1695.         return ( CR4ReactionManager ) GetBehTreeReactionManager();
  1696.     }
  1697.        
  1698.     public function GetDifficultyMode() : EDifficultyMode
  1699.     {
  1700.         var diff : EDifficultyMode;
  1701.                
  1702.         diff = GetDifficultyLevel();
  1703.        
  1704.        
  1705.         if(diff == EDM_NotSet)
  1706.         {
  1707.             return EDM_Medium;
  1708.         }
  1709.        
  1710.         return diff;
  1711.     }
  1712.    
  1713.     event OnDifficultyChanged(newDifficulty : int)
  1714.     {
  1715.         var i : int;
  1716.         var lowestDiff : EDifficultyMode;
  1717.        
  1718.        
  1719.         if(!thePlayer)
  1720.         {
  1721.             diffChangePostponed = newDifficulty;
  1722.             return false;
  1723.         }
  1724.        
  1725.         theTelemetry.SetCommonStatI32(CS_DIFFICULTY_LVL, newDifficulty);
  1726.  
  1727.        
  1728.         lowestDiff = GetLowestDifficultyUsed();    
  1729.         if(lowestDiff != newDifficulty && MinDiffMode(lowestDiff, newDifficulty) == newDifficulty)
  1730.             SetLowestDifficultyUsed(newDifficulty);
  1731.            
  1732.         UpdateStatsForDifficultyLevel( GetSpawnDifficultyMode() );
  1733.     }
  1734.    
  1735.    
  1736.     public function OnPlayerChanged()
  1737.     {
  1738.         var i : int;
  1739.         var buffs : array<CBaseGameplayEffect>;
  1740.         var witcher : W3PlayerWitcher;
  1741.        
  1742.        
  1743.         thePlayer.RemoveAllNonAutoBuffs( , true );
  1744.        
  1745.        
  1746.         buffs = thePlayer.GetBuffs();
  1747.         for(i=0; i<buffs.Size(); i+=1)
  1748.         {
  1749.             buffs[i].ResumeForced();
  1750.         }
  1751.    
  1752.        
  1753.         GetGameCamera().StopEffect( 'frost' );
  1754.         DisableCatViewFx( 1.0f );
  1755.         thePlayer.StopEffect('critical_low_health');
  1756.         DisableDrunkFx();
  1757.         thePlayer.StopEffect('critical_toxicity');
  1758.        
  1759.         if(GetWitcherPlayer())
  1760.             GetWitcherPlayer().UpdateEncumbrance();
  1761.    
  1762.        
  1763.        
  1764.         UpdateStatsForDifficultyLevel( GetSpawnDifficultyMode() );
  1765.        
  1766.        
  1767.         RemoveAllTimeScales();
  1768.     }
  1769.    
  1770.    
  1771.    
  1772.     public function GetSpawnDifficultyMode() : EDifficultyMode
  1773.     {
  1774.         //if( thePlayer && thePlayer.IsCiri() )
  1775.         //{
  1776.         //  return MinDiffMode( GetDifficultyMode(), EDM_Medium );
  1777.         //}
  1778.         return GetDifficultyMode();
  1779.     }
  1780.    
  1781.     public function UpdateStatsForDifficultyLevel( difficulty : EDifficultyMode )
  1782.     {
  1783.         var i : int;
  1784.         var actor : CActor;
  1785.         var npcs : array< CNewNPC >;
  1786.         GetAllNPCs( npcs );
  1787.         for( i=0; i < npcs.Size(); i+=1 )
  1788.         {
  1789.             actor = (CActor)npcs[i];
  1790.             if( actor )
  1791.             {
  1792.                 actor.UpdateStatsForDifficultyLevel( difficulty );
  1793.             }
  1794.         }
  1795.     }
  1796.  
  1797.     public function CanTrackQuest( questEntry : CJournalQuest ) : bool
  1798.     {
  1799.         var questName : string;
  1800.         var baseName : string;
  1801.         var i : int;
  1802.         var questCount : int;
  1803.         var playerLevel : int;
  1804.         var questLevel : int;
  1805.         var questLevels : C2dArray;
  1806.         var questLevelsCount : int;
  1807.         var iterQuestLevels : int;
  1808.        
  1809.         baseName = questEntry.baseName;
  1810.         playerLevel = thePlayer.GetLevel();
  1811.  
  1812.         if ( questEntry.GetType() == MonsterHunt )
  1813.         {
  1814.             questLevelsCount = theGame.questLevelsContainer.Size();
  1815.             for( iterQuestLevels = 0; iterQuestLevels < questLevelsCount; iterQuestLevels += 1 )
  1816.             {
  1817.                 questLevels = theGame.questLevelsContainer[iterQuestLevels];
  1818.            
  1819.                 questCount = questLevels.GetNumRows();
  1820.                 for( i = 0; i < questCount; i += 1 )
  1821.                 {
  1822.                     questName = questLevels.GetValueAtAsName( 0, i );
  1823.                     if ( questName == baseName )
  1824.                     {
  1825.                         questLevel = NameToInt( questLevels.GetValueAtAsName( 1, i ) );
  1826.                         return playerLevel >= questLevel - 5;
  1827.                     }
  1828.                 }
  1829.             }
  1830.         }
  1831.         return true;
  1832.     }
  1833.    
  1834.     import final function GetGwintManager() : CR4GwintManager;
  1835.    
  1836.     public function IsBlackscreenOrFading() : bool
  1837.     {
  1838.         return IsBlackscreen() || IsFading();
  1839.     }
  1840.        
  1841.    
  1842.    
  1843.    
  1844.  
  1845.     var postponedPreAttackEvents : array< SPostponedPreAttackEvent >;
  1846.    
  1847.     event OnPreAttackEvent( entity : CGameplayEntity, animEventName : name, animEventType : EAnimationEventType, data : CPreAttackEventData, animInfo : SAnimationEventAnimInfo )
  1848.     {
  1849.         var postponedPreAttackEvent : SPostponedPreAttackEvent;
  1850.        
  1851.         postponedPreAttackEvent.entity      = entity;
  1852.         postponedPreAttackEvent.eventName   = animEventName;
  1853.         postponedPreAttackEvent.eventType   = animEventType;
  1854.         postponedPreAttackEvent.data        = data;
  1855.         postponedPreAttackEvent.animInfo    = animInfo;
  1856.        
  1857.         postponedPreAttackEvents.PushBack( postponedPreAttackEvent );
  1858.     }
  1859.  
  1860.     function FirePostponedPreAttackEvents()
  1861.     {
  1862.         var i, size : int;
  1863.         var entity : CGameplayEntity;
  1864.        
  1865.         size = postponedPreAttackEvents.Size();
  1866.         for ( i = 0; i < size; i+=1 )
  1867.         {
  1868.             entity = postponedPreAttackEvents[i].entity;
  1869.             if ( entity )
  1870.             {
  1871.                 entity.OnPreAttackEvent( postponedPreAttackEvents[i].eventName,
  1872.                                          postponedPreAttackEvents[i].eventType,
  1873.                                          postponedPreAttackEvents[i].data,
  1874.                                          postponedPreAttackEvents[i].animInfo );
  1875.             }
  1876.         }
  1877.         postponedPreAttackEvents.Clear();
  1878.     }
  1879.    
  1880.     public final function AddDynamicallySpawnedBoatHandle(handle : EntityHandle)
  1881.     {
  1882.         var i : int;
  1883.        
  1884.         if(EntityHandleGet(handle))
  1885.         {          
  1886.             dynamicallySpawnedBoats.PushBack(handle);
  1887.            
  1888.             if(dynamicallySpawnedBoats.Size() >= theGame.params.MAX_DYNAMICALLY_SPAWNED_BOATS)
  1889.             {
  1890.                
  1891.                 for(i=dynamicallySpawnedBoatsToDestroy.Size()-1; i>=0; i-=1)
  1892.                 {
  1893.                     if(!EntityHandleGet(dynamicallySpawnedBoats[i]))
  1894.                         dynamicallySpawnedBoats.EraseFast(i);
  1895.                 }
  1896.            
  1897.                 if(dynamicallySpawnedBoats.Size() >= theGame.params.MAX_DYNAMICALLY_SPAWNED_BOATS)
  1898.                 {
  1899.                     dynamicallySpawnedBoatsToDestroy.PushBack( dynamicallySpawnedBoats[0] );
  1900.                     dynamicallySpawnedBoats.Erase(0);
  1901.                 }
  1902.             }
  1903.         }
  1904.     }
  1905.    
  1906.     public final function IsBoatMarkedForDestroy(boat : W3Boat) : bool
  1907.     {
  1908.         var handle : EntityHandle;
  1909.         var i : int;
  1910.        
  1911.         EntityHandleSet(handle, boat);
  1912.         for(i=0; i<dynamicallySpawnedBoatsToDestroy.Size(); i+=1)
  1913.         {
  1914.             if(handle == dynamicallySpawnedBoatsToDestroy[i])
  1915.             {
  1916.                 dynamicallySpawnedBoatsToDestroy.EraseFast(i);
  1917.                 return true;
  1918.             }
  1919.         }
  1920.        
  1921.         return false;
  1922.     }
  1923.  
  1924.     public final function VibrateControllerVeryLight(optional duration : float)
  1925.     {
  1926.         if ( !theInput.LastUsedGamepad() )
  1927.             return;
  1928.            
  1929.         if(duration == 0)
  1930.             duration = 0.15f;
  1931.            
  1932.         if(IsSpecificRumbleActive(0.2, 0))
  1933.         {
  1934.             OverrideRumbleDuration(0.2, 0, duration);
  1935.         }
  1936.         else
  1937.         {
  1938.             VibrateController(0.2, 0, duration);
  1939.         }
  1940.     }
  1941.    
  1942.     public final function VibrateControllerLight(optional duration : float)
  1943.     {
  1944.         if ( !theInput.LastUsedGamepad() )
  1945.             return;
  1946.            
  1947.         if(duration == 0)
  1948.             duration = 0.2f;
  1949.            
  1950.         if(IsSpecificRumbleActive(0.5, 0))
  1951.         {
  1952.             OverrideRumbleDuration(0.5, 0, duration);
  1953.         }
  1954.         else
  1955.         {
  1956.             VibrateController(0.5, 0, duration);
  1957.         }
  1958.     }
  1959.    
  1960.     public final function VibrateControllerHard(optional duration : float)
  1961.     {
  1962.         if ( !theInput.LastUsedGamepad() )
  1963.             return;
  1964.            
  1965.         if(duration == 0)
  1966.             duration = 0.2f;
  1967.        
  1968.         if(IsSpecificRumbleActive(0.75, 0.75))
  1969.         {
  1970.             OverrideRumbleDuration(0.75, 0.75, duration);
  1971.         }
  1972.         else
  1973.         {
  1974.             VibrateController(0.75, 0.75, duration);
  1975.         }
  1976.     }
  1977.    
  1978.     public final function VibrateControllerVeryHard(optional duration : float)
  1979.     {
  1980.         if ( !theInput.LastUsedGamepad() )
  1981.             return;
  1982.            
  1983.         if(duration == 0)
  1984.             duration = 0.5f;
  1985.        
  1986.         if(IsSpecificRumbleActive(1, 1))
  1987.         {
  1988.             OverrideRumbleDuration(1, 1, duration);
  1989.         }
  1990.         else
  1991.         {
  1992.             VibrateController(1, 1, duration);
  1993.         }
  1994.     }
  1995.     import public final function GetWorldDLCExtender() : CR4WorldDLCExtender;
  1996.    
  1997.     public function GetMiniMapSize( areaType : int ) : float
  1998.     {
  1999.         var mapSize  : float;
  2000.         var valueAsString : string;
  2001.        
  2002.         valueAsString = minimapSettings.GetValueAt( 1, areaType );
  2003.        
  2004.         if( StrLen( valueAsString ) != 0 )
  2005.         {
  2006.             mapSize = StringToFloat( valueAsString );
  2007.         }
  2008.         else
  2009.         {
  2010.             mapSize = GetWorldDLCExtender().GetMiniMapSize( areaType );
  2011.         }
  2012.         return mapSize;
  2013.     }
  2014.    
  2015.     public function GetMiniMapTileCount( areaType : int ) : int
  2016.     {
  2017.         var tileCount  : int;
  2018.         var valueAsString : string;
  2019.        
  2020.         valueAsString = minimapSettings.GetValueAt( 2, areaType );
  2021.        
  2022.         if( StrLen( valueAsString ) != 0 )
  2023.         {
  2024.             tileCount = StringToInt( valueAsString );
  2025.         }
  2026.         else
  2027.         {
  2028.             tileCount = GetWorldDLCExtender().GetMiniMapTileCount( areaType );
  2029.         }
  2030.         return tileCount;
  2031.     }
  2032.    
  2033.     public function GetMiniMapExteriorTextureSize( areaType : int ) : int
  2034.     {
  2035.         var exteriorTextureSize  : int;
  2036.         var valueAsString : string;
  2037.        
  2038.         valueAsString = minimapSettings.GetValueAt( 3, areaType );
  2039.        
  2040.         if( StrLen( valueAsString ) != 0 )
  2041.         {
  2042.             exteriorTextureSize = StringToInt( valueAsString );
  2043.         }
  2044.         else
  2045.         {
  2046.             exteriorTextureSize = GetWorldDLCExtender().GetMiniMapExteriorTextureSize( areaType );
  2047.         }
  2048.         return exteriorTextureSize;
  2049.     }
  2050.    
  2051.        
  2052.     public function GetMiniMapInteriorTextureSize( areaType : int ) : int
  2053.     {
  2054.         var interiorTextureSize  : int;
  2055.         var valueAsString : string;
  2056.        
  2057.         valueAsString = minimapSettings.GetValueAt( 4, areaType );
  2058.        
  2059.         if( StrLen( valueAsString ) != 0 )
  2060.         {
  2061.             interiorTextureSize = StringToInt( valueAsString );
  2062.         }
  2063.         else
  2064.         {
  2065.             interiorTextureSize = GetWorldDLCExtender().GetMiniMapInteriorTextureSize( areaType );
  2066.         }
  2067.         return interiorTextureSize;
  2068.     }
  2069.    
  2070.     public function GetMiniMapTextureSize( areaType : int ) : int
  2071.     {
  2072.         var textureSize  : int;
  2073.         var valueAsString : string;
  2074.        
  2075.         valueAsString = minimapSettings.GetValueAt( 5, areaType );
  2076.        
  2077.         if( StrLen( valueAsString ) != 0 )
  2078.         {
  2079.             textureSize = StringToInt( valueAsString );
  2080.         }
  2081.         else
  2082.         {
  2083.             textureSize = GetWorldDLCExtender().GetMiniMapTextureSize( areaType );
  2084.         }
  2085.         return textureSize;
  2086.     }
  2087.    
  2088.     public function GetMiniMapMinLod( areaType : int ) : int
  2089.     {
  2090.         var minLod  : int;
  2091.         var valueAsString : string;
  2092.        
  2093.         valueAsString = minimapSettings.GetValueAt( 6, areaType );
  2094.        
  2095.         if( StrLen( valueAsString ) != 0 )
  2096.         {
  2097.             minLod = StringToInt( valueAsString );
  2098.         }
  2099.         else
  2100.         {
  2101.             minLod = GetWorldDLCExtender().GetMiniMapMinLod( areaType );
  2102.         }
  2103.         return minLod;
  2104.     }
  2105.    
  2106.     public function GetMiniMapMaxLod( areaType : int ) : int
  2107.     {
  2108.         var maxLod  : int;
  2109.         var valueAsString : string;
  2110.        
  2111.         valueAsString = minimapSettings.GetValueAt( 7, areaType );
  2112.        
  2113.         if( StrLen( valueAsString ) != 0 )
  2114.         {
  2115.             maxLod = StringToInt( valueAsString );
  2116.         }
  2117.         else
  2118.         {
  2119.             maxLod = GetWorldDLCExtender().GetMiniMapMaxLod( areaType );
  2120.         }
  2121.         return maxLod;
  2122.     }
  2123.  
  2124.    
  2125.     public function GetMiniMapExteriorTextureExtension( areaType : int ) : string
  2126.     {
  2127.         var exteriorTextureExtension  : string;
  2128.         var valueAsString : string;
  2129.        
  2130.         valueAsString = minimapSettings.GetValueAt( 8, areaType );
  2131.        
  2132.         if( StrLen( valueAsString ) != 0 )
  2133.         {
  2134.             exteriorTextureExtension = ExtractStringFromCSV( valueAsString );
  2135.         }
  2136.         else
  2137.         {
  2138.             exteriorTextureExtension = GetWorldDLCExtender().GetMiniMapExteriorTextureExtension( areaType );
  2139.         }
  2140.         return exteriorTextureExtension;
  2141.     }
  2142.    
  2143.     public function GetMiniMapInteriorTextureExtension( areaType : int ) : string
  2144.     {
  2145.         var interiorTextureExtension  : string;
  2146.         var valueAsString : string;
  2147.        
  2148.         valueAsString = minimapSettings.GetValueAt( 9, areaType );
  2149.        
  2150.         if( StrLen( valueAsString ) != 0 )
  2151.         {
  2152.             interiorTextureExtension = ExtractStringFromCSV( valueAsString );
  2153.         }
  2154.         else
  2155.         {
  2156.             interiorTextureExtension = GetWorldDLCExtender().GetMiniMapInteriorTextureExtension( areaType );
  2157.         }
  2158.         return interiorTextureExtension;
  2159.     }
  2160.    
  2161.     public function GetMiniMapVminX( areaType : int ) : int
  2162.     {
  2163.         var vminX  : int;
  2164.         var valueAsString : string;
  2165.        
  2166.         valueAsString = minimapSettings.GetValueAt( 11, areaType );
  2167.        
  2168.         if( StrLen( valueAsString ) != 0 )
  2169.         {
  2170.             vminX = StringToInt( valueAsString );
  2171.         }
  2172.         else
  2173.         {
  2174.             vminX = GetWorldDLCExtender().GetMiniMapVminX( areaType );
  2175.         }
  2176.         return vminX;
  2177.     }
  2178.    
  2179.     public function GetMiniMapVmaxX( areaType : int ) : int
  2180.     {
  2181.         var vmaxX  : int;
  2182.         var valueAsString : string;
  2183.        
  2184.         valueAsString = minimapSettings.GetValueAt( 12, areaType );
  2185.        
  2186.         if( StrLen( valueAsString ) != 0 )
  2187.         {
  2188.             vmaxX = StringToInt( valueAsString );
  2189.         }
  2190.         else
  2191.         {
  2192.             vmaxX = GetWorldDLCExtender().GetMiniMapVmaxX( areaType );
  2193.         }
  2194.         return vmaxX;
  2195.     }
  2196.    
  2197.     public function GetMiniMapVminY( areaType : int ) : int
  2198.     {
  2199.         var vminY  : int;
  2200.         var valueAsString : string;
  2201.        
  2202.         valueAsString = minimapSettings.GetValueAt( 13, areaType );
  2203.        
  2204.         if( StrLen( valueAsString ) != 0 )
  2205.         {
  2206.             vminY = StringToInt( valueAsString );
  2207.         }
  2208.         else
  2209.         {
  2210.             vminY = GetWorldDLCExtender().GetMiniMapVminY( areaType );
  2211.         }
  2212.         return vminY;
  2213.     }
  2214.    
  2215.     public function GetMiniMapVmaxY( areaType : int ) : int
  2216.     {
  2217.         var vmaxY  : int;
  2218.         var valueAsString : string;
  2219.        
  2220.         valueAsString = minimapSettings.GetValueAt( 14, areaType );
  2221.        
  2222.         if( StrLen( valueAsString ) != 0 )
  2223.         {
  2224.             vmaxY = StringToInt( valueAsString );
  2225.         }
  2226.         else
  2227.         {
  2228.             vmaxY = GetWorldDLCExtender().GetMiniMapVmaxY( areaType );
  2229.         }
  2230.         return vmaxY;
  2231.     }
  2232.    
  2233.     public function GetMiniMapSminX( areaType : int ) : int
  2234.     {
  2235.         var sminX  : int;
  2236.         var valueAsString : string;
  2237.        
  2238.         valueAsString = minimapSettings.GetValueAt( 15, areaType );
  2239.        
  2240.         if( StrLen( valueAsString ) != 0 )
  2241.         {
  2242.             sminX = StringToInt( valueAsString );
  2243.         }
  2244.         else
  2245.         {
  2246.             sminX = GetWorldDLCExtender().GetMiniMapSminX( areaType );
  2247.         }
  2248.         return sminX;
  2249.     }
  2250.    
  2251.     public function GetMiniMapSmaxX( areaType : int ) : int
  2252.     {
  2253.         var smaxX  : int;
  2254.         var valueAsString : string;
  2255.        
  2256.         valueAsString = minimapSettings.GetValueAt( 16, areaType );
  2257.        
  2258.         if( StrLen( valueAsString ) != 0 )
  2259.         {
  2260.             smaxX = StringToInt( valueAsString );
  2261.         }
  2262.         else
  2263.         {
  2264.             smaxX = GetWorldDLCExtender().GetMiniMapSmaxX( areaType );
  2265.         }
  2266.         return smaxX;
  2267.     }
  2268.    
  2269.     public function GetMiniMapSminY( areaType : int ) : int
  2270.     {
  2271.         var sminY  : int;
  2272.         var valueAsString : string;
  2273.        
  2274.         valueAsString = minimapSettings.GetValueAt( 17, areaType );
  2275.        
  2276.         if( StrLen( valueAsString ) != 0 )
  2277.         {
  2278.             sminY = StringToInt( valueAsString );
  2279.         }
  2280.         else
  2281.         {
  2282.             sminY = GetWorldDLCExtender().GetMiniMapSminY( areaType );
  2283.         }
  2284.         return sminY;
  2285.     }
  2286.    
  2287.     public function GetMiniMapSmaxY( areaType : int ) : int
  2288.     {
  2289.         var smaxY  : int;
  2290.         var valueAsString : string;
  2291.        
  2292.         valueAsString = minimapSettings.GetValueAt( 18, areaType );
  2293.        
  2294.         if( StrLen( valueAsString ) != 0 )
  2295.         {
  2296.             smaxY = StringToInt( valueAsString );
  2297.         }
  2298.         else
  2299.         {
  2300.             smaxY = GetWorldDLCExtender().GetMiniMapSmaxY( areaType );
  2301.         }
  2302.         return smaxY;
  2303.     }
  2304.    
  2305.     public function GetMiniMapMinZoom( areaType : int ) : float
  2306.     {
  2307.         var minZoom  : float;
  2308.         var valueAsString : string;
  2309.        
  2310.         valueAsString = minimapSettings.GetValueAt( 19, areaType );
  2311.        
  2312.         if( StrLen( valueAsString ) != 0 )
  2313.         {
  2314.             minZoom = StringToFloat( valueAsString );
  2315.         }
  2316.         else
  2317.         {
  2318.             minZoom = GetWorldDLCExtender().GetMiniMapMinZoom( areaType );
  2319.         }
  2320.         return minZoom;
  2321.     }
  2322.    
  2323.     public function GetMiniMapMaxZoom( areaType : int ) : float
  2324.     {
  2325.         var maxZoom  : float;
  2326.         var valueAsString : string;
  2327.        
  2328.         valueAsString = minimapSettings.GetValueAt( 20, areaType );
  2329.        
  2330.         if( StrLen( valueAsString ) != 0 )
  2331.         {
  2332.             maxZoom = StringToFloat( valueAsString );
  2333.         }
  2334.         else
  2335.         {
  2336.             maxZoom = GetWorldDLCExtender().GetMiniMapMaxZoom( areaType );
  2337.         }
  2338.         return maxZoom;
  2339.     }
  2340.    
  2341.     public function GetMiniMapZoom12( areaType : int ) : float
  2342.     {
  2343.         var zoom12  : float;
  2344.         var valueAsString : string;
  2345.        
  2346.         valueAsString = minimapSettings.GetValueAt( 21, areaType );
  2347.        
  2348.         if( StrLen( valueAsString ) != 0 )
  2349.         {
  2350.             zoom12 = StringToFloat( valueAsString );
  2351.         }
  2352.         else
  2353.         {
  2354.             zoom12 = GetWorldDLCExtender().GetMiniMapZoom12( areaType );
  2355.         }
  2356.         return zoom12;
  2357.     }
  2358.    
  2359.     public function GetMiniMapZoom23( areaType : int ) : float
  2360.     {
  2361.         var zoom23  : float;
  2362.         var valueAsString : string;
  2363.        
  2364.         valueAsString = minimapSettings.GetValueAt( 22, areaType );
  2365.        
  2366.         if( StrLen( valueAsString ) != 0 )
  2367.         {
  2368.             zoom23 = StringToFloat( valueAsString );
  2369.         }
  2370.         else
  2371.         {
  2372.             zoom23 = GetWorldDLCExtender().GetMiniMapZoom23( areaType );
  2373.         }
  2374.         return zoom23;
  2375.     }
  2376.    
  2377.     public function GetMiniMapZoom34( areaType : int ) : float
  2378.     {
  2379.         var zoom34  : float;
  2380.         var valueAsString : string;
  2381.        
  2382.         valueAsString = minimapSettings.GetValueAt( 23, areaType );
  2383.        
  2384.         if( StrLen( valueAsString ) != 0 )
  2385.         {
  2386.             zoom34 = StringToFloat( valueAsString );
  2387.         }
  2388.         else
  2389.         {
  2390.             zoom34 = GetWorldDLCExtender().GetMiniMapZoom34( areaType );
  2391.         }
  2392.         return zoom34;
  2393.     }
  2394.    
  2395.     public function GetGradientScale( areaType : int ) : float
  2396.     {
  2397.         var scale  : float;
  2398.         var valueAsString : string;
  2399.        
  2400.         valueAsString = minimapSettings.GetValueAt( 24, areaType );
  2401.        
  2402.         if( StrLen( valueAsString ) != 0 )
  2403.         {
  2404.             scale = StringToFloat( valueAsString );
  2405.         }
  2406.         else
  2407.         {
  2408.             scale = GetWorldDLCExtender().GetGradientScale( areaType );
  2409.         }
  2410.         return scale;
  2411.     }
  2412.    
  2413.     public function GetPreviewHeight( areaType : int ) : float
  2414.     {
  2415.         var height  : float;
  2416.         var valueAsString : string;
  2417.        
  2418.         valueAsString = minimapSettings.GetValueAt( 25, areaType );
  2419.        
  2420.         if( StrLen( valueAsString ) != 0 )
  2421.         {
  2422.             height = StringToFloat( valueAsString );
  2423.         }
  2424.         else
  2425.         {
  2426.             height = GetWorldDLCExtender().GetPreviewHeight( areaType );
  2427.         }
  2428.         return height;
  2429.     }
  2430.  
  2431.     private function UnlockMissedAchievements()
  2432.     {
  2433.         var manager : CCommonMapManager = theGame.GetCommonMapManager();   
  2434.         if ( manager )
  2435.         {
  2436.             manager.CheckExplorerAchievement();
  2437.         }
  2438.  
  2439.         GetWitcherPlayer().CheckForFullyArmedAchievement();
  2440.         GetGamerProfile().CheckProgressOfAllStats();
  2441.         if (FactsDoesExist("witcher3_game_finished"))
  2442.         {
  2443.             Achievement_FinishedGame();
  2444.         }
  2445.     }
  2446.    
  2447.     public final function MutationHUDFeedback( type : EMutationFeedbackType )
  2448.     {
  2449.         var hud : CR4ScriptedHud;
  2450.         var hudWolfHeadModule : CR4HudModuleWolfHead;      
  2451.  
  2452.         hud = (CR4ScriptedHud)GetHud();
  2453.         if ( hud )
  2454.         {
  2455.             hudWolfHeadModule = (CR4HudModuleWolfHead)hud.GetHudModule( "WolfHeadModule" );
  2456.             if ( hudWolfHeadModule )
  2457.             {
  2458.                 hudWolfHeadModule.DisplayMutationFeedback( type );
  2459.             }
  2460.         }
  2461.     }
  2462. }
  2463.  
  2464. function hasSaveDataToLoad():bool
  2465. {
  2466.     var currentSave : SSavegameInfo;
  2467.     var saveGames   : array< SSavegameInfo >;
  2468.    
  2469.     theGame.ListSavedGames( saveGames );
  2470.     if ( saveGames.Size() > 0 )
  2471.     {
  2472.         return true;
  2473.     }
  2474.    
  2475.     return false;
  2476. }
  2477.  
  2478. exec function EnableLog( enable : bool )
  2479. {
  2480.     theGame.EnableLog( enable );
  2481. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement