Add killer bees. Correct light in trees.

This commit is contained in:
Duane 2016-06-13 13:10:14 -05:00
parent 99eb220fef
commit 68e8671235
4 changed files with 228 additions and 101 deletions

View file

@ -1,101 +1,6 @@
-- goblins_digger.lua
--
-- He destroys everything diggable in his path. It's too much trouble
-- to fudge around with particulars. Besides, I don't want them to
-- mine for me.
--local diggable_nodes = {"group:stone", "group:sand", "group:soil", "group:plant", "default:stone_with_coal", "default:stone_with_iron", "default:stone_with_copper", "default:stone_with_gold", "default:stone_with_mese", "default:stone_with_diamond", "default:mese", "default:coalblock"}
local diggable_nodes = {"group:cracky", "group:snappy", "group:crumbly"}
-- This translates yaw into vectors.
local cardinals = {{x=0,y=0,z=0.75}, {x=-0.75,y=0,z=0}, {x=0,y=0,z=-0.75}, {x=0.75,y=0,z=0}}
local goblin_tunneling = function(self, type)
-- Types are available for fine-tuning.
if type == nil then
type = "digger"
end
local pos = self.object:getpos()
if self.state == "tunnel" then
-- Yaw is stored as one of the four cardinal directions.
if not self.digging_dir then
self.digging_dir = math.random(0,3)
end
-- Turn him roughly in the right direction.
-- self.object:setyaw(self.digging_dir * math.pi * 0.5 + math.random() * 0.5 - 0.25)
self.object:setyaw(self.digging_dir * math.pi * 0.5)
-- Get a pair of coordinates that should cover what's in front of him.
local p = vector.add(pos, cardinals[self.digging_dir+1])
p.y = p.y - 0.5 -- What's this about?
local p1 = vector.add(p, -0.3)
local p2 = vector.add(p, 0.3)
-- Get any diggable nodes in that area.
local np_list = minetest.find_nodes_in_area(p1, p2, diggable_nodes)
if #np_list > 0 then
-- Dig it.
for _, np in pairs(np_list) do
if np.name ~= "default:cobble" then
minetest.remove_node(np)
end
end
end
if math.random() < 0.2 then
local d = {-1,1}
self.digging_dir = (self.digging_dir + d[math.random(2)]) % 4
end
set_animation(self, "walk")
set_velocity(self, self.walk_velocity)
elseif self.state == "room" then -- Dig a room.
if not self.room_radius then
self.room_radius = 1
end
set_animation(self, "stand")
set_velocity(self, 0)
-- Work from the inside, out.
for r = 1,self.room_radius do
-- Get a pair of coordinates that form a room.
local p1 = vector.add(pos, -r)
local p2 = vector.add(pos, r)
-- But not below him.
p1.y = pos.y
local np_list = minetest.find_nodes_in_area(p1, p2, diggable_nodes)
-- I wanted to leave the outer layer incomplete, but this
-- actually tends to make it look worse.
if r >= self.room_radius and #np_list == 0 then
self.room_radius = math.random(1,2) + math.random(0,1)
self.state = "stand"
break
end
if #np_list > 0 then
-- Dig it.
minetest.remove_node(np_list[math.random(#np_list)])
break
end
end
end
if self.state == "stand" and math.random() < 0.5 then
self.state = "tunnel"
elseif self.state == "tunnel" and math.random() < 0.05 then
self.state = "room"
elseif self.state == "tunnel" and math.random() < 0.1 then
self.state = "stand"
end
end
mobs:register_mob("fun_caves:goblin_digger", {
description = "Digger Goblin",
type = "monster",
@ -209,7 +114,7 @@ mobs:register_mob("fun_caves:goblin_digger", {
return
end
goblin_tunneling(self, "digger")
fun_caves.tunneling(self, "digger")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_torch_freq, {"default:torch"}, "air")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone", "default:sandstone"}, "default:mossycobble")