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

Build it into your mod

Add thermal and night vision to your optic

Four steps and about thirty lines. The example is a sight of your own called MyOptic; the names that belong to the framework are the real ones.

In plain wordsAdd the framework as a dependency, put one component on your optic prefab, call SetInputEnabled when the player looks through it, and give it keys.
1. Dependency→2. Component on the prefab→3. Tell it when you look through→4. Keys→5. Test

Step 1 – Add the framework as a dependency

Put the framework’s GUID into the Dependencies of your addon.gproj. Its own project file shows why that is all it asks for:

Example code – free to useGTG Thermal Framework / addon.gproj
GameProject {
 ID "GTGThermalFramework"
 GUID "6A48B5AFEAF2488C"
 TITLE "GTG Thermal Framework"
 Dependencies {
  "58D0FB3206B6F859"
 }
}
Example code – free to useyour addon / addon.gproj
GameProject {
 ID "MyOptic"
 GUID "<your own GUID>"
 TITLE "My optic"
 Dependencies {
  "58D0FB3206B6F859" "6A48B5AFEAF2488C"
 }
}
NoteThe framework depends on the game only. It does not pull in WCS Armaments, RHS or the SOFLAM Core. Say required in the Workshop description of your mod, so that players subscribe to it.

Step 2 – Put the component on your optic prefab

Add GTG_SOFLAM_VisionModeComponent to the entity that carries your sight. Two attributes decide which modes the device has at all; the cycle is built from them. Leave a mode out and the player never lands in it. The key attributes carry the names of input actions – step 4 defines them.

Example code – free to useMyOptic.et (component block)
GTG_SOFLAM_VisionModeComponent "{<unique 16 hex digits>}" {
 m_bAllowNightVision 1
 m_bAllowThermal 1
 m_sCycleAction "MyOptic_VisionModeAction"
 m_sToggleNvThermalAction "MyOptic_ToggleNvThermalAction"
 m_sPaletteAction "MyOptic_PaletteAction"
 m_sGainUpAction "MyOptic_GainUpAction"
 m_sGainDownAction "MyOptic_GainDownAction"
}
AttributeDefaultMeaning
m_bAllowNightVision, m_bAllowThermaltrue, trueWhich modes exist. Both on: normal → night → thermal. One on: normal ↔ that one. None: the component hooks up no keys and does nothing.
m_sCycleActionGTG_SOFLAM_VisionModeActionCycle the vision mode. Empty = no key.
m_sToggleNvThermalActionGTG_SOFLAM_ToggleNvThermalActionJump straight between night vision and thermal.
m_sPaletteActionGTG_SOFLAM_ThermalPaletteActionNext palette: White Hot, Black Hot, Ironbow, Rainbow.
m_sGainUpAction, m_sGainDownActionGTG_SOFLAM_GainUpAction, GTG_SOFLAM_GainDownActionIn night vision: gain. In thermal: the temperature window up and down.
m_sNightVisionMaterial, m_sNightGrainMaterialemptyEmpty = the game’s own night-vision materials (see Night vision). Set your own .emat to change the look.
m_aThermalFiltersemptyEmpty = the built-in 40 materials. A list of your own materials replaces them – and with them the window labels (see Palettes and windows).
m_iThermalSlot12Post-process slot of the thermal picture. 12 does not collide with the vehicle thermal of RHS (11). Two effects on one slot overwrite each other.

Step 3 – Tell it when the player looks through

The component does not guess when your sight is in use. Your sight calls SetInputEnabled(true) when the player starts looking through it and false when they stop. That call hooks the key listeners up and takes them down again, and the false returns the mode to normal and takes the filters off the camera. Both calls live in one method with a bool parameter, so there is no way to hook up and forget to take down.

Example code – free to useMyOptic_SightsComponent.c
class MyOptic_SightsComponentClass : SCR_2DSightsComponentClass
{
}

class MyOptic_SightsComponent : SCR_2DSightsComponent
{
	protected GTG_SOFLAM_VisionModeComponent m_Vision;

	//------------------------------------------------------------------------------------------------
	override void OnSightADSActivated()
	{
		super.OnSightADSActivated();

		// ask the owner every time instead of keeping a field set in OnInit: if OnInit runs early or not at all, the field stays null and everything is silent
		if (!m_Vision)
			m_Vision = GTG_SOFLAM_VisionModeComponent.Cast(GetOwner().FindComponent(GTG_SOFLAM_VisionModeComponent));

		if (m_Vision)
			m_Vision.SetInputEnabled(true);
	}

	//------------------------------------------------------------------------------------------------
	override void OnSightADSDeactivated()
	{
		if (m_Vision)
			m_Vision.SetInputEnabled(false);		// resets the mode and clears the camera effects

		super.OnSightADSDeactivated();
	}
}
Handheld devicesThis is exactly what the SOFLAM sight does, minus the laser. If your optic is a handheld device of the binoculars kind, keep reading the page about zoom on a handheld device: that kind of device is a gadget, not a weapon, and some of the weapon inputs never reach it.

Step 4 – Give it keys

The component listens to action names. Somebody has to define those actions and put them into an input context that is active while the player looks through the optic. That is a piece of the game’s input configuration, and only one addon can override it, so it is its own page: Keys and hooks. Short version for a mod without the SOFLAM Core: define the actions in your own chimeraInputCommon.conf and enter their names on the component, as in step 2.

Step 5 – Test

  1. Start a Workbench session, look through the optic and press the cycle key. You should get normal → night vision → thermal → normal.
  2. In thermal, the palette key cycles four palettes; the gain keys move the temperature window.
  3. Leave the optic. The screen must be normal again, with no leftover tint or white wash (see Night vision).
  4. Press the keys outside the optic. Nothing may happen: the listeners are only registered while you look through.
  5. After a script reload, restart the Workbench before you judge key behaviour. A hot reload can leave a second key listener behind, and one press then counts twice.
On a serverA dedicated server has no renderer, and the component does nothing there. That is intended: it checks for a renderer before it touches a camera. Do not add your own checks around it.
Example code on this page is free to use in your own projects (credit appreciated). The GTG Thermal Framework mod is published under the Arma Public License (APL). Suggestions: Discord. Arma Reforger / Enfusion are trademarks of Bohemia Interactive.
Impressum · Privacy Policy