1
0
mirror of https://github.com/t-affeldt/regional_weather.git synced 2025-07-24 11:20:20 +02:00

Enable dynamic cloud size

This commit is contained in:
Till Affeldt
2020-04-13 16:52:45 +02:00
parent c43e972e83
commit 79fb0a234d
5 changed files with 36 additions and 29 deletions

28
ca_weathers/ambient.lua Normal file
View File

@ -0,0 +1,28 @@
local name = "regional_weather:wind"
local CLOUD_SPEED = 1.8
local conditions = {}
local function generate_effects(params)
local override = {}
override["climate_api:clouds"] = {
size = climate_api.utility.rangelim(params.humidity, 0.25, 0.9),
speed = vector.multiply(params.wind, CLOUD_SPEED)
}
local movement = params.player:get_player_velocity()
local movement_direction
if (vector.length(movement) < 0.1) then
movement_direction = vector.new(0, 0, 0)
else
movement_direction = vector.normalize(movement)
end
local vector_product = vector.dot(movement_direction, params.wind)
local movement_penalty = climate_api.utility.sigmoid(vector_product, 1.6, 0.2, 0.8) + 0.2
override["regional_weather:speed_buff"] = movement_penalty
return override
end
climate_api.register_weather(name, conditions, generate_effects)

View File

@ -1,24 +0,0 @@
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.wind * CLOUD_SPEED_MULTIPLICATOR
}
}
local movement_direction = vector.normalize(params.player:get_player_velocity())
local vector_product = vector.dot(movement_direction, params.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)