As you know i've been working on a top down survival shooter for a while now
Well one of the main features of the game is a set of Missions which i've kind of been putting off, since I was sure how I was going to setup and run the missions.
However, after the release of the Halloween Demo (which seemed to go over pretty well :D) I decided it was time to man up and see if I could figure it out.
The first step in creating missions within the game was to know what the player was doing or had done.
Luckily for me most of the common actions the player does such as collecting a airdrop crate, killing an enemy or changing their weapon already have a function related to them. This meant I could record/detect when these events were happening fairly easily.
For example when the player wants to change weapon.
The Player presses #1 Key to change to the Pistol > ChangeWeapon("pistol") is called > ChangeWeapon function swaps the players appearance to be holding the correct gun, tells the game it should be firing pistol bullets now, etc
By adding a new function within the changeWeapon function, I call check if and when the player changes his gun and make the game responde accordingly.
Player Press #1 > ChangeWeapon("pistol") > Game sets up the pistol > "gunChangeEvent()"
By creating these events for actions I want the player to carry out as objectives within a mission, I can begin to script chains of objectives and in short create missions for the player to carry out.
So far I have:
waypointEvent - When the player moves to a specified target area (marked with an X)
swapWeaponEvent - When the player changes their gun
killEvent - Fairly obvious, when the player kills an enemy
collectEvent - when the player collects an airdrop crate.
as you can begin to see, by using these events, I can tell the player what he should be doing (an objective) and then check if the objective is completed by waiting for the correct event to happen and responding when it does.
To test this out properly I've created a very simple training mission which runs the player through the basics of the game. The player follows a chain of objectives which lead them through a "basic training session" before it is rudely interrupted by an outbreak of parasites and the training session quickly becomes a real threat situation.
As you'll see if you play the game, not only can I use the events to check when the player is completing the objectives, I can also reward them for doing so, the M16 Airdrop crate is scripted to be dropped into the level once the movement training is finished, and the target is scripted to pop up once the player has the correct gun equipped. Obviously these are simple events, but using this system it would be easy to automatically drop in more ammo should the player's health fall below a certain amount (once a playerDamageEvent is implemented).
Anyway for now check out the scripted mission test (sorry that it just ends after you kill the parasites, not setup a mission complete screen yet so you'll have to refresh if you wanna go back and play the other game modes after)
Infestation: Mission Scripting Test