MIT License

Copyright (c) 2017 Artūras Norkus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-------------------------------------------------------------------------------
Modifications by TechnoWolfTV (2025-2026)

The following changes were made to the original weather_pack mod by
Artūras Norkus (xeranas) and are released under the same MIT License above.

-- Administrative / housekeeping --

- Removed deprecated files: depends.txt, description.txt
- mod.conf: Updated to modern format (name, description, optional_depends).

-- Weather frequency rebalancing --

All weather types reduced to approximately 25% of their original spawn
frequency to better suit long-play sessions:

- light_rain:  0.0375  (was 0.15)
- rain:        0.025   (was 0.1)
- heavy_rain:  0.015   (was 0.06, tropical: 0.1)
- snow:        0.05    (was 0.2)
- snowstorm:   0.0125  (was 0.05)
- thunder:     0.8     (restored to original — controls how quickly thunder
                        kicks in once heavy_rain is active, not spawn rate)

-- Shelter-aware sound attenuation --

- utils.lua: Added shelter detection (get_shelter_factor), per-weather gain
  profiles (outdoor/indoor/cave), and sound fading via minetest.sound_fade.

- weathers/light_rain.lua, rain.lua, heavy_rain.lua, snowstorm.lua,
  thunder.lua: Integrated shelter-aware sound attenuation throughout.

-- New weather types --

- weathers/light_fog.lua, moderate_fog.lua, dense_fog.lua: Three fog
  densities implemented via Luanti's set_sky fog table API (not particles),
  giving true engine-level atmospheric depth. Each tier applies a sky tint,
  cloud color/density overlay, 25% lighting reduction (day/night ratio 0.75),
  and engine fog at progressive distances (100/50/20 nodes). Both fog
  distance and lighting fade in over 10 seconds on entry and out over 10
  seconds on exit. Fog is suppressed entirely when the player is indoors
  (checked via get_shelter_factor, throttled to once per second). Biome-aware
  (no fog in dry biomes). Fog does not appear during heavy_rain or snowstorm.
  moderate_fog displaces light_fog; dense_fog displaces both lighter tiers.
  On natural end, dense_fog usually lifts to moderate_fog; moderate_fog
  sometimes lifts to light_fog.

- weathers/pds_severe_thunderstorm.lua: Five-phase "Particularly Dangerous
  Situation" severe thunderstorm with progressive sky darkening, ominous
  green sky hue, rain buildup, day/night ratio override, low rumble sound
  during onslaught, escalating lightning, and proportional wind-down.
  Rare tier (chance 0.0075).

- weathers/severe_thunderstorm.lua: Five-phase severe thunderstorm, less
  intense counterpart to PDS: no green sky, no rumble, reduced darkness,
  reduced lightning frequency, shorter phase durations. More common tier
  (chance 0.015).

-- Modifications to existing weather types --

- weathers/overcast.lua: New weather type applying heavy_rain's sky and
  cloud colors with no rain, sound, or lighting changes. Sky-only overcast
  effect. Frequency matches rain (chance 0.025, check_interval 300s).

- weathers/clear.lua: New weather type that disables clouds and lets
  Luanti's default blue sky render unmodified. No sky layer, no particles,
  no sound, no lighting changes. Frequency matches overcast.

- weathers/heavy_rain.lua: Sky, sound, and rain particles all fade in over
  10 seconds on entry and out over 10 seconds on exit instead of switching
  instantly. Minimum active duration enforced before any end request is
  honored. Severe storms still override heavy_rain instantly. Admin
  stop/disable bypasses the taper and takes effect immediately.

- weathers/snowstorm.lua: Added a natural random end condition. The original
  had none — once started, it ran until manually stopped.

- weathers/severe_thunderstorm.lua, pds_severe_thunderstorm.lua: Fixed a
  multiplayer bug where a new player joining a running storm reset the phase
  machine back to Phase 1. Rain particles now visible through windows from
  indoors (removed an extra player-shelter gate that blocked all spawning).

-- Bug fixes and improvements --

- utils.lua: Added hw_utils.random_float() and corrected invalid non-integer
  math.random() calls in snow.lua, snowstorm.lua, and light_rain.lua.

- lib_happy_weather_api.lua: Added disconnect cleanup hook (stale per-player
  state was left behind when a player disconnected mid-weather). Added
  happy_weather.force_end() for instant admin stops. Added
  happy_weather.get_active_duration() to power elapsed-time display in
  /weather_status. Activated-at timestamp now cleared on weather end.

- abm.lua: Fire extinguishing covers both fire:basic_flame and
  lightning:dying_flame (the node the lightning mod creates on a strike).
  heavy_rain and both severe storm tiers extinguish outdoor fire quickly
  (~5 seconds average). rain extinguishes more slowly (~10 seconds average).
  light_rain never extinguishes fire.

-- Command additions --

- commands.lua: Added /disable_weather and /enable_weather (persists across
  restarts). Added /stop_weather all. Added /weather_status (shows active
  with elapsed time, enabled, and disabled). Admin stop and disable now use
  force_end for instant effect on all weather types.

-- New assets --

- sounds/severe-storm-rumble.ogg: Used during pds_severe_thunderstorm
  onslaught only. "Low Rumbling" by Musheran (opengameart.org).
  License: CC BY (creativecommons.org/publicdomain/zero/1.0/)

-- API modernization and crash hardening (2026-07) --

- utils.lua, lib_happy_weather_api.lua: Replaced deprecated player:getpos()
  with player:get_pos() (7 call sites).

- lib_sky_layer_api.lua: Replaced the deprecated positional set_sky()
  signature with the modern table form in set_default_sky() and
  update_sky_details(). The clouds argument moves from the 4th positional
  parameter to a named field. The deprecated positional form also controlled
  sun/moon/star visibility as an undocumented side effect ("regular" showed
  them, any other type hid them); the table form does not, so that behaviour
  is now applied explicitly via apply_celestial_visibility().

- utils.lua: Added hw_utils.get_wind(), a validating wrapper around
  breasy.get_wind(). Non-finite wind vectors (NaN or infinity) are replaced
  with zero wind and logged at most once per 60 seconds. A non-finite value
  reaching minetest.add_particle() aborts the globalstep and shuts down the
  server.

- weathers/*.lua: All 13 breasy.get_wind() call sites now route through
  hw_utils.get_wind(). Direct calls to breasy.get_wind() should not be
  reintroduced.

-- Severe storm wind envelope + celestial cleanup fix (2026-07) --

- weathers/severe_thunderstorm.lua, weathers/pds_severe_thunderstorm.lua:
  Both severe storms now amplify ambient breasy wind on a per-phase envelope
  instead of a flat factor. Two tunables per file: WIND_ONSET (multiplier at
  the first visible rain, so the storm's opening drops already blow) and
  WIND_PEAK (multiplier sustained through onslaught). The multiplier ramps
  WIND_ONSET -> WIND_PEAK across Build, holds WIND_PEAK through Onslaught, and
  descends WIND_PEAK -> 1.0 across Unwind, handing back to unmodified breasy
  wind. Because it multiplies ambient wind, a calm patch stays calm -- breasy's
  own behaviour is preserved, only amplified. severe_thunderstorm uses
  WIND_ONSET 1.4 / WIND_PEAK 2.5; pds_severe_thunderstorm uses 1.4 / 3.5 (a
  stronger peak, as its onslaught is longer, darker and noisier).

- weathers/severe_thunderstorm.lua, weathers/pds_severe_thunderstorm.lua:
  remove_player() now restores sun/moon/star visibility. The storms hide the
  celestial bodies while active; the modern table-form set_sky() used in
  cleanup does not re-enable them, which previously left a sunless daytime sky
  after a storm. Now set explicitly during teardown.

- weathers/severe_thunderstorm.lua, weathers/pds_severe_thunderstorm.lua:
  Removed the automatic hand-off to light_rain on natural storm completion.
  light_rain added its own sky layer which, since skylayer has no priority
  system, immediately overrode the retreat-phase sky before it finished
  brightening -- a visible snap. Storms now end cleanly to ambient weather.
-------------------------------------------------------------------------------
