bbosen - 2020-06-02

I just created some general-purpose mission infrastructure in support of events that occur every ten seconds. To make this easy, I created a new, global unsigned integer named "MissionTenSecondTimer" that is available in every mission. Here is an example of how to use it:

MissionTenSecondTimer += DeltaTime;
if (MissionTenSecondTimer > 10000)
   { //@ Get here once every 10 seconds
    MissionTenSecondTimer = 0; //@ Will expire again in 10 more seconds

   }

Within the curly braces shown above, mission designers can insert any additional, new logic that they want to happen once every ten seconds. For example, it could manipulate, move, create, change the course of, or destroy mission objects, activate sound effects, update cockpit instruments, etc. This would also be a great place to insert code to determine who is the current MissionCommander. Defined conditions could be tested within this loop, resulting in activities being carried out every ten seconds "conditionally".

Obviously, one of the most important aspects of code samples like these is knowing WHERE to insert them into your mission. All of the suggestions published in this forum today will be used somewhere within the "processtimer()" function of your mission, but the actual location will depend on a lot of other factors under your control. In the case shown above, it must be located within the primary line of execution so that the first statement gets executed on every single pass through the mission.

Understanding this example will be facilitated if you know that "DeltaTime" is always equal to the time interval, in milliseconds, since the PRIOR execution of this mission's "processtimer()" function, and that LAC tries to execute that "processtimer()" function over and over again and again, as rapidly as possible, in a repeating loop, until the mission ends.

The published mission source code already has similar blocks that get executed exactly once per second and exactly ten times per second. They are clearly identified and described in associated source-code comments. The "Ten Times Per Second" code block is used to rotate the RADAR antenna.

Mission designers that learn these principles can use them to good advantage to make more interesting missions.

; )

 

Last edit: bbosen 2020-06-06