THUG1 - Where playing music is handled

THUG+ discussions can go here, about modding, or what ever you want
Catarax
VIP
Posts: 130
Joined: Sat Oct 25, 2014 6:50 pm

THUG1 - Where playing music is handled

Postby Catarax » Tue Dec 20, 2016 7:09 am

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.

Morten1337
Site Admin
Posts: 322
Joined: Mon Mar 01, 2010 2:23 pm
Location: Norway

Re: THUG1 - Where playing music is handled

Postby Morten1337 » Tue Dec 20, 2016 10:48 am

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.

Catarax
VIP
Posts: 130
Joined: Sat Oct 25, 2014 6:50 pm

Re: THUG1 - Where playing music is handled

Postby Catarax » Tue Dec 20, 2016 11:02 am

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.

%.gone.
Global Moderator
Posts: 389
Joined: Sun Mar 07, 2010 5:12 pm

Re: THUG1 - Where playing music is handled

Postby %.gone. » Tue Dec 20, 2016 10:48 pm

Well that's pretty much how all randomizing works. There isn't any true randomization anywhere.

Catarax
VIP
Posts: 130
Joined: Sat Oct 25, 2014 6:50 pm

Re: THUG1 - Where playing music is handled

Postby Catarax » Wed Dec 21, 2016 9:30 pm

Okay!

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


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.

%.gone.
Global Moderator
Posts: 389
Joined: Sun Mar 07, 2010 5:12 pm

Re: THUG1 - Where playing music is handled

Postby %.gone. » Thu Dec 22, 2016 6:42 am

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.

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$

OR

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$

Catarax
VIP
Posts: 130
Joined: Sat Oct 25, 2014 6:50 pm

Re: THUG1 - Where playing music is handled

Postby Catarax » Wed Jan 04, 2017 11:17 am

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.

%.gone.
Global Moderator
Posts: 389
Joined: Sun Mar 07, 2010 5:12 pm

Re: THUG1 - Where playing music is handled

Postby %.gone. » Wed Jan 04, 2017 1:12 pm

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.

Catarax
VIP
Posts: 130
Joined: Sat Oct 25, 2014 6:50 pm

Re: THUG1 - Where playing music is handled

Postby Catarax » Sat Jan 07, 2017 10:11 am

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?

%.gone.
Global Moderator
Posts: 389
Joined: Sun Mar 07, 2010 5:12 pm

Re: THUG1 - Where playing music is handled

Postby %.gone. » Sat Jan 07, 2017 11:18 am

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.


Return to “THUG+”

Who is online

Users browsing this forum: No registered users and 3 guests