Finish ice zombie and sand zombie
parent
0f2157f5f5
commit
936f897a81
137
api.lua
137
api.lua
|
@ -6,8 +6,8 @@ natspawner.on_mob_die = function(self, pos)
|
||||||
if self.spawn and self.spawn.pos then
|
if self.spawn and self.spawn.pos then
|
||||||
local meta = minetest.get_meta(self.spawn.pos)
|
local meta = minetest.get_meta(self.spawn.pos)
|
||||||
meta:set_int("entity_killed_count", meta:get_int("entity_killed_count") + 1)
|
meta:set_int("entity_killed_count", meta:get_int("entity_killed_count") + 1)
|
||||||
if self.variation then
|
if self.variation then
|
||||||
meta:set_int("spawned_variation_count", meta:get_int("spawned_variation_count") - 1)
|
meta:set_int("spawned_variation_count", meta:get_int("spawned_variation_count") - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,23 +16,23 @@ local function spawn(pos, force)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local spawner_name = meta:get_string("spawner_name")
|
local spawner_name = meta:get_string("spawner_name")
|
||||||
|
|
||||||
if spawner_name then
|
if spawner_name then
|
||||||
local spawner = spawners[spawner_name]
|
local spawner = spawners[spawner_name]
|
||||||
local replacement_node_name = meta:get_string("replaced_node_name")
|
local replacement_node_name = meta:get_string("replaced_node_name")
|
||||||
|
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
local interval = math.random(spawner.min_spawn_interval, spawner.max_spawn_interval)
|
local interval = math.random(spawner.min_spawn_interval, spawner.max_spawn_interval)
|
||||||
|
|
||||||
if replacement_node_name and replacement_node_name ~= "" then
|
if replacement_node_name and replacement_node_name ~= "" then
|
||||||
|
|
||||||
-- Check if variations are forced
|
-- Check if variations are forced
|
||||||
local force_variation = false
|
local force_variation = false
|
||||||
--minetest.log("Spawner data: "..dump(spawners[spawner_name].replacement_nodes[replacement_node_name]))
|
--minetest.log("Spawner data: "..dump(spawners[spawner_name].replacement_nodes[replacement_node_name]))
|
||||||
if spawners[spawner_name].replacement_nodes[replacement_node_name].variations_only == true then
|
if spawners[spawner_name].replacement_nodes[replacement_node_name].variations_only == true then
|
||||||
force_variation = true
|
force_variation = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Entity names for which we are going to search
|
-- Entity names for which we are going to search
|
||||||
local search_names = {}
|
local search_names = {}
|
||||||
local variation_names = {}
|
local variation_names = {}
|
||||||
|
@ -48,7 +48,7 @@ local function spawn(pos, force)
|
||||||
else
|
else
|
||||||
search_names = spawners[spawner_name].entities.all_entity_names
|
search_names = spawners[spawner_name].entities.all_entity_names
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Search for nearby players and entities
|
-- Search for nearby players and entities
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 10)
|
local objects = minetest.get_objects_inside_radius(pos, 10)
|
||||||
local entity_count = 0
|
local entity_count = 0
|
||||||
|
@ -60,9 +60,9 @@ local function spawn(pos, force)
|
||||||
timer:start(interval)
|
timer:start(interval)
|
||||||
minetest.log("Next spawning scheduled in "..interval.." seconds")
|
minetest.log("Next spawning scheduled in "..interval.." seconds")
|
||||||
return
|
return
|
||||||
elseif object:get_luaentity()
|
elseif object:get_luaentity()
|
||||||
and object:get_luaentity().entity_name then
|
and object:get_luaentity().entity_name then
|
||||||
|
|
||||||
-- Check if the found entity has the name of one the entities
|
-- Check if the found entity has the name of one the entities
|
||||||
-- that this spawner cares about
|
-- that this spawner cares about
|
||||||
for i = 1, #search_names do
|
for i = 1, #search_names do
|
||||||
|
@ -71,11 +71,11 @@ local function spawn(pos, force)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create a list of names we are to spawn
|
-- Create a list of names we are to spawn
|
||||||
local spawn_names = {}
|
local spawn_names = {}
|
||||||
if force_variation then
|
if force_variation then
|
||||||
|
@ -88,10 +88,10 @@ local function spawn(pos, force)
|
||||||
else
|
else
|
||||||
spawn_names[#spawn_names + 1] = spawners[spawner_name].entities.default
|
spawn_names[#spawn_names + 1] = spawners[spawner_name].entities.default
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Choose an entity name.
|
-- Choose an entity name.
|
||||||
local is_variation = false
|
local is_variation = false
|
||||||
|
|
||||||
if force_variation == true then
|
if force_variation == true then
|
||||||
entity_name = spawn_names[math.random(1, #spawn_names)]
|
entity_name = spawn_names[math.random(1, #spawn_names)]
|
||||||
--minetest.log("New entity name: "..dump(entity_name))
|
--minetest.log("New entity name: "..dump(entity_name))
|
||||||
|
@ -110,10 +110,10 @@ local function spawn(pos, force)
|
||||||
entity_name = spawners[spawner_name].entities.default
|
entity_name = spawners[spawner_name].entities.default
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Validation: enforce entity max spawn count
|
-- Validation: enforce entity max spawn count
|
||||||
local max_mob_count = spawner.max_mob_count
|
local max_mob_count = spawner.max_mob_count
|
||||||
|
|
||||||
if force_variation then
|
if force_variation then
|
||||||
--minetest.log("Entity name: "..dump(entity_name))
|
--minetest.log("Entity name: "..dump(entity_name))
|
||||||
--minetest.log("Mob data: "..dump(spawners[spawner_name]
|
--minetest.log("Mob data: "..dump(spawners[spawner_name]
|
||||||
|
@ -125,21 +125,24 @@ local function spawn(pos, force)
|
||||||
.max_count or spawner.max_mob_count
|
.max_count or spawner.max_mob_count
|
||||||
entity_count = meta:get_int("spawned_variation_count")
|
entity_count = meta:get_int("spawned_variation_count")
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("Entity count: "..dump(entity_count))
|
minetest.log("Entity count: "..dump(entity_count))
|
||||||
minetest.log("Max mob count: "..dump(max_mob_count))
|
minetest.log("Max mob count: "..dump(max_mob_count))
|
||||||
--minetest.log("Force: "..dump(force))
|
|
||||||
|
|
||||||
if force or (entity_count <= max_mob_count) then
|
if force or (entity_count <= max_mob_count) then
|
||||||
|
|
||||||
-- Spawn
|
-- Spawn
|
||||||
local spawn_pos = {x=pos.x + math.random(0, spawner.spawn_radius), y=pos.y+3, z=pos.z + math.random(0, spawner.spawn_radius)}
|
local spawn_pos = {
|
||||||
|
x=pos.x + math.random(0, spawner.spawn_radius),
|
||||||
|
y=pos.y+3,
|
||||||
|
z=pos.z + math.random(0, spawner.spawn_radius)
|
||||||
|
}
|
||||||
-- Check spawn position - if not air, then spawn just above the spawner
|
-- Check spawn position - if not air, then spawn just above the spawner
|
||||||
local spawn_node = minetest.get_node_or_nil(spawn_pos)
|
local spawn_node = minetest.get_node_or_nil(spawn_pos)
|
||||||
if spawn_node and spawn_node.name ~= "air" then
|
if spawn_node and spawn_node.name ~= "air" then
|
||||||
spawn_pos = pos
|
spawn_pos = pos
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.log("Spawning "..entity_name.." at pos "..minetest.pos_to_string(spawn_pos))
|
minetest.log("Spawning "..entity_name.." at pos "..minetest.pos_to_string(spawn_pos))
|
||||||
local entity = minetest.add_entity(spawn_pos, entity_name)
|
local entity = minetest.add_entity(spawn_pos, entity_name)
|
||||||
if entity then
|
if entity then
|
||||||
|
@ -147,7 +150,7 @@ local function spawn(pos, force)
|
||||||
entity:get_luaentity().spawn = {
|
entity:get_luaentity().spawn = {
|
||||||
pos = pos
|
pos = pos
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_variation == true then
|
if is_variation == true then
|
||||||
entity:get_luaentity().variation = true
|
entity:get_luaentity().variation = true
|
||||||
end
|
end
|
||||||
|
@ -160,7 +163,7 @@ local function spawn(pos, force)
|
||||||
minetest.log("Deactivating spawner for "..interval.." seconds")
|
minetest.log("Deactivating spawner for "..interval.." seconds")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Re-schedule
|
-- Re-schedule
|
||||||
timer:start(interval)
|
timer:start(interval)
|
||||||
end
|
end
|
||||||
|
@ -182,7 +185,7 @@ natspawner.register_spawner = function(spawner_name, def)
|
||||||
max_mob_count = def.max_mob_count or 15,
|
max_mob_count = def.max_mob_count or 15,
|
||||||
spawn_on_dig = def.spawn_on_dig
|
spawn_on_dig = def.spawn_on_dig
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Process all names
|
-- Process all names
|
||||||
local all_names = {}
|
local all_names = {}
|
||||||
all_names[#all_names + 1] = def.entities.default
|
all_names[#all_names + 1] = def.entities.default
|
||||||
|
@ -190,12 +193,12 @@ natspawner.register_spawner = function(spawner_name, def)
|
||||||
all_names[#all_names + 1] = def.entities.others[i]
|
all_names[#all_names + 1] = def.entities.others[i]
|
||||||
end
|
end
|
||||||
spawners[spawner_name].entities.all_entity_names = all_names
|
spawners[spawner_name].entities.all_entity_names = all_names
|
||||||
|
|
||||||
spawner_count = spawner_count + 1
|
spawner_count = spawner_count + 1
|
||||||
|
|
||||||
-- Register all spawners
|
-- Register all spawners
|
||||||
for _,val in pairs(def.node_replacement_map) do
|
for _,val in pairs(def.node_replacement_map) do
|
||||||
|
|
||||||
minetest.register_node("natspawner:"..spawner_name..val.name, {
|
minetest.register_node("natspawner:"..spawner_name..val.name, {
|
||||||
description = "Spawner",
|
description = "Spawner",
|
||||||
drop = "natspawner:"..spawner_name.."_"..val.name,
|
drop = "natspawner:"..spawner_name.."_"..val.name,
|
||||||
|
@ -208,11 +211,11 @@ natspawner.register_spawner = function(spawner_name, def)
|
||||||
meta:set_int("entity_spawn_count", 0)
|
meta:set_int("entity_spawn_count", 0)
|
||||||
meta:set_int("entity_killed_count", 0)
|
meta:set_int("entity_killed_count", 0)
|
||||||
meta:set_int("spawned_variation_count", 0)
|
meta:set_int("spawned_variation_count", 0)
|
||||||
meta:set_int("max_variation_count",
|
meta:set_int("max_variation_count",
|
||||||
math.random(def.min_variation_count or 0, def.max_variation_count or 0))
|
math.random(def.min_variation_count or 0, def.max_variation_count or 0))
|
||||||
meta:set_int("next_deactivation_count",
|
meta:set_int("next_deactivation_count",
|
||||||
math.random(def.min_kill_count, def.max_kill_count))
|
math.random(def.min_kill_count, def.max_kill_count))
|
||||||
meta:set_int("next_deactivation_time",
|
meta:set_int("next_deactivation_time",
|
||||||
math.random(def.min_deactivation_time, def.max_deactivation_time))
|
math.random(def.min_deactivation_time, def.max_deactivation_time))
|
||||||
|
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
@ -236,7 +239,7 @@ natspawner.register_spawner = function(spawner_name, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -252,14 +255,14 @@ natspawner.register_spawner("zombie", {
|
||||||
},
|
},
|
||||||
node_replacement_map = {
|
node_replacement_map = {
|
||||||
["default:stone"] = {
|
["default:stone"] = {
|
||||||
name = "stone_spawner",
|
name = "stone_spawner",
|
||||||
tiles = {"default_stone.png^[cracko:1:2", "default_stone.png", {name = "default_stone.png"}}
|
tiles = {"default_stone.png^[cracko:1:2", "default_stone.png", {name = "default_stone.png"}}
|
||||||
},
|
},
|
||||||
["default:sand"] = {
|
["default:sand"] = {
|
||||||
name = "sand_spawner",
|
name = "sand_spawner",
|
||||||
tiles = {"default_sand.png^[cracko:1:2", "default_sand.png", {name = "default_sand.png"}},
|
tiles = {"default_sand.png^[cracko:1:2", "default_sand.png", {name = "default_sand.png"}},
|
||||||
variations = {
|
variations = {
|
||||||
["natspawner:sand_zombie"] = {},
|
["natspawner:sand_zombie"] = {},
|
||||||
["natspawner:sand_zombie_small"] = {
|
["natspawner:sand_zombie_small"] = {
|
||||||
max_count = 5
|
max_count = 5
|
||||||
}
|
}
|
||||||
|
@ -267,10 +270,10 @@ natspawner.register_spawner("zombie", {
|
||||||
variations_only = true
|
variations_only = true
|
||||||
},
|
},
|
||||||
["default:desert_sand"] = {
|
["default:desert_sand"] = {
|
||||||
name = "desert_sand_spawner",
|
name = "desert_sand_spawner",
|
||||||
tiles = {"default_desert_sand.png^[cracko:1:2", "default_desert_sand.png", {name = "default_desert_sand.png"}},
|
tiles = {"default_desert_sand.png^[cracko:1:2", "default_desert_sand.png", {name = "default_desert_sand.png"}},
|
||||||
variations = {
|
variations = {
|
||||||
["natspawner:sand_zombie"] = {},
|
["natspawner:sand_zombie"] = {},
|
||||||
["natspawner:sand_zombie_small"] = {
|
["natspawner:sand_zombie_small"] = {
|
||||||
max_count = 5
|
max_count = 5
|
||||||
}
|
}
|
||||||
|
@ -278,7 +281,7 @@ natspawner.register_spawner("zombie", {
|
||||||
variations_only = true
|
variations_only = true
|
||||||
},
|
},
|
||||||
["default:ice"] = {
|
["default:ice"] = {
|
||||||
name = "ice_spawner",
|
name = "ice_spawner",
|
||||||
tiles = {"default_ice.png^[cracko:1:2", "default_ice.png", {name = "default_ice.png"}},
|
tiles = {"default_ice.png^[cracko:1:2", "default_ice.png", {name = "default_ice.png"}},
|
||||||
variations = {
|
variations = {
|
||||||
["natspawner:ice_zombie"] = {
|
["natspawner:ice_zombie"] = {
|
||||||
|
@ -289,7 +292,7 @@ natspawner.register_spawner("zombie", {
|
||||||
variations_only = true
|
variations_only = true
|
||||||
},
|
},
|
||||||
["default:snowblock"] = {
|
["default:snowblock"] = {
|
||||||
name = "snowblock_spawner",
|
name = "snowblock_spawner",
|
||||||
tiles = {"default_snow.png^[cracko:1:2", "default_snow.png", {name = "default_snow.png"}},
|
tiles = {"default_snow.png^[cracko:1:2", "default_snow.png", {name = "default_snow.png"}},
|
||||||
variations = {
|
variations = {
|
||||||
["natspawner:ice_zombie"] = {
|
["natspawner:ice_zombie"] = {
|
||||||
|
@ -300,14 +303,21 @@ natspawner.register_spawner("zombie", {
|
||||||
variations_only = true
|
variations_only = true
|
||||||
},
|
},
|
||||||
["default:dirt_with_grass"] = {
|
["default:dirt_with_grass"] = {
|
||||||
name = "dirt_with_grass_spawner",
|
name = "dirt_with_grass_spawner",
|
||||||
tiles = {"default_grass.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_grass_side.png"}}},
|
tiles = {"default_grass.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_grass_side.png"}},
|
||||||
|
variations = {
|
||||||
|
["natspawner:giant_zombie"] = {
|
||||||
|
max_count = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
["default:dirt_with_dry_grass"] = {
|
["default:dirt_with_dry_grass"] = {
|
||||||
name = "dirt_with_dry_grass_spawner",
|
name = "dirt_with_dry_grass_spawner",
|
||||||
tiles = {"default_dry_grass.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_dry_grass_side.png"}}},
|
tiles = {"default_dry_grass.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_dry_grass_side.png"}}
|
||||||
|
},
|
||||||
["default:dirt_with_snow"] = {
|
["default:dirt_with_snow"] = {
|
||||||
name = "dirt_with_snow_spawner",
|
name = "dirt_with_snow_spawner",
|
||||||
tiles = {"default_snow.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_snow_side.png"}},
|
tiles = {"default_snow.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_snow_side.png"}},
|
||||||
variations = {
|
variations = {
|
||||||
["natspawner:ice_zombie"] = {
|
["natspawner:ice_zombie"] = {
|
||||||
max_count = 15,
|
max_count = 15,
|
||||||
|
@ -317,29 +327,34 @@ natspawner.register_spawner("zombie", {
|
||||||
variations_only = true
|
variations_only = true
|
||||||
},
|
},
|
||||||
["default:dirt_with_rainforest_litter"] = {
|
["default:dirt_with_rainforest_litter"] = {
|
||||||
name = "dirt_with_rainforest_litter_spawner",
|
name = "dirt_with_rainforest_litter_spawner",
|
||||||
tiles = {"default_rainforest_litter.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_rainforest_litter_side.png"}}
|
tiles = {"default_rainforest_litter.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_rainforest_litter_side.png"}},
|
||||||
|
variations = {
|
||||||
|
["natspawner:giant_zombie"] = {
|
||||||
|
max_count = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
["default:dirt_with_coniferous_litter"] = {
|
["default:dirt_with_coniferous_litter"] = {
|
||||||
name = "dirt_with_coniferous_litter_spawner",
|
name = "dirt_with_coniferous_litter_spawner",
|
||||||
tiles = {"default_coniferous_litter.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_coniferous_litter_side.png"}}
|
tiles = {"default_coniferous_litter.png^[cracko:1:2", "default_dirt.png", {name = "default_dirt.png^default_coniferous_litter_side.png"}}
|
||||||
},
|
},
|
||||||
["default:permafrost"] = {
|
["default:permafrost"] = {
|
||||||
name = "permafrost_spawner",
|
name = "permafrost_spawner",
|
||||||
tiles = {"default_permafrost.png^[cracko:1:2", "default_permafrost.png", {name = "default_permafrost.png"}},
|
tiles = {"default_permafrost.png^[cracko:1:2", "default_permafrost.png", {name = "default_permafrost.png"}},
|
||||||
variations = {
|
variations = {
|
||||||
["natspawner:ice_zombie"] = {}
|
["natspawner:ice_zombie"] = {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
["default:permafrost_with_stones"] = {
|
["default:permafrost_with_stones"] = {
|
||||||
name = "permafrost_with_stones_spawner",
|
name = "permafrost_with_stones_spawner",
|
||||||
tiles = {"default_permafrost.png^default_stones.png^[cracko:1:2", "default_permafrost.png", {name = "default_permafrost.png"}},
|
tiles = {"default_permafrost.png^default_stones.png^[cracko:1:2", "default_permafrost.png", {name = "default_permafrost.png"}},
|
||||||
variations = {
|
variations = {
|
||||||
["natspawner:ice_zombie"] = {}
|
["natspawner:ice_zombie"] = {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
["default:permafrost_with_moss"] = {
|
["default:permafrost_with_moss"] = {
|
||||||
name = "permafrost_with_moss_spawner",
|
name = "permafrost_with_moss_spawner",
|
||||||
tiles = {"default_moss.png^[cracko:1:2", "default_permafrost.png", {name = "default_permafrost.png^default_moss_side.png"}},
|
tiles = {"default_moss.png^[cracko:1:2", "default_permafrost.png", {name = "default_permafrost.png^default_moss_side.png"}},
|
||||||
variations = {
|
variations = {
|
||||||
["natspawner:ice_zombie"] = {}
|
["natspawner:ice_zombie"] = {}
|
||||||
|
@ -381,10 +396,10 @@ local function ground(pos, old)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_air_or_buildable(node)
|
local function is_air_or_buildable(node)
|
||||||
return node
|
return node
|
||||||
and node.name
|
and node.name
|
||||||
and (node.name == "air"
|
and (node.name == "air"
|
||||||
or minetest.registered_nodes[node.name].buildable_to == true)
|
or minetest.registered_nodes[node.name].buildable_to == true)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
|
@ -403,9 +418,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
|
||||||
|
|
||||||
local p2 = minetest.find_node_near(mpos, 25, {
|
local p2 = minetest.find_node_near(mpos, 25, {
|
||||||
"default:dirt_with_grass",
|
"default:dirt_with_grass",
|
||||||
"default:dirt_with_snow",
|
"default:dirt_with_snow",
|
||||||
"default:dirt_with_coniferous_litter",
|
"default:dirt_with_coniferous_litter",
|
||||||
|
"default:dirt_with_rainforest_litter",
|
||||||
"default:permafrost",
|
"default:permafrost",
|
||||||
"default:permafrost_with_moss",
|
"default:permafrost_with_moss",
|
||||||
"default:permafrost_with_stones",
|
"default:permafrost_with_stones",
|
||||||
|
@ -419,6 +435,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
"default:dirt_with_grass",
|
"default:dirt_with_grass",
|
||||||
"default:dirt_with_snow",
|
"default:dirt_with_snow",
|
||||||
"default:dirt_with_coniferous_litter",
|
"default:dirt_with_coniferous_litter",
|
||||||
|
"default:dirt_with_rainforest_litter",
|
||||||
"default:permafrost",
|
"default:permafrost",
|
||||||
"default:permafrost_with_moss",
|
"default:permafrost_with_moss",
|
||||||
"default:permafrost_with_stones",
|
"default:permafrost_with_stones",
|
||||||
|
@ -438,14 +455,14 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
minetest.log("Found next node above: "..dump(next_node_above))
|
minetest.log("Found next node above: "..dump(next_node_above))
|
||||||
local next_mapblock_above = minetest.get_node_or_nil({x=p2.x, y=p2.y+16, z=p2.z})
|
local next_mapblock_above = minetest.get_node_or_nil({x=p2.x, y=p2.y+16, z=p2.z})
|
||||||
minetest.log("Found next node above mapblock: "..dump(next_mapblock_above))
|
minetest.log("Found next node above mapblock: "..dump(next_mapblock_above))
|
||||||
|
|
||||||
if is_air_or_buildable(next_node_above) and is_air_or_buildable(next_mapblock_above) then
|
if is_air_or_buildable(next_node_above) and is_air_or_buildable(next_mapblock_above) then
|
||||||
|
|
||||||
-- Choose a spawner
|
-- Choose a spawner
|
||||||
for i = 1, spawner_count do
|
for i = 1, spawner_count do
|
||||||
local spawner_name = next(spawners)
|
local spawner_name = next(spawners)
|
||||||
local chance = math.random(1, spawner_count)
|
local chance = math.random(1, spawner_count)
|
||||||
|
|
||||||
if chance == i then
|
if chance == i then
|
||||||
-- Create spawner
|
-- Create spawner
|
||||||
minetest.after(0.8, function(spawner_name, pos)
|
minetest.after(0.8, function(spawner_name, pos)
|
||||||
|
@ -461,7 +478,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
minetest.log("Unable to find replacement for node '"..dump(node_to_replace.name).."'")
|
minetest.log("Unable to find replacement for node '"..dump(node_to_replace.name).."'")
|
||||||
end
|
end
|
||||||
end, spawner_name, p2)
|
end, spawner_name, p2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
72
mobs.lua
72
mobs.lua
|
@ -1,5 +1,33 @@
|
||||||
-- Entity registrations
|
-- Entity registrations
|
||||||
|
|
||||||
|
local function ice_breaking_effect(pos)
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = math.random(15, 25),
|
||||||
|
|
||||||
|
time = 0.5,
|
||||||
|
-- Lifespan of spawner in seconds.
|
||||||
|
-- If time is 0 spawner has infinite lifespan and spawns the `amount` on
|
||||||
|
-- a per-second basis.
|
||||||
|
minpos = {x=pos.x-1, y=pos.y+1, z=pos.z-1},
|
||||||
|
maxpos = {x=pos.x+1, y=pos.y+1, z=pos.z+1},
|
||||||
|
minvel = {x = -2.5, y = -2.5, z = -2.5},
|
||||||
|
maxvel = {x = 2.5, y = 2.5, z = 2.5},
|
||||||
|
|
||||||
|
|
||||||
|
-- minpos = {x=pos.x-1, y=pos.x-1, z=pos.x-1},
|
||||||
|
-- maxpos = {x=pos.x+1, y=pos.x+1, z=pos.x+1},
|
||||||
|
-- minvel = {x=0, y=0, z=0},
|
||||||
|
-- maxvel = {x=0, y=0, z=0},
|
||||||
|
minacc = {x=0, y=-10, z=0},
|
||||||
|
maxacc = {x=0, y=-10, z=0},
|
||||||
|
minexptime = 0.5,
|
||||||
|
maxexptime = 1,
|
||||||
|
minsize = 0.5,
|
||||||
|
maxsize = 1,
|
||||||
|
texture = "frozen_ice.png"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
local function normal_attack(self, to_attack)
|
local function normal_attack(self, to_attack)
|
||||||
--set_animation(self, "punch")
|
--set_animation(self, "punch")
|
||||||
|
|
||||||
|
@ -11,7 +39,7 @@ local function normal_attack(self, to_attack)
|
||||||
|
|
||||||
--local line = minetest.line_of_sight(p2, s2)
|
--local line = minetest.line_of_sight(p2, s2)
|
||||||
--minetest.log(dump(line))
|
--minetest.log(dump(line))
|
||||||
|
|
||||||
--r, pos = minetest.line_of_sight(p2, s2, stepsize)
|
--r, pos = minetest.line_of_sight(p2, s2, stepsize)
|
||||||
--if line_of_sight(self, p2, s2) == true then
|
--if line_of_sight(self, p2, s2) == true then
|
||||||
|
|
||||||
|
@ -146,9 +174,9 @@ mobs:register_mob("natspawner:ice_zombie", {
|
||||||
visual_size = {x=1, y=1},
|
visual_size = {x=1, y=1},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
sounds = {
|
sounds = {
|
||||||
random = "mobs_zombie.1",
|
random = "mobs_zombie",
|
||||||
damage = "mobs_zombie_ice_hit",
|
damage = "mobs_zombie_ice_hit",
|
||||||
attack = "mobs_zombie.3",
|
attack = "mobs_zombie",
|
||||||
death = "mobs_zombie_death",
|
death = "mobs_zombie_death",
|
||||||
},
|
},
|
||||||
walk_velocity = 0.5,
|
walk_velocity = 0.5,
|
||||||
|
@ -180,10 +208,10 @@ mobs:register_mob("natspawner:ice_zombie", {
|
||||||
end,
|
end,
|
||||||
on_die = natspawner.on_mob_die,
|
on_die = natspawner.on_mob_die,
|
||||||
custom_attack = function(self, to_attack)
|
custom_attack = function(self, to_attack)
|
||||||
|
|
||||||
self.ice_attack_timer = self.ice_attack_timer + 1
|
self.ice_attack_timer = self.ice_attack_timer + 1
|
||||||
|
|
||||||
if self.ice_attack_timer >= 5 then
|
if self.ice_attack_timer >= 3 then
|
||||||
self.ice_attack_timer = 0
|
self.ice_attack_timer = 0
|
||||||
local chance = math.random(1, 5)
|
local chance = math.random(1, 5)
|
||||||
if chance > 3 then
|
if chance > 3 then
|
||||||
|
@ -193,13 +221,16 @@ mobs:register_mob("natspawner:ice_zombie", {
|
||||||
minetest.set_node({x=to_attack.x, y=to_attack.y+1, z=to_attack.z}, {name="natspawner:freezing_ice"})
|
minetest.set_node({x=to_attack.x, y=to_attack.y+1, z=to_attack.z}, {name="natspawner:freezing_ice"})
|
||||||
-- Remove node
|
-- Remove node
|
||||||
minetest.after(math.random(1,2), function(pos)
|
minetest.after(math.random(1,2), function(pos)
|
||||||
|
local pos_above = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
minetest.sound_play("default_break_glass")
|
minetest.sound_play("default_break_glass")
|
||||||
minetest.set_node(to_attack, {name="air"})
|
ice_breaking_effect(pos)
|
||||||
minetest.set_node({x=to_attack.x, y=to_attack.y+1, z=to_attack.z}, {name="air"})
|
ice_breaking_effect(pos_above)
|
||||||
|
minetest.set_node(pos, {name="air"})
|
||||||
|
minetest.set_node(pos_above, {name="air"})
|
||||||
end, to_attack)
|
end, to_attack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
normal_attack(self, to_attack)
|
normal_attack(self, to_attack)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -283,8 +314,7 @@ mobs:register_mob("natspawner:sand_zombie", {
|
||||||
floats = 0,
|
floats = 0,
|
||||||
view_range = 12,
|
view_range = 12,
|
||||||
drops = {
|
drops = {
|
||||||
{name = "zombie:rotten_flesh",
|
{name = "zombie:rotten_flesh", chance = 2, min = 3, max = 5},
|
||||||
chance = 2, min = 3, max = 5,},
|
|
||||||
},
|
},
|
||||||
water_damage = 0,
|
water_damage = 0,
|
||||||
lava_damage = 1,
|
lava_damage = 1,
|
||||||
|
@ -302,7 +332,7 @@ mobs:register_mob("natspawner:sand_zombie", {
|
||||||
minetest.log(dump(self))
|
minetest.log(dump(self))
|
||||||
end,
|
end,
|
||||||
on_die = function(self, pos)
|
on_die = function(self, pos)
|
||||||
|
|
||||||
-- TODO: Add particle effects
|
-- TODO: Add particle effects
|
||||||
--minetest.add_particle_spawner()
|
--minetest.add_particle_spawner()
|
||||||
local positions = {}
|
local positions = {}
|
||||||
|
@ -315,7 +345,7 @@ mobs:register_mob("natspawner:sand_zombie", {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(1, function(positions)
|
minetest.after(1, function(positions)
|
||||||
for i = 1, #positions do
|
for i = 1, #positions do
|
||||||
local chance = math.random(1, 10)
|
local chance = math.random(1, 10)
|
||||||
|
@ -325,18 +355,25 @@ mobs:register_mob("natspawner:sand_zombie", {
|
||||||
end
|
end
|
||||||
--minetest.add_entity({x=pos.x - 1, y=pos.y, z=pos.z}, "natspawner:sand_zombie_small")
|
--minetest.add_entity({x=pos.x - 1, y=pos.y, z=pos.z}, "natspawner:sand_zombie_small")
|
||||||
end, positions)
|
end, positions)
|
||||||
|
|
||||||
-- Spawner callback
|
-- Spawner callback
|
||||||
natspawner.on_mob_die(self, pos)
|
natspawner.on_mob_die(self, pos)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Nodes
|
-- Nodes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("natspawner:freezing_ice", {
|
minetest.register_node("natspawner:freezing_ice", {
|
||||||
description = "Freezing Ice",
|
description = "Freezing Ice",
|
||||||
|
tiles = {"frozen_ice.png"},
|
||||||
|
groups = {cracky = 3, cools_lava = 1, slippery = 3, flammable = 2, liquid = 1},
|
||||||
|
use_texture_alpha = true,
|
||||||
|
sunlight_propagates = true,
|
||||||
drawtype = "glasslike",
|
drawtype = "glasslike",
|
||||||
tiles = {"freezing_ice.png"},
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
sounds = default.node_sound_glass_defaults(),
|
||||||
walkable = false,
|
walkable = false,
|
||||||
pointable = true,
|
pointable = true,
|
||||||
diggable = true,
|
diggable = true,
|
||||||
|
@ -345,13 +382,12 @@ minetest.register_node("natspawner:freezing_ice", {
|
||||||
drowning = 1,
|
drowning = 1,
|
||||||
liquid_renewable = false,
|
liquid_renewable = false,
|
||||||
liquidtype = "source",
|
liquidtype = "source",
|
||||||
use_textrure_alpha = true,
|
|
||||||
liquid_range= 0,
|
liquid_range= 0,
|
||||||
liquid_alternative_flowing = "natspawner:freezing_ice",
|
liquid_alternative_flowing = "natspawner:freezing_ice",
|
||||||
liquid_alternative_source = "natspawner:freezing_ice",
|
liquid_alternative_source = "natspawner:freezing_ice",
|
||||||
liquid_viscosity = 30,
|
liquid_viscosity = 30,
|
||||||
post_effect_color = {a = 103, r = 30, g = 60, b = 90},
|
post_effect_color = {a = 128, r = 30, g = 60, b = 90},
|
||||||
groups = {cracky = 3, cools_lava = 1, slippery = 3, flammable=2, liquid=1, not_in_creative_inventory=1},
|
--groups = {cracky = 3, cools_lava = 1, slippery = 3, flammable=2, liquid=1, not_in_creative_inventory=1},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("natspawner:evil_sand", {
|
minetest.register_node("natspawner:evil_sand", {
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Loading…
Reference in New Issue