If you don't know what a mission is... you should probably play more Simpsons Hit and Run.
A mission is simply a mission... There are 4 types of missions in The Simpsons Hit and Run: story missions, street races, wager races, and bonus missions.
Creating a Mission File
There are two different ways to create a mission - using a .mfk file or using a .lua file.
To create a mission using a .mfk file, create a new folder in your Mod's root folder and title it CustomFiles (must include the capital letters). In this folder, create another new folder, titled scripts (all lowercase). In the scripts folder, create another new folder, titled missions (all lowercase). Finally, in the missions folder, create another folder titled level0X (all lowercase; replace X with a number from 1 to 7). In the level0X folder, you can create a new text file by Right Clicking > New > Text Document. Title the file mYi.mfk (where Y is a number from 1 to 7, or 0 to 7 in level01). This is the information file that the game reads when a mission is loading. In the same folder, you'll need to create another .mfk file - title it mYl (lowercase L, and again Y is a number from 1 to 7, or 0 to 7 in level01). This is the file that tells the game what objects/persons to load for the mission.
NOTE: You can also title the text file srYi for street races (where Y is a number from 1 to 3), gr1i for the Wager Race, and bm1i for the bonus mission. These files must also have a corrosponding srYl, gr1l, or bm1l file.
NOTE2: To edit the pre-mission file, create a text file titled mYsdi (and mYsdl) (Y is a number from 1 to 7) in the correct folder. For example, m1sdi is the pre-mission info for level0X's first mission.
To create a mission using a .lua file, create a new folder in your Mod's root folder and title it Resources (must be capitalized). In the Resources folder, there will be two things - a file titled mfk.lua (click here to download it) and a new folder, titled missions (all lowercase). In the missions folder, create another folder - titled levelX (where X is a number from 1 to 7). In the levelX file, create a new folder - which will be titled mY for a story mission (where Y is a number from 1 to 7; or 0 to 7 in level1), rY for a race (where Y is a number from 1 to 4; and 4 is the Wager Race) or bm for the bonus mission. In the mission folder, there will be 5 files - 4 text files and one .p3d file. Create the text files and title them mYinfo.lua, mYload.lua, mYpreinfo.lua, and mYpreload.lua. These replace the mYi.mfk, mYl.mfk, mYsdi.mfk, and mYsdl.mfk files, respectively. For the .p3d file, see the Using .p3d Files section below.
Differences Between .mfk and .lua Files
Before I explain how to create a basic mission, there are a few differences between .mfk and .lua format for missions.
In .mfk mission files, you must include a ; (semi-colon) symbol at the end of each line. For example:
AddStage(); AddObjective(); SetDestination( "simpsons_house", "carsphere" ); CloseObjective(); SetStageTime(45); CloseStage();In .mfk load files, you must use a single \ when typing out directories, like this:
LoadP3DFile("art\missions\level02\monkey.p3d")In .mfk mission files, if you want a part of the mission to be "ignored" by the game, use \\ as shown below:
AddObjective( "goto" ) SetDestination( "simpson_house", "carsphere" ) \\ This line will be ignored by the game. CloseObjective() \\ This line too! SetStageTime(75) \\ So many double backslashes!In .lua mission files, the ; (semi-colon) symbol is not used at the end of ANY lines. So, the above .mfk example would look like this in .lua:
AddStage() AddObjective() SetDestination( "simpsons_house", "carsphere" ) CloseObjective() SetStageTime(45) CloseStage()In .lua load files, you must use a double \\ when typing out directories, like this:
LoadP3DFile("art\\missions\\level02\\monkey.p3d")In .lua mission files, if you want a part of the mission to be "ignored" by the game, use -- as shown below:
AddObjective( "goto" ) SetDestination( "simpson_house", "carsphere" ) -- This line will be ignored by the game. CloseObjective() -- This line too! SetStageTime(75) -- So many double dashes!Keep this in mind as you work to create a basic mission.
Creating a Basic Mission
Now it's time for the purpose of this forum... creating a basic mission. To create a basic mission, first you'll need to tell the game what to do before the mission - the pre-mission info file will be used for this.
Create a text file titled m1sdi.mfk or m1preinfo.lua (depending on the route you chose when creating a mission file). Open the file. First, you'll need to tell the game what mission we are working with... so, in this case, we are working with the pre-mission 1 info. At the top of the text file, type the following:
SelectMission( "m1sd" )This tells the game to only load this file before mission 1 of level0X (or levelX). (Remember: In .mfk files, you must put a semi-colon at the end of the line.)
The next thing you'll type depends on the level you're working in. To find out what comes next, you'll need to look at the mission files of the original Simpsons Hit and Run. (These files can be found in the following directory: /VivendiUniversalGames/TheSimpsons***&Run/scripts/missions - or, if you have a shortcut to the game on your desktop, right-click it and choose Open File Location > scripts > missions.) Open the level and mission file that corrosponds to the mission file you are making. In this case, we'll open level01 and open the m1sdi.mfk file. Copy all the lines between SelectMission( "m1sd" ); and AddStage(); and paste them into your new text file. (Remember, if you're using a .lua file, remove the semi-colon from the end of each line!)
After pasting those lines, we'll create our first Mission Objective - or "stage" - in the mission.
Create a new line after the last one and type this:
AddStage()There should be nothing in the parenthesis - however, if it's the last stage in the mission file, it should say:
AddStage( "final" )These tell the game that a new objective is being added. For this "stage", we'll simply make this objective: Drive to the Simpsons' House.
To create this stage, first you'll need to add an objective. To add an objective, type this:
AddObjective( "goto" ) CloseObjective()When adding an objective, you'll need to specify what that objective is. For example, "goto" means Go To this Location, "talkto" means Talk to this Person, "race" means Race to Here, etc. In this example, we'll begin with a "goto" objective.
Next, you'll need to specify where to go to. For the Simpsons' House, the destination is "m2_simpsonhouse_sd", which you type like this:
AddObjective( "goto" ) SetDestination( "m2_simpsonhouse_sd", "carsphere" ) SetCollectibleEffect( "wrench_collect" ) CloseObjective()The "carsphere" is basically the checkpoint marker used in Checkpoint Races, but it can also be used as a destination marker. The "wrench_collect" effect makes the carsphere disappear correctly. If this is not included, the carsphere will disappear in a large cloud of yellow sparkles.
Next is the HUD icon. This is the icon used in the top-left corner of the screen to remind the player of the current objective. For this objective, we'll use the Simpsons House icon, which can be added like this:
SetHUDIcon( "simpsons" )The last thing to add to this objective is the mission objective text. For this example, the mission objective text is "Drive to the Simpsons' House." You can add it yourself using the CustomText file (tutorial here), or use the game's default text, which is objective 217. It can be added like this:
SetStageMessageIndex(217)Upon finishing the stage, type this line:
CloseStage()If done correctly, the stage should look like this:
AddStage() AddObjective( "goto" ) SetDestination( "m2_simpsonhouse_sd", "carsphere" ) SetCollectibleEffect( "wrench_collect" ) CloseObjective() SetHUDIcon( "simpsons" ) SetStageMessageIndex(217) CloseStage()Next, we'll create a "talkto" stage. In these stages, the objective is: Talk to Marge, Talk to Lisa, etc.
To create a talkto stage, first create a new stage as before.
AddStage() CloseStage()When creating the new objective for this stage, type "talkto", "both" instead of "goto", like this:
AddStage() AddObjective( "talkto", "both" ) CloseObjective() CloseStage()In this case, we want to talk to Marge. You'll need to look at the game's original file for this mission to see what the dialogue is coded as... because it is too advanced for this tutorial. When creating this talkto objective, type this:
AddStage() AddObjective( "talkto", "both" ) AddNPC("marge", "m1_marge_sd") AddObjectiveNPCWaypoint( "marge", "marge_walk_1" ) AddObjectiveNPCWaypoint( "marge", "marge_walk_2" ) SetTalkToTarget( "marge", 0, 0.2 ) CloseObjective() CloseStage()The "AddNPC" command adds the NPC (Marge, in this case) in a location (m1_marge_sd) mentioned in the .p3d file of this level/mission. The "AddObjectiveNPCWaypoint" commands tell the NPC (Marge) where to walk to (marge_walk_1 and marge_walk_2), which is used for when the NPC needs to walk back and forth (as seen in-game). The "SetTalkToTarget" command tells the game which character the player will talk to (Marge, in this case).
Remember to set a HUD icon and a Mission Objective text when creating this stage, as shown below:
AddStage() AddObjective( "talkto", "both" ) AddNPC("marge", "m1_marge_sd") AddObjectiveNPCWaypoint( "marge", "marge_walk_1" ) AddObjectiveNPCWaypoint( "marge", "marge_walk_2" ) SetTalkToTarget( "marge", 0, 0.2 ) CloseObjective() SetHUDIcon( "marage" ) SetStageMessageIndex(00) CloseStage()After this stage, copy the dialogue from the game's original file and paste it into your new file. Make sure it includes EVERYTHING between the AddStage() and CloseStage() lines. Also, because it is the final stage, make sure the first line of the stage reads:
AddStage( "final" )This will tell the game that there are no more stages after this one. When you finished creating the mission file, you'll need to type this closing line at the end:
CloseMission()
Creating a Mission Load File
This section is Coming Soon!
Using .p3d Files in Missions
This section is Coming Soon!
Other Useful Text Strings in Mission Files
There are many more basic text strings you can use for each stage. Here is a list of them, with a description:
RESET_TO_HERE()If the player selects "Restart Mission," the game will reload the mission starting with the stage that contains this line. If this is used in a pre-mission file, the game will load the mission from this point when selected from the "Mission Select" menu.
SetStageTime(30)This is used for a time limit in a stage. The number (in SECONDS) tells the game how much time to give the player. It can be set anywhere from 1 to 999 (*). If this is used in a mission, the stage it's used in must also include the following:
AddCondition("timeout") CloseCondition()This tells the game that if the TIME runs OUT, the player will fail the mission and have to start over.
TurnGotoDialogOff()This MUST be used along with an AddObjective( "goto" ) stage. It will turn off all dialogue of the player when they arrive at their destination.
DisableHitAndRun()This will disable Hit and Run in the stage it is used in. It will not carry over through the entire mission/level.
AddCondition( "outofvehicle" ) SetCondTime(10000) CloseCondition()This tells the game that if the player is out of their vehicle for 10,000 MILLISECONDS (10 seconds), they will fail the mission. The Condition Time can be any number in milliseconds.
ShowStageComplete()This will cause the "Task Complete!" text to appear on-screen when a stage is completed. It is recommended to NOT use this at the end of a mission, as it will display the Task Complete and Mission Complete text at the same time on-screen.
AddCondition( "damage" ) SetCondMinHealth ( 0.0 ) SetCondTargetVehicle( "current" ) CloseCondition()This will tell the game that if the player destroys their vehicle, they will fail the mission. The Condition Min. Health is the lowest amount of health that the player's vehicle can be in during that stage (must be a decimal, such as 0.0). The Condition Target Vehicle is the vehicle that must be destroyed in order to fail the mission. Current is the player's current vehicle that they are driving.
StartCountdown( "count" ) AddToCountdownSequence( "3", 1000 ) AddToCountdownSequence( "2", 1000 ) AddToCountdownSequence( "1", 1000 ) AddToCountdownSequence( "GO", 400 )This will trigger the countdown used at the start of Street Races. The "3", "2", "1", and "GO" must be in quotes, because they are the names of the text used in the CustomText file. The number after it (1000, as shown above) is the time, in MILLI-seconds, that the number will be on-screen for.
AddStageTime(45)This will tell the game how much time, in seconds, to add to the time remaining from the previous stage. Again, it can be set to any number from 1 to 999 (*) and must include the "timeout" condition with it.
NOTE: When setting Stage Time, using 0 will make the game default the timer to 1. Using -1 (yes, you can use -1) will not spawn the timer, and there will be no time limit.
CREDITS
legomariofanatic - Created Tutorial
Donut Team - Created the mfk.lua file
Other Mission Tutorials
Creating a Item-Collecting Mission
Creating a Follow Mission
Coming Soon: Creating a Destroy Mission
Coming Soon: Creating a Follow-and-Collect Mission
Coming Soon: Creating an Avoid Mission
Coming Soon: Creating a Simple Race Mission
Coming Soon: Creating a Checkpoint Race
Coming Soon: Creating a Race with Laps
Coming Soon: Creating a Hit-and-Collect Mission
Coming Soon: Creating a Wager Race