bbosen - 2020-06-02

The sample source code for Missions 4, 5, 6, 7, 8, 9, and 10 is intended to help mission developers create new LAC missions. As published, each of those missions advances through 201 distinct mission "states" according to the progress of various mission timers. All of this is tracked through a kind of "master" variable named "MissionStateNetworkBattle". The first 12 distinct states are all used to synchronize audio messages as the mission commences.

If mission developers want to place additional, timed events into their missions, they can easily continue this pattern of additional states.

For example, consider a mission intended to last for an hour and in which four Battleships have to change course frequently. In support of that 60-minute plan, mission designers might need about 360 distinct mission states, each of about 10 seconds duration, and many of which might change the course or speed of one or more ships.

In that case, after the mission designer works out all of the detailed logistics for the one-hour duration of the mission and any course corrections to be associated with each of the 360 mission states, he could choose 10 states, each ocurring at tactically significant points of time, for special attention, recording the positions of all four battleships at each of those 10 points in a table. For a 60-minute mission, the mission designer might define the timetable of those waypoints so that each is entered six minutes after its predecessor. We will refer to those 10 points as "MissionChronoMilestones".

Thereafter, whenever an incoming message from the "MissionCommander" urges synchronization at one of those 10 MissionChronoMilestones, the message recipients can all cause their four battleships to "leap" to the corresponding positions. Thus the positions of all four battleships can be synchronized among all players whenever the MissionCommander's battleships reach any of those 10 MissionChronoMilestones, even if one or more players enter the mission long after others have done so. (Of course, for any players that had already been synchronized by receipt of a prior MissionChronoMilestone message, the "leap" should be so tiny as to be almost imperceptible. But upon entry of a new player into a mission that has already been running for a significant period of time, that first leap might be huge.)

Here is some sample code, commencing with a large comment block that you will already find in the source code as published, that creates two additional states, numbered "13" and "14", respectively:

=======================

//
//  Mission Designers: If you want to insert additional, timed, one-time steps
//  into your mission, you can continue the pattern of the 12 prior
//  "MissionStateNetworkBattle" blocks with additional, similar blocks here.
//
//  You could create as many new code blocks, each activated according to
//  the pattern of the above 12 blocks as time and "MissionStateNetworkBattle"
//  advance, as you want. Within each block you have a lot of freedom
//  to handle any one-time event you can imagine.
//
//  You could easily put new messages into the SystemMessagePanel and/or
//  play or replay additional sound files or beeps, or you could change
//  the direction of travel of ships, destroy or repair objects, change
//  Mumble channels, etc.
//
if (MissionStateNetworkBattle == 13 && (timer > PriorStateEndTimer +10000))
   { //  Only get here once, 10000 ms after MissionStateNetworkBattle
   //  advances to "13":
   //
   if (! (NetworkMode & 16))
      {
      popen ("espeak -p 1  -s 140 \"Mission State = 13.\"", "r");
      }
   MissionStateNetworkBattle = 14;
   PriorStateEndTimer = timer;
   }
if (MissionStateNetworkBattle == 14 && (timer > PriorStateEndTimer +10000))
   { //  Only get here once, 10000 ms after MissionStateNetworkBattle
   //  advances to "14":
   //
   if (! (NetworkMode & 16))
      {
      popen ("espeak -p 1  -s 140 \"Mission State = 14.\"", "r");
      }
   MissionStateNetworkBattle = 15;
   PriorStateEndTimer = timer;
   }

=====================

Each of those two new "states" is executed only once. Each commences exactly 10 seconds after the prior state. Each uses the well-known "espeak" application to vocalize a text-to-speech message, and each of those messages is contrived simply to announce commencement of the corresponding new mission state.

Mission designers can use this pattern to create as many timed "states" as they may desire within new missions. By adjusting the values tested for "timer" versus "PriorStateEndTimer", they can precisely determine when each new state will be activated,

Within the curly brackets bookending each state, mission designers can insert their own code for whatever timed events they want to create within their missions. As described in other posts within this "Mission Developers" forum, It's easy to change the illustrated text-to-speech data to verbalize different messages, or to play a video clip with "vlc", or even to display a web page. Aircraft, tanks, ships, or other objects can be moved around, strengthened, re-fueled or damaged, etc. SystemPanel messages can be inserted. "Beeps" can be sounded through the player's speakers or headphones. With a little imagination, this technique can add great interest and variety to LAC's missions!

 

Last edit: bbosen 2025-04-05