• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Cinematic mode sets all random values to fixed ones

Status
Not open for further replies.
Level 8
Joined
Mar 10, 2009
Messages
213
Ok, I've browsed and found no exact or similar theme so far.
Here's the thing: whenever I enable cinematic mode, all of my random numbers run through triggers during the process are set to fixed ones. The trouble is: I require that cinematic mode turned on for combat (units fight on their own), and thus the outcome is always the same. As I require several thousands randomized variables, it makes me a very sad person. (That's got nothing to do with worldedit fixed seed, I turned it off).
Is there a way to prohibit that fixed seed during a cinematic event?

If not, the only reasonable solution would be calculating everything in advance and just showing afterwards a "movie".

It's quite a huge project I'm dealing with at the moment, and the whole point was about making random events, so any suggestions on that matter would be most appreciated.
Thank you in advance for your time and efforts.
 
Level 11
Joined
Jun 2, 2013
Messages
613
Does this only occur when testing the map (alt +f9) or do you get the same results if you launched the map from Warcraft > single player? In my experience when testing, a lot of times it seems to predominately be a fixed variable when it's supposed to be random but every so often I'll get a different result like I'm supposed to. It tends to be more random in an actual game setting. (I'm not saying this statement is accurate, just from my own experience it seems to be this way)

I can't think of a reason why a cinematic would alter a random variable though.
 
Level 8
Joined
Mar 10, 2009
Messages
213
It happens in both ways of launching the map. Whenever I turn the mode off before testing, however, every single time I get new results, as it's supposed to happen. You see, I've got that many variables generating in background, that the map freezes a bit (cannot help it, so I use timers and recycling to unload the memory a bit). And all of them are set to same values every time when the cinematic is on.
I've googled that info so far: http://www.thehelper.net/threads/question-on-cinematic-random-numbers.148270/
http://www.hiveworkshop.com/forums/...m-thing-same-every-time-wtf-88745/#post730698
Apparently, I have to find a way to run it with Jass. This theme should be either deleted or merged with the one I've just mentioned.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
So why did people claim it would be avoidable in Jass? =(
In GUI it does this...
JASS:
function CinematicModeExBJ takes boolean cineMode,force forForce,real interfaceFadeTime returns nothing
    if (not bj_gameStarted) then
        set interfaceFadeTime = 0
    endif
    if (cineMode) then
        if (not bj_cineModeAlreadyIn) then
            set bj_cineModeAlreadyIn = true
            set bj_cineModePriorSpeed = GetGameSpeed()
            set bj_cineModePriorFogSetting = IsFogEnabled()
            set bj_cineModePriorMaskSetting = IsFogMaskEnabled()
            set bj_cineModePriorDawnDusk = IsDawnDuskEnabled()
            set bj_cineModeSavedSeed = GetRandomInt(0, 1000000)
        endif
        if (IsPlayerInForce(GetLocalPlayer(), forForce)) then
            call ClearTextMessages()
            call ShowInterface(false, interfaceFadeTime)
            call EnableUserControl(false)
            call EnableOcclusion(false)
            call SetCineModeVolumeGroupsBJ()
        endif
        call SetGameSpeed(bj_CINEMODE_GAMESPEED)
        call SetMapFlag(MAP_LOCK_SPEED, true)
        call FogMaskEnable(false)
        call FogEnable(false)
        call EnableWorldFogBoundary(false)
        call EnableDawnDusk(false)
        call SetRandomSeed(0)
    else
        set bj_cineModeAlreadyIn = false
        if (IsPlayerInForce(GetLocalPlayer(), forForce)) then
            call ShowInterface(true, interfaceFadeTime)
            call EnableUserControl(true)
            call EnableOcclusion(true)
            call VolumeGroupReset()
            call EndThematicMusic()
            call CameraResetSmoothingFactorBJ()
        endif
        call SetMapFlag(MAP_LOCK_SPEED, false)
        call SetGameSpeed(bj_cineModePriorSpeed)
        call FogMaskEnable(bj_cineModePriorMaskSetting)
        call FogEnable(bj_cineModePriorFogSetting)
        call EnableWorldFogBoundary(true)
        call EnableDawnDusk(bj_cineModePriorDawnDusk)
        call SetRandomSeed(bj_cineModeSavedSeed)
    endif
endfunction
As you can see it is making calls to manipulate the session random seed. If you were to not make those calls then the seed would not be altered.

JASS:
function CinematicModeCustom takes boolean cineMode,force forForce,real interfaceFadeTime returns nothing
    if (not bj_gameStarted) then
        set interfaceFadeTime = 0
    endif
    if (cineMode) then
        if (not bj_cineModeAlreadyIn) then
            set bj_cineModeAlreadyIn = true
            set bj_cineModePriorSpeed = GetGameSpeed()
            set bj_cineModePriorFogSetting = IsFogEnabled()
            set bj_cineModePriorMaskSetting = IsFogMaskEnabled()
            set bj_cineModePriorDawnDusk = IsDawnDuskEnabled()
            //set bj_cineModeSavedSeed = GetRandomInt(0, 1000000)
        endif
        if (IsPlayerInForce(GetLocalPlayer(), forForce)) then
            call ClearTextMessages()
            call ShowInterface(false, interfaceFadeTime)
            call EnableUserControl(false)
            call EnableOcclusion(false)
            call SetCineModeVolumeGroupsBJ()
        endif
        call SetGameSpeed(bj_CINEMODE_GAMESPEED)
        call SetMapFlag(MAP_LOCK_SPEED, true)
        call FogMaskEnable(false)
        call FogEnable(false)
        call EnableWorldFogBoundary(false)
        call EnableDawnDusk(false)
        //call SetRandomSeed(0)
    else
        set bj_cineModeAlreadyIn = false
        if (IsPlayerInForce(GetLocalPlayer(), forForce)) then
            call ShowInterface(true, interfaceFadeTime)
            call EnableUserControl(true)
            call EnableOcclusion(true)
            call VolumeGroupReset()
            call EndThematicMusic()
            call CameraResetSmoothingFactorBJ()
        endif
        call SetMapFlag(MAP_LOCK_SPEED, false)
        call SetGameSpeed(bj_cineModePriorSpeed)
        call FogMaskEnable(bj_cineModePriorMaskSetting)
        call FogEnable(bj_cineModePriorFogSetting)
        call EnableWorldFogBoundary(true)
        call EnableDawnDusk(bj_cineModePriorDawnDusk)
        //call SetRandomSeed(bj_cineModeSavedSeed)
    endif
endfunction
Putting the above in the map header you can then substitute all calls to it rather than the standard one which does modify RNG.

The fixed RNG was needed to prevent different outcomes during cinematic scenes in the campaign. Clearly this is not what you want so you need to customize it.
 
If you're intimidated by the process of copying a JASS script to your header and using it in your triggers, then try this alternative: Add this custom script after your "Cinematic - Turn on cinematic mode" function:
  • Cinematic - Turn cinematic mode On for (All players)
  • Custom script: call SetRandomSeed(bj_cineModeSavedSeed)
When you turn a cinematic off, you'll want to add this line before it:
  • Custom script: set bj_cineModeSavedSeed = GetRandomInt(0, 1000000)
  • Cinematic - Turn cinematic mode Off for (All players)
 
Status
Not open for further replies.
Top