THUG1 - Where playing music is handled
THUG1 - Where playing music is handled
Hello,
I would like to know which file of THUG1 handle the action to play a music track (alphabetical/random), i'm looking to fix the broken random music order.
Thanks.
I would like to know which file of THUG1 handle the action to play a music track (alphabetical/random), i'm looking to fix the broken random music order.
Thanks.
-
- Site Admin
- Posts: 327
- Joined: Mon Mar 01, 2010 2:23 pm
- Location: Norway
Re: THUG1 - Where playing music is handled
THUG.exe
When the game is first run it uses a fixed seed value (107482099), which makes all "random" actions at startup very predictable.
From scripts you can call "Randomize" to randomize the seed and then "SetRandomMode" to re-shuffle the soundtrack.
But its still going to be rather predictable.
To fix this you need to change the function that generates the "random seed", in the executable.
When the game is first run it uses a fixed seed value (107482099), which makes all "random" actions at startup very predictable.
From scripts you can call "Randomize" to randomize the seed and then "SetRandomMode" to re-shuffle the soundtrack.
But its still going to be rather predictable.
To fix this you need to change the function that generates the "random seed", in the executable.
Re: THUG1 - Where playing music is handled
Okay.
I think calling randomly a number of randomize could be okay in the scripts, don't know if it could slow the startup.
What is the best way to change the function in the exe? I'm limited to only hex edit.
Thanks.
I think calling randomly a number of randomize could be okay in the scripts, don't know if it could slow the startup.
What is the best way to change the function in the exe? I'm limited to only hex edit.
Thanks.
Re: THUG1 - Where playing music is handled
Well that's pretty much how all randomizing works. There isn't any true randomization anywhere.
Re: THUG1 - Where playing music is handled
Okay!
I tried to add this to startup2.qb but doesn't have a particular effect.
Doubt I am using Randomize like it should.
Can't find a proper code example of it since the game doesn't randomize the list while switching the music order, same thing on thug2.
Thanks again.
I tried to add this to startup2.qb but doesn't have a particular effect.
Code: Select all
:i $Randomize$
:i $SetRandomMode$%i(1,00000001) // note: original line
Can't find a proper code example of it since the game doesn't randomize the list while switching the music order, same thing on thug2.
Thanks again.
Re: THUG1 - Where playing music is handled
If you can select the track by index you could try this, perhaps in a loop where you get a random number for the iteration count to add an additional level of randomness.
OR
Code: Select all
:i $GetRandomValue$ $Name$ = $track_number$$a$ = %i(0,0) $b$ = %i(?,?"max number of audio tracks")$integer$
:i #/ then select the track using %GLOBAL%$track_number$
Code: Select all
:i $GetRandomValue$ $Name$ = $loop_count$$a$ = %i(1,0) $b$ = %i(5,0)$integer$
:i while
:i $GetRandomValue$ $Name$ = $track_number$$a$ = %i(0,0) $b$ = %i(?,?"max number of audio tracks")$integer$
:i loop_to %GLOBAL%$loop_count$
:i #/ then select the track using %GLOBAL%$track_number$
Re: THUG1 - Where playing music is handled
Thanks!
I'm lost to find the code of the $SkipMusicTrack$ function.
Is it in the "engine" folder or elsewhere? Would like to know where the global functions are created.
I'm lost to find the code of the $SkipMusicTrack$ function.
Is it in the "engine" folder or elsewhere? Would like to know where the global functions are created.
Re: THUG1 - Where playing music is handled
Typically, if a function name has an underscore in it you'll find it in scripts if it doesn't it's in the exe. For multi-word function names.
Re: THUG1 - Where playing music is handled
Thanks for this precious information.
And little question, creating a function inside a qb, does it make it usuable everywhere or I have to re-write it on each qb files?
Is it possible to create a global qb function without modifying the exe?
And little question, creating a function inside a qb, does it make it usuable everywhere or I have to re-write it on each qb files?
Is it possible to create a global qb function without modifying the exe?
Re: THUG1 - Where playing music is handled
Qb's are global.
If you load a Qb file with global variables and scripts all variables and scripts can be used outside of that qb, too.
By global variables I don't mean objects prefixed by %GLOBAL%, I mean objects found outside of a function.
If you load a Qb file with global variables and scripts all variables and scripts can be used outside of that qb, too.
By global variables I don't mean objects prefixed by %GLOBAL%, I mean objects found outside of a function.