Need Help with small script env.

+
Hello, i need help for loading env file in DLC with script after time played in game .

i have this for take time passed in game by consol (type: "timebox")

Code:
exec function timebox()
{

    var message : string;
    var gameTimeDays    : string;  
    var gameTime        : GameTime;
    var gameTimeHours    : string;

    gameTime =    theGame.CalculateTimePlayed();
    gameTimeHours = (string)(GameTimeDays(gameTime) * 24 + GameTimeHours(gameTime));
    message = message + " " + gameTimeHours;  
    theGame.GetGuiManager().ShowUserDialogAdv(0, "gameTimeHours", message, 0, UDB_Ok);
}

Now, this script not work

Code:
statemachine class ChangeEnvironmentDefinition
{
    private function UpdateEnvironment()
    {  
        var gameTimeDays        : string;  
        var gameTime            : GameTime;
        var gameTimeHours        : string;
        var environmentautumn     : CEnvironmentDefinition;
        var envID                 : Int32;
       
        gameTime = theGame.CalculateTimePlayed();
        gameTimeHours = (string)(GameTimeDays(gameTime) * 24 + GameTimeHours(gameTime));
        environmentautumn = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\ureal_novigrad_sunset.env\ureal__novigrad_autom.env", true );
               
        if (gameTimeHours > 70)
       
        {
                   
            envID = ActivateEnvironmentDefinition(environmentautumn, 1000, 1.0, 1.000000);
           
            theGame.SetEnvironmentID(envID);
                                   
        }
   
    }
}
 
Last edited:
I am trying to create a script to load the env file. after playing a number of days.

I'll looking in the Atmospheric Nights script.

I change the variables for int, it has no more errors but nothing works in the game.

Code:
statemachine class ChangeEnvironmentDefinition
{
    private function UpdateEnvironment()
    {   
        var gameTimeDays        : int;   
        var gameTime            : GameTime;
        var gameTimeHours        : int;
        var environmentautumn     : CEnvironmentDefinition;
        var envID                 : Int;
        
        gameTime = theGame.CalculateTimePlayed();
        gameTimeHours = (GameTimeDays(gameTime) * 24 + GameTimeHours(gameTime));
        environmentautumn = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\ureal_novigrad_sunset.env\ureal__novigrad_autom.env", true );

       if (gameTimeHours >= 10)
        
       {
                
            envID = ActivateEnvironmentDefinition(environmentautumn, 1000, 1.0, 1.000000);
            
            theGame.SetEnvironmentID(envID);
                                    
       }
    
    }
}
 
Code:
statemachine class ChangeEnvironmentDefinition extends CR4Game
{                
    public function ActivateAutumnEnvironmentDefinition()
    {   
        var gameTimeDays        : string;
        var gameTime            : GameTime;
        var gameTimeHours        : string;
        var environmentautumn     : CEnvironmentDefinition;
        var envID                 : Int32;
        var condition             : Int32;
        var gameTimeHoursint     : Int32;
        
        gameTime = theGame.CalculateTimePlayed();
        gameTimeHours = (string)(GameTimeDays(gameTime) * 24 + GameTimeHours(gameTime));
        
        environmentautumn = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\ureal_novigrad_autom.env", true );

        condition = StringToInt("gameTimeHours");
        gameTimeHoursint = 70;
        
            if (condition > gameTimeHoursint)
            {
                envID = ActivateEnvironmentDefinition(environmentautumn, 1000, 1, 1.000000);
                      
                theGame.SetEnvironmentID(envID);
                                        
            }
            else if (condition < gameTimeHoursint)
            {
            
                DeactivateEnvironment(envID, 1000);
                    
            }       

    }
    event OnAfterLoadingScreenGameStart()
    {
        ActivateAutumnEnvironmentDefinition();
    }
}

I do not know if "StringToInt" works.
File is not loading.
 
Events of derived classes are not fired when the parent class event fires.
So your OnAfterLoadingScreenStart event is not triggered.


Also, do not put the game time parameter in the function as a literal string.
You are trying to convert "gameTimeHours" to an integer, which doesn't work, use the variable itself.
 
Code:
statemachine class ChangeEnvironmentDefinition
{
    event OnAfterLoadingScreenGameStart()
    {
        ActivateAutumnEnvironmentDefinition();
    }
               
    public function ActivateAutumnEnvironmentDefinition()
    {
        var gameTimeDays        : Int32;
        var gameTime            : GameTime;
        var gameTimeHours        : Int32;
        var environmentautumn     : CEnvironmentDefinition;
        var envID                 : Int32;
        var condition             : Int32;
        var gameTimeHoursint     : Int32;
    
       
        gameTime = theGame.CalculateTimePlayed();
        gameTimeHours = (GameTimeDays(gameTime) * 24 + GameTimeHours(gameTime));  

        environmentautumn = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\ureal_novigrad_autom.env", true );
        condition = gameTimeHours;
        gameTimeHoursint = 70;
     
            if (condition > gameTimeHoursint)          
            {

                envID = ActivateEnvironmentDefinition(environmentautumn, 1000, 1, 1.000000);
                     
                theGame.SetEnvironmentID(envID);
                                       
            }
            else if (condition < gameTimeHoursint)      
            {
           
                DeactivateEnvironment(envID, 1000);
                   
            }  

    }

}

}

how to make it work?
Post automatically merged:

Ok, is done by r4Game.ws


Code:
    event OnAfterLoadingScreenGameStart()

    {

        var tut : STutorialMessage;


   

//                environmentautumn start  


        var gameTimeDays        : Int32;

        var gameTime            : GameTime;

        var gameTimeHours        : Int32;

        var envID                 : Int32;

        var gameTimeHoursint     : Int32;

        var gameTimeHoursh        : Int32;

        var environmentautumn     : CEnvironmentDefinition;

       

       

           

        gameTime = theGame.CalculateTimePlayed();

        gameTimeHours = (GameTimeDays(gameTime) * 24 + GameTimeHours(gameTime));

       

        gameTimeHoursint = 365;


            if (gameTimeHours > gameTimeHoursint)  

            {

                gameTimeHours = gameTimeHours - ((gameTimeHours / gameTimeHoursint)*365);

            }

            else if (gameTimeHours > 70)

            {


                environmentautumn = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\ureal_novigrad_autom.env", true );

                envID = ActivateEnvironmentDefinition(environmentautumn, 1000, 1, 1.000000);

                theGame.SetEnvironmentID(envID);

            }

            else if (gameTimeHours > 90)  

            {

                DeactivateEnvironment(envID, 1000);          

               

            }

               

//                environmentautumn  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);

        }

    }
 
Last edited:
Now, if I can change this line by starting a quest to change the environment and textures, we could get seasons in the game.

Code:
environmentautumn = (CEnvironmentDefinition)LoadResource( "dlc\dlcuphoenix\data\environment\definitions\ureal\ureal_novigrad_autom.env", true );
envID = ActivateEnvironmentDefinition(environmentautumn, 1000, 1, 1.000000);
theGame.SetEnvironmentID(envID);

For this env file, in DLC, I only kept m_speedTree and changed the color of the trees.
 
Last edited:
Top Bottom