1
0
mirror of https://github.com/t-affeldt/regional_weather.git synced 2024-11-18 00:18:21 +01:00

Separate weathers from engine

This commit is contained in:
Till Affeldt 2020-04-13 01:58:27 +02:00
commit 5b3ddf895c
48 changed files with 544 additions and 0 deletions

157
LICENSE.md Normal file
View File

@ -0,0 +1,157 @@
### GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the
terms and conditions of version 3 of the GNU General Public License,
supplemented by the additional permissions listed below.
#### 0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the
GNU General Public License.
"The Library" refers to a covered work governed by this License, other
than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
#### 1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
#### 2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
- a) under this License, provided that you make a good faith effort
to ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
- b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
#### 3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a
header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
- a) Give prominent notice with each copy of the object code that
the Library is used in it and that the Library and its use are
covered by this License.
- b) Accompany the object code with a copy of the GNU GPL and this
license document.
#### 4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken
together, effectively do not restrict modification of the portions of
the Library contained in the Combined Work and reverse engineering for
debugging such modifications, if you also do each of the following:
- a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
- b) Accompany the Combined Work with a copy of the GNU GPL and this
license document.
- c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
- d) Do one of the following:
- 0) Convey the Minimal Corresponding Source under the terms of
this License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
- 1) Use a suitable shared library mechanism for linking with
the Library. A suitable mechanism is one that (a) uses at run
time a copy of the Library already present on the user's
computer system, and (b) will operate properly with a modified
version of the Library that is interface-compatible with the
Linked Version.
- e) Provide Installation Information, but only if you would
otherwise be required to provide such information under section 6
of the GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the Application
with a modified version of the Linked Version. (If you use option
4d0, the Installation Information must accompany the Minimal
Corresponding Source and Corresponding Application Code. If you
use option 4d1, you must provide the Installation Information in
the manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.)
#### 5. Combined Libraries.
You may place library facilities that are a work based on the Library
side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
- a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities, conveyed under the terms of this License.
- b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
#### 6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
as you received it specifies that a certain numbered version of the
GNU Lesser General Public License "or any later version" applies to
it, you have the option of following the terms and conditions either
of that published version or of any later version published by the
Free Software Foundation. If the Library as you received it does not
specify a version number of the GNU Lesser General Public License, you
may choose any version of the GNU Lesser General Public License ever
published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

9
README.md Normal file
View File

@ -0,0 +1,9 @@
## Assets
- Rain sounds CC0 by Q.K., taken from mymonths
- Thunder sound and puddle texture DWYWPL by Don, Nathan from mymonths at https://github.com/minetest-mods/mymonths
- Snow cover texture WTFPL, taken from mymonths
- Rain texture CC-BY-SA 3.0 from TeddyDesTodes, taken from his weather branch at https://github.com/TeddyDesTodes/minetest/tree/weather
- Snow flake and rain drop textures CC BY-SA (3.0) by paramat, found in snowdrift mod at https://github.com/paramat/snowdrift
- Snow texture composited from individual snow flakes by paramat. CC-BY-SA (3.0)
- Wind sound CC-BY (3.0) by InspectorJ from https://freesound.org/people/InspectorJ/sounds/376415/
- Hail sound CC0 by ikayuka from https://freesound.org/people/ikayuka/sounds/240742/

0
ca_effects/damage.lua Normal file
View File

18
ca_effects/lightning.lua Normal file
View File

@ -0,0 +1,18 @@
if not minetest.get_modpath("lightning") then return end
local LIGHTNING_CHANCE = 10
lightning.auto = false
local function handle_effect(player_data)
for playername, data in pairs(player_data) do
local player = minetest.get_player_by_name(playername)
local ppos = player:get_pos()
local random = rng:next(1, LIGHTNING_CHANCE)
if random == 1 then
lightning.strike(ppos)
end
end
end
climate_api.register_effect("regional_weather:lightning", handle_effect, "tick")
climate_api.set_effect_cycle("regional_weather:lightning", climate_api.LONG_CYCLE)

0
ca_effects/puddles.lua Normal file
View File

View File

0
ca_effects/soil.lua Normal file
View File

21
ca_effects/speed_buff.lua Normal file
View File

@ -0,0 +1,21 @@
local function handle_effect(player_data)
for playername, data in ipairs(player_data) do
local player = minetest.get_player_by_name(playername)
local product = 1
for weather, value in pairs(data) do
product = product * value
end
climate_api.utility.add_physics("regional_weather:speed_buff", player, "speed", product)
end
end
local function remove_effect(player_data)
for playername, data in ipairs(player_data) do
local player = minetest.get_player_by_name(playername)
climate_api.utility.remove_physics("regional_weather:speed_buff", player, "speed")
end
end
climate_api.register_effect("regional_weather:speed_buff", handle_effect, "tick")
climate_api.register_effect("regional_weather:speed_buff", remove_effect, "end")
climate_api.set_effect_cycle("regional_weather:speed_buff", climate_api.SHORT_CYCLE)

36
ca_weathers/hail.lua Normal file
View File

@ -0,0 +1,36 @@
local name = "regional_weather:hail"
local conditions = {
min_height = regional_weather.settings.min_height,
max_height = regional_weather.settings.max_height,
max_heat = 45,
min_humidity = 65,
min_windspeed = 2.5
}
local effects = {}
effects["regional_weather:spawn_puddles"] = true
effects["regional_weather:lightning"] = true
effects["climate_api:damage"] = 1
effects["climate_api:sound"] = {
name = "weather_hail",
gain = 1
}
effects["climate_api:particles"] = {
min_pos = {x=-9, y=7, z=-9},
max_pos = {x= 9, y=7, z= 9},
falling_speed=15,
amount=5,
exptime=0.8,
size=1,
textures = {}
}
for i = 1,5,1 do
effects["climate_api:particles"].textures[i] = "weather_hail" .. i .. ".png"
end
climate_api.register_weather(name, conditions, effects)

24
ca_weathers/pollen.lua Normal file
View File

@ -0,0 +1,24 @@
local name = "regional_weather:pollen"
local conditions = {
min_height = regional_weather.settings.min_height,
max_height = regional_weather.settings.max_height,
min_heat = 40,
min_humidity = 30,
max_humidity = 40,
max_windspeed = 2
}
local effects = {}
effects["climate_api:particles"] = {
min_pos = {x=-12, y=-4, z=-12},
max_pos = {x= 12, y= 1, z= 12},
falling_speed=-0.1,
amount=2,
exptime=5,
size=1,
texture="weather_pollen.png"
}
climate_api.register_weather(name, conditions, effects)

44
ca_weathers/rain.lua Normal file
View File

@ -0,0 +1,44 @@
local name = "regional_weather:rain"
local conditions = {
min_height = regional_weather.settings.min_height,
max_height = regional_weather.settings.max_height,
min_heat = 30,
min_humidity = 40,
max_humidity = 60
}
local effects = {}
effects["regional_weather:spawn_puddles"] = true
effects["regional_weather:wetten_farmland"] = true
effects["climate_api:sound"] = {
name = "weather_rain",
}
effects["climate_api:particles"] = {
min_pos = {x=-9, y=7, z=-9},
max_pos = {x= 9, y=7, z= 9},
exptime=0.8,
size=1,
texture = "weather_raindrop.png"
}
local function generate_effects(params)
local avg_humidity = 40
local intensity = params.humidity / avg_humidity
local override = {}
override["climate_api:sound"] = {
gain = math.min(intensity, 1.2)
}
override["climate_api:particles"] = {
amount = 20 * math.min(intensity, 1.5),
falling_speed = 10 / math.min(intensity, 1.3)
}
return climate_api.utility.merge_tables(effects, override)
end
climate_api.register_weather(name, conditions, generate_effects)

View File

@ -0,0 +1,31 @@
local name = "regional_weather:rain_heavy"
local conditions = {
min_height = regional_weather.settings.min_height,
max_height = regional_weather.settings.max_height,
min_heat = 30,
min_humidity = 60
}
local effects = {}
effects["regional_weather:spawn_puddles"] = true
effects["regional_weather:wetten_farmland"] = true
effects["regional_weather:lightning"] = true
effects["climate_api:sound"] = {
name = "weather_rain",
gain = 1
}
effects["climate_api:particles"] = {
min_pos = {x=-9, y=7, z=-9},
max_pos = {x= 9, y=7, z= 9},
falling_speed=10,
amount=20,
exptime=0.8,
size=25,
texture="weather_rain.png"
}
climate_api.register_weather(name, conditions, effects)

25
ca_weathers/sandstorm.lua Normal file
View File

@ -0,0 +1,25 @@
local name = "regional_weather:sandstorm"
local conditions = {
min_height = regional_weather.settings.min_height,
max_height = regional_weather.settings.max_height,
min_heat = 50,
max_humidity = 25,
min_windspeed = 6
}
local effects = {}
effects["regional_weather:damage"] = true
effects["climate_api:particles"] = {
min_pos = {x=-9, y=-5, z=-9},
max_pos = {x= 9, y= 5, z= 9},
falling_speed=1,
amount=40,
exptime=0.8,
size=15,
texture="weather_sand.png"
}
climate_api.register_weather(name, conditions, effects)

40
ca_weathers/snow.lua Normal file
View File

@ -0,0 +1,40 @@
local name = "regional_weather:snow"
local conditions = {
min_height = regional_weather.settings.min_height,
max_height = regional_weather.settings.max_height,
max_heat = 40,
min_humidity = 40,
max_humidity = 55
}
local effects = {}
effects["regional_weather:spawn_snow"] = true
effects["climate_api:particles"] = {
min_pos = {x=-20, y= 3, z=-20},
max_pos = {x= 20, y=12, z= 20},
exptime=8,
size=1,
textures = {}
}
for i = 1,12,1 do
effects["climate_api:particles"].textures[i] = "weather_snowflake" .. i .. ".png"
end
local function generate_effects(params)
local avg_humidity = 40
local intensity = params.humidity / avg_humidity
local override = {}
override["climate_api:particles"] = {
amount = 50 * math.min(intensity, 1.5),
falling_speed = 1 / math.min(intensity, 1.3)
}
return climate_api.utility.merge_tables(effects, override)
end
climate_api.register_weather(name, conditions, generate_effects)

View File

@ -0,0 +1,39 @@
local name = "regional_weather:snow_heavy"
local conditions = {
min_height = regional_weather.settings.min_height,
max_height = regional_weather.settings.max_height,
max_heat = 40,
min_humidity = 55
}
local effects = {}
effects["regional_weather:spawn_snow"] = true
effects["climate_api:particles"] = {
min_pos = {x=-12, y= 5, z=-12},
max_pos = {x= 12, y=9, z= 12},
exptime=8,
size=12,
texture="weather_snow.png"
}
local function generate_effects(params)
local avg_humidity = 55
local intensity = params.humidity / avg_humidity
local override = {}
override["climate_api:sound"] = {
gain = math.min(intensity, 1.2)
}
override["climate_api:particles"] = {
amount = 50 * math.min(intensity, 1.5),
falling_speed = 1 / math.min(intensity, 1.3)
}
return climate_api.utility.merge_tables(effects, override)
end
climate_api.register_weather(name, conditions, generate_effects)

27
ca_weathers/storm.lua Normal file
View File

@ -0,0 +1,27 @@
local name = "regional_weather:storm"
local conditions = {
min_height = regional_weather.settings.min_height,
max_height = regional_weather.settings.max_height,
min_windspeed = 3.5
}
local effects = {}
effects["climate_api:sound"] = {
name = "weather_wind"
}
local function generate_effects(params)
local avg_windspeed = 5
local intensity = params.windspeed / avg_windspeed
local override = {}
override["climate_api:sound"] = {
gain = math.min(intensity, 1.2)
}
return climate_api.utility.merge_tables(effects, override)
end
climate_api.register_weather(name, conditions, generate_effects)

24
ca_weathers/wind.lua Normal file
View File

@ -0,0 +1,24 @@
local name = "regional_weather:wind"
local CLOUD_SPEED_MULTIPLICATOR = 1.8
local conditions = {}
local function generate_effects(params)
local override = {}
override["climate_api:skybox"] = {
clouds_data = {
speed = params.state.wind * CLOUD_SPEED_MULTIPLICATOR
}
}
local movement_direction = vector.normalize(params.player:get_player_velocity())
local vector_product = vector.dot(movement_direction, params.state.wind)
local movement_penalty = climate_api.utility.logistic_growth(vector_product, 1.6, 0.15, 0.8) + 0.1
override["regional_weather:speed_buff"] = movement_penalty
return override
end
climate_api.register_weather(name, conditions, generate_effects)

33
init.lua Normal file
View File

@ -0,0 +1,33 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local function get_setting_bool(name, default)
return minetest.is_yes(minetest.settings:get_bool("regional_weather_" .. name) or default)
end
local function get_setting_number(name, default)
return tonumber(minetest.settings:get("regional_weather_" .. name) or default)
end
regional_weather = {}
regional_weather.settings = {}
regional_weather.settings.damage = get_setting_bool("damage", true)
regional_weather.settings.snow = get_setting_bool("snow_layers", true)
regional_weather.settings.puddles = get_setting_bool("puddles", true)
regional_weather.settings.soil = get_setting_bool("soil", true)
regional_weather.settings.max_height = get_setting_number("max_height", 120)
regional_weather.settings.min_height = get_setting_number("min_height", -50)
-- import individual weather types
dofile(modpath.."/ca_weathers/rain.lua")
dofile(modpath.."/ca_weathers/rain_heavy.lua")
dofile(modpath.."/ca_weathers/snow.lua")
dofile(modpath.."/ca_weathers/snow_heavy.lua")
dofile(modpath.."/ca_weathers/storm.lua")
dofile(modpath.."/ca_weathers/sandstorm.lua")
dofile(modpath.."/ca_weathers/hail.lua")
dofile(modpath.."/ca_weathers/pollen.lua")
-- register environment effects
dofile(modpath.."/ca_effects/lightning.lua")
dofile(modpath.."/ca_effects/speed_buff.lua")

10
mod.conf Normal file
View File

@ -0,0 +1,10 @@
name = regional_weather
title = Regional Weather
author = TestificateMods
release = 1
depends = climate_api
optional_depends = lightning
description = """
The ultimate weather mod with support not only for rain, snow, and hail,
but also seasons, dynamic puddles and snow layers, wind, regrowing fruit and much more.
"""

6
settingtypes.txt Normal file
View File

@ -0,0 +1,6 @@
regional_weather_damage (Storms and hail cause damage to players) bool true
regional_weather_snow_layers (Place snow layers on ground) bool true
regional_weather_puddles (Place rain puddles on ground) bool true
regional_weather_soil (Soil turns wet during rain) bool true
regional_weather_max_height (Maximum height of weather effects) int 120
regional_weather_min_height (Minimum height of weather effects) int -50

BIN
sounds/weather_hail.ogg Normal file

Binary file not shown.

BIN
sounds/weather_rain.0.ogg Normal file

Binary file not shown.

BIN
sounds/weather_rain.ogg Normal file

Binary file not shown.

BIN
sounds/weather_wind.ogg Normal file

Binary file not shown.

BIN
textures/weather_hail1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

BIN
textures/weather_hail2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

BIN
textures/weather_hail3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

BIN
textures/weather_hail4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

BIN
textures/weather_hail5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

BIN
textures/weather_pollen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
textures/weather_puddle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

BIN
textures/weather_rain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

BIN
textures/weather_sand.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
textures/weather_snow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B