--[[
mm_p_01.lua
SR3 Mission Script
DATE: 9-2-2010
AUTHOR: Jimmy Cross
]]--
-- Debug flags --
-- Tweakable Parameters --
-- Groups --
MM_P_01_group = {
helicopter = "mm_p_01_heli"
}
-- Navpoints --
MM_P_01_navs = {
hq = "MM_P_01_Nav_Saints_HQ",
cp_start = { "local_tele", "remote_tele" }
}
-- Triggers --
MM_P_01_trigger = {
--[[
hq = {
name = "HQ_trigger",
hit = false
}
]]--
}
-- Characters --
MM_P_01_DRIVER = "npc_Heli_Pilot"
-- Vehicles --
MM_P_01_HELICOPTER = "veh_Player_Heli"
-- Mesh Movers --
-- Text --
-- Threads --
MM_P_01_HELI_FLIGHT = INVALID_THREAD_HANDLE
-- Checkpoints --
MM_P_01_checkpoint = {
start = {
name = MISSION_START_CHECKPOINT,
nav1 = "start_nav 001",
nav2 = "start_nav 002"
}
}
-- Cutscenes --
MM_P_01_cutscene = "P_Z01"
-- Other --
local MM_P_01_HELI_PATH = "heli_path"
local MM_P_01_HELI_SPEED = 35
local MM_P_01_HELI_MAX_BANK_ANGLE = 12
local mission_success = false
-- *************************
--
-- Standard functions
--
-- *************************
-- This is the primary entry point for the mission, and is responsible for starting up the mission
-- at the specified checkpoint.
-- CALLED FROM CODE
--
-- checkpoint: The checkpoint the mission should begin at
-- is_restart: TRUE if the mission is restarting, FALSE otherwise
--
function mm_p_01_start(checkpoint, is_restart)
--zscene_prep( MM_P_01_cutscene )
if( MM_P_01_cutscene ~= "" ) then
--cutscene_in()
zscene_prep( MM_P_01_cutscene )
while( not zscene_is_loaded(MM_P_01_cutscene) ) do
thread_yield()
end
cutscene_play( MM_P_01_cutscene, nil, MM_P_01_navs.cp_start, false )
--cutscene_out()
end
-- Handle mission initialization for the current checkpoint
mm_p_01_initialize(checkpoint)
-- Run the mission from the current checkpoint
mm_p_01_run(checkpoint)
end
-- This is the primary function responsible for running the entire mission from start to finish.
--
-- first_checkpoint: The first checkpoint to begin running the mission at
--
function mm_p_01_run(first_checkpoint)
local current_checkpoint = first_checkpoint
-- Run the mission from the beginning
if( current_checkpoint == MM_P_01_checkpoint.start.name ) then
--[[ INSERT PROCESSING FOR THE FIRST CHECKPOINT HERE ]]--
inv_weapon_add_temporary( LOCAL_PLAYER, "Explosive-RocketLauncher" )
if coop_is_active() then
inv_weapon_add_temporary( REMOTE_PLAYER, "Explosive-RocketLauncher" )
end
inv_weapon_disable_all_but_this_slot( WEAPON_SLOT_EXPLOSIVE, true, SYNC_ALL )
vehicle_enter_teleport( MM_P_01_DRIVER, MM_P_01_HELICOPTER, 0, true )
vehicle_enter_teleport( LOCAL_PLAYER, MM_P_01_HELICOPTER, 2, true )
set_player_can_enter_exit_vehicles( LOCAL_PLAYER, false )
if coop_is_active() then
vehicle_enter_teleport( REMOTE_PLAYER, MM_P_01_HELICOPTER, 3, true )
set_player_can_enter_exit_vehicles( REMOTE_PLAYER, false )
end
-- Start fading in
mission_start_fade_in()
delay(1)
mission_set_cancel_warp_location( "local_player", "remote_player" )
marker_add( MM_P_01_navs.hq, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL )
objective_text( 0, "MM01_OBJ_GOTO_GA", nil, nil , SYNC_ALL, OI_ASSET_LOCATION )
if MM_P_01_HELI_FLIGHT == INVALID_THREAD_HANDLE then
MM_P_01_HELI_FLIGHT = thread_new("mm_p_01_heli_flight")
end
delay(4.5)
audio_persona_load_2d("Pierce")
local mission_convo_handle = audio_conversation_load("mm_p_01_ga_drive_start") --("MM_P_01_GA_Drive_Start")
audio_conversation_play( mission_convo_handle )
audio_conversation_wait_for_end( mission_convo_handle )
audio_conversation_end( mission_convo_handle )
delay(.5)
mission_success = true
fade_out(0)
fade_out_block()
-- Delay to hopefully let the client catch up
delay(1)
-- Clear the cancel warps, so that we don't warp an extra time before starting the activity
mission_set_cancel_warp_location()
mission_end_to_activity("mm_p_01", "_A_GA_DT_03")
end
end
-- This is the primary function responsible for cleaning up the entire mission
-- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++)
--
function mm_p_01_cleanup()
--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]--
objective_text_clear(0)
marker_remove( MM_P_01_navs.hq, SYNC_ALL )
inv_weapon_disable_all_slots( false, SYNC_ALL )
inv_weapon_remove_temporary( LOCAL_PLAYER, "Explosive-RocketLauncher" )
if coop_is_active() then
inv_weapon_remove_temporary( REMOTE_PLAYER, "Explosive-RocketLauncher" )
end
inv_weapon_disable_all_slots( false, SYNC_ALL )
if MM_P_01_HELI_FLIGHT ~= INVALID_THREAD_HANDLE then
thread_kill( MM_P_01_HELI_FLIGHT )
MM_P_01_HELI_FLIGHT = thread_new("mm_p_01_heli_flight")
end
set_player_can_enter_exit_vehicles( LOCAL_PLAYER, true )
if coop_is_active() then
set_player_can_enter_exit_vehicles( REMOTE_PLAYER, true )
end
group_destroy( MM_P_01_group.helicopter )
end
-- Called when the mission has ended with success
-- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++)
--
function mm_p_01_success()
--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]--
end
-- *************************
--
-- Local functions
--
-- *************************
-- Initialize the mission for the specified checkpoint
--
-- checkpoint: Checkpoint to initialize the mission to
--
function mm_p_01_initialize(checkpoint)
-- Make sure the screen is completly faded out
mission_start_fade_out(0.0)
-- Set the mission author
set_mission_author("Jimmy Cross")
-- Common initialization
mm_p_01_initialize_common()
-- Checkpoint specific initialization
mm_p_01_initialize_checkpoint(checkpoint)
end
-- ***************************************************
-- mm_p_01_run Helper Functions
-- ***************************************************
-- ***************************************************
-- mm_p_01_initialize Helper Functions
-- ***************************************************
-- Handle any common initialization
--
function mm_p_01_initialize_common()
--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]--
end
-- Checkpoint specific initialization
--
-- checkpoint: The checkpoint to be initialized
function mm_p_01_initialize_checkpoint(checkpoint)
if (checkpoint == MM_P_01_checkpoint.start.name) then
--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]--
group_create( MM_P_01_group.helicopter, true )
end
end
-- ***************************************************
-- Miscellaneous mm_p_01 Helper Funcrtions
-- ***************************************************
-- *************************
--
-- Callback functions
--
-- *************************
-- *************************
--
-- Thread functions
--
-- *************************
function mm_p_01_heli_flight()
helicopter_set_max_bank_angle( MM_P_01_HELICOPTER, MM_P_01_HELI_MAX_BANK_ANGLE )
helicopter_fly_to(MM_P_01_HELICOPTER, MM_P_01_HELI_SPEED, MM_P_01_HELI_PATH)
end