Prototyping - Mission Scripting
We're going to fully script Mission 1 by adding the appropriate lines to our mission initialization framework. These steps are all that's required to add in the content for the remaining 58 missions.
No new objects are required for this part
GML Code
We only have to add to our set_mission_* scripts from last time. The code below includes the code from last time so you only have to replace the code
Script: set_mission_messages
We'll update the script with the messages for mission 1. The default mission will rename to handle the missions that aren't defined yet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/* Sets the messages for mission - only callable from obj_hq Arg0 - current mission */ switch argument0 { case 1: /* Mission 1 */ { wave_messages[1] = "destroy the two trucks heading for the north entrance" wave_messages[2] = "take out the trucks entering from the west, and kill escort" wave_messages[3] = "destroy the two trucks that are arriving from the north" wave_messages[4] = "a vulture patrol skid is entering from the east" wave_messages[5] = "mission complete. return to base, velasquez" } break; default: { wave_messages[1] = choose("Give em hell, vel", "Destroy all vulture ships") wave_messages[2] = choose("Mission complete vel", "Come on back, vel") } break; } |
Script: set_mission_parameters
The parameters for mission 1 happen to match the default, but we should define them anyway.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/* Sets overall mission paramters */ switch argument0 { case 1: /* Mission 1 */ { night = false player_ship_type = SHIPTYPE.hornet } break; default: { night = false player_ship_type = SHIPTYPE.hornet } break; } |
Script: set_mission_waves
We'll assign the ships to waves. This is the most cumbersome part of adding a mission beacuse we have to go through the original binary to discover which ships go with which wave. More on this in the video.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/* Assign ships to waves, all default to wave 1 already */ switch argument0 { case 1: /* Mission 1 */ { npc_ship[0].wave_number = 1; npc_ship[1].wave_number = 1; npc_ship[2].wave_number = 1; npc_ship[3].wave_number = 1; npc_ship[4].wave_number = 2; npc_ship[5].wave_number = 2; npc_ship[6].wave_number = 2; npc_ship[7].wave_number = 2; npc_ship[8].wave_number = 3; npc_ship[9].wave_number = 3; npc_ship[10].wave_number = 4; npc_ship[11].wave_number = 0; npc_ship[12].wave_number = 0; npc_ship[13].wave_number = 0; npc_ship[14].wave_number = 0; npc_ship[15].wave_number = 0; npc_ship[16].wave_number = 0; npc_ship[17].wave_number = 0; npc_ship[18].wave_number = 0; npc_ship[19].wave_number = 0; last_wave = 4; } break; default: last_wave = 1; break; } |