Sunday, March 19, 2017

NDB Navigation

One of two aircraft related mods that I planned to do is the NDB non-directional-beacon navigation support; the other one is the MAAS system, which is still sadly lacking a nice model.

At the end of summer I got contacted by madsolosniper on the BI forums who had a mod idea for adding navigational aids to arma 3. When a few weeks later NightIntruder wrote me about his aircraft sign mod I sat down and wrote a couple of test missions at the end of September. One of them eventually was released by NightIntruder with his mod.

Then the project sat idle for quite a while. This weekend I then finally converted the sample mission into a mod, which still needs testing, especially in multiplayer.

The mod as it is now (2017-03-19) is quite minimalistic. It consists of an invisible NDB object and some actions on players to control the NDB navigation. The basic work flow is to add one or more NDB objects to the map at places like airfields, aircraft carrier, or the NDB building from NightIntruder's mod. On the object the frequency for the NDB can be set. In the mission players in aircraft can then change their direction finders frequency to that of any NDB. For publication of the NDB frequency for example a map marker or a note in the mission briefing can be used.

In the mission a player in an aircraft has three action menu entries:

  1. change frequency of direction finder to NDB frequency
  2. show the direction arrow on the HUD
  3. hide the direction arrow on the HUD
The implementation is quite straight forward and might be in need of optimisation for performance later on. In the config.cpp the "ttt_ndb1" class defines the invisible beacon object. It's main purpose is to keep the "Frequency" stored in a like named variable. Further it uses an init event handler to store the object in a global array (ttt_ndb_beacons) and initialize the mission event handler for showing the arrow on the HUD (addMissionEventHandler EachFrame). Also the Man class gets an extended init eventhandler to add the above mentioned user actions.

The init eventhandler for the Man class calls fn_addUI.sqf. The code there sets up the arrow for later use and adds three actions to the scroll wheel menu for the player. It relies on the locality of the global variable beaconActive and a few others to determine the state the system is in, e.g. if the arrow is displayed on the HUD or not. From the "Enter beacon frequency" action the dialog for entering the beacon frequency is triggered.

The init eventhandler for the beacon class "ttt_ndb1" checks if the global variable ttt_ndb_beacons is present. If this is not the case, it will be initialized and the mission event handler "EachFrame" is added to display the directional arrow on the HUD. Also the beacon object is added to the "ttt_ndb_beacons" array.

When the frequency is changed through the dialog, the "ttt_ndb_beacons" array is traversed and checked for the given frequency. If found, the new active beacon is set and the arrow points toward it. If not found, a message via "vehicleChat" is shown to the player that no such beacon frequency exists.

As this is pretty much my first attempt at changing the UI via mod, there might be other ways to achieve the wanted behaviour. Maybe some are much better than the way chosen, and I'd be glad to hear about them.



No comments:

Post a Comment