Introduction: (San Andreas PC specific, but the same general principles apply to GTA3 era games)
This question (paraphrased) came up in PM and I wanted to move the discussion to the open forums for others to use as reference. This is intended as an introductions to saved data and game scripts, and I won't answer the current question right away.
This topic will cover the basics of getting started with decompiling the main script file (main.scm) using Sanny Builder 3 and figuring out what the mess of bizarre codes might mean.
SASE 1.00 will be used to view and modify save information. This isn't exactly a perfect editing tool, but it's a powerful save viewer and much easier to use than a hex editor or learning to write custom cleo scripts.
I'll fill in the blanks later if necessary but I'll trust that readers won't have too much trouble searching for official links to Sanny or finding specific files in their data folders.
Decompiling with Sanny
If you are working with a decompiled main.scm in Sanny you run the risk of accidentally hitting Compile and Copy or otherwise overwriting your original main.scm, so make a backup, and zip up your backup for safe keeping. script.img is paired with main.scm, so keep them together in the same archives. Then make a another copy of your backup folder in your user files and decompile those.
Rename your decompiled main scripts to keep track of their purpose and decompile settings. unmoddified.GTASA.v1.default.main.scm, for whatever you get out of the box.
Decompiled scripts will look much different depending on the settings. It won't make much sense if my examples look different than yours so I'll cover some specific settings. However, I've made many adjustments to Sanny over the years and sometimes lose track of why I set what. Hopefully I haven't mess things up too much.
Debug Options - gear icon on right of menu bar
- ON = CONSTANT_INDEXES (don't know why)
- all others off
Edit Mode - game icon in lower right corners
- use GTA SA mode - this is the format everyone has been using for many years
- GTA SA SCR - original Rockstar command names and format (not always compatible)
- SA Mobile - mobile versions have different commands and variable names
Tools > Options (F10)
- off = Always overwrite output file
- on = Show progress
- on = Show report
- on = Show warning
- off = Manual IMG opening
- on = Quick game loading
- on = Conditions check
- on = Ranges check
- on = Write opcodes (this will force the display of all opcodes)
- on = Insert original mission names
- off = Add extra info to SCM
- use Thread+Local Offset (most common setting)
- off = hex offsets
- on = Custom label names (MS_Riot_Missions)
- on = Custom variable names ($Riot_Total_Passed_Missions)
- off = Custom array names
- Case conversion: As is
The specific issue is that the Riot mission won't start even though all the mission requirements have been unlocked. First I want to show a few examples from the RIOT sniffer thread. This is the thread that is supposed to loop in memory and start the RIOT1 mission when CJ is inside the marker. But before I show the full snippet I want to show a few examples of how the code vary depending on the setting.
Decompile main.scm using the settings above, then make the changes below:
:MS_Riot_Missions 03A4: name_thread 'RIOT' :RIOT_11 0001: wait $DEFAULT_WAIT_TIME ms 00D6: if 0038: $Riot_Total_Passed_Missions == 5 004D: jump_if_false @RIOT_36 004E: end_thread
Write Opcodes OFF (close to default, I think)
:MS_Riot_Missions thread 'RIOT' :RIOT_11 wait $DEFAULT_WAIT_TIME if $Riot_Total_Passed_Missions == 5 jf @RIOT_36 end_thread
Hex Offsets, Custom label names OFF, UPPER case conversion (upper might be default)
:RIOT thread 'RIOT' :RIOT_B wait $DEFAULT_WAIT_TIME if $RIOT_TOTAL_PASSED_MISSIONS == 5 jf @RIOT_24 end_thread
Thread+Global Offset, Custom variable names OFF, lower case conversion
:riot_12257 thread 'RIOT' :riot_12262 wait $14 if $629 == 5 jf @riot_1227B end_thread
Reset to the suggested settings at the top.
Change to the GTA SA SCR edit mode.
:MS_Riot_Missions 03A4: script_name 'RIOT' :RIOT_11 0001: wait $DEFAULT_WAIT_TIME 00D6: if 0038: $Riot_Total_Passed_Missions == 5 004D: goto_if_false @RIOT_36 004E: terminate_this_script
Up until we started SCR mode, Sanny would work with any of the format setting. Sanny can figure out which opcodes belong where during compile. An import difference in SCR mode, besides it not being setup to find vehicles.ide, is that SCR uses a handle first format which makes these codes incompatible. The text changes don't matter, but the change in the sequence of the variables ($7997) makes a huge difference.
00A5: $7997 = create_car #CAMPER at 1242.9 -805.4 82.9 // GTA SA 00A5: create_car 483 at 1242.9 -805.4 82.9 store_to $7997 // GTA SA SCR