Delay custom actions.

This commit is contained in:
Duane Robertson 2016-05-26 01:12:06 -05:00
parent f8678a3d44
commit 234b71064c
12 changed files with 83 additions and 15 deletions

View file

@ -70,8 +70,15 @@ mobs:register_mob("fun_caves:dangler", {
--replace_with = "air", --replace_with = "air",
--replace_offset = -1, --replace_offset = -1,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
fun_caves.climb(self) fun_caves.climb(self)
fun_caves.search_replace(self.object:getpos(), 200, {"air"}, "mobs:cobweb") fun_caves.search_replace(self.object:getpos(), 100, {"air"}, "mobs:cobweb")
fun_caves.surface_damage(self) fun_caves.surface_damage(self)
end, end,

View file

@ -108,6 +108,13 @@ mobs:register_mob("fun_caves:goblin_coal", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
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_torch_freq, {"default:torch"}, "air")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_coal_trap") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_coal_trap")

View file

@ -112,6 +112,13 @@ mobs:register_mob("fun_caves:goblin_cobble", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
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_torch_freq, {"default:torch"}, "air")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone", "default:desert_stone", "default:sandstone"}, "default:mossycobble") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone", "default:desert_stone", "default:sandstone"}, "default:mossycobble")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:mossycobble"}, "fun_caves:mossycobble_trap") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:mossycobble"}, "fun_caves:mossycobble_trap")

View file

@ -108,6 +108,13 @@ mobs:register_mob("fun_caves:goblin_copper", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
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_torch_freq, {"default:torch"}, "air")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_copper_trap") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_copper_trap")

View file

@ -110,6 +110,13 @@ mobs:register_mob("fun_caves:goblin_diamond", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
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_torch_freq, {"default:torch"}, "air")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_diamond_trap") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_diamond_trap")

View file

@ -87,7 +87,7 @@ local goblin_tunneling = function(self, type)
end end
end end
if self.state == "stand" and math.random() < 0.05 then if self.state == "stand" and math.random() < 0.5 then
self.state = "tunnel" self.state = "tunnel"
elseif self.state == "tunnel" and math.random() < 0.05 then elseif self.state == "tunnel" and math.random() < 0.05 then
self.state = "room" self.state = "room"
@ -204,6 +204,13 @@ mobs:register_mob("fun_caves:goblin_digger", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
goblin_tunneling(self, "digger") goblin_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_torch_freq, {"default:torch"}, "air")

View file

@ -108,6 +108,13 @@ mobs:register_mob("fun_caves:goblin_gold", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
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_torch_freq, {"default:torch"}, "air")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_gold_trap") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_gold_trap")

View file

@ -107,6 +107,13 @@ mobs:register_mob("fun_caves:goblin_ice", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
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_torch_freq, {"default:torch"}, "air")
--fun_caves.search_replace(self.object:getpos(), 20, {"default:stone"}, "default:mossycobble") --fun_caves.search_replace(self.object:getpos(), 20, {"default:stone"}, "default:mossycobble")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:ice"}, "fun_caves:ice_trap") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:ice"}, "fun_caves:ice_trap")

View file

@ -110,6 +110,13 @@ mobs:register_mob("fun_caves:goblin_iron", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
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_torch_freq, {"default:torch"}, "air")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_iron_trap") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"group:stone"}, "fun_caves:stone_with_iron_trap")

View file

@ -109,6 +109,13 @@ mobs:register_mob("fun_caves:goblin_king", {
end, end,
do_custom = function(self) do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
return
end
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_torch_freq, {"default:torch"}, "air")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:stone"}, "default:mossycobble")
fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:mossycobble"}, "fun_caves:mossycobble_trap") fun_caves.search_replace(self.object:getpos(), fun_caves.goblin_trap_freq, {"default:mossycobble"}, "fun_caves:mossycobble_trap")

View file

@ -17,13 +17,13 @@ fun_caves.search_replace = function(pos, search_rate, replace_what, replace_with
end end
fun_caves.surface_damage = function(self, cold_natured) fun_caves.surface_damage = function(self, cold_natured)
if not self.fun_caves_damage_timer then --if not self.fun_caves_damage_timer then
self.fun_caves_damage_timer = 0 -- self.fun_caves_damage_timer = 0
end --end
self.fun_caves_damage_timer = self.fun_caves_damage_timer + 1 --self.fun_caves_damage_timer = self.fun_caves_damage_timer + 1
if self.fun_caves_damage_timer > 30 then --if self.fun_caves_damage_timer > 30 then
self.fun_caves_damage_timer = 0 -- self.fun_caves_damage_timer = 0
local pos = self.object:getpos() local pos = self.object:getpos()
local minp = vector.subtract(pos, 1.5) local minp = vector.subtract(pos, 1.5)
local maxp = vector.add(pos, 1.5) local maxp = vector.add(pos, 1.5)
@ -44,10 +44,12 @@ fun_caves.surface_damage = function(self, cold_natured)
end end
check_for_death(self) check_for_death(self)
end --end
end end
fun_caves.custom_delay = 50
local path = minetest.get_modpath(minetest.get_current_modname()) local path = minetest.get_modpath(minetest.get_current_modname())
dofile(path .. "/danglers.lua") dofile(path .. "/danglers.lua")
dofile(path .. "/spider.lua") dofile(path .. "/spider.lua")
@ -88,8 +90,8 @@ end
fun_caves.goblin_spawn_frequency = 150 fun_caves.goblin_spawn_frequency = 150
fun_caves.goblin_trap_freq = 500 fun_caves.goblin_trap_freq = 25
fun_caves.goblin_torch_freq = 10 fun_caves.goblin_torch_freq = 2
fun_caves.goblin_drops = { "default:pick_steel", "default:sword_steel", "default:shovel_steel", "farming:bread", "bucket:bucket_water", "default:pick_stone", "default:sword_stone" } fun_caves.goblin_drops = { "default:pick_steel", "default:sword_steel", "default:shovel_steel", "farming:bread", "bucket:bucket_water", "default:pick_stone", "default:sword_stone" }
--{"group:stone"} = { "default:stone", "default:mossycobble", "default:sandstone", "default:desert_stone", "default:stone_with_coal", "default:stone_with_iron", "default:stone_with_copper", "default:stone_with_gold", "default:stone_with_diamond" } --{"group:stone"} = { "default:stone", "default:mossycobble", "default:sandstone", "default:desert_stone", "default:stone_with_coal", "default:stone_with_iron", "default:stone_with_copper", "default:stone_with_gold", "default:stone_with_diamond" }

View file

@ -48,10 +48,6 @@ mobs:register_mob("fun_caves:spider", {
punch_end = 90, punch_end = 90,
}, },
do_custom = function(self) do_custom = function(self)
if not self.fun_caves_damage_timer then
self.fun_caves_damage_timer = 0
end
fun_caves.surface_damage(self) fun_caves.surface_damage(self)
end, end,
}) })