particles for mob spawners
This commit is contained in:
parent
5305b5c4cc
commit
de0ab3351a
@ -38,9 +38,68 @@ for k, mob_mod in ipairs(ENABLED_MODS) do
|
||||
end
|
||||
end
|
||||
|
||||
-- particles
|
||||
function spawners_mobs.cloud_booom(pos)
|
||||
minetest.add_particlespawner({
|
||||
amount = 5,
|
||||
time = 2,
|
||||
minpos = vector.subtract({x=pos.x-0.5, y=pos.y, z=pos.z-0.5}, 0.5),
|
||||
maxpos = vector.add({x=pos.x+0.5, y=pos.y, z=pos.z+0.5}, 0.5),
|
||||
minvel = {x=0.1, y=0.1, z=0.1},
|
||||
maxvel = {x=0.2, y=0.2, z=0.2},
|
||||
minacc = vector.new({x=-0.1, y=0.1, z=-0.1}),
|
||||
maxacc = vector.new({x=0.1, y=0.3, z=0.1}),
|
||||
minexptime = 2,
|
||||
maxexptime = 3,
|
||||
minsize = 4,
|
||||
maxsize = 8,
|
||||
texture = "spawners_mobs_smoke2_particle.png",
|
||||
})
|
||||
end
|
||||
|
||||
function spawners_mobs.add_flame_effects(pos)
|
||||
local id = minetest.add_particlespawner({
|
||||
amount = 6,
|
||||
time = 0,
|
||||
minpos = vector.subtract({x=pos.x-0.001, y=pos.y-0.001, z=pos.z-0.001}, 0.5),
|
||||
maxpos = vector.add({x=pos.x+0.001, y=pos.y+0.001, z=pos.z+0.001}, 0.5),
|
||||
minvel = {x=-0.1, y=-0.1, z=-0.1},
|
||||
maxvel = {x=0.1, y=0.1, z=0.1},
|
||||
minacc = vector.new(),
|
||||
maxacc = vector.new(),
|
||||
minexptime = 1,
|
||||
maxexptime = 5,
|
||||
minsize = .5,
|
||||
maxsize = 2.5,
|
||||
texture = "spawners_mobs_flame_particle.png",
|
||||
})
|
||||
|
||||
return id
|
||||
end
|
||||
|
||||
function spawners_mobs.add_smoke_effects(pos)
|
||||
local id = minetest.add_particlespawner({
|
||||
amount = 1,
|
||||
time = 0,
|
||||
minpos = vector.subtract({x=pos.x-0.001, y=pos.y-0.001, z=pos.z-0.001}, 0.5),
|
||||
maxpos = vector.add({x=pos.x+0.001, y=pos.y+0.001, z=pos.z+0.001}, 0.5),
|
||||
minvel = {x=-0.5, y=0.5, z=-0.5},
|
||||
maxvel = {x=0.5, y=1.5, z=0.5},
|
||||
minacc = vector.new({x=-0.1, y=0.1, z=-0.1}),
|
||||
maxacc = vector.new({x=0.1, y=0.3, z=0.1}),
|
||||
minexptime = .5,
|
||||
maxexptime = 1.5,
|
||||
minsize = .5,
|
||||
maxsize = 2,
|
||||
texture = "spawners_mobs_smoke_particle.png",
|
||||
})
|
||||
|
||||
return id
|
||||
end
|
||||
|
||||
-- start spawning mobs
|
||||
function spawners_mobs.start_spawning(pos, how_many, mob_name, mod_prefix, sound_custom)
|
||||
if not (pos or how_many or mob_name) then return end
|
||||
function spawners_mobs.start_spawning(random_pos, how_many, mob_name, mod_prefix, sound_custom, pos)
|
||||
if not (random_pos or how_many or mob_name) then return end
|
||||
|
||||
local sound_name
|
||||
-- remove 'spawners_mobs:' from the string
|
||||
@ -64,18 +123,25 @@ function spawners_mobs.start_spawning(pos, how_many, mob_name, mod_prefix, sound
|
||||
end
|
||||
|
||||
for i=1,how_many do
|
||||
pos.y = pos.y+1
|
||||
local obj = minetest.add_entity(pos, mod_prefix..":"..mob_name)
|
||||
random_pos.y = random_pos.y+1
|
||||
|
||||
spawners_mobs.cloud_booom(random_pos)
|
||||
|
||||
if obj then
|
||||
if sound_name then
|
||||
minetest.sound_play(sound_name, {
|
||||
pos = pos,
|
||||
max_hear_distance = 32,
|
||||
gain = 5,
|
||||
})
|
||||
local obj
|
||||
|
||||
minetest.after(1, function()
|
||||
obj = minetest.add_entity(random_pos, mod_prefix..":"..mob_name)
|
||||
|
||||
if obj then
|
||||
if sound_name then
|
||||
minetest.sound_play(sound_name, {
|
||||
random_pos = random_pos,
|
||||
max_hear_distance = 32,
|
||||
gain = 5,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,12 +43,6 @@ function spawners_mobs.create(mob_name, mod_prefix, size, offset, mesh, texture,
|
||||
|
||||
minetest.register_entity("spawners_mobs:dummy_"..mod_prefix.."_"..mob_name, dummy_definition)
|
||||
|
||||
--
|
||||
-- * CRAFTING SPAWNERS *
|
||||
--
|
||||
|
||||
-- print("[Mod][Spawners] Registering Crafting Spawner.")
|
||||
|
||||
--
|
||||
-- ACTIVE SPAWNER
|
||||
--
|
||||
@ -56,29 +50,38 @@ function spawners_mobs.create(mob_name, mod_prefix, size, offset, mesh, texture,
|
||||
minetest.register_node("spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner_active", {
|
||||
description = mod_prefix.."_"..mob_name.." spawner active",
|
||||
paramtype = "light",
|
||||
light_source = 4,
|
||||
light_source = 6 ,
|
||||
drawtype = "allfaces",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
damage_per_second = 4,
|
||||
sunlight_propagates = true,
|
||||
tiles = {
|
||||
{
|
||||
name = "spawners_mobs_spawner_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0
|
||||
},
|
||||
}
|
||||
},
|
||||
tiles = {"spawners_mobs_spawner_16.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1},
|
||||
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner",
|
||||
on_construct = function(pos)
|
||||
pos.y = pos.y + offset
|
||||
minetest.add_entity(pos,"spawners_mobs:dummy_"..mod_prefix.."_"..mob_name)
|
||||
local id_flame = spawners_mobs.add_flame_effects(pos)
|
||||
local id_smoke = spawners_mobs.add_smoke_effects(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
print("construct: "..id_flame)
|
||||
print("construct: "..id_smoke)
|
||||
meta:set_int("id_flame", id_flame)
|
||||
meta:set_int("id_smoke", id_smoke)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local id_flame = meta:get_int("id_flame")
|
||||
local id_smoke = meta:get_int("id_smoke")
|
||||
|
||||
if id_flame and id_smoke and id_flame ~= nil and id_smoke ~= nil then
|
||||
print("destruct: "..id_flame)
|
||||
print("destruct: "..id_smoke)
|
||||
minetest.delete_particlespawner(id_flame)
|
||||
minetest.delete_particlespawner(id_smoke)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@ -122,7 +125,7 @@ function spawners_mobs.create(mob_name, mod_prefix, size, offset, mesh, texture,
|
||||
walkable = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
sunlight_propagates = true,
|
||||
tiles = {"spawners_mobs_spawner.png"},
|
||||
tiles = {"spawners_mobs_spawner_16.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2},
|
||||
stack_max = 1,
|
||||
@ -151,7 +154,7 @@ function spawners_mobs.create(mob_name, mod_prefix, size, offset, mesh, texture,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
damage_per_second = 4,
|
||||
sunlight_propagates = true,
|
||||
tiles = {"spawners_mobs_spawner.png^[colorize:#FF000030"},
|
||||
tiles = {"spawners_mobs_spawner_16.png^[colorize:#FF000030"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=1,level=2,igniter=1,not_in_creative_inventory=1},
|
||||
drop = "spawners_mobs:"..mod_prefix.."_"..mob_name.."_spawner",
|
||||
@ -176,7 +179,7 @@ function spawners_mobs.create(mob_name, mod_prefix, size, offset, mesh, texture,
|
||||
},
|
||||
neighbors = {"air"},
|
||||
interval = 10.0,
|
||||
chance = 6,
|
||||
chance = 5,
|
||||
catch_up = false,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
@ -208,7 +211,7 @@ function spawners_mobs.create(mob_name, mod_prefix, size, offset, mesh, texture,
|
||||
end
|
||||
|
||||
-- enough place to spawn more mobs
|
||||
spawners_mobs.start_spawning(random_pos, 1, "spawners_mobs:"..mob_name, mod_prefix, sound_custom)
|
||||
spawners_mobs.start_spawning(random_pos, 1, "spawners_mobs:"..mob_name, mod_prefix, sound_custom, pos)
|
||||
|
||||
elseif waiting then
|
||||
-- waiting status
|
||||
|
BIN
spawners_mobs/textures/spawners_mobs_flame_particle.png
Normal file
BIN
spawners_mobs/textures/spawners_mobs_flame_particle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 278 B |
BIN
spawners_mobs/textures/spawners_mobs_smoke2_particle.png
Normal file
BIN
spawners_mobs/textures/spawners_mobs_smoke2_particle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 233 B |
Binary file not shown.
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 170 B |
BIN
spawners_mobs/textures/spawners_mobs_spawner_16.png
Normal file
BIN
spawners_mobs/textures/spawners_mobs_spawner_16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 329 B |
Loading…
Reference in New Issue
Block a user