Compare commits
5 Commits
6034125cd7
...
aa4b4d6676
Author | SHA1 | Date |
---|---|---|
|
aa4b4d6676 | |
|
f72dc694e0 | |
|
67f1d0a757 | |
|
78416a79a1 | |
|
bd93559568 |
|
@ -1,2 +1,2 @@
|
||||||
default
|
default
|
||||||
seasons?
|
|
||||||
|
|
165
init.lua
165
init.lua
|
@ -1,6 +1,17 @@
|
||||||
|
|
||||||
|
|
||||||
local on_strike = {}
|
|
||||||
|
local FREQ_BIAS = -.6
|
||||||
|
local FREQ_SCALE = 3
|
||||||
|
local SPEED = .02
|
||||||
|
|
||||||
|
local fns = {
|
||||||
|
on_strike = {},
|
||||||
|
freq_bias = {},
|
||||||
|
intens_bias = {},
|
||||||
|
heat_bias = {},
|
||||||
|
humidity_bias = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
storms = {
|
storms = {
|
||||||
|
@ -35,10 +46,59 @@ end
|
||||||
|
|
||||||
|
|
||||||
storms.register_on_lightning_strike = function(fn)
|
storms.register_on_lightning_strike = function(fn)
|
||||||
table.insert(on_strike, fn)
|
table.insert(fns.on_strike, fn)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
storms.register_freq_bias = function(fn)
|
||||||
|
table.insert(fns.freq_bias, fn)
|
||||||
|
end
|
||||||
|
|
||||||
|
storms.register_intensity_bias = function(fn)
|
||||||
|
table.insert(fns.intens_bias, fn)
|
||||||
|
end
|
||||||
|
|
||||||
|
storms.register_heat_bias = function(fn)
|
||||||
|
table.insert(fns.heat_bias, fn)
|
||||||
|
end
|
||||||
|
|
||||||
|
storms.register_humidity_bias = function(fn)
|
||||||
|
table.insert(fns.humidty_bias, fn)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function get_intens_bias(pos, orig_intens, player)
|
||||||
|
local bias = 0
|
||||||
|
for _,fn in ipairs(fns.intens_bias) do
|
||||||
|
bias = bias + fn(pos, orig_intens, player)
|
||||||
|
end
|
||||||
|
return bias
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_freq_bias(pos, orig_freq, player)
|
||||||
|
local bias = 0
|
||||||
|
for _,fn in ipairs(fns.freq_bias) do
|
||||||
|
bias = bias + fn(pos, orig_freq, player)
|
||||||
|
end
|
||||||
|
return bias
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_heat_bias(pos, orig)
|
||||||
|
local bias = 0
|
||||||
|
for _,fn in ipairs(fns.heat_bias) do
|
||||||
|
bias = bias + fn(pos, orig)
|
||||||
|
end
|
||||||
|
return bias
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_humidity_bias(pos, orig)
|
||||||
|
local bias = 0
|
||||||
|
for _,fn in ipairs(fns.humidity_bias) do
|
||||||
|
bias = bias + fn(pos, orig)
|
||||||
|
end
|
||||||
|
return bias
|
||||||
|
end
|
||||||
|
|
||||||
local on = false
|
local on = false
|
||||||
local storm_players = {}
|
local storm_players = {}
|
||||||
|
|
||||||
|
@ -74,11 +134,8 @@ end
|
||||||
|
|
||||||
local function get_biome(pos)
|
local function get_biome(pos)
|
||||||
local he, hu = get_noise(pos)
|
local he, hu = get_noise(pos)
|
||||||
if storms.biome_offset then
|
he = he + get_heat_bias(pos, he)
|
||||||
local oe, ou = storms.biome_offset(pos)
|
hu = hu + get_humidity_bias(pos, hu)
|
||||||
he = he + oe
|
|
||||||
hu = hu + ou
|
|
||||||
end
|
|
||||||
|
|
||||||
return find_biome(he, hu)
|
return find_biome(he, hu)
|
||||||
end
|
end
|
||||||
|
@ -140,7 +197,7 @@ local function do_lightning(cloudh, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- global callbacks
|
-- global callbacks
|
||||||
for _,fn in pairs(on_strike) do
|
for _,fn in pairs(fns.on_strike) do
|
||||||
fn(pcopy(p), n)
|
fn(pcopy(p), n)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -250,6 +307,29 @@ local function spawn_rain(pos, vel, sz, lvl)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function spawn_snow(pos, vel, sz, lvl)
|
||||||
|
local offht = 10
|
||||||
|
local ht = 10
|
||||||
|
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = lvl * 1000,
|
||||||
|
time = 5,
|
||||||
|
minpos = {x=pos.x-sz, y=pos.y+offht, z=pos.z-sz},
|
||||||
|
maxpos = {x=pos.x+sz, y=pos.y+offht+ht, z=pos.z+sz},
|
||||||
|
minvel = {x=vel.x, y=-20, z=vel.z},
|
||||||
|
maxvel = {x=vel.x, y=-20, z=vel.z},
|
||||||
|
minacc = {x=-0.1, y=0.1, z=-0.1},
|
||||||
|
maxacc = {x=0.1, y=0.3, z=0.1},
|
||||||
|
collisiondetection = true,
|
||||||
|
collision_removal = true,
|
||||||
|
minexptime = 2,
|
||||||
|
maxexptime = 7,
|
||||||
|
minsize = 10,
|
||||||
|
maxsize = 15,
|
||||||
|
texture = "storms_snowflake.png",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local function spawn_lightning(pos, amount, sz)
|
local function spawn_lightning(pos, amount, sz)
|
||||||
local offht = 60
|
local offht = 60
|
||||||
|
@ -286,11 +366,11 @@ biome_spawners.tundra = function(pos, dir, lvl)
|
||||||
end
|
end
|
||||||
|
|
||||||
biome_spawners.taiga = function(pos, dir, lvl)
|
biome_spawners.taiga = function(pos, dir, lvl)
|
||||||
spawn_blizzard(pos, dir, 15, lvl)
|
spawn_snow(pos, {x=0, y=0, z=0}, 20, lvl)
|
||||||
end
|
end
|
||||||
|
|
||||||
biome_spawners.grassland = function(pos, dir, lvl)
|
biome_spawners.grassland = function(pos, dir, lvl)
|
||||||
spawn_rainclouds(pos, dir, 20, lvl)
|
spawn_rainclouds(pos, dir, 200, lvl)
|
||||||
spawn_rain(pos, {x=0, y=0, z=0}, 20, lvl)
|
spawn_rain(pos, {x=0, y=0, z=0}, 20, lvl)
|
||||||
spawn_lightning(pos, 15 * lvl, 60)
|
spawn_lightning(pos, 15 * lvl, 60)
|
||||||
end
|
end
|
||||||
|
@ -300,13 +380,13 @@ biome_spawners.snowy_grassland = function(pos, dir, lvl)
|
||||||
end
|
end
|
||||||
|
|
||||||
biome_spawners.savanna = function(pos, dir, lvl)
|
biome_spawners.savanna = function(pos, dir, lvl)
|
||||||
spawn_rainclouds(pos, dir, 20, lvl)
|
spawn_rainclouds(pos, dir, 200, lvl)
|
||||||
-- spawn_rain(pos, {x=0, y=0, z=0}, 10)
|
-- spawn_rain(pos, {x=0, y=0, z=0}, 10)
|
||||||
spawn_lightning(pos, 30 * lvl, 70)
|
spawn_lightning(pos, 30 * lvl, 70)
|
||||||
end
|
end
|
||||||
|
|
||||||
biome_spawners.deciduous_forest = function(pos, dir, lvl)
|
biome_spawners.deciduous_forest = function(pos, dir, lvl)
|
||||||
spawn_rainclouds(pos, dir, 20, lvl)
|
spawn_rainclouds(pos, dir, 200, lvl)
|
||||||
spawn_rain(pos, {x=0, y=0, z=0}, 20, lvl)
|
spawn_rain(pos, {x=0, y=0, z=0}, 20, lvl)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -396,7 +476,7 @@ minetest.register_craftitem("storms:rainstick", {
|
||||||
if not fn then
|
if not fn then
|
||||||
print("missing spawner biome: "..biome)
|
print("missing spawner biome: "..biome)
|
||||||
end
|
end
|
||||||
fn(pos)
|
fn(pos, {x=20, y=0, x=10}, 1)
|
||||||
|
|
||||||
-- set_biome_storm_sky(player, biome)
|
-- set_biome_storm_sky(player, biome)
|
||||||
|
|
||||||
|
@ -419,8 +499,8 @@ minetest.register_craftitem("storms:rainstick", {
|
||||||
|
|
||||||
|
|
||||||
storms.register_on_lightning_strike(function(pos)
|
storms.register_on_lightning_strike(function(pos)
|
||||||
pos.y = pos.y + 1
|
-- pos.y = pos.y + 1
|
||||||
minetest.set_node(pos, {name="fire:basic_flame"})
|
-- minetest.set_node(pos, {name="fire:basic_flame"})
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -465,8 +545,6 @@ local function activate_storm(player )
|
||||||
end
|
end
|
||||||
fn(pos)
|
fn(pos)
|
||||||
|
|
||||||
-- set_biome_storm_sky(player, biome)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function clamp(min, max, n)
|
local function clamp(min, max, n)
|
||||||
|
@ -494,47 +572,39 @@ local function storm_loop()
|
||||||
local dx = perlins.dx:get2dMap_flat(p1)[1]
|
local dx = perlins.dx:get2dMap_flat(p1)[1]
|
||||||
local dz = perlins.dz:get2dMap_flat(p1)[1]
|
local dz = perlins.dz:get2dMap_flat(p1)[1]
|
||||||
|
|
||||||
local tscale = .1
|
|
||||||
|
|
||||||
local t3 = time % 32768
|
-- for i = 1,2000,3 do
|
||||||
local t4 = time % 32768
|
-- local f3 = perlins.freq3:get3dMap_flat({x=pos.x, y=pos.z, z=i --[[(time *20) % 2000]]})[1]
|
||||||
|
-- f3 = (f3 * 4) - 1.6
|
||||||
local p2 = {
|
-- print("perlin: ".. dump(f3))
|
||||||
x = ((t3 * (dx/10) + pos.x ) % 65536) - 32768,
|
-- end
|
||||||
y = 0,
|
local f3 = perlins.freq3:get3dMap_flat({x=pos.x, y=pos.z, z=(time * SPEED) % 65536})[1]
|
||||||
z = ((t4 * (dx/10) + pos.z) % 65536) - 32768,
|
f3 = (f3 * FREQ_SCALE) + FREQ_BIAS -- - 1.6
|
||||||
}
|
-- print("perlin: ".. dump(f3))
|
||||||
|
|
||||||
local f1 = perlins.freq1:get2dMap_flat(p1)[1]
|
|
||||||
local f2 = perlins.freq2:get2dMap_flat(p1)[1]
|
|
||||||
|
|
||||||
print("p2: "..p2.x..", ".. p2.z)
|
|
||||||
print("perlin: ".. dx.. ", "..dz.. ", "..f1.. ", "..f2)
|
|
||||||
|
|
||||||
local f = (f1 + f2) - .5
|
|
||||||
|
|
||||||
|
f3 = f3 + get_freq_bias(pos, f3, pinfo.player)
|
||||||
|
|
||||||
local biome = get_biome(pos)
|
local biome = get_biome(pos)
|
||||||
|
-- f3 = nil
|
||||||
print("storm intensity: ".. f .. " ("..f1..", "..f2..")")
|
-- print("storm intensity: ".. f .. " ("..f1..", "..f2..")")
|
||||||
if f > 0 then
|
local intens = f3 + get_intens_bias(pos, f3, pinfo.player)
|
||||||
|
if f3 > 0 then
|
||||||
|
|
||||||
local dir = {x = dx, y = 0, z = dz}
|
local dir = {x = dx, y = 0, z = dz}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local fn = biome_spawners[biome]
|
local fn = biome_spawners[biome]
|
||||||
|
|
||||||
if not fn then
|
if not fn then
|
||||||
print("missing spawner biome: "..biome)
|
print("missing spawner biome: "..biome)
|
||||||
end
|
end
|
||||||
fn(pos, dir, 1, f)
|
fn(pos, dir, 1, intens)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set_biome_storm_sky(pinfo, biome, biome, 1, clamp(0, 1, 1-f))
|
set_biome_storm_sky(pinfo, biome, biome, 1, clamp(0, 1, 1-intens))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -566,6 +636,7 @@ minetest.after(2, function()
|
||||||
spread = {x=1000, y=1000, z=1000}
|
spread = {x=1000, y=1000, z=1000}
|
||||||
}, {x=1,y=1,z=1})
|
}, {x=1,y=1,z=1})
|
||||||
|
|
||||||
|
--[[
|
||||||
perlins.freq1 = minetest.get_perlin_map({
|
perlins.freq1 = minetest.get_perlin_map({
|
||||||
flags = {eased = false},
|
flags = {eased = false},
|
||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
|
@ -587,6 +658,18 @@ minetest.after(2, function()
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x=2000, y=2000, z=2000}
|
spread = {x=2000, y=2000, z=2000}
|
||||||
}, {x=1,y=1,z=1})
|
}, {x=1,y=1,z=1})
|
||||||
|
]]
|
||||||
|
|
||||||
|
perlins.freq3 = minetest.get_perlin_map({
|
||||||
|
flags = {eased = false},
|
||||||
|
lacunarity = 4,
|
||||||
|
octaves = 5,
|
||||||
|
offset = 0,
|
||||||
|
persistence = 0.45,
|
||||||
|
seed = 179334,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x=500, y=500, z=500}
|
||||||
|
}, {x=2,y=2,z=2})
|
||||||
|
|
||||||
|
|
||||||
storm_loop()
|
storm_loop()
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 153 B |
Loading…
Reference in New Issue