← 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

GTG Thermal Framework

Climate per server New

The same windows show a desert hot and a winter cold, if the world’s climate says so. The framework sets that climate on the server: from a file at start, from the Game Master during the session.

In plain wordsThe server sets the air temperature for the thermal picture from a file in its profile folder, the same on every map. A Game Master can change it during the session. A mission script can set its own.

Who sets what

WhenWhoWhat happens
Server startThe file GTG_ThermalClimate.jsonAir minimum and maximum for every map. The sun is set to its fixed range, the sky follows the air.
During the sessionThe Game MasterTwo sliders under Scenario properties > Weather: air temperature minimum and maximum, −40 to 80 degrees.
After a restartThe file againThe Game Master’s values are not stored; the file applies again.

All of it runs on the server only. The values go into the world’s TimeAndWeatherManagerEntity, and the game sends them to every player, so every player’s thermal picture uses the same climate.

Server file→World climate (server)→Every player→Heat simulation in the materials

The server file

At its first start the server writes the file into its profile folder ($profile:). On a rented server that is usually the folder where the settings files of other mods are, for example profile/GTG_ThermalClimate.json inside the folder given with -profile. In single player and when you host from the game, it is your own profile folder. The file as the server writes it:

Example code – free to use$profile:GTG_ThermalClimate.json (as written by the server)
{
/* ~~~~~~~~~~~~~~~~~~ GTG THERMAL FRAMEWORK - SERVER CLIMATE ~~~~~~~~~~~~~~~~~~ */
/* Air temperature for the thermal picture, the same for every map on this server. */
/* The server reads this file at start and sends the values to every player. */
/* AirMin = coldest air of the day (night), AirMax = warmest air of the day, in degrees C. */
/* Allowed: -40 to 80. The sky follows the air by itself, the sun heating is fixed. */
/* A Game Master can still change both values during the session (Scenario properties > Weather). */
/* After a server restart this file applies again. */

  "AirMin": 12,
  "AirMax": 28
}
RuleWhat it means
Comments are allowedBlocks /* ... */ and whole lines starting with // are removed before the JSON is read.
LimitsValues outside −40 to 80 are clamped. If the minimum is above the maximum, the two are swapped.
A broken file is never overwrittenThe server uses the defaults (12 and 28) and says why in its log. Fix the file and restart.
Every mapThe file wins over a scenario that brings its own temperature values. One server, one climate.

At start the server writes one line to its log, with the values and where they came from:

Example code – free to useconsole.log of the server
[GTG_THERMAL] Server climate: air 0 .. 10 C, sun fixed 0 .. 1000 ($profile:GTG_ThermalClimate.json: from the file)

The other endings are file created with the defaults, file could not be read (check the JSON format), defaults used and AirMin or AirMax missing in the file, defaults used. About ten seconds after the start the server checks once more: if something other than the Game Master has changed the climate by then (a scenario, a loaded save), the file is applied again and the log says so.

What the framework writes into the world

From two air values the framework derives the rest. The sky radiates much colder than the air; with the defaults it lands on the −15 degrees the materials were calibrated with:

Example code – free to useGTG_ThermalClimate.c (excerpt)
static const float SKY_BELOW_AIR_MIN = 27;
static const float SKY_BELOW_AIR_MAX = 43;

protected static void ApplyTemperature(TimeAndWeatherManagerEntity tm, float airMin, float airMax)
{
	float skyMin = airMin - SKY_BELOW_AIR_MIN;
	float skyMax = Math.Max(airMax - SKY_BELOW_AIR_MAX, skyMin);
	tm.SetOverrideTemperature(true);
	tm.SetTemperatureOverrideValues(airMin, airMax, skyMin, skyMax, WATER_MIN, WATER_MAX);
}

// at start, after the air: the sun is always the same
tm.SetOverrideSunIrradiance(true);
tm.SetSunIrradianceOverrideValues(DEFAULT_SUN_MIN, DEFAULT_SUN_MAX);	// 0 .. 1000

After every change the engine’s temperature table is computed again with ForceTemperatureTableRecompute(). That is expensive, so several changes in quick succession are collected and computed once, 0.6 seconds later.

Windows stay where they areThe scale under the picture does not follow the climate. The windows are fixed: in a hot world a cool window simply runs out at the top and turns bright, in a cold world a warm window stays dark. Pick another window, that is what they are for.

A mission with its own climate

A scenario script of your own can set the air on the server, for example a desert mission at 25 to 48 degrees. Call it after the game has started: the start applies the server file first, and the check ten seconds later leaves your values alone once you have set them.

Example code – free to useMyMission_GameMode.c (pattern)
// server only; values in degrees C, clamped to -40 .. 80
if (Replication.IsServer())
	GTG_ThermalClimate.SetAir(25, 48);

// read the current air range (any machine)
float airMin = GTG_ThermalClimate.GetAirMin();
float airMax = GTG_ThermalClimate.GetAirMax();
Order at startA value set before the framework has applied the file is overwritten by it. The framework does that in OnGameStart() of the game mode, so in your own game mode call SetAir after super.OnGameStart(), or later.
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