--[[
sh03.lua
SR3 Mission Script
DATE: 8/18/2010
AUTHOR: Jimmy Cross
]]--
-- Debug flags --
-- Tweakable Parameters --
local SH03_NOTERIETY_LEVEL = 1
local SH03_HELI_MAX_BANK_ANGLE = 15
local SH03_HELI_ARRIVAL_SPEED = 22
local SH03_HELI_LAND_SPEED = 10
local SH03_HELI_SPEED = 17
local SH03_UPDATE_DIST = 10
local SH03_SPECIALIST_DELAY = 22.0
local SH03_SOLDIER_DELAYY = 13
local SH03_TIMER = 100
-- Groups --
sh03_group =
{
START =
{
name = "start_group",
members = {"NPC_Kinzie"},
},
START_CAR =
{
name = "start_car_group",
members = "Courtesy car",
},
ROOM_DEFENSE =
{
name = "Router 001",
members ={ "decker 01", "decker 02", "Decker 03", "Decker 04", "Decker 05", "Decker 06", "decker 07", "decker 08", "Decker 09", "decker 10", "Decker 11", "Decker 13" , "decker 14", "Decker 16" , "Decker 17" },
size = 15
},
STAIRS =
{
name = "stairs_npcs",
members = { "stairs01", "stairs02" }
},
HELICOPTER =
{
name = "helicopter_group",
members = {"Rail_Heli", "Heli_Pilot"}
},
ATTACK_SPEC =
{ --specialist group
name = "attack_group 001",
members ={ "Decker 23" }
},
ATTACK_SOL =
{ --soldier group
name = "attack_group 002",
members ={ "Decker 24", "Decker 25" }
},
WAVE_ONE =
{
name = "wave01",
members = { "defender1_1", "defender1_2", "defender1_3", "defender1_4" },
thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE },
size = 4
},
WAVE_TWO =
{
name = "wave02",
members = { "defender2_1", "defender2_2", "defender2_3", "defender2_4" },
thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE },
size = 4
},
WAVE_THREE =
{
name = "wave03",
members = { "defender3_1", "defender3_2" },
thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE },
size = 2
},
COOP_WAVE_ONE =
{
name = "coop_wave01",
members = { "coop_defender1_1", "coop_defender1_2", "coop_defender1_3", "coop_defender1_4", "coop_defender1_5", "coop_defender1_6" },
thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE },
size = 6
},
COOP_WAVE_TWO =
{
name = "coop_wave02",
members = { "coop_defender2_1", "coop_defender2_2", "coop_defender2_3", "coop_defender2_4", "coop_defender2_5", "coop_defender2_6" },
thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE },
size = 6
},
COOP_WAVE_THREE =
{
name = "coop_wave03",
members = { "coop_defender3_1", "coop_defender3_2", "coop_defender3_3" },
thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE },
size = 2
},
COOP_DEFENDERS =
{
name = "coop_router_defenders",
members = { "coop_decker", "coop_decker<001>", "coop_decker<002>", "coop_decker<003>", "coop_decker<004>" },
size = 5
},
COOP_TOWER =
{
name = "coop_tower_attackers"
}
}
local sh03_queue = {}
local sh03_queue_size = 0
-- Navpoints --
local NAV_ONE = ""
local NAV_TWO = ""
local SH03_GPS_OBJECTIVE_ONE = "GPS_NAV_01"
local SH03_TOWER_NAV_ONE = "tower_nav 001"
local SH03_TOWER_NAV_TWO = "tower_nav 002"
local SH03_HELI_ARRIVE_NAV = "heli_arrival_nav"
sh03_navs = {
cp_start = { "player_start 001", "player_start 002" }
}
-- Triggers --
local SH03_TRIG_OBJECTIVE_ONE = "nuke_trigger_obj_one"
local SH03_TOWER_TRIGGER1 = "Tower_Trigger 001"
local SH03_TOWER_TRIGGER2 = "Tower_Trigger2"
local SH03_TOWER_TRIGGER3 = "Tower_Trigger3"
local SH03_TOWER_NAV1 = "TowerNavPoint 001"
local SH03_TOWER_NAV2 = "TowerNavPoint 002"
local SH03_TOWER_NAV3 = "TowerNavPoint 003"
local EXT1 = "TowerNavPointExt01"
local EXT2 = "TowerNavPointExt02"
local EXT3 = "TowerNavPointExt03"
local PIT_TRIGGER1 = "LinkTrigger1"
local PIT_TRIGGER2 = "LinkTrigger2"
local PIT_TRIGGER3 = "LinkTrigger3"
local PIT_TRIGGER4 = "LinkTrigger4"
local SH03_FINAL_LINK = "FinalLinkTrigger"
local SH03_FINAL_NAV = "FinalLinkNav"
local SH03_HELICOPTER_TRIGGER = "Helicopter_trigger"
local SH03_CONTINUOUS_SPAWN = "activate_spawns"
local TOWER_TRIGGER = "inside_trigger"
local SH03_PATH_UPDATE = "update_path"
local SH03_PLAY_CAR_CONVO = "start_convo_trigger"
-- Characters --
local KINZIE = "NPC_Kinzie"
local SH03_PILOT = "Heli_Pilot"
-- Vehicles --
local SH03_COURTESY_CAR = "Courtesy car"
local SH03_HELICOPTER = "Rail_Heli"
-- Mesh Movers --
--Objectives--
sh03_objectives = {
towers =
{
members = {SH03_TOWER_TRIGGER1, SH03_TOWER_TRIGGER2, SH03_TOWER_TRIGGER3},
status = {false, false, false},
active = {false, false, false},
nav = {SH03_TOWER_NAV1, SH03_TOWER_NAV2, SH03_TOWER_NAV3},
ext = {EXT1, EXT2, EXT3}
},
HELICOPTER =
{
name = "helicopter",
members = {"Rail_Heli","Heli_Pilot"}
},
routers =
{
members = {PIT_TRIGGER1, PIT_TRIGGER2, PIT_TRIGGER3,PIT_TRIGGER4},
status = {false, false, false, false},
navs = { "link_nav1", "link_nav2", "link_nav3", "link_nav4" },
hack = { "hack_nav01", "hack_nav02", "hack_nav03", "hack_nav04" }
},
}
-- Text --
SH03_HACK_TOWER = "SH03_DIRECTIVE_ONE" -- Escort Kinzie to the towers
SH03_DEFEND_KINZIE = "SH03_PROTECT_KINZIE" -- Defend Kinzie while she hacks the chair interfaces
SH03_CALL_FOR_CHOPPA = "SH03_CALL_CHOPPA"
DEFEND_THE_CHOPPA = "SH03_DEFEND_THE_CHOPPA" -- Defend the Chopper while Kinzie located the chair
TURN_OF_THE_ROUTERS = "SH03_TURN_OFF_ROUTERS" --Turn off the routers
SH03_TURN_OFF_THE_FINAL_LINK = "SH03_TURN_OFF_FINAL" --Turn off the final link
SH03_HACKING_TIME = "SH03_HACKING_TIME"
SH03_SURVIVE = "SH03_OBJ_SURVIVE" --survive until the chopper arrives
KILL_TARGETS = "SH03_OBJ_KILL_TARGETS" --kill the remaining decker guards
SH03_PARACHUTE = "SH03_OBJ_PARA" --Parachute inside the building
START_MESSAGE = "SH03_START_MESSAGE" --drive to the nuke plant
SH03_GET_TO_THE_CHOPPA ="SH03_OBJ_CHOPPA" -- Get to the choppa!
GO_DOWNSTAIRS = "SH03_OBJ_GO_DOWNSTAIRS" --direct the player down stairs in the plant
ENTER_HELI = "SH03_OBJ_ENTER_HELI"--get in the helicopter
SH03_CHAIR_DESTROYED = "SH03_FAIL_CHAIR" --the deckers destroyed the chair =(
SH03_KINZIE_DIED = "SH03_KINZIE_DIED" --Kinzie Died
SH03_KINZIE_ABANDODNED = "SH03_KINZIE_ABANDONDED" --Kinzie was abandonded
-- Threads --
sh03_threads = {
CAR_RIDE = INVALID_THREAD_HANDLE,
HELI_RIDE = INVALID_THREAD_HANDLE,
HELI_ARRIVE = INVALID_THREAD_HANDLE,
KINZIE_WATCHER_THREAD = INVALID_THREAD_HANDLE,
CONVO_PLAY_THREAD = INVALID_THREAD_HANDLE,
UPDATE_PATH_THREAD = INVALID_THREAD_HANDLE,
SPAWN_THREAD = INVALID_THREAD_HANDLE,
attack_line_timer = INVALID_THREAD_HANDLE,
}
-- GLOBAL VARIABLES --
local COOP_IS_ACTIVE = false
local IS_RESTART = false
local TOTAL_TOWERS = 3
local TOWER_INDEX = 0
local CURRENT_TOWER = nil
local SH03_KINZIE_HACKING = false
local SH03_MUSIC_ON = false
local play_once = true
SH03_TOWERS_HACKED = 0
SH03_SHORTEST_PATH = ""
SH03_BASE_TIME = 25000
SH03_MULTIPLIER = .825 --2.15
SH03_TOWER_HACKED = false
LINKS_COMPLETED = 0
SH03_HELI_LANDED = false
SH03_GOT_TO_CHOPPA = false
SH03_GOT_INSIDE = false
SH03_ROUTERS_TURNED_OFF = 0
SH03_TOTAL_LINKS = 4 --total # of routers, used in objective_text
SH03_OBJECTIVE_ONE_COMPLETE = false
SH03_OBJECTIVE_TWO_COMPLETE = false
SH03_OBJECTIVE_THREE = false
SH03_OBJ_FOUR_COMPLETE = false
SH03_SHOULD_TELE = false
SH03_ROOM_DEFENDERS_LEFT = 0
local mission_success = false
local first_cycle = false
SH03_HIT_TRIGGER = false
local kinzie_id = -1
local sh03_matt_id = -1
-- Checkpoints --
CHECKPOINT_START = MISSION_START_CHECKPOINT -- defined in ug_lib.lua
sh03_checkpoint = {
start = {
name = MISSION_START_CHECKPOINT,
nav1 = "player_start 001",
nav2 = "player_start 002"
},
nuke_plant = {
name = "sh03_checkpoint_plant",
nav1 = "CHECKPOINT_TWO_PLAYER_ONE",
nav2 = "CHECKPOINT_TWO_PLAYER_TWO",
nav3 = "CHECKPOINT_KINZIE",
car = "CHECKPOINT_TWO_VEHICLE"
},
helicopter = {
name = "sh03_checkpoint_helicopter",
nav1 = "CHECKPOINT_THREE_PLAYER_ONE",
nav2 = "CHECKPOINT_THREE_PLAYER_TWO",
nav3 = "CHECKPOINT_THREE_KINZIE",
car = "CHECKPOINT_THREE_VEHICLE"
},
cooling_tower = {
name = "sh03_checkpoint_tower",
nav1 = "CHECKPOINT_FOUR_PLAYER_ONE",
nav2 = "CHECKPOINT_FOUR_PLAYER_TWO"
},
}
-- Cutscenes --
CUTSCENE_MISSION_INTRO = "DK_SH01"
SH03_convo = {
intro_call = {
name = "SH03_Pre_Phone_Call",
handle = INVALID_CONVERSATION_HANDLE
},
mission_start = {
name = "sh03_convo_2", --"sh03_mission_start",
handle = INVALID_CONVERSATION_HANDLE
},
drive_over = {
name = "SH03_Drive_Over",
handle = INVALID_CONVERSATION_HANDLE
},
drive_over2 = {
name = "SH03_Drive_Over_2",
handle = INVALID_CONVERSATION_HANDLE
},
first_shack = {
name = "SH03_1st_Power_Shack",
handle = INVALID_CONVERSATION_HANDLE
},
uplink_convo = {
name = "SH03_Uplink_Convo_1",
handle = INVALID_CONVERSATION_HANDLE
},
uplink_convo2 = {
name = "SH03_Uplink_Convo_2",
handle = INVALID_CONVERSATION_HANDLE
},
hacking_complication = {
name = "SH03 Hacking Complication",
handle = INVALID_CONVERSATION_HANDLE
},
triangulate_done = {
name = "SH03_Uplink_3_Down",
handle = INVALID_CONVERSATION_HANDLE
},
enter_heli = {
name = "SH03_Getting_In_Heli",
handle = INVALID_CONVERSATION_HANDLE
},
heli_ride = {
name = "SH03_Heli_Ride",
handle = INVALID_CONVERSATION_HANDLE
},
heli_ride2 = {
name = "SH03_New_Helicopter_Ride",
handle = INVALID_CONVERSATION_HANDLE
},
cooling_tower = {
name = "SH03_Cooling_Tower",
handle = INVALID_CONVERSATION_HANDLE
},
enter_tower = {
name = "SH03_Enter_Chair_Room",
handle = INVALID_CONVERSATION_HANDLE
},
see_chair = {
name = "SH03_Seeing_Chair",
handle = INVALID_CONVERSATION_HANDLE
},
cut_links = {
name = "sh03_cut_chair_link",
handle = INVALID_CONVERSATION_HANDLE
},
clean_house = {
name = "SH03_Clear_Out_Deckers",
handle = INVALID_CONVERSATION_HANDLE
},
}
SH03_dialog_lines = {
kinzie_ouch = {
"sh03_kinzie_getting_shot_01",
"sh03_kinzie_getting_shot_02",
"sh03_kinzie_getting_shot_03",
},
kinzie_triangulate = {
"sh03_uplink_one_down",
"sh03_uplink_two_down",
},
impatient_player = {
"sh03_hurry_up_01",
"sh03_hurry_up_02",
"sh03_hurry_up_03",
"sh03_hurry_up_04",
"sh03_hurry_up_05",
"sh03_hurry_up_06",
"sh03_hurry_up_07",
"sh03_hurry_up_08",
},
kinzie_chair = "SH03_Located_Chair_01",
matt_taunts = {
"SH03_Miller_Over_Speakers_1",
"SH03_Miller_Over_Speakers_2",
"SH03_Miller_Over_Speakers_3",
"SH03_Miller_Over_Speakers_4"
},
player_annoyed = {
"SH03_Annoyed_at_Miller_1",
"SH03_Annoyed_at_Miller_2",
"SH03_Annoyed_at_Miller_3",
"SH03_Annoyed_at_Miller_4"
},
arrive = "sh03_plant_arrive",
jump = "SH03_Jumping_Out"
}
SH03_cont_spawn = {
area1 = "ContAttack 001",
area2 = "ContAttack 002",
area3 = "ContAttack 003",
area4 = "ContAttack 004"
}
-- Music
sh03_emitters = {
ff = "Force_Field",
main = "SH03_Music"
}
-- Other --
SH03_PATH_TO_TOWER = "AirPath"
HELICOPTER_ARRIVE = "AirPath<001>"
HELICOPTER_LAND = "heli_land"
SH03_KINZIE_WAIT = "kinzie_wait"
-- *************************
--
-- 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
--
-- sh03_checkpoint: The checkpoint the mission should begin at
-- is_restart: TRUE if the mission is restarting, FALSE otherwise
--
function sh03_start(sh03_checkpoint, is_restart)
IS_RESTART = is_restart
-- Check if this mission starting from the beginning
if (sh03_checkpoint == CHECKPOINT_START) then
if (is_restart == false) then
-- First time playing mission
-- Play an intro cutscene???
if (CUTSCENE_MISSION_INTRO ~= "") then
zscene_prep( CUTSCENE_MISSION_INTRO )
--while( not zscene_is_loaded( CUTSCENE_MISSION_INTRO ) ) do
--thread_yield()
--end
cutscene_play(CUTSCENE_MISSION_INTRO, nil, sh03_navs.cp_start, false )
end
end
fade_out(0)
end
-- Handle mission initialization for the current checkpoint
sh03_initialize(sh03_checkpoint)
-- Run the mission from the current checkpoint
sh03_run(sh03_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 sh03_run(first_checkpoint)
local current_checkpoint = first_checkpoint
-- Run the mission from the beginning
if current_checkpoint == CHECKPOINT_START then
--[[ INSERT PROCESSING FOR THE FIRST CHECKPOINT HERE ]]--
notoriety_set_max("deckers", 1)
notoriety_set_max("police", 0)
sh03_setup_obj_one()
fade_in(0)
while SH03_OBJECTIVE_ONE_COMPLETE == false do
thread_yield()
end
current_checkpoint = sh03_checkpoint.nuke_plant.name
mission_set_checkpoint(sh03_checkpoint.nuke_plant.name, true)
end
if current_checkpoint == sh03_checkpoint.nuke_plant.name then
notoriety_set_max("deckers", 0)
notoriety_set("deckers", 0)
notoriety_set_max("police", 0)
notoriety_set("police", 0)
notoriety_set_can_decay(false)
if group_is_loaded( sh03_group.COOP_TOWER.name ) == false then
group_create( sh03_group.COOP_TOWER.name, true )
end
set_ignore_ai_flag( KINZIE, false )
first_cycle = true
sh03_setup_obj_two()
fade_in(0)
while SH03_OBJECTIVE_THREE==false do
while CURRENT_TOWER == nil do --yield until the player hits a tower trigger. on_trigger_exit will set this to nil
repeat --don't let Kinzie start hacking if the player is in a car, he could just drive away and fuck everything up
thread_yield()
until character_is_in_vehicle( LOCAL_PLAYER ) == false
thread_yield()
end
--thread_yield()
--the player hit a trigger and got out of the car, everything should be good for Kinzie to start hacking
sh03_kinzie_hack_tower( CURRENT_TOWER )
end
end
if current_checkpoint == sh03_checkpoint.helicopter.name then
sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.triangulate_done)
--notoriety_set_max("deckers", 5)
--notoriety_set("deckers", 5)
--make the player think he has 5* notoriety
hud_set_fake_notoriety("deckers", true, 5)
sh03_control_notoriety( 4 ) --pull it back a little
notoriety_set_can_decay(false)
--sh03_checkpoint_spawn_kinzie()
set_ignore_ai_flag( KINZIE, false )
sh03_obj_three_heli()
fade_in(0)
current_checkpoint = sh03_checkpoint.cooling_tower.name
mission_set_checkpoint(sh03_checkpoint.cooling_tower.name, true)
end
if current_checkpoint == sh03_checkpoint.cooling_tower.name then
if SH03_MUSIC_ON == false then
audio_ambient_emitter_start(sh03_emitters.main)
end
if kinzie_id == -1 then
kinzie_id = audio_persona_load_2d("Kinzie")
end
notoriety_set_max("deckers", 5)
notoriety_set("deckers", 5)
notoriety_set_can_decay(false)
SH03_SHOULD_TELE = true
sh03_obj_four_cooling_tower()
--fade_in(0)
while SH03_OBJ_FOUR_COMPLETE == false do
thread_yield()
end
audio_ambient_emitter_stop( sh03_emitters.ff )
sh03_final_link()
end
-- Call mission success??
--mission_end_success("sh03", CUTSCENE_MISSION_OUTRO)
end
-- This is the primary function responsible for cleaning up the entire mission
-- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++)
--
function sh03_cleanup() --[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]--
--parachute_enable()
base_jumping_enable(true)
--helicopters_set_jitter_override(1.0, 1.0)
hud_prompt_clear(LOCAL_PLAYER)
hud_prompt_clear(REMOTE_PLAYER)
thread_kill( sh03_threads.CAR_RIDE )
cleanup_threads( sh03_threads )
cleanup_threads( sh03_group.WAVE_ONE.thread )
cleanup_threads( sh03_group.WAVE_TWO.thread )
cleanup_threads( sh03_group.WAVE_THREE.thread )
cleanup_threads( sh03_group.COOP_WAVE_ONE.thread )
cleanup_threads( sh03_group.COOP_WAVE_TWO.thread )
cleanup_threads( sh03_group.COOP_WAVE_THREE.thread )
sh03_cleanup_convos()
sh03_cleanup_enemies()
sh03_cleanup_kinzie()
--sh03_clear_trigger(SH03_TRIG_OBJECTIVE_ONE)
sh03_obj_two_cleanup()
sh03_clear_trigger(SH03_FINAL_LINK)
sh03_clear_trigger(TOWER_TRIGGER)
sh03_clear_trigger(SH03_PATH_UPDATE)
sh03_obj_four_cleanup()
sh03_cleanup_groups()
sh03_cleanup_notoriety()
trigger_enable( SH03_PLAY_CAR_CONVO, false )
on_trigger_exit( "", SH03_PLAY_CAR_CONVO )
on_trigger_exit( "", SH03_TOWER_TRIGGER1 )
on_trigger_exit( "", SH03_TOWER_TRIGGER2 )
on_trigger_exit( "", SH03_TOWER_TRIGGER3 )
inv_weapon_disable_all_slots( false ) --enable all weapon slots
if kinzie_id ~= -1 then
audio_persona_remove_2d(kinzie_id)
kinzie_id = -1
end
if sh03_matt_id ~= -1 then
audio_persona_remove_2d(sh03_matt_id)
sh03_matt_id = -1
end
--sh03_cleanup_convo_thread()
--hud_timer_hide(1, true)
--hud_timer_stop(1)
on_vehicle_enter( "", LOCAL_PLAYER )
player_force_vehicle_seat( LOCAL_PLAYER, -1 )
if COOP_IS_ACTIVE == true then
player_force_vehicle_seat( REMOTE_PLAYER, -1 )
end
sh03_clear_trigger( SH03_HELICOPTER_TRIGGER )
continuous_spawn_stop( sh03_group.ATTACK_SOL.name ) --stop the soldiers
continuous_spawn_stop( sh03_group.ATTACK_SPEC.name ) --stop the specialists
spawn_region_enable( SH03_cont_spawn.area1, false )
spawn_region_enable( SH03_cont_spawn.area2, false )
spawn_region_enable( SH03_cont_spawn.area3, false )
spawn_region_enable( SH03_cont_spawn.area4, false )
set_player_can_enter_exit_vehicles( LOCAL_PLAYER, true )
if COOP_IS_ACTIVE == true then
set_player_can_enter_exit_vehicles( REMOTE_PLAYER, true )
end
if character_is_in_vehicle( LOCAL_PLAYER, SH03_HELICOPTER ) == true then
sh03_get_out_of_vehicles()
if SH03_SHOULD_TELE == true then --only teleport the player(s) if they're inside the nuke plant
teleport( LOCAL_PLAYER, sh03_checkpoint.nuke_plant.nav1 )
if COOP_IS_ACTIVE == true then
teleport( REMOTE_PLAYER,sh03_checkpoint.nuke_plant.nav2 )
end
--teleport_coop( sh03_checkpoint.nuke_plant.nav1, sh03_checkpoint.nuke_plant.nav2, true )
end
else
if SH03_SHOULD_TELE == true then --only teleport the player(s) if they're inside the nuke plant
teleport( LOCAL_PLAYER, sh03_checkpoint.nuke_plant.nav1 )
if COOP_IS_ACTIVE == true then
teleport( REMOTE_PLAYER,sh03_checkpoint.nuke_plant.nav2 )
end
--teleport_coop( sh03_checkpoint.nuke_plant.nav1, sh03_checkpoint.nuke_plant.nav2, false )
end
end
if mission_success == false then
mesh_mover_show( "sh03_cap" )
mesh_mover_show( "sh03_force_field" )
audio_ambient_emitter_stop( sh03_emitters.main )
end
audio_ambient_emitter_stop( sh03_emitters.ff )
--reset globals
SH03_MUSIC_ON = false
COOP_IS_ACTIVE = false
IS_RESTART = false
TOTAL_TOWERS = 3
TOWER_INDEX = 0
CURRENT_TOWER = 0
SH03_TOWERS_HACKED = 0
SH03_SHORTEST_PATH = ""
SH03_TOWER_HACKED = false
LINKS_COMPLETED = 0
SH03_SHOULD_TELE = false
end
function sh03_cleanup_convo_thread()
if sh03_threads.CONVO_PLAY_THREAD ~= INVALID_THREAD_HANDLE then
thread_kill(sh03_threads.CONVO_PLAY_THREAD)
sh03_threads.CONVO_PLAY_THREAD = INVALID_THREAD_HANDLE
--message("convo thread killed", 2)
end
end
-- Called when the mission has ended with success
-- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++)
--
function sh03_success()
--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]--
mission_success = true
local skip_teleport = true
sh03_coop_skip(skip_teleport)
end
function sh03_obj_two_cleanup()
CURRENT_TOWER = nil
SH03_KINZIE_HACKING = false
for i, trigger in pairs(sh03_objectives.towers.members) do
sh03_objectives.towers.active[i] = false
sh03_clear_trigger(trigger)
end
hud_timer_stop(1)
end
function sh03_obj_four_cleanup()
SH03_ROUTERS_TURNED_OFF = 0
for i, trigger in pairs(sh03_objectives.routers.members) do
sh03_clear_trigger(trigger)
sh03_objectives.routers.status[i] = true
end
SH03_ROUTERS_TURNED_OFF = 0
SH03_OBJ_FOUR_COMPLETE = false
end
function sh03_cleanup_convos()
for index, convo in pairs( SH03_convo ) do
if convo.handle ~= INVALID_CONVERSATION_HANDLE then
if audio_is_playing(convo.handle) then
audio_conversation_end(convo.handle)
end
convo.handle = INVALID_CONVERSATION_HANDLE
end
end
end
function sh03_cleanup_enemies()
if group_is_loaded( sh03_group.WAVE_ONE.name ) == true then
for index, member in pairs( sh03_group.WAVE_ONE.members ) do
if ( character_is_dead( member ) == false ) then
on_death( "", member )
on_attack_performed("", member)
end
end
end
if group_is_loaded( sh03_group.WAVE_TWO.name ) == true then
for index, member in pairs( sh03_group.WAVE_TWO.members ) do
if ( character_is_dead( member ) == false ) then
on_death( "", member )
on_attack_performed("", member)
end
end
end
if group_is_loaded( sh03_group.WAVE_THREE.name ) == true then
for index, member in pairs( sh03_group.WAVE_THREE.members ) do
if ( character_is_dead( member ) == false ) then
on_death( "", member )
on_attack_performed("", member)
end
end
end
if group_is_loaded( sh03_group.COOP_WAVE_ONE.name ) == true then
for index, member in pairs( sh03_group.COOP_WAVE_ONE.members ) do
if ( character_is_dead( member ) == false ) then
on_death( "", member )
on_attack_performed("", member)
end
end
end
if group_is_loaded( sh03_group.COOP_WAVE_TWO.name ) == true then
for index, member in pairs( sh03_group.COOP_WAVE_TWO.members ) do
if ( character_is_dead( member ) == false ) then
on_death( "", member )
on_attack_performed("", member)
end
end
end
if group_is_loaded( sh03_group.COOP_WAVE_THREE.name ) == true then
for index, member in pairs( sh03_group.COOP_WAVE_THREE.members ) do
if ( character_is_dead( member ) == false ) then
on_death( "", member )
on_attack_performed("", member)
end
end
end
if group_is_loaded( sh03_group.STAIRS.name ) == true then
for index, member in pairs( sh03_group.STAIRS.members ) do
if ( character_is_dead( member ) == false ) then
on_death( "", member )
on_attack_performed("", member)
end
end
end
if group_is_loaded( sh03_group.ROOM_DEFENSE.name ) == true then
for index, member in pairs( sh03_group.ROOM_DEFENSE.members ) do
if ( character_is_dead( member ) == false ) then
on_death( "", member )
on_attack_performed("", member)
end
end
end
end
function sh03_cleanup_kinzie()
if sh03_threads.KINZIE_WATCHER_THREAD ~= INVALID_THREAD_HANDLE then
thread_kill(sh03_threads.KINZIE_WATCHER_THREAD)
sh03_threads.KINZIE_WATCHER_THREAD = INVALID_THREAD_HANDLE
end
if group_is_loaded(sh03_group.START.name) then
on_death("", KINZIE)
on_dismiss( "", KINZIE )
follower_set_can_abandon( KINZIE, false )
group_destroy( sh03_group.START.name, true )
end
end
function sh03_cleanup_notoriety()
notoriety_set( "deckers", 0 )
notoriety_set_max( "deckers", 0 )
notoriety_set_max("police", 5)
notoriety_set_can_decay( true )
hud_set_fake_notoriety("deckers", false, 0)
disable_specific_notoriety_group( "deckers", 3, "G_Decker_SUV_1S", true )
disable_specific_notoriety_group( "deckers", 3, "G_Decker_Car_1S", true )
disable_specific_notoriety_group( "deckers", 4, "G_Decker_Car_1S", true )
disable_specific_notoriety_group( "deckers", 4, "G_Decker_Car_2S", true )
disable_specific_notoriety_group( "deckers", 4, "G_Decker_Brute_F", true )
disable_specific_notoriety_group( "deckers", 5, "G_Decker_Brute_M", true )
disable_specific_notoriety_group( "deckers", 5, "G_Decker_Brute_G", true )
disable_specific_notoriety_group( "deckers", 5, "G_Decker_Car_2S", true )
disable_specific_notoriety_group( "deckers", 5, "G_Decker_SUV_2S", true )
end
function sh03_cleanup_groups()
if( mission_success == true ) then
--release groups to the world
for i, grp in pairs( sh03_group ) do
if group_is_loaded( grp.name ) then
if( (grp.name == sh03_group.ROOM_DEFENSE.name) or( grp.name == sh03_group.WAVE_ONE.name ) or ( grp.name == sh03_group.WAVE_TWO.name ) or ( grp.name == sh03_group.WAVE_THREE.name ) or (grp.name == sh03_group.ROOM_DEFENSE.name) or ( grp.name == sh03_group.COOP_WAVE_ONE.name ) or ( grp.name == sh03_group.COOP_WAVE_TWO.name ) or ( grp.name == sh03_group.COOP_WAVE_THREE.name ) ) then
for index, char in pairs( grp.members ) do
if ( character_is_dead( char ) == false ) then
on_death( "", char )
end
end
end
--sh03_release_enemies( grp.name )
release_to_world( grp.name )
end
end
else --mission was failed or quit, destroy them like the mission never happened
for i, grp in pairs( sh03_group ) do
if group_is_loaded( grp.name ) then
if( (grp.name == sh03_group.ROOM_DEFENSE.name) or( grp.name == sh03_group.WAVE_ONE.name ) or ( grp.name == sh03_group.WAVE_TWO.name ) or ( grp.name == sh03_group.WAVE_THREE.name ) or ( grp.name == sh03_group.COOP_WAVE_ONE.name ) or ( grp.name == sh03_group.COOP_WAVE_TWO.name ) or ( grp.name == sh03_group.COOP_WAVE_THREE.name ) ) then
for index, char in pairs( grp.members ) do
if ( character_is_dead( char ) == false ) then
on_death( "", char )
end
end
end
group_destroy( grp.name )
--on_death( "", grp.members )
end
end
end
end
-- *************************
--
-- Local functions
--
-- *************************
-- Initialize the mission for the specified checkpoint
--
-- checkpoint: Checkpoint to initialize the mission to
--
function sh03_initialize(current_checkpoint)
-- Make sure the screen is completly faded out
mission_start_fade_out(0.0)
-- Common initialization
sh03_initialize_common()
-- Checkpoint specific initialization
sh03_initialize_checkpoint(current_checkpoint)
-- Set the mission author
set_mission_author("Jimmy Cross")
-- Start fading in
mission_start_fade_in()
end
-- ***************************************************
-- sh03_run Helper Functions
-- ***************************************************
function sh03_setup_obj_one()
trigger_enable( SH03_PLAY_CAR_CONVO, true )
on_trigger_exit( "sh03_play_car_convo", SH03_PLAY_CAR_CONVO )
sh03_checkpoint_spawn_kinzie()
sh03_spawn_watcher_thread()
--trigger_enable( SH03_TRIG_OBJECTIVE_ONE, true )
--on_trigger( "sh03_obj_one", SH03_TRIG_OBJECTIVE_ONE )
mission_waypoint_add(SH03_GPS_OBJECTIVE_ONE, SYNC_ALL)
--mission_waypoint_add( OBJECTIVE_ONE, SYNC_ALL )
marker_add(SH03_GPS_OBJECTIVE_ONE, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL )
objective_text(0, START_MESSAGE, nil, nil, SYNC_ALL, OI_ASSET_LOCATION)
repeat thread_yield() until ( get_dist_closest_player_to_object( SH03_GPS_OBJECTIVE_ONE ) < 40 )
sh03_obj_one()
end
-- Spawn Kinzie, setup death callback and (optionally) teleport her to a given navpoint
--
-- checkpoint_nav - (string, optional) navpoint to teleport Kinzie to
--
function sh03_checkpoint_spawn_kinzie()
if group_is_loaded( sh03_group.START.name ) == false then
group_create( sh03_group.START.name, true )
end
on_death("sh03_kinzie_dead", KINZIE) --callback for kinzie dying
on_dismiss( "sh03_kinzie_abandoned", KINZIE ) --abandoning kinzie makes her sadface
follower_set_can_abandon(KINZIE, true)
--party_add(KINZIE)
end
function sh03_spawn_watcher_thread()
if sh03_threads.KINZIE_WATCHER_THREAD == INVALID_THREAD_HANDLE then
sh03_threads.KINZIE_WATCHER_THREAD = thread_new("sh03_kinzie_in_party")
end
end
function sh03_teleport_kinzie(checkpoint_nav)
if checkpoint_nav ~= nil then
teleport( KINZIE, checkpoint_nav, true )
end
--and (checkpoint_nav == sh03_checkpoint.nuke_plant.name or checkpoint_nav == sh03_checkpoint.helicopter.name)
end
function sh03_setup_obj_two()
objective_text( 0, SH03_HACK_TOWER, SH03_TOWERS_HACKED, TOTAL_TOWERS, SYNC_ALL, OI_ASSET_LOCATION )
--kill car convos and play kinzie's arrival line
if first_cycle == true then
if sh03_threads.CAR_RIDE ~= INVALID_THREAD_HANDLE then
thread_kill( sh03_threads.CAR_RIDE )
sh03_threads.CAR_RIDE = INVALID_THREAD_HANDLE
end
delay(1.0)
audio_play_persona_line( KINZIE, SH03_dialog_lines.arrive )
end
first_cycle = false
--check for objective complete
if SH03_TOWERS_HACKED == 3 then
SH03_OBJECTIVE_THREE = true
mission_set_checkpoint(sh03_checkpoint.helicopter.name, true)
sh03_run(sh03_checkpoint.helicopter.name)
return
end
local dist = 9999
--mark the tower triggers
for i, trigger in pairs(sh03_objectives.towers.members) do
if sh03_objectives.towers.status[i] == false then
--marker_add_trigger(trigger, MINIMAP_ICON_LOCATION,INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL)
sh03_set_trigger( trigger, "sh03_obj_two" )
if get_dist( LOCAL_PLAYER, sh03_objectives.towers.nav[i] ) < dist then
SH03_SHORTEST_PATH = sh03_objectives.towers.nav[i]
dist = get_dist( LOCAL_PLAYER, sh03_objectives.towers.nav[i] )
end
end
end
--display the shortest path
mission_waypoint_add( SH03_SHORTEST_PATH, SYNC_ALL )
--marker_add( SH03_SHORTEST_PATH, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL)
--fire off a thread to update the shortest path
if sh03_threads.UPDATE_PATH_THREAD == INVALID_THREAD_HANDLE then
sh03_threads.UPDATE_PATH_THREAD = thread_new("sh03_update_path")
end
end
function sh03_obj_three_heli()
local kinzie_id = -1
--message(SH03_CALL_FOR_CHOPPA, 6)
objective_text_clear( 0 )
objective_text_clear( 1 )
--sh03_set_trigger( SH03_HELICOPTER_TRIGGER, "sh03_get_to_the_choppa", "LOCATION" )
--mission_waypoint_add(SH03_HELICOPTER_TRIGGER)
trigger_enable(SH03_HELICOPTER_TRIGGER, true)
on_trigger( "sh03_get_to_the_choppa", SH03_HELICOPTER_TRIGGER )
if sh03_threads.HELI_ARRIVE == INVALID_THREAD_HANDLE then
sh03_threads.HELI_ARRIVE = thread_new("sh03_heli_arrival")
end
objective_text(0, SH03_GET_TO_THE_CHOPPA, nil, nil, SYNC_ALL, OI_ASSET_LOCATION)
--marker_add_trigger(SH03_HELICOPTER_TRIGGER, MINIMAP_ICON_LOCATION, nil, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL)
--marker_add(SH03_HELI_ARRIVE_NAV, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL)
mission_waypoint_add(SH03_HELI_ARRIVE_NAV, SYNC_ALL )
while SH03_GOT_TO_CHOPPA == false do
thread_yield()
end
sh03_cleanup_convo_thread()
objective_text_clear(0)
if SH03_HELI_LANDED == false then
objective_text(0, SH03_SURVIVE, nil, nil, SYNC_ALL, OI_ASSET_LOCATION)
while SH03_HELI_LANDED == false do
thread_yield()
delay(.1)
end
end
player_force_vehicle_seat( LOCAL_PLAYER, 5 )
if coop_is_active() then
player_force_vehicle_seat( REMOTE_PLAYER, 4 )
end
--marker_remove(SH03_HELI_ARRIVE_NAV, SYNC_ALL)
mission_waypoint_remove(SYNC_ALL)
--prevent Kinzie from dying to minimize fuck ups
set_ignore_ai_flag( KINZIE, true )
turn_invulnerable(KINZIE, false)
character_allow_ragdoll(KINZIE, false)
ai_do_scripted_move(KINZIE, SH03_KINZIE_WAIT, true, false) --tell kinzie to go to the helicopter and get in
--objective_text_clear(0)
objective_text(0, ENTER_HELI, nil, nil, SYNC_ALL, OI_ASSET_LOCATION)
marker_add( SH03_HELICOPTER, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL )
--GET TO THE CHOPPA!!!!!!!
repeat
thread_yield()
--don't enter the choppa if Kinzie is dead (this can only happen if she died before the helicopter landed
while ( (character_is_dead(KINZIE) == true) or (follower_is_unconscious(KINZIE) == true) ) do
thread_yield()
end
--dont' teleport in if one of the players is dead
while ( (human_is_downed(LOCAL_PLAYER) == true) or (human_is_downed(REMOTE_PLAYER) == true) ) do
thread_yield()
end
--don't enter the helicopter if the player is in a vehicle
while( (character_is_in_vehicle(LOCAL_PLAYER) == true) or (character_is_in_vehicle(REMOTE_PLAYER) == true) ) do
thread_yield()
end
--don't teleport into the heli if involved in a qte
while( (qte_human_is_used(LOCAL_PLAYER) == true) or (coop_is_active() and qte_human_is_used(REMOTE_PLAYER) == true) ) do
thread_yield()
end
--thread_yield()
delay(.1)
until get_dist_closest_player_to_object( SH03_HELICOPTER ) <= 9
--player within range, time to teleport into the helicopter
fade_out(1)
party_dismiss_all() --get rid of followers, they mess things up
delay(1)
if kinzie_id == -1 then --load kinzie's persona so she can still talk to us
kinzie_id = audio_persona_load_2d("Kinzie")
end
vehicle_enter_teleport( KINZIE, SH03_HELICOPTER, 1, true )
local weapon
if coop_is_active() then
weapon = inv_item_in_slot(REMOTE_PLAYER, "rifle")
inv_item_equip(weapon, REMOTE_PLAYER)
vehicle_enter_teleport( REMOTE_PLAYER, SH03_HELICOPTER, 4, true )
end
weapon = inv_item_in_slot(LOCAL_PLAYER, "rifle")
inv_item_equip(weapon, LOCAL_PLAYER)
vehicle_enter_teleport( LOCAL_PLAYER, SH03_HELICOPTER, 5, true )
vehicle_set_keyframed_physics( SH03_HELICOPTER, false )
delay(1)
fade_in(1)
--wait until the player hits the trigger inside
while SH03_GOT_INSIDE == false do
thread_yield()
end
end
function sh03_obj_four_cooling_tower()
hud_prompt_clear() --just to make sure it's cleaned up
--sh03_remove_weapon()
--parachute_disable()
-- Remove the player's parachute
player_parachute_wear_backpack(LOCAL_PLAYER, false)
character_parachute_detach(LOCAL_PLAYER)
if (coop_is_active() ) then
player_parachute_wear_backpack(REMOTE_PLAYER, false)
character_parachute_detach(REMOTE_PLAYER)
end
if sh03_threads.HELI_RIDE ~= INVALID_THREAD_HANDLE then
thread_kill( sh03_threads.HELI_RIDE )
sh03_threads.HELI_RIDE = INVALID_THREAD_HANDLE
end
if sh03_matt_id == -1 then
sh03_matt_id = audio_persona_load_2d("Matt")
end
inv_weapon_disable_all_slots( false ) --enable all weapon slots
objective_text_clear( 0 )
objective_text_clear( 1 )
--head downstairs
objective_text( 0, GO_DOWNSTAIRS, nil, nil, SYNC_ALL, OI_ASSET_LOCATION )
trigger_enable(SH03_PATH_UPDATE, true)
on_trigger("sh03_update_stairs", SH03_PATH_UPDATE)
--mission_waypoint_add( SH03_TOWER_NAV_ONE, SYNC_ALL )
marker_add( SH03_TOWER_NAV_ONE, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL )
delay(2)
sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.enter_tower)
--mission_waypoint_add( SH03_TOWER_NAV_TWO, SYNC_ALL )
--repeat thread_yield() until ( get_dist_closest_player_to_object( SH03_TOWER_NAV_ONE ) <= SH03_UPDATE_DIST )
--mission_waypoint_remove( SYNC_ALL )
repeat thread_yield() until ( get_dist_closest_player_to_object( SH03_TOWER_NAV_TWO ) <= SH03_UPDATE_DIST )
audio_object_post_event("SH03_Break", nil, nil, "SH03_Music")
sh03_mark_routers()
sh03_spawn_enemies( SH03_ROUTERS_TURNED_OFF )
marker_remove( SH03_TOWER_NAV_TWO, SYNC_ALL )
--mission_waypoint_remove( SYNC_ALL )
trigger_enable( SH03_CONTINUOUS_SPAWN, true )
on_trigger( "sh03_spawns_cb", SH03_CONTINUOUS_SPAWN )
objective_text_clear( 0 )
objective_text_clear( 1 )
--downstairs, turn off the routers
objective_text( 0, TURN_OF_THE_ROUTERS, SH03_ROUTERS_TURNED_OFF, SH03_TOTAL_LINKS, SYNC_ALL, OI_ASSET_USE )
delay(2)
end
function sh03_heli_fly(player, veh, seat)
if player ~= LOCAL_PLAYER then
return
end
on_vehicle_enter("", SH03_HELICOPTER)
mesh_mover_hide( "sh03_cap" )
--set_player_can_enter_exit_vehicles( KINZIE, false )
set_dont_attack_me_on_sight_flag( KINZIE, true )
--kill the arrival thread
if sh03_threads.HELI_ARRIVE ~= INVALID_THREAD_HANDLE then
thread_kill( sh03_threads.HELI_ARRIVE )
sh03_threads.HELI_ARRIVE = INVALID_THREAD_HANDLE
end
--don't progress until kinzie is in the choppa
--while character_is_in_vehicle(KINZIE, SH03_HELICOPTER) == false do
--thread_yield() --now we play the waiting game
--end
--only take off if local and remote player are in the choppa
while( character_is_in_vehicle(LOCAL_PLAYER, SH03_HELICOPTER ) == false ) do
if COOP_IS_ACTIVE then
while(character_is_in_vehicle(REMOTE_PLAYER, SH03_HELICOPTER) == false) do
thread_yield()
end
end
thread_yield() --now we play the waiting game
end
set_player_can_enter_exit_vehicles( LOCAL_PLAYER, false )
if COOP_IS_ACTIVE then
set_player_can_enter_exit_vehicles( REMOTE_PLAYER, false )
end
objective_text_clear(0)
--is kinzie in the heli? if not, get in the damn helicopter already
if character_is_in_vehicle(KINZIE, SH03_HELICOPTER) == false then
vehicle_enter_teleport( KINZIE, SH03_HELICOPTER, 1, true )
end
SH03_SHOULD_TELE = true
inv_weapon_disable_all_but_this_slot(WEAPON_SLOT_RIFLE, true, SYNC_ALL) --do this to limit the animations used in the heli
helicopter_set_max_bank_angle( SH03_HELICOPTER, SH03_HELI_MAX_BANK_ANGLE )
marker_remove(SH03_HELICOPTER, SYNC_ALL)
base_jumping_enable(false)
--fire off a thread to play helicopter convos
if sh03_threads.HELI_RIDE == INVALID_THREAD_HANDLE then
sh03_threads.HELI_RIDE = thread_new("sh03_heli_convo_thread", SH03_convo.enter_heli, SH03_convo.heli_ride, SH03_convo.cooling_tower) --SH03_convo.heli_ride2
end
--fly, helicopter. fly!
helicopter_fly_to( SH03_HELICOPTER, SH03_HELI_SPEED, SH03_PATH_TO_TOWER )
vehicle_speed_override(SH03_HELICOPTER, 0.0)
--we're at our destination, allow the player(s) to jump out of the helicopter again
set_player_can_enter_exit_vehicles( LOCAL_PLAYER, true )
if COOP_IS_ACTIVE == true then
set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true)
end
objective_text(0, SH03_PARACHUTE, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) --tell the player to jump
trigger_enable( TOWER_TRIGGER, true )
marker_add( TOWER_TRIGGER, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL )
on_trigger( "sh03_inside_tower", TOWER_TRIGGER )
--helicopters_set_jitter_override(0.01, 0.01)
-- Prompt the players to jump
hud_prompt(LOCAL_PLAYER, "SH03_MSG_JUMP", "sh03_jump_local")
if (COOP_IS_ACTIVE == true) then
hud_prompt(REMOTE_PLAYER, "SH03_MSG_JUMP", "sh03_jump_remote")
end
--wait until the player(s) jump
while character_is_in_vehicle(LOCAL_PLAYER, SH03_HELICOPTER ) or character_is_in_vehicle(REMOTE_PLAYER, SH03_HELICOPTER) do
thread_yield()
end
delay(2)
audio_play_persona_line( LOCAL_PLAYER, SH03_dialog_lines.jump)
if (COOP_IS_ACTIVE == true) then
audio_play_persona_line( REMOTE_PLAYER, SH03_dialog_lines.jump)
end
audio_ambient_emitter_start(sh03_emitters.main)
SH03_MUSIC_ON = true
sh03_cleanup_kinzie()
end
function sh03_final_link()
objective_text_clear(0)
objective_text( 0, SH03_TURN_OFF_THE_FINAL_LINK, nil, nil, SYNC_ALL, OI_ASSET_USE)
sh03_set_trigger_use( SH03_FINAL_LINK, "sh03_final_trigger" )
sh03_cleanup_convo_thread()
sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.cut_links)
end
function sh03_inside_tower()
SH03_GOT_INSIDE = true
--mission_waypoint_remove( SYNC_ALL )
marker_remove(TOWER_TRIGGER, SYNC_ALL)
end
function sh03_jump_local()
hud_prompt_clear(LOCAL_PLAYER)
vehicle_exit(LOCAL_PLAYER)
end
-- Catch the remote player jumping
function sh03_jump_remote()
hud_prompt_clear(REMOTE_PLAYER)
vehicle_exit(REMOTE_PLAYER)
end
-- ***************************************************
-- sh03_initialize Helper Functions
-- ***************************************************
-- Handle any common initialization
--
function sh03_initialize_common()
--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]--
--sh03_spawn_watcher_thread()
--set_time_of_day(00, 00) -- Set TOD to the middle of the night
end
-- Checkpoint specific initialization
--
-- checkpoint: The checkpoint to be initialized
function sh03_initialize_checkpoint(current_checkpoint)
if coop_is_active() then
COOP_IS_ACTIVE = true
end
if current_checkpoint == CHECKPOINT_START then
group_create(sh03_group.START_CAR.name, true)
vehicle_car_alarm_enable( sh03_group.START_CAR.members, false )
sh03_spawn_watcher_thread()
if (IS_RESTART == true) then
teleport_coop(sh03_checkpoint.start.nav1, sh03_checkpoint.start.nav2, true)
end
end
if current_checkpoint == sh03_checkpoint.nuke_plant.name then
if group_is_loaded( sh03_group.START_CAR.name ) == false then
group_create(sh03_group.START_CAR.name, true)
end
teleport_vehicle(sh03_group.START_CAR.members, sh03_checkpoint.nuke_plant.car)
sh03_checkpoint_spawn_kinzie()
sh03_teleport_kinzie(sh03_checkpoint.nuke_plant.nav3)
teleport_coop(sh03_checkpoint.nuke_plant.nav1, sh03_checkpoint.nuke_plant.nav2, true)
sh03_spawn_watcher_thread()
end
if current_checkpoint == sh03_checkpoint.helicopter.name then
if group_is_loaded( sh03_group.START_CAR.name ) == false then
group_create(sh03_group.START_CAR.name, true)
end
teleport_vehicle(sh03_group.START_CAR.members, sh03_checkpoint.helicopter.car)
sh03_checkpoint_spawn_kinzie()
sh03_teleport_kinzie(sh03_checkpoint.helicopter.nav3)
teleport_coop(sh03_checkpoint.helicopter.nav1, sh03_checkpoint.helicopter.nav2, true)
sh03_spawn_watcher_thread()
end
if current_checkpoint == sh03_checkpoint.cooling_tower.name then
teleport_coop(sh03_checkpoint.cooling_tower.nav1, sh03_checkpoint.cooling_tower.nav2, true)
--sh03_checkpoint_spawn_kinzie(sh03_checkpoint.cooling_tower.nav2)
end
end
-- ***************************************************
-- Miscellaneous sh03 Helper Funcrtions
-- ***************************************************
function sh03_set_trigger(trigger, trigger_callback)
trigger_enable(trigger, true)
marker_add_trigger(trigger, MINIMAP_ICON_LOCATION, nil, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) --INGAME_EFFECT_CHECKPOINT
on_trigger(trigger_callback, trigger)
end
function sh03_set_trigger_use(trigger, trigger_callback)
trigger_enable(trigger, true)
marker_add_trigger(trigger, MINIMAP_ICON_USE, INGAME_EFFECT_CHECKPOINT, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) --INGAME_EFFECT_CHECKPOINT
on_trigger(trigger_callback, trigger)
end
function sh03_spawns_cb()
audio_ambient_emitter_start(sh03_emitters.ff)
sh03_clear_trigger( SH03_CONTINUOUS_SPAWN )
sh03_cleanup_convo_thread()
--enable the continuous spawn groups
spawn_region_enable( SH03_cont_spawn.area1, true )
spawn_region_enable( SH03_cont_spawn.area2, true )
spawn_region_enable( SH03_cont_spawn.area3, true )
spawn_region_enable( SH03_cont_spawn.area4, true )
delay(1)
sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.see_chair) --see chair convo
delay(1)
sh03_manage_defense()
end
function sh03_update_stairs( player, trigger )
on_trigger("", trigger)
marker_remove( SH03_TOWER_NAV_ONE, SYNC_ALL )
marker_add( SH03_TOWER_NAV_TWO, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL )
delay(2)
if group_is_loaded( sh03_group.STAIRS.name ) == false then
group_create( sh03_group.STAIRS.name, true )
for i, char in pairs(sh03_group.STAIRS.members) do
on_death( "sh03_release_enemies", char )
end
end
end
-- Disable trigger
--
-- trigger: (string) Name of the trigger
--
function sh03_clear_trigger(trigger)
--mission_waypoint_remove(SYNC_ALL)
on_trigger("", trigger)
trigger_enable(trigger, false)
marker_remove_trigger(trigger, SYNC_ALL)
end
function sh03_obj_two(player, current_trigger)
on_trigger_exit( "sh03_left_tower_trigger", current_trigger )
if play_once == true then
sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.first_shack)
play_once = false
end
--marker_remove( SH03_SHORTEST_PATH, SYNC_ALL )
for i, trigger in pairs(sh03_objectives.towers.members) do
if sh03_objectives.towers.status[i] == false and sh03_objectives.towers.members[i] == current_trigger then
CURRENT_TOWER = sh03_objectives.towers.nav[i]
TOWER_INDEX = i
--sh03_objectives.towers.active[i] = true
end
end
--[[
while character_is_in_vehicle( LOCAL_PLAYER ) == true do
thread_yield()
end
sh03_kinzie_hack_tower( CURRENT_TOWER )
]]--
end
function sh03_left_tower_trigger( player, trigger )
if SH03_KINZIE_HACKING == true then
return
end
on_trigger( "sh03_obj_two", trigger )
CURRENT_TOWER = nil
end
function sh03_get_to_the_choppa()
--sh03_clear_trigger(SH03_HELICOPTER_TRIGGER)
on_trigger("", SH03_HELICOPTER_TRIGGER)
trigger_enable(SH03_HELICOPTER_TRIGGER, false)
objective_text_clear(0)
SH03_GOT_TO_CHOPPA = true
--make the player think he has 5* notoriety
--hud_set_fake_notoriety("deckers", true, 5)
--sh03_control_notoriety( SH03_NOTERIETY_LEVEL ) --old value 4
if( character_is_in_vehicle(KINZIE) == false ) then
ai_do_scripted_move(KINZIE, SH03_KINZIE_WAIT, true, false)
end
end
-- called when a router is turned off
--
function sh03_obj_four(player, current_trigger)
local nav
--get the nav point
for i, trigger in pairs(sh03_objectives.routers.members) do
if sh03_objectives.routers.members[i] == current_trigger then
sh03_objectives.routers.status[i] = true
nav = i
end
end
--be a l33t hax0r
character_allow_ragdoll( player, false )
player_movement_disable(player)
action_play(player, "m24 computer hack", "m24 computer hack", false, 1.0, true, true, sh03_objectives.routers.hack[nav] )
while action_play_is_finished( player, 1.0 ) == false do
thread_yield()
end
--delay(.5)
character_allow_ragdoll( player, true )
player_movement_enable(player)
--update objective
SH03_ROUTERS_TURNED_OFF = SH03_ROUTERS_TURNED_OFF + 1
objective_text( 0, TURN_OF_THE_ROUTERS , SH03_ROUTERS_TURNED_OFF , SH03_TOTAL_LINKS , SYNC_ALL, OI_ASSET_USE )
sh03_clear_trigger(current_trigger)
sh03_manage_defense() --spawn enemies and/or disable cont spawns
audio_object_post_event("Force_Field_Powerdown")
if SH03_ROUTERS_TURNED_OFF == 4 then
SH03_OBJ_FOUR_COMPLETE = true
mesh_mover_hide( "sh03_force_field" )
end
delay(2)
audio_play_persona_line_2d( sh03_matt_id, SH03_dialog_lines.matt_taunts[SH03_ROUTERS_TURNED_OFF] )
end
function sh03_final_trigger(player, current_trigger)
character_allow_ragdoll( player, false )
player_movement_disable(player)
action_play(player, "m24 computer hack", "", true, false, true, "", SH03_FINAL_NAV )
while action_play_is_finished( player, 1.0 ) == false do
thread_yield()
end
--delay(.5)
player_movement_enable(player)
character_allow_ragdoll( player, true )
audio_object_post_event("Force_Field_Powerdown")
delay(1)
audio_object_post_event("SH03_Music_Stop", nil, nil, "SH03_Music")
if sh03_threads.SPAWN_THREAD ~= INVALID_THREAD_HANDLE then
thread_kill(sh03_threads.SPAWN_THREAD)
sh03_threads.SPAWN_THREAD = INVALID_THREAD_HANDLE
--message("convo thread killed", 2)
end
sh03_clear_trigger( SH03_FINAL_LINK )
--[[
if( SH03_ROOM_DEFENDERS_LEFT > 0 ) then
sh03_clean_house()
end
]]--
objective_text_clear( 0 )
delay(1)
--audio_ambient_emitter_stop( sh03_emitters.main )
mission_end_success( "sh03" ) --, CUTSCENE_MISSION_OUTRO )
end
function sh03_kinzie_hack_tower(current_tower)
local hack_done = false
SH03_KINZIE_HACKING = true --fail safe for the player leaving the trigger while Kinzie is in the process of hacking
sh03_control_notoriety(SH03_NOTERIETY_LEVEL)
sh03_cleanup_convo_thread() --kill the convo thread, if it's still playing when the player gets to this point
--stop updating the shortest path
SH03_HIT_TRIGGER = true
if sh03_threads.UPDATE_PATH_THREAD ~= INVALID_THREAD_HANDLE then
thread_kill(sh03_threads.UPDATE_PATH_THREAD)
sh03_threads.UPDATE_PATH_THREAD = INVALID_THREAD_HANDLE
end
--mark the current tower as active
for i, trigger in pairs(sh03_objectives.towers.members) do
if sh03_objectives.towers.status[i] == false and sh03_objectives.towers.members[i] == current_tower then
sh03_objectives.towers.active[i] = true
end
end
--disable the current trigger callbacks
for i, trigger in pairs(sh03_objectives.towers.members) do
if sh03_objectives.towers.status[i] == false then
sh03_clear_trigger( trigger )
on_trigger_exit( "", trigger )
end
end
mission_waypoint_remove( SYNC_ALL )
--object_indicator_add( KINZIE, OI_ASSET_DEFEND, OI_FLAGS_FULL )
marker_add(KINZIE, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL, SYNC_ALL )
--start hacking
ai_do_scripted_move(KINZIE, current_tower, true, false) --tell kinzie to go to the tower and start hacking
while ai_scripted_action_is_complete( KINZIE ) == false do --wait for her to get to the tower
thread_yield()
end
--Kinzie is kind of an idiot and will forget to go to teh tower every now and then
if get_dist( KINZIE, current_tower ) > 2.0 then --safety net, if she isn't in the navpoint tell her to go there again
ai_do_scripted_move(KINZIE, current_tower, true, false)
repeat thread_yield() until ( get_dist( KINZIE, current_tower ) < 2.0 ) -- wait for kinzie to get in the tower before starting the timer
end
--message("kinzie is at the tower!!!!!", 6)
action_play_non_blocking( KINZIE, "SH03 kenzie hack enter", "", true, false, true, "", current_tower)
objective_text_clear(0)
objective_text_clear(1)
local progress = 0
local r = rand_int(1, 8)
local hack_time = SH03_BASE_TIME -- + ( SH03_MULTIPLIER * 10 * ( SH03_TOWERS_HACKED + 1 ) + (SH03_MULTIPLIER * 100 ) )
local t = rand_int(15000, (SH03_BASE_TIME * .8))
hud_bar_on( 0, "Default", SH03_HACKING_TIME, hack_time, SYNC_ALL )
--action_play_non_blocking( KINZIE, "SH03 kenzie hack","", true, false, true, current_tower )
set_animation_state(KINZIE, "SH03 kenzie hack")
--do a bunch of shit so kinzie stays in her animation and doesn't look stupid
character_prevent_flinching(KINZIE, true)
set_ignore_ai_flag( KINZIE, true )
turn_invulnerable(KINZIE, false)
character_allow_ragdoll(KINZIE, false)
--kinzie is hacking the tower loop
while progress < hack_time do
-- if action_play_is_finished(KINZIE, 1.0) == true then
-- action_play_non_blocking( KINZIE, "SH03 kenzie hack","", true, false, true, current_tower )
-- end
progress = progress + SH03_TIMER -- - (SH03_MULTIPLIER * (TOTAL_TOWERS - SH03_TOWERS_HACKED) * 10) )
if progress >= t then --the player is impatient, play a random comment telling kinzie to hurry up
if SH03_TOWERS_HACKED == 0 then
sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.uplink_convo2)
t = 999999
elseif SH03_TOWERS_HACKED == 1 then
sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.uplink_convo)
t = 999999
elseif SH03_TOWERS_HACKED == 2 then
audio_play_persona_line( LOCAL_PLAYER, SH03_dialog_lines.impatient_player[r] )
t = 999999
end
end
if human_is_downed(KINZIE) == true then
progress = 0 --reset the timer if kinzie gets killed
end
hud_bar_set_value( 0, progress )
delay(.1)
end
delay(.25)
clear_animation_state(KINZIE)
action_play( KINZIE, "SH03 kenzie hack exit" )
character_allow_ragdoll(KINZIE, true)
turn_vulnerable(KINZIE)
character_prevent_flinching(KINZIE, false)
--we done! let's clean everything up
sh03_tower_complete()
end
function sh03_tower_complete(cur_tower)
for i, trigger in pairs(sh03_objectives.towers.members) do
if sh03_objectives.towers.active[i] == true then
sh03_objectives.towers.active[i] = false
end
end
CURRENT_TOWER = nil
SH03_KINZIE_HACKING = false
if SH03_TOWERS_HACKED == 0 then
audio_play_persona_line( KINZIE, SH03_dialog_lines.kinzie_triangulate[1] )
end
if SH03_TOWERS_HACKED == 1 then
audio_play_persona_line( KINZIE, SH03_dialog_lines.kinzie_triangulate[2] )
end
--mission_debug("hacking complete")
--object_indicator_remove( KINZIE )
marker_remove(KINZIE, SYNC_ALL)
set_ignore_ai_flag( KINZIE, false )
--hud_timer_hide(0, true)
--hud_timer_stop( 1 )
hud_bar_off( 0 )
objective_text_clear( 0 )
objective_text_clear( 1 )
sh03_objectives.towers.status[TOWER_INDEX] = true
--objective_text( 0, SH03_HACK_TOWER, SH03_TOWERS_HACKED , TOTAL_TOWERS , SYNC_ALL, OI_ASSET_LOCATION )
npc_leash_remove( KINZIE ) --allow Kinzie to run away from the navpoint
SH03_NOTERIETY_LEVEL = SH03_NOTERIETY_LEVEL + 1
SH03_TOWERS_HACKED = SH03_TOWERS_HACKED + 1
SH03_TIMER = SH03_TIMER * SH03_MULTIPLIER
--mission_debug("calling setup")
sh03_setup_obj_two()
end
function sh03_mark_routers()
for i, trigger in pairs(sh03_objectives.routers.members) do
if sh03_objectives.routers.status[i] == false then
marker_add_trigger(trigger, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) --INGAME_EFFECT_CHECKPOINT
sh03_set_trigger_use( trigger, "sh03_obj_four" )
end
end
end
function sh03_spawn_enemies( wave )
if( wave == 0 ) then
sh03_add_queue(sh03_group.ROOM_DEFENSE)
--spawn additional defenders if in co-op
if coop_is_active() then
sh03_add_queue(sh03_group.COOP_DEFENDERS)
end
--make sure the spawning thread is active
if sh03_threads.SPAWN_THREAD == INVALID_THREAD_HANDLE then
sh03_threads.SPAWN_THREAD = thread_new("sh03_spawning")
end
end
if( wave == 1 ) then
if coop_is_active() then
sh03_add_queue(sh03_group.COOP_WAVE_ONE)
else
sh03_add_queue(sh03_group.WAVE_ONE)
end
end
if( wave == 2 ) then
if coop_is_active() then
sh03_add_queue(sh03_group.COOP_WAVE_TWO)
else
sh03_add_queue(sh03_group.WAVE_TWO)
end
end
if( wave == 3 ) then
if coop_is_active() then
sh03_add_queue(sh03_group.COOP_WAVE_THREE)
else
sh03_add_queue(sh03_group.WAVE_THREE)
end
end
end
function sh03_manage_defense()
if( SH03_ROUTERS_TURNED_OFF == 0 ) then
continuous_spawn_start( sh03_group.ATTACK_SOL.name, 0, SH03_SOLDIER_DELAYY )
return
end
if( SH03_ROUTERS_TURNED_OFF == 1 ) then
--cont spawn specialists
continuous_spawn_start( sh03_group.ATTACK_SPEC.name, 2, SH03_SPECIALIST_DELAY )
end
if( SH03_ROUTERS_TURNED_OFF == 2 ) then
continuous_spawn_stop( sh03_group.ATTACK_SPEC.name ) --stop the specialists
continuous_spawn_stop( sh03_group.ATTACK_SOL.name ) --stop the soldiers
--disable continuous spawns
spawn_region_enable( SH03_cont_spawn.area1, false )
spawn_region_enable( SH03_cont_spawn.area2, false )
spawn_region_enable( SH03_cont_spawn.area3, false )
spawn_region_enable( SH03_cont_spawn.area4, false )
end
sh03_spawn_enemies( SH03_ROUTERS_TURNED_OFF )
end
function sh03_add_queue(insert)
sh03_queue[sh03_queue_size] = insert
sh03_queue_size = sh03_queue_size + 1
end
-- mark the remaining deckers and wait for them to be killed
--
function sh03_clean_house()
if group_is_loaded( sh03_group.ROOM_DEFENSE.name ) then
for i, char in pairs(sh03_group.ROOM_DEFENSE.members) do
if character_is_dead( char ) == false then
sh03_mark_enemies(char)
end
end
end
if group_is_loaded( sh03_group.WAVE_ONE.name ) then
for i, char in pairs(sh03_group.WAVE_ONE.members) do
if character_is_dead( char ) == false then
sh03_mark_enemies(char)
end
end
end
if group_is_loaded( sh03_group.WAVE_TWO.name ) then
for i, char in pairs(sh03_group.WAVE_TWO.members) do
if character_is_dead( char ) == false then
sh03_mark_enemies(char)
end
end
end
if group_is_loaded( sh03_group.WAVE_THREE.name ) then
for i, char in pairs(sh03_group.WAVE_THREE.members) do
if character_is_dead( char ) == false then
sh03_mark_enemies(char)
end
end
end
sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.clean_house)
objective_text( 0, KILL_TARGETS, nil, nil, SYNC_ALL, OI_ASSET_KILL )
repeat thread_yield() until ( SH03_ROOM_DEFENDERS_LEFT <= 0 )
--message("cleaning house", 5)
--mission_end_success( "sh03" ) --, CUTSCENE_MISSION_OUTRO )
end
-- this function limits what enemies spawn at certain notoriety levels
--
function sh03_control_notoriety(level)
notoriety_set_max( "deckers", level )
notoriety_set_can_decay( false )
notoriety_set( "deckers", level )
if level == 3 then
disable_specific_notoriety_group( "deckers", level, "G_Decker_SUV_1S", true )
disable_specific_notoriety_group( "deckers", level, "G_Decker_Car_1S", true )
end
if level == 4 then
disable_specific_notoriety_group( "deckers", level, "G_Decker_Car_1S", true )
disable_specific_notoriety_group( "deckers", level, "G_Decker_Car_2S", true )
disable_specific_notoriety_group( "deckers", level, "G_Decker_Brute_F", true )
end
if level == 5 then
disable_specific_notoriety_group( "deckers", level, "G_Decker_Brute_M", true )
disable_specific_notoriety_group( "deckers", level, "G_Decker_Brute_G", true )
--disable_specific_notoriety_group( "deckers", level, "G_Decker_Car_2S", true )
disable_specific_notoriety_group( "deckers", level, "G_Decker_SUV_2S", true )
end
end
-- this function tells the interior enemies where to go once they're spawned
--
function sh03_dispense_enemies( enemy_group )
local j
-- make sure they aren't the initial group, they don't need to go anywhere
if enemy_group.name ~= "Router 001" and enemy_group.name ~= "coop_router_defenders" then
for i, enemy in pairs(enemy_group.members) do
if i > 4 then --only 4 routers. the goal is to send 2 guards to each open router
j = i % 4
else
j = i
end
--Look for routers that haven't been shut off (true = off), we don't want the deckers defending an inactive router
local num_tests = 0
while (sh03_objectives.routers.status[j] == true) and (num_tests < 4) do
if j == 4 then --overflow check
j = 1
else
j = j + 1
end
num_tests = num_tests + 1
end
enemy_group.thread[i] = thread_new( "sh03_attack", enemy, sh03_objectives.routers.navs[j] )
end
end
end
function sh03_kinzie_dead()
mission_end_failure( "sh03", SH03_KINZIE_DIED )
end
function sh03_kinzie_abandoned()
mission_end_failure( "sh03", SH03_KINZIE_ABANDODNED )
end
function sh03_get_out_of_vehicles()
if character_is_in_vehicle(KINZIE, nil) then
character_evacuate_from_all_vehicles(KINZIE, false)
end
if character_is_in_vehicle(LOCAL_PLAYER, nil) then
character_evacuate_from_all_vehicles(LOCAL_PLAYER, false)
end
if COOP_IS_ACTIVE == true then
if character_is_in_vehicle(REMOTE_PLAYER, nil) then
character_evacuate_from_all_vehicles(REMOTE_PLAYER, false)
end
end
end
function sh03_mark_enemies(char)
marker_add( char, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL )
end
function sh03_release_enemies( char )
release_to_world( char )
on_death( "", char )
on_attack_performed("", char)
end
function sh03_free_enemies( char )
marker_remove( char, SYNC_ALL )
SH03_ROOM_DEFENDERS_LEFT = SH03_ROOM_DEFENDERS_LEFT - 1
sh03_release_enemies( char )
end
-- *************************
--
-- Callback functions
--
-- *************************
function sh03_obj_one( )--player, trigger )
--sh03_clear_trigger(trigger)
mission_waypoint_remove(SYNC_ALL)
marker_remove(SH03_GPS_OBJECTIVE_ONE, SYNC_ALL)
objective_text_clear(0)
SH03_OBJECTIVE_ONE_COMPLETE = true
--on_vehicle_enter( "", LOCAL_PLAYER ) --unregister the call incase the player decides to run over to the nuke plant
end
function sh03_jump()
end
function sh03_attack_line_cb( name, weapon, attack )
-- SAY IT! - "it"
local situation = "SH03_Attack"
-- don't play this if we have done this recently
if (not thread_check_done(sh03_threads.attack_line_timer)) then
return
end
-- start timer
sh03_threads.attack_line_timer = thread_new("delay", 10)
-- play situation
audio_play_persona_line(name, situation)
end
function sh03_play_car_convo()
trigger_enable( SH03_PLAY_CAR_CONVO, false )
on_trigger_exit( "", SH03_PLAY_CAR_CONVO )
--fire off a thread to play car convos
if sh03_threads.CAR_RIDE == INVALID_THREAD_HANDLE then
sh03_threads.CAR_RIDE = thread_new("sh03_car_convo_thread", SH03_convo.mission_start, SH03_convo.drive_over, SH03_convo.drive_over2)
end
end
-- *************************
--
-- Thread functions
--
-- *************************
function sh03_kinzie_in_party()
while group_is_loaded( sh03_group.START.name ) == false do
delay(1)
end
party_add( KINZIE, LOCAL_PLAYER )
--if (coop_is_active() == true) then
--party_add( KINZIE, REMOTE_PLAYER )
--end
while npc_is_in_party(KINZIE) == true do
thread_yield()
end
--mission_end_failure("sh03",SH03_KINZIE_DIED)
end
function sh03_play_convo_thread(convo)
convo.handle = audio_conversation_load(convo.name)
audio_conversation_play(convo.handle)
audio_conversation_wait_for_end(convo.handle)
audio_conversation_end(convo.handle)
--convo.handle = INVALID_CONVERSATION_HANDLE
end
function sh03_car_convo_thread(convo1, convo2, convo3)
delay(2)
convo1.handle = audio_conversation_load(convo1.name)
audio_conversation_play(convo1.handle)
audio_conversation_wait_for_end(convo1.handle)
audio_conversation_end(convo1.handle)
convo1.handle = INVALID_THREAD_HANDLE
delay(4)
convo2.handle = audio_conversation_load(convo2.name)
audio_conversation_play(convo2.handle)
audio_conversation_wait_for_end(convo2.handle)
audio_conversation_end(convo2.handle)
convo2.handle = INVALID_THREAD_HANDLE
delay(6.5)
convo3.handle = audio_conversation_load(convo3.name)
audio_conversation_play(convo3.handle)
audio_conversation_wait_for_end(convo3.handle)
audio_conversation_end(convo3.handle)
convo3.handle = INVALID_THREAD_HANDLE
end
function sh03_heli_convo_thread(convo1, convo2, convo3)
delay(2)
convo1.handle = audio_conversation_load(convo1.name)
audio_conversation_play(convo1.handle)
audio_conversation_wait_for_end(convo1.handle)
audio_conversation_end(convo1.handle)
convo1.handle = INVALID_THREAD_HANDLE
delay(5) --fix this to time the flight
--find anything yet? ... blah blah blah, needs more time
convo2.handle = audio_conversation_load(convo2.name)
audio_conversation_play(convo2.handle)
audio_conversation_wait_for_end(convo2.handle)
audio_conversation_end(convo2.handle)
convo2.handle = INVALID_THREAD_HANDLE
delay(6.5)
audio_play_persona_line( KINZIE, SH03_dialog_lines.kinzie_chair )
delay(3)
convo3.handle = audio_conversation_load(convo3.name)
audio_conversation_play(convo3.handle)
audio_conversation_wait_for_end(convo3.handle)
audio_conversation_end(convo3.handle)
convo3.handle = INVALID_THREAD_HANDLE
end
-- this function updates the shortest path to the hack towers
--
function sh03_update_path()
local dist = 99999
local old_path = SH03_SHORTEST_PATH
while(true) do--while( SH03_HIT_TRIGGER == false ) do
for i, trigger in pairs(sh03_objectives.towers.members) do
if sh03_objectives.towers.status[i] == false then
if get_dist( LOCAL_PLAYER, sh03_objectives.towers.nav[i] ) < dist then --sh03_objectives.towers.nav[i]
SH03_SHORTEST_PATH = sh03_objectives.towers.members[i] --make sure to draw the waypoint on the trigger
dist = get_dist( LOCAL_PLAYER, sh03_objectives.towers.nav[i] )
end
end
end
if( old_path ~= SH03_SHORTEST_PATH) then --only print if there's a new shortest path
mission_waypoint_remove( SYNC_ALL )
mission_waypoint_add( SH03_SHORTEST_PATH, SYNC_ALL )
--marker_add( SH03_SHORTEST_PATH, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL)
old_path = SH03_SHORTEST_PATH
end
dist = 99999
delay(.5)
end
end
-- thread function to control spawning
-- we can't have more than 32 objective markers on screen, so this function makes sure we never have more than 32 enemies spawned
--
function sh03_spawning()
while(true) do
-- do we have anything in the queue?
if( sh03_queue_size > 0 ) then
if( sh03_queue[0].size + SH03_ROOM_DEFENDERS_LEFT < 32 ) then
group_create( sh03_queue[0].name, true )
if group_is_loaded( sh03_queue[0].name ) then
for i, char in pairs(sh03_queue[0].members) do
--sh03_mark_enemies(char)
SH03_ROOM_DEFENDERS_LEFT = SH03_ROOM_DEFENDERS_LEFT + 1
on_death( "sh03_free_enemies", char )
on_attack_performed("sh03_attack_line_cb", char)
end
end
--defense group created, now tell the enemies where to go
sh03_dispense_enemies( sh03_queue[0] )
--update the queue
for i = 1, sh03_queue_size do
sh03_queue[i - 1] = sh03_queue[i]
end
sh03_queue_size = sh03_queue_size - 1
end
end
delay(.5)
end
end
-- thread function for the helicopter to arrive at the landing spot
--
function sh03_heli_arrival()
group_create( sh03_group.HELICOPTER.name, true )
while group_is_loaded( sh03_group.HELICOPTER.name ) == false do
thread_yield()
end
vehicle_enter_teleport(SH03_PILOT, SH03_HELICOPTER, 0, true)
set_dont_attack_me_on_sight_flag(SH03_PILOT, true)
--object_indicator_add( SH03_HELICOPTER, OI_ASSET_DEFEND, OI_FLAGS_DEFAULT )
--fly, helicopter. fly!
helicopter_fly_to( SH03_HELICOPTER, SH03_HELI_ARRIVAL_SPEED, HELICOPTER_ARRIVE )
delay(1)
on_vehicle_enter("sh03_heli_fly", SH03_HELICOPTER)
helicopter_fly_to_direct( SH03_HELICOPTER, SH03_HELI_LAND_SPEED, HELICOPTER_LAND )
--helicopter_land( SH03_HELICOPTER, HELICOPTER_LAND )
vehicle_speed_override(SH03_HELICOPTER, 0.0)
vehicle_set_keyframed_physics( SH03_HELICOPTER, true )
vehicle_suppress_npc_exit(SH03_HELICOPTER)
vehicle_suppress_flipping( SH03_HELICOPTER, true )
--delay(3)
SH03_HELI_LANDED = true
end
function sh03_attack( attacker, dest )
--tell the AI to go to the router and attack the player on sight
move_to_safe( attacker, dest, 3, true, false )
ai_attack_region(attacker, dest, 18.0)
set_attack_player_flag( attacker, true )
end