forked from mtcontrib/regional_weather
Adjust lightning chances and update speed buff to new API
This commit is contained in:
parent
231642af2f
commit
e874daa894
@ -1,15 +1,14 @@
|
|||||||
--[[
|
--[[
|
||||||
# Lightning Effect
|
# Lightning Effect
|
||||||
Use this effect to cause lightning strikes.
|
Use this effect to cause lightning strikes.
|
||||||
Requires lightning mod in order to function.
|
Requires lightning mod in order to function. Uses default lightning configuration.
|
||||||
Uses default lightning configuration. Expects any non-nil parameter.
|
Expects an integer indicating a chance (between 0 and 1) for lightning to strike (per cycle and player).
|
||||||
]]
|
]]
|
||||||
|
|
||||||
if not minetest.get_modpath("lightning") then return end
|
if not minetest.get_modpath("lightning") then return end
|
||||||
|
|
||||||
local EFFECT_NAME = "regional_weather:lightning"
|
local EFFECT_NAME = "regional_weather:lightning"
|
||||||
|
|
||||||
local LIGHTNING_CHANCE = 20
|
|
||||||
lightning.auto = false
|
lightning.auto = false
|
||||||
|
|
||||||
local rng = PcgRandom(82492402425)
|
local rng = PcgRandom(82492402425)
|
||||||
@ -39,8 +38,15 @@ end
|
|||||||
|
|
||||||
local function handle_effect(player_data)
|
local function handle_effect(player_data)
|
||||||
for playername, data in pairs(player_data) do
|
for playername, data in pairs(player_data) do
|
||||||
local random = rng:next(1, LIGHTNING_CHANCE)
|
local chance = 0
|
||||||
if random == 1 then
|
for weather, value in pairs(data) do
|
||||||
|
if type(value) ~= "number" then
|
||||||
|
value = 1/20
|
||||||
|
end
|
||||||
|
chance = chance + value - (chance * value)
|
||||||
|
end
|
||||||
|
local random = math.random()
|
||||||
|
if random <= chance then
|
||||||
local player = minetest.get_player_by_name(playername)
|
local player = minetest.get_player_by_name(playername)
|
||||||
local ppos = player:get_pos()
|
local ppos = player:get_pos()
|
||||||
local position = choose_pos(ppos)
|
local position = choose_pos(ppos)
|
||||||
|
@ -13,14 +13,14 @@ local function handle_effect(player_data)
|
|||||||
for weather, value in pairs(data) do
|
for weather, value in pairs(data) do
|
||||||
product = product * value
|
product = product * value
|
||||||
end
|
end
|
||||||
climate_api.utility.add_physics(EFFECT_NAME, player, "speed", product)
|
climate_api.player_physics.add(EFFECT_NAME, player, "speed", product)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function remove_effect(player_data)
|
local function remove_effect(player_data)
|
||||||
for playername, data in ipairs(player_data) do
|
for playername, data in ipairs(player_data) do
|
||||||
local player = minetest.get_player_by_name(playername)
|
local player = minetest.get_player_by_name(playername)
|
||||||
climate_api.utility.remove_physics(EFFECT_NAME, player, "speed")
|
climate_api.player_physics.remove(EFFECT_NAME, player, "speed")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ effects["climate_api:sound"] = {
|
|||||||
gain = 1
|
gain = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
effects["regional_weather:lightning"] = 1 / 30
|
||||||
|
|
||||||
local textures = {}
|
local textures = {}
|
||||||
for i = 1,5 do
|
for i = 1,5 do
|
||||||
textures[i] = "weather_hail" .. i .. ".png"
|
textures[i] = "weather_hail" .. i .. ".png"
|
||||||
|
@ -22,6 +22,8 @@ effects["climate_api:sound"] = {
|
|||||||
gain = 1
|
gain = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
effects["regional_weather:lightning"] = 1 / 20
|
||||||
|
|
||||||
effects["climate_api:particles"] = {
|
effects["climate_api:particles"] = {
|
||||||
boxsize = { x = 18, y = 0, z = 18 },
|
boxsize = { x = 18, y = 0, z = 18 },
|
||||||
v_offset = 7,
|
v_offset = 7,
|
||||||
|
Loading…
Reference in New Issue
Block a user