Time mechanics in the game

+

eLeRs

Forum veteran
Hi everyone.
I invite you to watch the YouTube channel - eLeR Creative, where, among other things, you can watch the discussion of time mechanics in the game and modifications that interfere with it.
I invite you to discuss and watch. The film is recorded in Polish but I added subtitles EN. I apologize in advance for my English, correct me if I misinterpreted something.


Greetings.
 

Guest 3841499

Guest
There is a mod that makes in-game 1 second = 1 real-life second.
 
i try to make script for load csv file in DLC folder with time past in game.

r4game

Code:
//                Uphoenixwether start   

        var gameTimeDays        : Int32;
        var gameTime            : GameTime;
        var gameTimeHours        : Int32;
        var envID                 : Int32;
        var gameTimeHoursint     : Int32;
        var gameTimeHoursh        : Int32;
        var Uphoenixwether        : CEnvironmentDefinition;
        var envclod                : C2dArray;
        var world                : CGameWorld;
        var template             : CEntityTemplate;
        var resourcePath         : String;
        
        gameTime = theGame.CalculateTimePlayed();
        gameTimeHours = (GameTimeDays(gameTime) * 24 + GameTimeHours(gameTime));
        
        gameTimeHoursint = 80;

//            if (gameTimeHours > gameTimeHoursint)   
//            {
//                gamet = (gameTimeHours / gameTimeHoursint); 1.5
                
//                gameTimeHours = gameTimeHours - ((gameTimeHours / gameTimeHoursint)-(gameTimeHours * gameTimeHoursint));
//            }
            if (gameTimeHours > 1 || gameTimeHours < 2)
        
            {
                envclod = LoadCSV("dlc\dlcuphoenix\data\environment\wether\novigrad_autumn.csv ");
                            
                Uphoenixwether = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\ureal_novigrad_autom.env", true );
                envID = ActivateEnvironmentDefinition(Uphoenixwether, 1000, 1, 1.f);
                theGame.SetEnvironmentID(envID);
        
            }
            else if (gameTimeHours >= 2 || gameTimeHours < 4)

            {
                
                envclod = LoadCSV("dlc\dlcuphoenix\data\environment\wether\novigrad_cold.csv ");
                    
                Uphoenixwether = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\env_novigrad_cold.env", true );
                envID = ActivateEnvironmentDefinition(Uphoenixwether, 0900, 1, 1.f);
                theGame.SetEnvironmentID(envID);


            }
            else if (gameTimeHours >= 4 || gameTimeHours < 5)

            {
                DeactivateEnvironment(envID, 1000);   
                envclod = LoadCSV("dlc\dlcuphoenix\data\environment\wether\novigrad_cold.csv ");
                
                Uphoenixwether = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\env_novigrad_cold.env", true );
                envID = ActivateEnvironmentDefinition(Uphoenixwether, 0900, 1, 1.f);
                theGame.SetEnvironmentID(envID);


            }           
            else if (gameTimeHours >= 5)

            {
                DeactivateEnvironment(envID, 1000);   
                DeactivateEnvironment(envID, 0900);               
            }
            resourcePath = envclod.GetValueAt(0, 0);
            template = (CEntityTemplate)LoadResource(resourcePath, true);       
//                Uphoenixwether  end     
            
        
        theSound.LeaveGameState(ESGS_Movie);
        
        
        theSound.SoundEvent("system_resume");
        
        
        if(ShouldProcessTutorial('TutorialStash') && FactsQuerySum("tut_stash_fresh_playthrough") <= 0)
        {           
            
            tut.type = ETMT_Message;
            tut.tutorialScriptTag = 'TutorialStash';
            tut.canBeShownInMenus = false;
            tut.glossaryLink = false;
            tut.markAsSeenOnShow = true;
            
            
            theGame.GetTutorialSystem().DisplayTutorial(tut);
        }
    }

i ave trouble with this line

if (gameTimeHours > 1 || gameTimeHours < 2)
envclod = LoadCSV("dlc\dlcuphoenix\data\environment\wether\novigrad_autumn.csv ");

it don't change wether and csv not loaded but ureal_novigrad_autom.env is loaded.

do you ave idea.
 
@jack91 hej Jack,

Your code if(x < 2 || x> 1) will always return true (and will never execute the else-code and so will never change envs)

That is beause you have a logical OR: imagine any number (say 0.5) this will be smaller than 2. then take 1.5 this will be both smaller than 2 and larger than 1. and take 3: this will be always greater than 1... so your if clause always returns true.

What check do you want? Do you check for numbers that are between 1 and 2? Then you need a logical AND: if (x > 1 && x < 2)

Hope That helps!

PS: looking at your whole code I would do it like this:
if ( gameTimeHours < 2) {} //this is true when smaller than 2
else if ( gameTimeHours < 4) {} //if not but smaller than 4
else if ( gameTimeHours < 5) {} //if neither of the above but still smaller than 5
else {} //if greater than 5
 
Last edited:
thank you rfuzzo,

now if time past is over 5hrs in game.
it is possible to create loop ?


with this if time is over 5 gameTimeHours - 5 + 1 = 1.
but if gameTimeHours = 20 : gameTimeHours - 5 + 1= 6


I want to create a loop for gameTime Hours without setting the time to 0.

Code:
gameTimeHoursint = 5;

           if (gameTimeHours > gameTimeHoursint)  
           {
              gameTimeHours = (gameTimeHours - gameTimeHoursint)+1;
 
Last edited:
Top Bottom