Page 1 of 1

Sentinel weather

Posted: Thu Aug 20, 2020 12:33 am
by pango
Trying to understand why it rains so often in Sentinel, I noticed that
  • the climate displayed by "tdbg" (and which is, I think, responsible for stuff like architecture and textures) is based on

    Code: Select all

    LocalPlayerGPS.ClimateSettings.ClimateType
    which is "Desert";
  • whereas the weather is based on

    Code: Select all

    PlayerWeather.PlayerGps.CurrentClimateIndex
    which is "Subtropical", hence the frequent rain and thunder
I guess it's based on classic, but that feels a bit strange...

Re: Sentinel weather

Posted: Thu Aug 20, 2020 6:33 am
by Ralzar
Sentinel should be subtropical. Does "LocalPlayerGPS.ClimateSettings.ClimateType" have a value for that?
Is it subtropical that makes it rain so much? I suspect it's during winter in particular, when instead of snowing, it rains.

Re: Sentinel weather

Posted: Thu Aug 20, 2020 3:19 pm
by DigitalMonk
pango wrote: Thu Aug 20, 2020 12:33 am
  • LocalPlayerGPS.ClimateSettings.ClimateType
  • PlayerWeather.PlayerGps.CurrentClimateIndex
That would confuse me greatly as a maintenance programmer / modder. Both forms retrieve a climate based on the players position, so how would I know which to use? I'm guessing that the architecture styles and the weather system were implemented a considerable time apart? Or is there a subtle reason for these being kept separate that I don't understand because I've not been in the code?

I could see that architecture would track by general year-round climate, while local weather would track by immediate weather chosen from the surrounding climate. But both of those appear to be long-term climate values, not immediate weather values.

Would it make sense to pick one or the other as the most accurate value, remove the other one, and refactor code to always use the one that was kept?

(BTW, no judgment here -- I know my own code, and I don't have any soapbox or high horse to get up on :oops: . Just wondering if this would help clarify things for future modders.)

Re: Sentinel weather

Posted: Thu Aug 20, 2020 5:29 pm
by Hazelnut
I think you'll find that these are representation of classic data and that's why it may not seem logical, but Interkarma would have to confirm - I am guessing.

Re: Sentinel weather

Posted: Thu Aug 20, 2020 11:20 pm
by Interkarma
The ClimateType field is of ClimateBaseType enum used for climate textures. It looks like below.

Code: Select all

/// <summary>
/// Climate base type enumeration for climate-swapping textures.
/// </summary>
public enum ClimateBaseType
{
    None = -1,
    Desert = 0,
    Mountain = 100,
    Temperate = 300,
    Swamp = 400,
}
These map directly to climate texture bases in TEXTURE files, e.g. TEXTURE.000 is base for Desert textures, TEXTURE.100 is base for Mountain textures, and so on. There is no such thing as a subtropical texture set for terrain and models. Rather, those four texture sets are shared across the various subclimates. That's why Sentinel is ClimateBaseType.Desert - it's the texture set Sentinel uses.

The ClimateIndex value is the subclimate read from CLIMATE.PAK for a specific map pixel. Other than determining the texture set above, it selects the sky, nature sprites, and used in weather inputs along with season. There are several subclimates with some variations between them, but they all use one of the four texture bases.

Weather was reverse engineered from classic by Allofich and functions identically as far as I know. See SetClimateWeathers() and SetWeatherFromWeatherClimateArray() in WeatherManager for this.

TLDR:
Everything climate-related ultimately hangs off ClimateIndex in some way. How that value is used depends on which system you're looking at. Texture swaps and weather are different systems.