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 » Sat Jan 07, 2017 7:08 pm

Okay!

I have some compiling issue of the original soundoptions.qb due to theses kind of line :

Code: Select all

:i $current_soundtrack$ = $$

Code: Select all

:i if  ($current_soundtrack$ = $$)

Code: Select all

:i default


What can be used instead? Thanks again.

%.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 7:41 pm

Those shouldn't every be empty.
On decompile it'll place a hexadecimal checksum if the checksum name is unknown.
I would try figuring out what those are because that cant be nothing and most certainly anything you place there aside from it's own data won't be correct.
Now if you know the checksum that should be there but don't know the name.
You can create unique checksums place their string in the qb and store their hex checksum somewhere along with the original hex checksum.
Do that for each unique checksum and make sure all occurrences of that checksum are changed to your new checksum.
Compile. After compile do a hex search for your hex checksum and replace them with the original.

And make sure you compile with the -thug1 flag.
THUG1 doesn't have jumps in switch statements like thug2+.

Skater1014
VIP
Posts: 182
Joined: Fri Apr 01, 2016 7:53 pm
Location: 'Murica!
Contact:

Re: THUG1 - Where playing music is handled

Postby Skater1014 » Sat Jan 07, 2017 7:54 pm

%.gone. wrote:You can create unique checksums place their string in the qb and store their hex checksum somewhere along with the original hex checksum.

Is this pretty much similar to the routine that I originally did with THUG2's skater_sfx.qb a few months ago?
(I've been helping them out with the decompiling/compiling via PM.)

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 8:33 pm

For the blank variable, using "$ffffffff$" fix it. (for THUG2).

I have some trouble with the random integer code on THUG2.

Code: Select all

$GetRandomValue$ $Name$ = $track_number$$a$ = %i(0,0) $b$ = %i(10,000000010)$integer$
:i $PlayTrack$%GLOBAL%$track_number$

Play nothing

Code: Select all

:i  $track_number$ =  %i(10,000000010)$integer$
:i $PlayTrack$%GLOBAL%$track_number$

Play the related track.

Don't understand what's wrong, thanks.

%.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 12:06 am

Skater1014 wrote:
%.gone. wrote:You can create unique checksums place their string in the qb and store their hex checksum somewhere along with the original hex checksum.

Is this pretty much similar to the routine that I originally did with THUG2's skater_sfx.qb a few months ago?
(I've been helping them out with the decompiling/compiling via PM.)

It is the exact method I suggested you use.

Catarax wrote:For the blank variable, using "$ffffffff$" fix it. (for THUG2).

Make a unique key, replace the ffffffff with text, search the compiled script for your unique keys hex value and replace it with ffffffff.

Catarax wrote:I have some trouble with the random integer code on THUG2.

Code: Select all

$GetRandomValue$ $Name$ = $track_number$$a$ = %i(0,0) $b$ = %i(10,000000010)$integer$
:i $PlayTrack$%GLOBAL%$track_number$

Play nothing

Code: Select all

:i  $track_number$ =  %i(10,000000010)$integer$
:i $PlayTrack$%GLOBAL%$track_number$

Play the related track.

Don't understand what's wrong, thanks.

%i(10,000000010)
First, the last value is the hex value of the integer. 10 = 0A.
With that being said %i(10,0) works just fine to compile.

$integer$ is a variable passed to the $GetRandomValue$ function and makes no sense in the context of :i $track_number$ = %i(10,000000010)$integer$

Did you make a typo while making this post or are you missing a :i at the beginning of
$GetRandomValue$ $Name$ = $track_number$$a$ = %i(0,0) $b$ = %i(10,000000010)$integer$
in your script?

Optionally try.

Code: Select all

:i $GetRandomValue$ $Name$ = $track_number$$a$ = %i(0,0) $b$ = %i(10,0)$integer$
:i $some_value$ = %GLOBAL%$track_number$
:i $PlayTrack$%GLOBAL%$some_value$

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 1:04 am

Thanks for the explanation of how work integer, yes the static variable was just for testing purpose, never written variable on this language.
Forgot the :i due to a fast copy/paste.

So all is good, I have a random track at each new level on thug2.

However, when I use $PlayTrack$, at the end of the track, another one is picked from the broken random soundtrack list.
This is not the function "skiptrack"/"SkipMusicTrack" used at that moment, i have no control.

So my questions are :
- When PlayTrack is used, does the next track is defined already before the new track launched?
- Is there a name to the function probably used when a track ends?

%.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 2:30 am

Catarax wrote:However, when I use $PlayTrack$, at the end of the track, another one is picked from the broken random soundtrack list.
This is not the function "skiptrack"/"SkipMusicTrack" used at that moment, i have no control.

So my questions are :
- When PlayTrack is used, does the next track is defined already before the new track launched?
- Is there a name to the function probably used when a track ends?

From my understanding, when randomize music tracks is set, the game builds a list of the tracks in a random order.
The list is rebuilt each time the end of the list is reached.

A suggestion, you could create 2 (or more if needing helper functions) scripts one for Play_Track and one for Skip_Track
Your play track function can be called without parameters and generates a random or in order index to the next track to play based on whether random is set or not. So you'll need to keep track of the current index set in the event in order is set you just add 1 to it or set to zero if max tracks. Your skip track can do the same thing.

Since the games PlayTrack can take a parameter of index of the track to play, this should work. However, you'll need to replace all instances of PlayTrack with Play_Track and all instances of SkipTrack with Skip_Track.

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 9:53 am

Ok, I start to understand what's wrong.

In the original code, there is :

Code: Select all

:i function $skip_track$
   :i $skiptrack$
:i endfunction


What skiptrack do/return? When I try to play a random track directly, this is ignored and random broken ost played.
Tried to return an integer like that ":i return %i(10,0000000a)" no success.
I have trouble to load a particular song in it.

Maybe it modify %GLOBAL%$current_track$ ?

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 4:06 pm

Forget my previous message.

But I think there is really a particular "skiptrack" function with another name after "PlayTrack" finished his job. Any ideas for the name of that?
Changing content of "skiptrack" or "skip_track" (used to skip in menu) doesn't have an impact on it, the next track is not picked from the qb code.
Thanks for the help.

Also, this can be seen in the preview track menu, automatically another track is started after.

%.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 7:02 pm

As I said you should over ride it and no longer call on the cfunc skiptrack anymore.
Instead, generate a number. Store that number each time, so from the very first time you ever call playtrack (integer value).
Have your skip track call playtrack with the value, if you want you can pass parameters to your skip track function to indicate whether it should skip to next track or to a random track next.

Taking it one step further, you maintain the random or in order property and set the in order property on start up so you aren't dealing with a game generated random list of songs. And from there on you no longer set the games in order or random value. Then using your property determine if you should play random order or in order where you use the methods discussed in this topic in your own play_track and skip_track (keep in mind im just giving general names and you should name these so they don't clash with anything else)


Return to “THUG+”

Who is online

Users browsing this forum: No registered users and 3 guests