Page 1 of 2

Script manipulation does nothing

Posted: Thu Nov 23, 2017 2:56 pm
by benne
Hey there,
I'm not new to the modding scene but quite new to modding THPS...
I've been reading this forum for one week now and thanks to you all I managed to change some textures in my THPS3 (PS2 version) but trying to change some script files I run into a strange problem. First I describe what exactly I do:

1. Unpack skate3.wad and skate3.hed from my THPS3 Iso using 7zip
2. Using WadEdit_v4 I unpack these files into a new folder
3. I change some textures / pngs inside the folders
4. I use THQBEditor to manipulate a Script.. lets say "mainmenu.qb" and change the words "Free Skate" to "Fraa Skaaa"
5. Now I use WadEdit_v4 again to pack my changes into skate3.wad and skate3.hed
6. Using UltraISO I change the original wad and hed file in my THPS3 ISO with the manipulated ones
7. I start the game in PCSX2 Emulator

Now the strange problem: the textures / png files I changed have changed in the game as well. BUT: the script manipulation didn't do anything at all! In a second try I even deleted "mainmenu.qb" and packed all files but the game (and the main menu) still runs normally

I just cannot understand whats wrong, because textures work but scripts dont -.- I also tried QBexplorer .. no success though
Please help me :)

Re: Script manipulation does nothing

Posted: Fri Nov 24, 2017 2:08 am
by WhoElseButMe
It's loading from the pre and not the loose files.
You'll need to extract the pre with prerip and repack it.

Re: Script manipulation does nothing

Posted: Fri Nov 24, 2017 11:52 am
by benne
Thanks for your help, sorry to bother you again but:

I tried both prereaper and preRIP2 on various .pre files in my directory (e.g. qb.pre) and both start extraction but crash at once after one single file...
i checked second DWORD, its 0200CDAB so they should be readable...
anyway, prerip gives the following warning:

Code: Select all

Allocated 792612 bytes for PRE buffer
Reading .pre file into memory...
Warning: Found uknown id in header: 0xABCD0002
Starting .pre extraction (214 files)...
pts\airtricks.qb - Size: 25694 Bytes (11847 Compressed)


at this point the application crashes.. could it be a little/big endian problem? (because 0xABCD0002 is 0200CDAB reverted)

thanks again

Re: Script manipulation does nothing

Posted: Fri Nov 24, 2017 3:33 pm
by WhoElseButMe
PS2 is little endian that isn't the issue. It appears you're using a pre tool designed for pre3 files as they have an additional checksum per entry and the first 4 characters of the name have been stripped off.
Pre Tool 1.1

Re: Script manipulation does nothing

Posted: Sat Nov 25, 2017 12:12 pm
by benne
Thank you SO much! It works :) :) :)

Re: Script manipulation does nothing

Posted: Tue Nov 28, 2017 7:00 pm
by benne
Hey I'm back with two more questions :)

first: I want to edit the tricks.qb, but when I decompile it the content is strange.. all function and variable names are changed with addresses:
example:

Code: Select all

#/ QB Script version 2
%include "tricks.qb_table.qbi"   #/ Table file

:u(02:00000001)function $[58f440e7]$
   :u(02:00000027)$[f40343bd]$
   :u(02:00000029)$[8b5bf231]$
   :u(02:0000002a)call $[8799b8ed]$ arguments
      $[ba676b90]$ = %i(0,00000000)


so my first question is: why is that and why only in tricks.qb, i did not find it in other qbs...

secondly: i managed to open tricks.qb with THQBEditor. in this editor all function and variable names are correctly resolved. For a test I want to create a global string variable and send a chat message with this string as soon as the skater lands. This code works:

Code: Select all

#00827  my_msg = "start"
     
#00829  FUNCTION Land
#00833    SendChatMessage string = my_msg
...


BUT: when i try to change the variable inside the function using "Change" like:

Code: Select all

#00827  my_msg = "start"
     
#00829  FUNCTION Land
#00830     Change my_msg = "hallo"   

#00833    SendChatMessage string = my_msg 


no chat message is printed. not even an empty one. What am I doing wrong? thanks!

Re: Script manipulation does nothing

Posted: Tue Nov 28, 2017 7:15 pm
by WhoElseButMe
There was a problem decompiling the script using blubs tool that's why it does that. Also, you're using an older version you should hunt down version 2.1 so you don't need to add your checksums to the table manually before a compile.

Make sure you're using the proper syntax for the tool you're using.
you don't want to do the chat message that way.
You can first try wrapping the variable in parenthesis to make the game evaluate it.
sendchatmessage string = (my_msg)

But really you want to
FormatText textname = msg "%i world" i = "hello"
sendchatmessage string = <msg> //use whatever the equivalent for %GLOBAL% is in the tool you're using. %GLOBAL%$msg$

Re: Script manipulation does nothing

Posted: Wed Nov 29, 2017 1:48 pm
by benne
It's still not working and I got the suspicion it has to do with the use of THQBEditor.. so I really want to use blubs tool for a "complete" decompile, but tricks.qb just dont want to decompile correctly,
I tried every qb version i could find, including the newest one (2.1) but still it yields in hex addresses instead of checksum names. in the end it says:

Code: Select all

:u(02:00000453)function $17549396$
   :u(02:00000455)$91721e0b$select(2f,2, 04 00 00 00) :OFFSET(0):OFFSET(1)
      Unknown instruction at 0000331f:98

I searched for this error but only found it in a thread reagarding another TH game.

what can I do to get my tricks.qb compiled correctly?

and one more (i guess stupid) question:
what about thouse line numbers in qb files... e.g. :u(02:00000453) or as printed in THQBEditor: #0085
do i have to write them myself if I add some code inside a script? is there some rule I should know?

thanks again!

Re: Script manipulation does nothing

Posted: Wed Nov 29, 2017 3:01 pm
by rodneyM7
Had the same problem as you. I manually just deleted the offsets, decompiled, deleted... repeat. If it works it ain't stupid right :P BUt there has to be a better solution.
Anyway, here's my decompiled trick.qb: https://www.mediafire.com/file/fofp7aut ... tricks.txt

Re: Script manipulation does nothing

Posted: Thu Nov 30, 2017 3:56 am
by WhoElseButMe
0x02 is a line ending that is followed by a line number it's for debugging of the scripts and doesn't matter what the line number is.
You can convert them all to 0x01 and the game will run fine.
That isn't your issue though.
At location 0000331f in the file is an unknown instruction.

THPS3 and THPS4 don't use weight values in randoms and this is more than likely the issue you're having.
Because 0x2F is a random (known as a select in blubs tool). So blubs tool is trying to read weight values and offsets and the weights don't exist leaving it reading something else after all that 0x98 which isn't a token at all.

Re: Script manipulation does nothing

Posted: Thu Nov 30, 2017 11:11 am
by rodneyM7
As far as I know these randoms are just timing parameters and probably not of interest for you anyway. See the comp_scripts.qb (I put this together manually):

Code: Select all

:u(02:000003df)function $Comp_PedEnd_Norm$
   :u(02:000003e7) while
   :u(02:000003e8) $Obj_PlayAnim$$Anim$ = $Idle$
   :u(02:000003e9) $Wait$ 2F 04 00 00 00 11 00 00 00 21 00 00 00 31 00 00 00 41 00 00 00
   :u(02:000003ea) %i(1a0000803e)$Seconds$
   :u(02:000003eb) 2E 37 00 00 00 1A 00 00 00 3F $Seconds$
   :u(02:000003ec) 2E 23 00 00 00 1A 00 00 40 3F $Seconds$
   :u(02:000003ed) 2E 0F 00 00 00 17 01 00 00 00 $Seconds$
   :u(02:000003ee)
   :u(02:000003ef) $Obj_CycleAnim$$Anim$ = 2F 05 00 00 00 15 00 00 00 20 00 00 00 2B 00 00 00 36 00 00 00 41 00 00 00
   :u(02:000003f0) $Cheering$
   :u(02:000003f1) 2E 37 00 00 00 $Clap$
   :u(02:000003f2) 2E 28 00 00 00 $ShakeFist$
   :u(02:000003f3) 2E 19 00 00 00 $Wave$
   :u(02:000003f4) 2E 0A 00 00 00 $ThinManCheering$
   :u(02:000003f5)
   :u(02:000003f6) loop_to
:u(02:000003f7)endfunction
:u(02:000003f8)function $Comp_PedEnd_Pro$
   :u(02:000003fb) while
   :u(02:000003fc) $Obj_CycleAnim$$Anim$ = $StandIdle$$NumCycles$ = 17 02 00 00 00
   :u(02:000003fd) $Obj_CycleAnim$$Anim$ = 2F 03 00 00 00 0D 00 00 00 18 00 00 00 23 00 00 00
   :u(02:000003fe) $StandLeftRight$
   :u(02:000003ff) 2E 19 00 00 00 $StandCheckBoard$
   :u(02:00000400) 2E 0A 00 00 00 $StandShoulder$
   :u(02:00000401) $Wait$ 17 01 00 00 00 $Gameframes$
   :u(02:00000402)
   :u(02:00000403) loop_to
:u(02:000000404)endfunction

Re: Script manipulation does nothing

Posted: Thu Nov 30, 2017 12:37 pm
by benne
Okay, first:
rodneyM7, I downloaded your tricks.txt and now I am able to do my scripting with it, it compiles correctly. BIG THANKS!!
I can post my code in "real" qb syntax now.
secondly, WhoElseButMe:
thanks for your big engagement...
unfortunately, almost nothing that I try to script works. (I'm not really trying to achieve something here, just testing stuff)
Examples
as i already said, the following change inside the Land function WORKS:

Code: Select all

:u(02:0000033b)$my_msg$ = %s(4,"YEAH")

:u(02:0000033b)function $Land$
   
   :u(02:00000371)call $SendChatMessage$ arguments
      $string$ = $my_msg$


As soon as my skater lands, the words "YEAH" appear on my screen. so far so good

But if I try to change the string before printing it like this:

Code: Select all

:u(02:0000033b)$my_msg$ = %s(4,"YEAH")

:u(02:0000033b)function $Land$
   :u(02:00000371)call $Change$ arguments
      $my_msg$ = %s(4,"hello")
   :u(02:00000371)call $SendChatMessage$ arguments
      $string$ = $my_msg$

There is no message when landing at all!

I also tried to use your example of format string:

Code: Select all

:u(02:0000033b)function $Land$
   :u(02:0000033b)call $FormatText$ arguments
      $TextName$ = $msg$%s(7,"asdf%a")$a$ = %i(69,00000045)
   :u(02:0000033b)call $SendChatMessage$ arguments
      $string$ = %GLOBAL%$msg$

nothing is printed as well.. I'm totally freaking out, I copy examples line by line and they just dont work :( :(
So I call for help:
If somebody manage to print an formatted string when skater is landing, please send me the corresponding tricks.txt. Best thing would be if the formatted string contains the scorepot :D

Re: Script manipulation does nothing

Posted: Fri Dec 01, 2017 4:30 pm
by benne
pleaaaase help me... I'm working on this so many hours now and nothing works :( :( :(
update: to exclude all sources of errors I tried the PC version instead of PS2.
Also, I tried a different script: grindscripts.qb. (that decompiles correctly)
here I want to do some stuff as soon as I fall off ("bail") from a grind. Function name is "$SkateInOrBail$"

what works:

Code: Select all

:u(02:00000001)$my_string$ = %s(4,"test")
:u(02:00000001)function $SkateInOrBail$
   
   :u(02:00000006)call $SendChatMessage$ arguments
      $string$ = $my_string$

WORKS! As soon as I bail, "test" is printed as chat message



does NOT work: Changing String:

Code: Select all

:u(02:00000001)$my_string$ = %s(4,"test")
:u(02:00000001)function $SkateInOrBail$
   
   :u(02:00000006)call $Change$ arguments
      $my_string$ = %s(4,"aaaa")
   :u(02:00000006)call $SendChatMessage$ arguments
      $string$ = $my_string$

Here, some random stuff is printed as chat message (e.g. "____T____T") and changes every time I do it!

does NOT work: Format Text:

Code: Select all

:u(02:00000001)$my_int$ = %i(1,00000001)
:u(02:00000001)function $SkateInOrBail$
   
   :u(02:00000006)call $FormatText$ arguments
      $textname$ = $msg$%s(0,"Test: %a")$a$= ($my_int$)
   :u(02:00000006)call $SendChatMessage$ arguments
      $string$ = %GLOBAL%$msg$

Game crashes when I bail

does NOT work: creating local variable

Code: Select all

:u(02:00000001)function $SkateInOrBail$
   :u(02:00000001)$msg$ = %s(4,"aaaa")

Game crashes when I bail. (no need to print it, just declaring crashes the game)

I dont know what to do... I'm so lost, plz help!!

Re: Script manipulation does nothing

Posted: Fri Dec 01, 2017 5:57 pm
by Morten1337
Strings are not supported by the change function.
Also, I don't think the FormatText function exists in THPS3.

Re: Script manipulation does nothing

Posted: Fri Dec 01, 2017 10:50 pm
by benne
:oo
Oh my ... Really?? Well that explains quite alot :rolleyes:
Thank you... so there is no way to print integers or floats on the screen in thps3? Printf does not work as far as i know. That makes debugging and trying out stuff so difficult!

And last question, do you know the variable/checksum names of the accumulated score and the current score you do with a trick?