Jan 28 2010, 05:33 PM Post #1 | |
Coding like a Rockstar! Posts: 1,468 From: ??? Joined: 28-May 09 | The San Andreas main.scm is a complex thing. It does many operations and activates many things according to situation. Various methods are used to shorten the file, such as making threads that do a task that has to be repeated many times and running it when needed. This topic will document the basic structure, letting you know which things loop and what important elements are required within them. Note, of course that you can leave a lot of the threads out depending on the main.scm you're building... But this just documents the default SCM, giving you an idea of the type of things that can be added. Hopefully you find it useful when next making a main.scm to be as good as Rockstars! CODE BEGIN BEGIN INITIAL DEFINITIONS DEFINE_OBJECTS DEFINE_MISSIONS DEFINE_EXTERNALS DEFINE_UNKNOWN_MEMORY END INITIAL DEFINITIONS BEGIN INITIAL CODE SET_INITIAL_GAME_STATUS CREATE_PLAYER SET_SOME_PLAYER_STUFF START_INITIAL_MISSION [wait 0] START_INITIAL2_MISSION CREATE_PICKUPS ASSIGN_GLOBALS NOP_EXTERNALS SET_EXTERNAL_SCRIPT_TRIGGERS CREATE_TEMP_MAP_OBJECTS CREATE_THREADS CREATE_THREADS_NO_EXTRA_PARAMS PREPARE_MISSION_2 END INITIAL CODE BEGIN MAIN LOOP ASSIGN_SOME_GLOBAL_VARIABLES CHECK_AND_RUN_EXTERNALS BEGIN_VIDEOGAME_SUBMISSIONS CHECK_AND_RUN_MORE_EXTERNALS RESTART MAIN LOOP BEGIN MISSION CHECK THREADS END_THREAD_IF_MISSIONS_PASSED CHECK_AND_START_MISSIONS GOSUB_OVERVIEW_ENTERED_SPHERE_AND_FADE_OUT* RESTART MISSION CHECK THREADS BEGIN EXTERNAL CHECK RESTART EXTERNAL CHECK BEGIN COLLECTABLES CHECK PLAY_MUSIC_IF_A_COLLECTABLES_OBJECTIVE_ACHIEVED SET_STUFF_IF_SINGLE_COLLECTABLES_OBJECTIVE_DONE RESTART COLLECTABLES CHECK BEGIN GANG TERRITORY CHECK ENDIF_MONEY_PICKUP_EXISTS SET_CASH_ACCORDING_TO_TERRITORIES_OWNED RESTART GANG TERRITORY CHECK BEGIN MILLIE KEYCARD COLLECT CHECK ENDIF_KEYCARD_PICKED_UP RESTART GANG TERRITORY CHECK BEGIN SAVE GAME PICKUP CHECK RECREATE_PICKUPS_IF_NONEXISTANT SAVEIF_SAVE_PICKUP_PICKED_UP RESTART SAVE GAME PICKUP CHECK BEGIN HELP CHECK SHOW_HELP_ACCORDING_TO_SITUATION RESTART HELP CHECK BEGIN INTRO CHECKS SHOW_HELP_ACCORDING_TO_SITUATION ENDIF_PLAYER_ABOUT_TO_DO_FIRST_RYDER_MISSION RESTART INTRO CHECKS BEGIN LAST MISSION CHECKS DO_OR_SET_THINGS_ACCORDING_TO_LAST_MISSION ENDIF_ALL_PASSED RESTART LAST MISSION CHECKS BEGIN ROTATE DOORS CHECKS ROTATE_DOOR_ACCORDING_TO_SITUATION END ROTATE DOORS CHECKS BEGIN DISPLAY TEXT SUB DISPLAY_MONEY_GAIN_WITH_HANDED_VARIABLES END DISPLAY TEXT SUB BEGIN MORE EXTERNALS CHECK_AND_RUN_EXTERNALS RESTART MORE EXTERNALS BEGIN GET TIME SINCE LAST CALL SUB GET_TIME_SINCE_LAST_CALL END GET TIME SINCE LAST CALL SUB BEGIN SET AVAILABLE PROPERTIES SET_AVAILABLE_PROPERTIES_ACCORDING_TO_UNLOCKED_CITIES SET_AVAILABLE_ACCESS_INTERIORS_ACCORDING_TO_UNLOCKED_CITIES ENDIF_ALL_AVAILABLE_THINGS_SET RESTART SET AVAILABLE PROPERTIES BEGIN PROJECT OBJECT SUB PROJECT_OBJECT_AND_GET_RESULT END PROJECT OBJECT SUB BEGIN GAME THREADS BASKETBALL_GAME LOWRIDER_GAME END GAMES BEGIN AUDIOLINE SUB THREADS AUDIOLINE CLEAN_AUDIOLINE END AUDIOLINE SUB THREADS BEGIN DRAW DANCE GAME TEXTURES SUB DRAW_TEXTURES END DRAW DANCE GAME TEXTURES SUB BEGIN IMPORT EXPORT THREAD IMPORT_EXPORT END IMPORT EXPORT THREAD BEGIN AIRPORT THREADS GOTO_OPEN_CLOSE_FENCE_WHEN_NEAR_THREAD MAKE_AIRPORT_GUARD_SPEAK_WHEN_NEAR OPEN_CLOSE_FENCE END AIRPORT THREADS [AND EVEN MORE THREADS I CANT BE BOTHERED DOCUMENTING] BEGIN CELLPHONE THREAD SET_CELLPHONE_SUBTITLES_ACCORDING_TO_CALL_VARIABLE SET_CELLPHONE_AUDIO_ACCORDING_TO_CALL_VARIABLE DO_CELLPHONE_CALL END CELLPHONE THREAD [AND EVEN MORE THREADS I CANT BE BOTHERED DOCUMENTING] BEGIN MISSIONS MISSION SET_VARIABLES_ACCORDING_TO_MISSION_IF_NECESSARY END MISSIONS BEGIN EXTERNALS EXTERNAL END EXTERNALS END The MISSION CHECK THREADS are a load of threads created by the last mission of each set of missions. These check if the player is in the mission sphere with any other required variables and if so, starts the next mission. It ends itself all the missions have passed. If not, it loops. However, these also include the sub-mission activation threads, which are started by the CREATE THREADS in the INITIAL CODE. The INTRO CHECKS thread does things while the player is doing the first missions (where CJ rides a BMX to Grove, does the first real missions where he rides away from ballas in the red car, goes in his house and then exits). This includes showing messages like "Grove Street - Home.", "Go inside CJ's house to continue." and "~s~Go and see Ryder, he lives down the street.". *displays the mission text and then gosubs to a globally used sub which points the camera at the building near the mission sphere the player has entered from a distance and fades out. Basically, the thing that happens when you enter a mission sphere.. -------------------- | CLEO 4.3.22 | A?i?a?o?3D | UI SDK | Black Market Mod 1.0.1 | GInput 0.3 | Cheat Keyboard | Tactile Cheat Activation | Stream Ini Extender 0.7 | SuperVars | ScrDebug | Vigilante Justice: San Andreas | |