Let’s Make: Traffic Department 2192 – Part 29

Prototyping - Finalizing the Default Mission

We broke down mission construction in to two parts. The default mission is the first step where the only goal is to destroy all ships with the 'enemy' alignment. Then return to base.

We add no new objects this time. Instead, we modify the headquarters object to add the capability to return to base. Then add several scripts to handle mission settings and checking. Refer to the mission design in part 23.

 

GML Code

Our work in GameMaker this time around

obj_ship: Destroy 4

When a ship is destroyed, we need to set the update_mission trigger in obj_hq to check for mission updates in the next frame. Then add to the kill count if the player caused the death.

 

obj_hq: Create 1

This is a replacement for the original variable declarations in obj_hq to account for the world and mission interactions. Note that we're adding sprites indices and world locations to act as the base.

 

obj_hq: Create 2

Introduce a data struction that holds important mission targets that we'll use later as a filter for all possible targets

 

obj_hq: Room Start 3

Call our mission initialization script that we'll define later

 

obj_hq: Step 1

Every step, we'll check to see if the player ship has returned to base and the mission has been completed

 

obj_hq: Step 2

Returns the game to the main menu after the player has died

 

obj_hq: Draw 1

Draws the sprites for the headquarters a layer higher than the player to simulate entering the headquarters building.

 

obj_hq: Room End 1

Update (actually remove) mission data on death

 

obj_hq: Begin Step 1

Perform the mission update if the trigger is set. It's set whenever a ship is destroyed.

 

Script: mission_initialize

Sets up the mission by calling several child scripts.

 

Script: mission_check

Checks to see if a wave is complete and advances us through the mission logic.

 

Script: set_mission_messages

Sets the messages for the mission used at the beginning of each wave in the HUD message ticker. Default is a random start and finish message.

 

Script: set_mission_parameters

Sets important mission parameters like the type of player ship. Default is the hornet ship on a daytime mission

 

Script: set_mission_waves

Assigns each of the 20 possible NPC ships to waves. Default is that all ships are in the first and only wave

 

Script: ship_inactivate

Suspends NPC ship operation

 

Script: ship_activate

Activates a ship in the game world

 

Script: wave_activate

Activates all ships in a wave in the game world

 

Script: is_wave_clear

Checks if all ships in a particular wave have been destroyed or otherwise completed their mission (inactivated)