← Home SEEBIE90 DOCS
Download PDF
The SOFLAM Integration Core mod is published under the Arma Public License (APL)Example code is free to useSuggestions: Discord to the author

For other modders

Picture sources for the tablet Changed

Since 3.1.0 the tablet shows more than a SOFLAM. A mod that has a camera on a drone or a vehicle registers a picture source, and the tablet gives it the screen, the zoom, the thermal and night vision, the heads-up display, the settings menu and the full-screen control. This page is the whole contract.

In plain wordsHow a drone or a ground vehicle puts its camera on the SOFLAM tablet: one class with three jobs, the setting types, the relay for commands, streaming, and what the tablet draws for you.

What you get, and what you provide

The tablet already does everything that is the same for every source: the list in the source menu (TAB → Source → UAV or UGV), the camera on the screen with the same five-step zoom as the SOFLAM, night vision and thermal with every palette and window of the GTG Thermal Framework, a HUD with compass, horizon and status lines, the settings menu, and the full-screen control with mouse, W A S D or the right stick. A source provides three things:

Where the camera is→The values to show→The settings and what they do

The class is GTG_SOFLAM_TabletFeedSource. You derive from it and override what you can; everything you leave out stays off, and the screen drops the matching field. That is how one HUD fits a drone with missiles and a ground vehicle with none.

The registry of sources is GTG_SOFLAM_TabletSources. Register once at game start, on every machine: the source runs on the viewer’s machine, because that is where the tablet is.

Example code – free to useMyBridge_DroneSource.c (pattern)
class MyBridge_DroneSource : GTG_SOFLAM_TabletFeedSource
{
	protected IEntity m_Drone;

	override GTG_ETabletSourceKind GetKind() { return GTG_ETabletSourceKind.UAV; }	// or UGV

	override string GetTitle() { return "MY DRONE"; }

	// asked often (the list and every frame): keep it cheap. false ends a running picture cleanly
	override bool IsAvailable() { return m_Drone != null; }

	// mat[3] = position, mat[2] = viewing direction. false = no position, the picture stays as it is
	override bool GetCameraTransform(out vector mat[4])
	{
		if (!m_Drone)
			return false;

		m_Drone.GetWorldTransform(mat);
		return true;
	}

	override void FillStatus(GTG_SOFLAM_TabletFeedStatus status)
	{
		status.m_sTitle = "MY DRONE";
		status.m_fAltitude = m_Drone.GetOrigin()[1];
		status.m_iSignal = 5;			// 0..5 bars, -1 = hide
		status.m_sLinkName = "SATCOM";
	}
}

// at game start, on every machine:
GTG_SOFLAM_TabletSources.Register(new MyBridge_DroneSource());

Register ignores the same instance twice. A source is a plain script object, not an entity: it is yours to create when your drone appears and to Unregister when it is gone.

The hooks

HookWhat it is for
GetKind(), GetTitle()Which tile of the menu the source appears on (UAV or UGV), and its name in the list. With several sources in the air, the blue LINK key switches between them.
IsAvailable()May this player see the source now? Asked often. false ends a running picture.
GetCameraTransform(out vector mat[4])Where the camera stands and where it looks.
OnFeedStart(), OnFeedStop()The viewer starts or stops looking. Ask for the streaming of the area around the camera here and give it back.
FillStatus(status)The values of the HUD, asked every frame. Only changed texts are rewritten.
GetSettings(list), OnSettingChanged(setting), OnAction(id)The settings menu and what a change does.
SupportsPointCommands(), OnPointPicked(action, worldPos)May the player pick a point in the picture (“look” = hold the camera there, “orbit” = a new circle point)? The tablet remembers the last point (RememberPoint, GetLastPoint).
OnFeedUpdate(dt)Every frame while the picture is open. A source can hold its remembered point here.
GetZoomLevels(levels), GetDefaultZoomLevel()Your own zoom steps, ascending (the drone: 2, 5, 10, 20, 30, 40, 50). Left empty, the five steps of the SOFLAM apply, up to 20x.
GetViewRange()How far objects are drawn in the picture, see below. Default 3000 m.
IsCameraLocked()true while the camera belongs to the source itself (a drone that attacks and guides its ball). The tablet then shows the real view, and point commands rest.
ShowsContacts()Should the tablet mark enemies and own forces in this picture? See below.
PopMessage()The source puts a line in m_sMessage (“Return home ordered”); the tablet asks for it once per frame and shows it in its message line.

Settings

A source fills a list of GTG_SOFLAM_TabletSetting each time the menu opens and after every change. Six kinds exist, each with a factory method:

KindFactoryHow the player uses it
StepStep(id, label, value, min, max, step, unit)Left and right change the value by one step.
NumberNumber(id, label, value, min, max, step, unit)A window opens; the player types digits with the keys 0 to 9. Minimum and maximum show as a hint, the value is rounded to the step. Made for an altitude.
ToggleToggle(id, label, on)On / off.
ChoiceChoice(id, label, choices, current)A pick from a list, for example the attack mode.
DigitsDigits(id, label, text, digits)A row of digits, 1 to 8 per place, for a laser code.
ButtonButton(id, label, confirm)An action. With text in confirm the player has to press ENTER a second time (“Return to home”).

A setting can be shown but not changeable: m_bEnabled = false (the laser code while laser on call is off). The menu shows (NOT NOW) behind it. Labels are English and short.

Example code – free to useMyBridge_DroneSource.c (pattern)
override void GetSettings(notnull array<ref GTG_SOFLAM_TabletSetting> list)
{
	list.Insert(GTG_SOFLAM_TabletSetting.Number("altitude", "ALTITUDE", m_fAltitude, 100, 3000, 50, "M"));
	list.Insert(GTG_SOFLAM_TabletSetting.Button("return_home", "RETURN HOME", "RETURN HOME?"));
}

override void OnSettingChanged(GTG_SOFLAM_TabletSetting setting)
{
	// the new value is already in the object; carry the command to the server
	if (setting.m_sId == "altitude")
		MyBridge_Send(MyCommand.ALTITUDE, setting.m_fValue);
}

override void OnAction(string id)
{
	if (id == "return_home")
		MyBridge_Send(MyCommand.RETURN_HOME, 0);
}
A row you did not writeThe tablet adds one row of its own behind the settings of the source: Auto map marking (see below). The menu shows five rows and scrolls with the cursor when a source has more.

Commands go to the server through your own relay

Everything in a source runs on the viewer’s machine. The tablet belongs to the player, the drone does not. A client that does not own the drone cannot send an RPC on it: the server drops it silently. This is the lesson of Who may send once more, and the answer is the same: send through the player’s own character, and let the server find the drone by its RplId.

Example code – free to useMyBridge_Relay.c (pattern)
modded class SCR_CharacterControllerComponent
{
	[RplRpc(RplChannel.Reliable, RplRcver.Server)]
	void MyBridge_RelayCommand(RplId drone, int command, float number)
	{
		// on the server: resolve the drone, check the command, then do it
		IEntity entity = IEntity.Cast(Replication.FindItem(drone));
		if (!entity)
			return;

		MyBridge_Execute(entity, command, number);
	}

	void MyBridge_SendCommand(RplId drone, int command, float number)
	{
		Rpc(MyBridge_RelayCommand, drone, command, number);
	}
}

The server must check what arrives: range of the number, whether the command is allowed now. The tablet shows a value as soon as the player changes it, but the drone is the source of truth. The drone bridge shows the changed value for a few seconds and then reads the real one back.

The area around the camera must exist on the viewer’s machine

A far drone is not thereA drone that flies 3 km from the viewer is not streamed to him: the entity does not exist there, and the picture would show nothing. Force it: the server enables spatial relevancy for the drone and tells the streaming not to stream it out for any player (EnableSpatialRelevancy(true) and EnableStreamingConNode(identity, false) on its RplComponent), from the moment it spawns and for players that join later. Do it for the one drone only; it is a single object. The AH-64 mod does the same for the operator’s character.

Units far from the viewerNew

The drone is one object and easy to keep. The soldiers and vehicles in its picture are not: they can be kilometres from the player with the tablet, the game does not stream them to him, and the picture shows empty ground. Since 3.1.1 the Core does three things, all of them only while a picture is open.

  1. The server holds what the camera sees. Every 1.5 seconds the tablet sends the camera position, the viewing direction, the width of the field of view and the observed point to the server, through the relay of the player’s character (unreliable, a lost message heals with the next). The server queries soldiers and vehicles in a sphere around the observed point, keeps those inside the view cone with EnableStreamingConNode(identity, false) for this player only, and lets go with true three seconds after they leave the picture. At most 80 objects per player. A request expires after 5 seconds without a message (picture closed, connection gone), and the message that ends the picture releases everything at once.
  2. Observers stand at the observed point. The engine simulates soldiers and vehicles only near observers (cameras and players). The drone camera is a camera of the tablet and does not count. Our working explanation, which fits what we saw but is not proven: what arrives far from every observer arrives half made, without VISIBLE and ACTIVE, soldiers drawn as arms and heads only, a truck without its cargo bed, an armoured vehicle without wheels. AI agents are even switched off at the highest level of detail (AIAgent: “AIAgents get disabled in MaxLOD by default”; the vanilla AI group comments give about 1000 m to the nearest observer as the default). So the Core registers observers with ObserversSystem: one local at the observed point, one far observer along the sight line (the call a scope or binoculars make every frame), and one on the server for the player’s connection. All three are removed when the picture ends. What they achieve: the AI agents in view run (level 0, active) about two seconds after the picture opens. On their own they did not complete the drawing of the soldiers; that took step 3.
  3. The tablet wakes what arrives. Every half second, on the viewer’s machine, for the soldiers and vehicles in the observed sphere: VISIBLE and ACTIVE on the root if one is missing, Update(), a physics body that sleeps is set active, and the pose of the skeleton is requested by reading a bone matrix.
Example code – free to useGTG_SOFLAM_TabletSources.c, GTG_SOFLAM_FeedInterest.c (excerpt)
// client: the observed point, with every request (1.5 s)
ObserversSystem observers = ObserversSystem.Cast(GetGame().GetWorld().FindSystem(ObserversSystem));
observers.InsertObserverSP(KEY, point[0], point[2], null);

// client: every frame, from the camera of the source (like SCR_2DOpticsComponent.UpdateFarObserver)
observers.AddFarObserver(viewer, tabletEntity, cameraPos, viewDirection, viewRange, timeSlice);

// server: with every request, for this player's connection
observers.InsertObserverMP(identity, point[0], point[2], null);

// the end of the picture: RemoveObserverSP(KEY), DelFarObserver(), RemoveObserverMP(identity)
Example code – free to useGTG_SOFLAM_FeedActivate.c (excerpt)
// client, every 0.5 s, for each soldier and vehicle (root entity) in the observed sphere
if ((entity.GetFlags() & needed) != needed)
	entity.SetFlags(needed, false);		// VISIBLE | ACTIVE -- the root only

entity.Update();

Physics physics = entity.GetPhysics();
if (physics && !physics.IsActive())
	physics.SetActive(ActiveState.ACTIVE);

// reading a bone matrix makes the engine compute the pose
Animation anim = entity.GetAnimation();
TNodeId head = anim.GetBoneIndex("Head");
if (head >= 0)
	anim.GetBoneMatrix(head, mat);
NoteOnly the combination of the last three steps helped. Update() and the physics alone changed nothing, and neither did the bone read alone. Why the three work together is not understood; the code keeps all of them and says so.

What does not work, so you can spare yourself the detour:

TriedResult
VISIBLE on all children of every soldier and vehicleSoldiers appeared, but so did things that are hidden on purpose: an ambulance stood in a large grey cylinder, the area mesh of its support station (SCR_SupportStationAreaMeshComponent). Touch the root only.
AIAgent.PreventMaxLODDoes nothing for an agent that is already on the highest level (the API says so).
SetPermanentLOD(0) and ActivateAI() on every agent in viewThe agents were switched off again before the next request. The observers fixed it: the agents stood on level 0, active, about two seconds after the picture opened.
The SET_RENDERED flag on all children, the third-person animation layer, the Object Draw Distance and Geometric Detail settingsNo effect. The flag stays set, the picture does not change; the settings were already at their maximum and their limits cannot be read from script.
Flying lower, zooming, waitingNo difference: it is not the distance to the camera.
RplComponent.InsertMPObserverObsolete. Use ObserversSystem.InsertObserverMP.
An open endVehicles far from the viewer are still not always drawn completely (a truck without its cargo bed, an armoured vehicle without wheels). Soldiers are shown with their gear. This is a known limit of 3.1.1, written into the Core’s known issues.

A Game Master as the operatorNew

When the Game Master opens the editor, the game streams all editable entities to him. When he closes it, SCR_DynamicSimulationEditorComponent.EOnEditorDeactivateServer calls EnableStreamingConNode(identity, true) for all of them and so cancels every “never stream out” you set. A drone that flies outside the streaming range disappears from his machine, the source unregisters, and the tablet says NO FEED. The client log shows it: the drone is created on his machine exactly when he opens the editor, and gone when he closes it.

The Core keeps its sources: it overrides the one function that frees an entity and leaves it out for entities that carry the component of a known source. The component is looked up by name ("UAV_OrbitComponent".ToType()), so the Core compiles without the drone mod and does nothing when it is absent.

Example code – free to useGTG_SOFLAM_StreamKeep.c (excerpt)
modded class SCR_DynamicSimulationEditorComponent
{
	override protected void EnableStreamingForEntity(SCR_EditableEntityComponent entity, bool enable)
	{
		if (enable && entity && GTG_SOFLAM_StreamKeep.IsKept(entity.GetOwner()))
			return;		// a picture source stays streamed

		super.EnableStreamingForEntity(entity, enable);
	}
}

If your source holds its entity with EnableStreamingConNode(identity, false), do the same after the editor closes. The same trap applies to anything you stream for a Game Master who also uses the editor, and to the units the Core holds for the picture: it sets the flag again with every request.

Where the camera looks firstNew

When a picture of a source with point commands is opened for the first time, and the player has not chosen a point yet, the tablet looks for a default: for a drone the centre of its circle, the loiter point. The Core finds the drone by the camera position (a 15 m sphere around it), its orbit component by name, and reads the centre by reflection, because the field is protected (typename.GetVariableValue). The source then holds the point like any remembered point. After that the camera stays on the point the player used last.

For your own source: set it in OnFeedStart, when nothing has been remembered.

Example code – free to useyour source (sketch)
override void OnFeedStart()
{
	vector known;
	if (!GetLastPoint(known))
		RememberPoint(MyDefaultPoint());	// the camera looks here at the first opening
}

View range: what the drone sees, not how far it may look

GetViewRange() (default 3000 m) is how far objects are drawn in the picture. While the picture is open, the tablet raises the game’s view distance to that value and sets the far plane of the camera; when the picture closes, it gives the player’s own setting back. It is not a limit for the distance between tablet and drone, and not a limit for the point that is observed.

What the tablet draws for you

Pitfalls

SymptomCauseFix
The list shows no sourceNot registered on this machine, or IsAvailable() returns false.Register on every machine, not only on the server. Check what IsAvailable() tests.
The picture shows nothing but sky and the HUD worksThe drone is not streamed to this client.Force the streaming (see above).
A command changes nothingIt was sent on an entity the client does not own: the server drops it silently.Send through the player’s character.
The HUD lacks a fieldThe field stayed at its default, and the HUD drops it on purpose.Set it in FillStatus.
The setting jumps backThe tablet shows the new value, then the source reads the old one from the drone.Hold the pending value for a few seconds, as the drone bridge does, until the drone has confirmed it.
The menu is slowFillStatus and IsAvailable are asked every frame.Do no searches in them; keep the entities in fields.
Soldiers in the picture are only arms and heads, a truck has no cargo bedThe units are far from every observer and arrive half made.Observers and the wake-up of the roots (see Units far from the viewer above).
The tablet says NO FEED for a Game Master right after he closed the editorThe editor frees every editable entity to stream out, and the drone is gone from his machine.Keep the source streamed after the editor closes (see A Game Master as the operator).
A large grey cylinder (or another helper) stands around a unit in the pictureVISIBLE was forced on all children, including those that are hidden on purpose.Touch the root only.
Example code on this page is free to use in your own projects (credit appreciated). The SOFLAM Integration Core mod is published under the Arma Public License (APL). Suggestions: Discord. Arma Reforger / Enfusion are trademarks of Bohemia Interactive.
Impressum · Privacy Policy