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

Re: THUG1 - Where playing music is handled

Postby Catarax » Sun Jan 08, 2017 7:28 pm

Okay, but the game doesn't limit only to skiptrack function when the stream is finished.

Here's the current code :

Code: Select all

:i function $SkipMusicTrack$ // Function used at startup of a level
   :i call $GetRandomValue$ arguments
      $name$ = $track_number$$a$ = %i(0,00000000)$b$ = %i(52,00000034)$integer$
   :i $PlayTrack$%GLOBAL%$track_number$
:i endfunction

:i function $skip_track$ // Function used in options menu to skip manually
   :i call $GetRandomValue$ arguments
      $name$ = $track_numberx$$a$ = %i(0,00000000)$b$ = %i(52,00000034)$integer$
   :i $PlayTrack$%GLOBAL%$track_numberx$
:i endfunction

:i function $skiptrack$ // Useless
   :i $track_numberxx$ = %i(5,00000005)$integer$
   :i $PlayTrack$%GLOBAL%$track_numberxx$
:i endfunction


What's happening :
Level loaded => Random PlayTrack (good) => Stream of the track finished => PlayTrack automatically call the next song from the original random order wihout using the custom "skip_track" or "SkipMusicTrack" function (BAD). This thing also happen in "Preview track" when this is finished.
This is out of my control.

Solutions:
- Rewrite PlayTrack to avoid the loading of a bad track after (didn't found concrete code example for playing a bik)
- Having the name of the possible function that PlayTrack use at the end of the stream to overwrite it.
- Setting an event at the end of PlayTrack or detecting when the stream is ended, don't know how the game handle that at all
- Randomizing multiple time the seed but don't know what variable handle it

Thanks, this is the last step missing.

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

Re: THUG1 - Where playing music is handled

Postby %.gone. » Sun Jan 08, 2017 9:03 pm

You can not reuse names of functions already in use $skiptrack$
If they're already loaded any function with that same name will not be loaded. skiptrack is a cfunc and is loaded before your scripts.

If you set the game to play tracks InOrder, the game will no longer build a list of random tracks, this allows YOU to select them randomly but your function names can not clash with preexisting function names whether in scripts or the exe.

When you pass an integer value to the PlayTrack cfunc the game plays that track. But it's an index in to the tracks list where if random order is set the list is in a random order and not in order. By nature there is never any random anything. You learn this in basic c programming 101. You conduct test to try and get a less repeating pattern but it ALWAYS repeats at some point.

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

Re: THUG1 - Where playing music is handled

Postby Catarax » Mon Jan 09, 2017 4:25 pm

%.gone. wrote:You can not reuse names of functions already in use $skiptrack$
If they're already loaded any function with that same name will not be loaded. skiptrack is a cfunc and is loaded before your scripts.

If you set the game to play tracks InOrder, the game will no longer build a list of random tracks, this allows YOU to select them randomly but your function names can not clash with preexisting function names whether in scripts or the exe.

When you pass an integer value to the PlayTrack cfunc the game plays that track. But it's an index in to the tracks list where if random order is set the list is in a random order and not in order. By nature there is never any random anything. You learn this in basic c programming 101. You conduct test to try and get a less repeating pattern but it ALWAYS repeats at some point.


Okay, that explain.
So is there a way to extract the qb content of theses exe function? (skiptrack, PlayTrack).
THUG2 use stuff like $loadstreamheader$, $playstream$?

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

Re: THUG1 - Where playing music is handled

Postby %.gone. » Mon Jan 09, 2017 5:03 pm

exe functions aren't in qb format.
Unless you create a proxy dll, as Mortens answer implied, you won't be able to override the existing function.
You can take my suggestion and prevent the current cfunc from being called from within qb scripts and instead call on your own functions but directly overriding the function is out of the question through scripting alone.
The THUG1 source was released and is on git hub somewhere. Have a look into cfuncs.cpp and music.cpp.

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

Re: THUG1 - Where playing music is handled

Postby Catarax » Tue Jan 10, 2017 1:20 pm

Thanks a lot %.gone, reading the source code of thug1 helped a lot!


Return to “THUG+”

Who is online

Users browsing this forum: No registered users and 2 guests