Compare commits
5 Commits
75ad89cd89
...
42a9eb9ee8
Author | SHA1 | Date |
---|---|---|
Lars Mueller | 42a9eb9ee8 | |
Lars Mueller | 189e796219 | |
Lars Mueller | f63e3577f7 | |
Lars Mueller | de2984e70a | |
Lars Mueller | fedd7ad52a |
|
@ -83,6 +83,8 @@ Decrease in chance of ghost spawning per night
|
|||
|
||||
* Type: number
|
||||
* Default: `0.5`
|
||||
* >= `0`
|
||||
* <= `1`
|
||||
|
||||
### `fallback_resolution`
|
||||
|
||||
|
@ -121,6 +123,8 @@ Particles per one metre (= node size)
|
|||
|
||||
* Type: number
|
||||
* Default: `10`
|
||||
* >= `1`
|
||||
* <= `100`
|
||||
|
||||
### `spawn_chance`
|
||||
|
||||
|
@ -128,6 +132,8 @@ Chance of a ghost spawning the first night
|
|||
|
||||
* Type: number
|
||||
* Default: `1`
|
||||
* >= `0`
|
||||
* <= `1`
|
||||
<!--modlib:conf-->
|
||||
|
||||
## API
|
||||
|
|
13
init.lua
13
init.lua
|
@ -40,12 +40,12 @@ end)
|
|||
|
||||
local b3d_triangle_sets = setmetatable({}, {__index = function(self, filename)
|
||||
local _, ext = modlib.file.get_extension(filename)
|
||||
if ext:lower() ~= "b3d" then
|
||||
if not ext or ext:lower() ~= "b3d" then
|
||||
-- Only B3D support currently
|
||||
return
|
||||
end
|
||||
local path = assert(media_paths[filename], filename)
|
||||
local model = io.open(path, "r")
|
||||
local model = io.open(path, "rb")
|
||||
local character = assert(modlib.b3d.read(model))
|
||||
assert(not model:read(1))
|
||||
model:close()
|
||||
|
@ -56,7 +56,6 @@ local b3d_triangle_sets = setmetatable({}, {__index = function(self, filename)
|
|||
vertex.pos = mlvec.divide_scalar(vertex.pos, 10)
|
||||
end
|
||||
local triangle_sets = assert(mesh.triangle_sets)
|
||||
assert(#triangle_sets == 1)
|
||||
local func = modlib.func
|
||||
-- Triangle sets by texture index
|
||||
local tris_by_tex = {}
|
||||
|
@ -89,7 +88,7 @@ local png_dimensions = setmetatable({}, {__index = function(self, filename)
|
|||
if not media_path then
|
||||
return
|
||||
end
|
||||
local file = io.open(media_path, "r")
|
||||
local file = io.open(media_path, "rb")
|
||||
if not file then
|
||||
return
|
||||
end
|
||||
|
@ -172,7 +171,8 @@ local function spawn_ghost(params)
|
|||
local rotation = get_rotation(vector.normalize(velocity))
|
||||
-- TODO as modlib doesn't have matrix support yet, we have to use axis-angle rotation
|
||||
-- which we obtain from Euler angles over quaternion representations
|
||||
local axis, angle = modlib.quaternion.to_axis_angle(modlib.quaternion.from_euler_rotation(rotation))
|
||||
local axis, angle = modlib.quaternion.to_axis_angle(
|
||||
modlib.quaternion.from_euler_rotation(vector.multiply(rotation, -1)))
|
||||
|
||||
local disperse = params.disperse or 0
|
||||
|
||||
|
@ -288,6 +288,7 @@ local function spawn_ghosts()
|
|||
if nights_passed >= conf.forget_duration_nights then
|
||||
data:set(data.root.players[name], ghostname, nil)
|
||||
elseif is_halloween or (math.random() <= conf.spawn_chance * conf.chance_reduction_per_night^nights_passed) then
|
||||
-- TODO nothing happens the very first night? 3d_armor support doesn't seem to work?
|
||||
-- Spread ghost spawning out across 10 seconds
|
||||
-- TODO make this configurable
|
||||
modlib.minetest.after(math.random() * 10, function()
|
||||
|
@ -343,4 +344,4 @@ minetest.register_on_player_hpchange(function(victim, hp_change, reason)
|
|||
end)
|
||||
|
||||
-- Export API as a global variable
|
||||
ghosts = {spawn_ghost = spawn_ghost}
|
||||
ghosts = {spawn_ghost = spawn_ghost}
|
||||
|
|
|
@ -4,22 +4,19 @@ return {
|
|||
particles_per_metre = {
|
||||
type = "number",
|
||||
description = "Particles per one metre (= node size)",
|
||||
min = 1,
|
||||
max = 100,
|
||||
range = {min = 1, max = 100},
|
||||
default = 10
|
||||
},
|
||||
spawn_chance = {
|
||||
type = "number",
|
||||
description = "Chance of a ghost spawning the first night",
|
||||
min = 0,
|
||||
max = 1,
|
||||
range = {min = 0, max = 1},
|
||||
default = 1
|
||||
},
|
||||
chance_reduction_per_night = {
|
||||
type = "number",
|
||||
description = "Decrease in chance of ghost spawning per night",
|
||||
min = 0,
|
||||
max = 1,
|
||||
range = {min = 0, max = 1},
|
||||
default = 0.5
|
||||
},
|
||||
forget_duration_nights = {
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
# Decrease in chance of ghost spawning per night
|
||||
ghosts.chance_reduction_per_night (Ghosts Chance reduction per night) float 0.5 0.000000 1.000000
|
||||
[*ghosts.fallback_resolution]
|
||||
# Fallback resolution width
|
||||
ghosts.fallback_resolution.1 (Ghosts Fallback resolution 1) float 64
|
||||
# Fallback resolution height
|
||||
ghosts.fallback_resolution.2 (Ghosts Fallback resolution 2) float 64
|
||||
|
||||
# Whether to always resize textures to the given fallback dimensions. Guarantees support for arbitrary resolution texture packs. If this is not set, texture packs with a resolution lower than the server texture resolution won't work at all; texture packs with a multiple of said resolution will work well, however. A resolution of 64x64 or lower is usually acceptable performance-wise.
|
||||
ghosts.force_fallback_resolution (Ghosts Force fallback resolution) bool false
|
||||
|
||||
# How many nights it takes for a ghost to forget their victim
|
||||
ghosts.forget_duration_nights (Ghosts Forget duration nights) float 10
|
||||
|
||||
# Particles per one metre (= node size)
|
||||
ghosts.particles_per_metre (Ghosts Particles per metre) float 10 1.000000 100.000000
|
||||
|
||||
# Chance of a ghost spawning the first night
|
||||
ghosts.spawn_chance (Ghosts Spawn chance) float 1 0.000000 1.000000
|
||||
ghosts.spawn_chance (Ghosts Spawn chance) float 1 0.000000 1.000000
|
||||
|
||||
[ghosts.fallback_resolution]
|
||||
|
||||
# Fallback resolution width
|
||||
ghosts.fallback_resolution.1 (Ghosts Fallback resolution 1) float 64
|
||||
|
||||
# Fallback resolution height
|
||||
ghosts.fallback_resolution.2 (Ghosts Fallback resolution 2) float 64
|
Loading…
Reference in New Issue