Mission Coding for Dummies-Rockstar Style Mission

A Tutorial for Grand Theft Auto: San Andreas

Greetings! We are one of the oldest mod sites on the Interwebs. Sign up and maximize your browsing experience.

  • Subscribe: Get notified of new submissions like this.
  • Say Thanks: Show your appreciation by sending Arman Ossi Loko points.
  • Post: Give Arman Ossi Loko your thoughts on this Tutorial.
  • Vote: Help Arman Ossi Loko win the Monthly Awards.
  • Rate: Give this Tutorial a rating out of 10.
  • Flag: Alert moderators and warn members of a problem with this Tutorial.
  • Watch: Get notified when this Tutorial is updated.
Mascot

Join the community!

Sign up

Already a Bananite? Login

A complete mission ( Rockstar Style )

A complete mission ( Rockstar Style ) In this tutorial, I will explain you how to make a real mission, just like Rockstar. So it will not be in a simple thread like the previous tutorials. First we will show the structure and specifics, then we will give templates for the different parts and explain these. Finally we will show you a mission based on this templates. Structure Missions like they are made by Rockstar have other behaviours then normal threads. First the code is only read when the mission starts, so there is only 1 mission at the same time active. Another big difference is how the code react when a player is Busted or Wasted. In a normal thread, you always have to check if the player is defined, but this isn't necessary in a mission-structure. When the player is Wasted or Busted, the SCM-engine will generate a "return"-opcode. So you don't have to check it during the mission. The framework which you should use to create a reak mission, will be explained later on in this mission. You will need two parts to make a mission: The mission itself The so called "sniffer"-thread, which checks the starting conditions of the mission and whether the player triggers a mission (like walk into a sphere). For both parts we will give you a template, which you can use for your own project. Sniffer-thread template The sniffer-thread will be started, when the missions are available. This can be directly from the start of the game, or when you passed other missions. This template contains the code for a sniffer-thread with two missions, but you can easily extend this with many more missions, which can be played after each other. CODE > // $TUT_MISSION_PASSED has to be cleared (0). // When you pass the mission, you have to raise $TUT_MISSIONS_PASSED. :TUT_MISSIONS_SNIFFER thread "TUT_SNIFF" $MARKER_SWEET_HOUSE = Marker.CreateIconAndSphere(42, <>, <>, <>) repeat wait $DEFAULT_WAIT_TIME if and player.Defined($PLAYER_CHAR) $ONMISSION == 0 then if and 00FF: actor $PLAYER_ACTOR sphere 0 in_sphere <>, <>, <> radius 1.0 1.0 2.0 on_foot Player.Controllable($PLAYER_CHAR) $TUT_MISSIONS_PASSED == 0 then $ONMISSION = 1 00BA: show_text_styled GXT 'INTRO_1' time 1000 style 2 start_mission 1 end if and 00FF: actor $PLAYER_ACTOR sphere 0 in_sphere <>, <>, <> radius 1.0 1.0 2.0 on_foot Player.Controllable($PLAYER_CHAR) $TUT_MISSIONS_PASSED == 1 then $ONMISSION = 1 00BA: show_text_styled GXT 'INTRO_2' time 1000 style 2 start_mission 2 end end until $TUT_MISSIONS_PASSED == 2 marker.Disable($MARKER_SWEET_HOUSE) end_thread This thread will make a sphere on the specified location, where you have to start the missions. It will wait until the player walks into the sphere and stop running when both missions are passed. While $TUT_MISSIONS_PASSED is 0, none of the missions is passed. When the player walks into the sphere, it will start the first mission. After the player passed the first mission, $TUT_MISSIONS_PASSED will be 1. Then the sniffer-thread will wait until the player walks into the sphere. After the player passed the second mission, $TUT_MISSIONS_PASSED will be 2, so the loop will be ended, the sphere will be destroyed and the thread will end. Mission template CODE > //-------------Mission 1--------------- // Mission wrapper :TUT_MISSION_1 thread 'TUT 1' gosub @TUT_MISSION_1_MAIN if wasted_or_busted then gosub @TUT_MISSION_1_FAIL end gosub @TUT_MISSION_1_CLEANUP end_thread //------------------------------------- :TUT_MISSION_1_MAIN //------------------------------------- :TUT_MISSION_1_PASSED Player.Money($PLAYER_CHAR) += 10000 01E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1 // MISSION PASSED!~n~~w~$~1~ // This subroutine is executed when the mission is passed. // Give the rewards, and make new missions available if needed. return //------------------------------------- :TUT_MISSION_1_FAIL 00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1 // ~r~MISSION FAILED! // This subroutine is executed when the mission fails. return //------------------------------------- :TUT_MISSION_1_CLEANUP $ONMISSION = 0 // This subroutine is always executed at the end of the mission, regardless the outcome. // This is the place to unload models etc. mission_cleanup return The first part of the code is called the mission-wrapper, which calls the various parts of the mission with the help of a "gosub". This way there can be an automatic "return" after the player is WASTED or BUSTED. First he calls the main part of the mission. When it comes back, there can be two possible scenarios:[list] •An automatic "return", because the player is Wasted or Busted. In this case the mission failed will be called, and after that the "cleanup" routine, which cleans everything up. •The mission is Passed or Failed for other reasons. In this case the mission_passed or mission_failed routine has already been called, so only the clean up has to happen. Below TUT_MISSION_1_MAIN will follow al the code for the gamneplay of the mission. In the complete example below, you will see how you can call the mission_passed and the mission_failed routines from within the main part, in certain situations. Example Mission Based on the above templates we made a simple mission. We will use the things we learned in the earlier tutorials. The purpose of the mission, which you can start in front of Sweet's house, is to kill an actor. There are two actors, a man and a woman. The woman is an enemy, the man is a friend. When you kill the woman, the mission is passed, but if you kill the man, the mission is failed. When the player is wasted or busted before the woman is killed, the mission will fail too. Click here to view the complete code The first part of the code, is the standard part of the stripped SCM file. The only thing you have to add, is for the start of the sniffer-thread: CODE > 00D7: create_thread @TUT_MISSIONS_SNIFFER Finally we will make a loop in the main-thread (:MAIN_LOOP). Then there is the sniffer thread, based on the template, but reduced to one mission. You will see that we defined two missions, the fist (mission 0), we will use, just like Rockstar, for initialising many things. Here you can add cargenerators or, for example, weapon pickups. We will set $TUT_MISSIONS_PASSED to 0, and we will define 3 variables for the mission trigger. The second mission (mission 1) is set up just like the template. In the main part, the models are loaded, the actors spawned, the weapons assigned and the car spawned, just like in previous tutorials. After that, the code waits in a loop, until $VICTIM is dead. In this case the code will go through the mission_passed routine, and the mission is finished. During the loop it will be checked whether the innocent man is still alive. When that isn't the case, we will jump to the mission_failed routine and the mission will end. In the mission passed routine, we will set a message on the screen, we will award the player some money and we will raise $TUT_MISSIONS_PASSED. In the mission failed routine, we will set a message on the screen and we will take away the weapon which we gave to him for this mission. In the cleanup routine, we clean up every used model, and we will set the wanted-level back to 0.

Posts

None found

Share

Shareable Image:
Share banner
HTML embed code:
BB embed code:
Markdown embed code:

More embeddable images

Bookmark and Share

Credits

Original Authors
Dutchy3010

Submitter

Arman Ossi Loko avatar
Arman Ossi Loko avatar Lurkin'
Admin Joined 10y
71,925 points Ranked 56th
63 medals 9 legendary 16 rare
  • GTAV First Adopter Medal icon
  • Submitted 15 Tools Medal icon
  • Submitted 30 Tutorials Medal icon
  • 1st place - 2015 Uberstyles Contest Medal icon
  • Achieved Admin clearance Medal icon
  • 15+ Entries! GameBanana’s Christmas Giveaway 2015 Medal icon

Arman Ossi Loko avatar
Arman Ossi Loko
KOPASSUS Incorporated Flag
KOPASSUS Incorporated

Redistributor
Are you the owner? Request Ownership
Sign up to access this!
Sign up to access this!
Sign up to access this!
Sign up to access this!

Category

Details

Difficulty Level
Beginner Difficulty

Attributes

Stats

Posts
0
Views
1,572
Date Added
5y
Date Modified
4y
bcp.crwdcntrl.net tracking pixel