Forum Mod Bakery Docs

Creating a Mission: How to Make a Follow Mission

Posted in Support
Please login to contribute to the conversation.
What are Follow missions?
Follow missions are missions where you must follow a certain vehicle from Point A to Point B, without letting that vehicle get too far away from you.

Before Starting...
Before you create a follow mission, you should probably read the Creating a Mission: The Basics thread.

Creating the Mission
In your level's mission file, create a new stage with the following setting:
AddStageVehicle( "VEHICLE_NAME", "VEHICLE_LOCATION", "NULL", "VEHICLE_STATS", "DRIVER" )
...where VEHICLE_NAME is the file name of the .p3d file that contains the vehicle's model, VEHICLE_LOCATION is the starting point of the vehicle (taken from the mission's .p3d file), VEHICLE_STATS is the .con file that you want to use which contains vehicle stats (found in the /Missions/level0X directory), and DRIVER is the name of the person that will drive the vehicle (which can be left out if you want to have no driver).

As an example, if you want Snake to drive Frink's hover car, starting at the Level 5 museum, you would type:
AddStageVehicle( "frink_v", "m5_museum_start", "NULL", "\Missions\level06\M3chase.con", "snake" )
NOTE: If you are using a .lua file, use a double backslash ( \\ ) instead of a single one ( \ ).

After the AddStageVehicle line, you'll need to put in some waypoints that the vehicle drives to... These are used to set the vehicle's path around the level. To add a waypoint, type this immediately after the AddStageVehicle line:
AddStageWaypoint( "WAYPOINT_NAME" )
...where WAYPOINT_NAME is the name of the waypoint in the mission's .p3d file. You can add as many waypoints as you need to in a mission.

After creating the vehicle and its path in the mission, you'll need to add a new objective to the stage:
AddObjective( "follow", "neither" )
   SetObjTargetVehicle( "VEHICLE_NAME" )
CloseObjective()
...where the VEHICLE_NAME should match the VEHICLE_NAME that you used in the AddStageVehicle setting.

Adding a Fail Condition
In order to fail the mission (due to getting too far away from the follow vehicle), you'll need to add a fail condition. To add a fail condition to the follow mission, add these lines under the objective (from above):
AddCondition( "followdistance" )
   SetFollowDistances(0, 150)
   SetConditionVehicle( "VEHICLE_NAME" )
CloseCondition()
...where the first number (0, in this case) is the highest point of the Follow Meter in-game (which means that if you are 0 meters away from the vehicle you are following, the Follow Meter will be full), and the second number (150, in this case) is the lowest point of the Follow Meter in-game (which means that if you are 150 meters away from the vehicle you are following, the Follow Meter will be empty - and you'll fail the mission). The VEHICLE_NAME must also match the vehicle name used earlier, in order for the game to know which vehicle you must be following.

Adding Items to the mYl.mfk or mYload.lua File
The vehicle you are following must also be in the mission load file, otherwise the game will crash. To add the vehicle to the mission load file, type this inside the file:
LoadDisposableCar("art\cars\VEHICLE_NAME.p3d", "VEHICLE_NAME", "AI" )
...where VEHICLE_NAME is the name of the .p3d file that contains the vehicle's model.

NOTE: If you are using a .lua file, use a double backslash ( \\ ) instead of a single one ( \ ).


Other Mission Tutorials
The Basics
Creating an Item-Collecting Mission
Coming Soon: Creating a Destroy Mission
Coming Soon: Creating a Follow-and-Collect 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
For Paths, you should be using \ (or \\ in Lua) instead of /.
Well, the / worked for me, so... I did the tutorial based on that...
Just because it works doesn't mean it's the right way to do it. I'd use \ or \\. It's a fluke if it happens to work in a place that is supposed to take \ and not /.

Also there's a typo in LoadDisposableCar near the end. Might want to fix that.

Other than that, good tutorial as per usual. I'm writing my own series of mission tutorials but I'm covering it a bit differently than you, I might still make yours official at some point anyways alongside mine.
You're covering the mission tutorials differently? That makes sense... my "Mission Basics" tutorial is OVERLY lengthy...
Yeah I plan on getting to that and Custom Music after I finish writing my Custom Files tutorial (this one is lengthy).
When will p3d tutorials come out?
a bit late joining this thread, but just wanted to ask for instance, if I want to change l1m1 from a race against skinner to following skinner instead (waypoints are the same etc), how would I go about doing it? I altered the current m1i file using this tutorial, but when I click enter to start the mission, I get an access at violation error.
Hi, IX, I know this is late to answer, But I see your Problem. By which you already answered it, did you change the setting of the mission instead of Race, to Follow? That is what you would have to do in order to change the way the game is seen.
[deleted user]
2 yrs ago (Statistics)
Hey, I'd advise you not to reply to 5 year old outdated topics, since they're, uh, 5 year old and outdated
Instead, you should create a separate thread describing your problem in detail