664 lines
20 KiB
Lua
664 lines
20 KiB
Lua
---------------------------------------------------------------
|
|
-- GOBLINS
|
|
---------------------------------------------------------------
|
|
|
|
local spawn_frequency = 350 -- 350
|
|
local dig_freq = 5 -- 5
|
|
local trap_freq = 25 -- 25
|
|
local torch_freq = 2 -- 2
|
|
|
|
local diggable = {
|
|
'default:dirt',
|
|
'default:dirt_with_grass',
|
|
'default:dirt_with_dry_grass',
|
|
'default:sand',
|
|
'default:stone',
|
|
'default:sandstone',
|
|
'default:desert_stone',
|
|
'default:stone_with_coal',
|
|
'default:stone_with_copper',
|
|
'default:stone_with_diamond',
|
|
'default:stone_with_gold',
|
|
'default:stone_with_iron',
|
|
'default:stone_with_mese',
|
|
'fun_caves:stone_with_coal_trap',
|
|
'fun_caves:stone_with_copper_trap',
|
|
'fun_caves:stone_with_diamond_trap',
|
|
'fun_caves:stone_with_gold_trap',
|
|
'fun_caves:stone_with_iron_trap',
|
|
'fun_caves:stone_with_salt',
|
|
'fun_caves:stone_with_algae',
|
|
'fun_caves:stone_with_lichen',
|
|
'fun_caves:stone_with_moss',
|
|
'fun_caves:dirt_with_snow',
|
|
'fun_caves:giant_mushroom_cap',
|
|
'fun_caves:huge_mushroom_cap',
|
|
'fun_caves:giant_mushroom_stem',
|
|
'fun_caves:stalactite',
|
|
'fun_caves:stalagmite',
|
|
'fun_caves:stalactite_slimy',
|
|
'fun_caves:stalagmite_slimy',
|
|
'fun_caves:stalactite_mossy',
|
|
'fun_caves:stalagmite_mossy',
|
|
'flowers:mushroom_red',
|
|
'flowers:mushroom_brown'
|
|
}
|
|
|
|
local burnable = {}
|
|
for i = 1, 4 do
|
|
burnable[#burnable+1] = "fun_caves:fungal_tree_leaves_"..i
|
|
end
|
|
|
|
|
|
local traps = {
|
|
'fun_caves:mossycobble_trap',
|
|
'fun_caves:stone_with_coal_trap',
|
|
'fun_caves:stone_with_copper_trap',
|
|
'fun_caves:stone_with_diamond_trap',
|
|
'fun_caves:stone_with_gold_trap',
|
|
'fun_caves:stone_with_iron_trap',
|
|
}
|
|
|
|
|
|
local function goblin_do(self)
|
|
if not (self and fun_caves.custom_ready and fun_caves.search_replace and fun_caves.surface_damage and fun_caves.custom_ready(self)) then
|
|
return
|
|
end
|
|
|
|
local cold_natured = false
|
|
local pos = self.object:getpos()
|
|
pos.y = pos.y + 0.5
|
|
|
|
-- dig
|
|
if self.name == 'fun_caves:goblin_digger' then
|
|
fun_caves.search_replace(pos, 1, diggable, 'air')
|
|
else
|
|
fun_caves.search_replace(pos, dig_freq, diggable, 'air')
|
|
end
|
|
|
|
fun_caves.search_replace(pos, dig_freq * 3, burnable, 'fire:basic_flame')
|
|
|
|
-- steal torches
|
|
fun_caves.search_replace(self.object:getpos(), torch_freq, {"default:torch"}, "air")
|
|
|
|
pos.y = pos.y - 0.5
|
|
|
|
-- place a mossycobble
|
|
local cobbling = trap_freq
|
|
if self.name == 'fun_caves:goblin_cobbler' then
|
|
cobbling = torch_freq
|
|
end
|
|
fun_caves.search_replace(pos, cobbling, {"group:stone", "default:sandstone"}, "default:mossycobble")
|
|
|
|
-- place a trap
|
|
local trap = 'fun_caves:mossycobble_trap'
|
|
if self.name == 'fun_caves:goblin_ice' then
|
|
cold_natured = true
|
|
trap = 'fun_caves:ice_trap'
|
|
fun_caves.search_replace(pos, trap_freq, {"default:ice"}, trap)
|
|
else
|
|
if self.name == 'fun_caves:goblin_coal' then
|
|
trap = 'fun_caves:stone_with_coal_trap'
|
|
elseif self.name == 'fun_caves:goblin_copper' then
|
|
trap = 'fun_caves:stone_with_copper_trap'
|
|
elseif self.name == 'fun_caves:goblin_diamond' then
|
|
trap = 'fun_caves:stone_with_diamond_trap'
|
|
elseif self.name == 'fun_caves:goblin_gold' then
|
|
trap = 'fun_caves:stone_with_gold_trap'
|
|
elseif self.name == 'fun_caves:goblin_iron' then
|
|
trap = 'fun_caves:stone_with_iron_trap'
|
|
elseif self.name == 'fun_caves:goblin_king' then
|
|
trap = traps[math.random(#traps)]
|
|
end
|
|
fun_caves.search_replace(pos, trap_freq, {"group:stone", "default:sandstone"}, trap)
|
|
end
|
|
|
|
fun_caves.surface_damage(self, cold_natured)
|
|
end
|
|
|
|
|
|
--local function goblin_right_click(self, clicker)
|
|
-- local item = clicker:get_wielded_item()
|
|
-- local name = clicker:get_player_name()
|
|
--
|
|
-- -- feed to heal goblin
|
|
-- if item:get_name() == "default:apple"
|
|
-- or item:get_name() == "farming:bread" then
|
|
--
|
|
-- local hp = self.object:get_hp()
|
|
-- -- return if full health
|
|
-- if hp >= self.hp_max then
|
|
-- minetest.chat_send_player(name, "goblin at full health.")
|
|
-- return
|
|
-- end
|
|
-- hp = hp + 4
|
|
-- if hp > self.hp_max then hp = self.hp_max end
|
|
-- self.object:set_hp(hp)
|
|
-- -- take item
|
|
-- if not minetest.setting_getbool("creative_mode") then
|
|
-- item:take_item()
|
|
-- clicker:set_wielded_item(item)
|
|
-- end
|
|
--
|
|
-- -- right clicking with gold lump drops random item from fun_caves.goblin_drops
|
|
-- elseif item:get_name() == "default:gold_lump" then
|
|
-- if not minetest.setting_getbool("creative_mode") then
|
|
-- item:take_item()
|
|
-- clicker:set_wielded_item(item)
|
|
-- end
|
|
-- local pos = self.object:getpos()
|
|
-- pos.y = pos.y + 0.5
|
|
-- minetest.add_item(pos, {name = fun_caves.goblin_drops[math.random(1, #fun_caves.goblin_drops)]})
|
|
--
|
|
-- else
|
|
-- -- if owner switch between follow and stand
|
|
-- if self.owner and self.owner == clicker:get_player_name() then
|
|
-- if self.order == "follow" then
|
|
-- self.order = "stand"
|
|
-- else
|
|
-- self.order = "follow"
|
|
-- end
|
|
-- -- else
|
|
-- -- self.owner = clicker:get_player_name()
|
|
-- end
|
|
-- end
|
|
--
|
|
-- mobs:capture_mob(self, clicker, 0, 5, 80, false, nil)
|
|
--end
|
|
|
|
|
|
local drops = {
|
|
digger = {
|
|
{name = "default:mossycobble", chance = 1, min = 1, max = 3},
|
|
},
|
|
cobbler = {
|
|
{name = "fun_caves:glowing_fungus", chance = 1, min = 2, max = 5},
|
|
},
|
|
coal = {
|
|
{name = "default:coal_lump", chance = 1, min = 1, max = 3},
|
|
},
|
|
copper = {
|
|
{name = "default:copper_lump", chance = 1, min = 1, max = 3},
|
|
},
|
|
diamond = {
|
|
{name = "default:diamond", chance = 5, min = 1, max = 3},
|
|
},
|
|
gold = {
|
|
{name = "default:gold_lump", chance = 1, min = 1, max = 3},
|
|
},
|
|
ice = {
|
|
{name = "default:coal_lump", chance = 1, min = 1, max = 3},
|
|
},
|
|
iron = {
|
|
{name = "default:iron_lump", chance = 1, min = 1, max = 3},
|
|
},
|
|
king = {
|
|
{name = "default:mese_crystal", chance = 1, min = 1, max = 3},
|
|
},
|
|
}
|
|
for name, drop in pairs(drops) do
|
|
if name == 'digger' or name == 'cobbler' or name == 'coal' or name == 'ice' then
|
|
drop[#drop+1] = {name = "default:pick_stone", chance = 3, min = 1, max = 3}
|
|
drop[#drop+1] = {name = "default:sword_stone", chance = 5, min = 1, max = 1}
|
|
elseif name == 'copper' or name == 'iron' then
|
|
drop[#drop+1] = {name = "default:pick_steel", chance = 3, min = 1, max = 3}
|
|
drop[#drop+1] = {name = "default:sword_steel", chance = 5, min = 1, max = 1}
|
|
elseif name == 'diamond' or name == 'gold' then
|
|
drop[#drop+1] = {name = "default:pick_diamond", chance = 3, min = 1, max = 3}
|
|
drop[#drop+1] = {name = "default:sword_diamond", chance = 5, min = 1, max = 1}
|
|
elseif name == 'king' then
|
|
drop[#drop+1] = {name = "default:pick_mese", chance = 3, min = 1, max = 3}
|
|
drop[#drop+1] = {name = "default:sword_mese", chance = 5, min = 1, max = 1}
|
|
end
|
|
|
|
drop[#drop+1] = {name = "fun_caves:mushroom_steak", chance = 2, min = 1, max = 2}
|
|
drop[#drop+1] = {name = "default:torch", chance = 3, min = 1, max = 10}
|
|
end
|
|
|
|
|
|
mobs:register_mob("fun_caves:goblin_digger", {
|
|
description = "Digger Goblin",
|
|
type = "monster",
|
|
passive = false,
|
|
damage = 1,
|
|
attack_type = "dogfight",
|
|
attacks_monsters = true,
|
|
hp_min = 5,
|
|
hp_max = 10,
|
|
armor = 100,
|
|
fear_height = 4,
|
|
collisionbox = {-0.35,-1,-0.35, 0.35,-.1,0.35},
|
|
visual = "mesh",
|
|
mesh = "goblins_goblin.b3d",
|
|
drawtype = "front",
|
|
textures = {
|
|
{"goblins_goblin_digger.png"},
|
|
},
|
|
makes_footstep_sound = true,
|
|
sounds = {
|
|
random = "goblins_goblin_ambient",
|
|
warcry = "goblins_goblin_attack",
|
|
attack = "goblins_goblin_attack",
|
|
damage = "goblins_goblin_damage",
|
|
death = "goblins_goblin_death",
|
|
distance = 15,
|
|
},
|
|
walk_velocity = 2,
|
|
run_velocity = 3,
|
|
jump = true,
|
|
drops = drops['digger'],
|
|
water_damage = 1,
|
|
lava_damage = 2,
|
|
light_damage = 0,
|
|
--lifetimer = 360,
|
|
follow = {"default:diamond"},
|
|
view_range = 10,
|
|
owner = "",
|
|
order = "follow",
|
|
animation = {
|
|
speed_normal = 30,
|
|
speed_run = 30,
|
|
stand_start = 0,
|
|
stand_end = 79,
|
|
walk_start = 168,
|
|
walk_end = 187,
|
|
run_start = 168,
|
|
run_end = 187,
|
|
punch_start = 200,
|
|
punch_end = 219,
|
|
},
|
|
on_rightclick = nil,
|
|
do_custom = goblin_do,
|
|
})
|
|
|
|
mobs:register_egg("fun_caves:goblin_digger", "Goblin Egg (digger)", "default_mossycobble.png", 1)
|
|
mobs:register_spawn("fun_caves:goblin_digger", {'fun_caves:stone_with_algae', 'fun_caves:stone_with_lichen'}, 100, 0, 30 * spawn_frequency, 3, 2000)
|
|
mobs:register_spawn("fun_caves:goblin_digger", {"default:mossycobble"}, 100, 0, 3 * spawn_frequency, 3, 2000)
|
|
|
|
|
|
local m = table.copy(minetest.registered_entities["fun_caves:goblin_digger"])
|
|
m.name = 'fun_caves:goblin_cobbler'
|
|
m.textures = { {"goblins_goblin_cobble1.png"}, {"goblins_goblin_cobble2.png"}, }
|
|
m.base_texture = m.textures[1]
|
|
m.drops = drops['cobbler']
|
|
minetest.registered_entities["fun_caves:goblin_cobbler"] = m
|
|
mobs.spawning_mobs["fun_caves:goblin_cobbler"] = true
|
|
|
|
mobs:register_spawn("fun_caves:goblin_cobbler", {'fun_caves:stone_with_algae', 'fun_caves:stone_with_lichen'}, 100, 0, 30 * spawn_frequency, 3, 2000)
|
|
mobs:register_spawn("fun_caves:goblin_cobbler", {"default:mossycobble"}, 100, 0, 3 * spawn_frequency, 3, 2000)
|
|
mobs:register_egg("fun_caves:goblin_cobbler", "Goblin Egg (cobbler)", "default_mossycobble.png", 1)
|
|
|
|
|
|
local m = table.copy(minetest.registered_entities["fun_caves:goblin_digger"])
|
|
m.name = 'fun_caves:goblin_coal'
|
|
m.hp_min = 7
|
|
m.hp_max = 15
|
|
m.armor = 90
|
|
m.textures = { {"goblins_goblin_coal1.png"}, {"goblins_goblin_coal2.png"}, }
|
|
m.base_texture = m.textures[1]
|
|
m.drops = drops['coal']
|
|
minetest.registered_entities["fun_caves:goblin_coal"] = m
|
|
mobs.spawning_mobs["fun_caves:goblin_coal"] = true
|
|
|
|
mobs:register_spawn("fun_caves:goblin_coal", {"default:mossycobble"}, 100, 0, 4 * spawn_frequency, 3, 2000)
|
|
mobs:register_egg("fun_caves:goblin_coal", "Goblin Egg (coal)", "default_mossycobble.png", 1)
|
|
|
|
|
|
local m = table.copy(minetest.registered_entities["fun_caves:goblin_digger"])
|
|
m.name = 'fun_caves:goblin_copper'
|
|
m.damage = 2
|
|
m.hp_min = 7
|
|
m.hp_max = 15
|
|
m.armor = 70
|
|
m.textures = { {"goblins_goblin_copper1.png"}, {"goblins_goblin_copper2.png"}, }
|
|
m.base_texture = m.textures[1]
|
|
m.drops = drops['copper']
|
|
minetest.registered_entities["fun_caves:goblin_copper"] = m
|
|
mobs.spawning_mobs["fun_caves:goblin_copper"] = true
|
|
|
|
mobs:register_spawn("fun_caves:goblin_copper", {"default:mossycobble"}, 100, 0, 6 * spawn_frequency, 3, 2000)
|
|
mobs:register_egg("fun_caves:goblin_copper", "Goblin Egg (copper)", "default_mossycobble.png", 1)
|
|
|
|
|
|
local m = table.copy(minetest.registered_entities["fun_caves:goblin_digger"])
|
|
m.name = 'fun_caves:goblin_diamond'
|
|
m.damage = 3
|
|
m.hp_min = 7
|
|
m.hp_max = 15
|
|
m.armor = 50
|
|
m.textures = { {"goblins_goblin_diamond1.png"}, {"goblins_goblin_diamond2.png"}, }
|
|
m.base_texture = m.textures[1]
|
|
m.drops = drops['diamond']
|
|
minetest.registered_entities["fun_caves:goblin_diamond"] = m
|
|
mobs.spawning_mobs["fun_caves:goblin_diamond"] = true
|
|
|
|
mobs:register_spawn("fun_caves:goblin_diamond", {"default:mossycobble"}, 100, 0, 8 * spawn_frequency, 3, 2000)
|
|
mobs:register_egg("fun_caves:goblin_diamond", "Goblin Egg (diamond)", "default_mossycobble.png", 1)
|
|
|
|
|
|
local m = table.copy(minetest.registered_entities["fun_caves:goblin_digger"])
|
|
m.name = 'fun_caves:goblin_gold'
|
|
m.damage = 3
|
|
m.hp_min = 7
|
|
m.hp_max = 15
|
|
m.armor = 60
|
|
m.textures = { {"goblins_goblin_gold1.png"}, {"goblins_goblin_gold2.png"}, }
|
|
m.base_texture = m.textures[1]
|
|
m.drops = drops['gold']
|
|
minetest.registered_entities["fun_caves:goblin_gold"] = m
|
|
mobs.spawning_mobs["fun_caves:goblin_gold"] = true
|
|
|
|
mobs:register_spawn("fun_caves:goblin_gold", {"default:mossycobble"}, 100, 0, 7 * spawn_frequency, 3, 2000)
|
|
mobs:register_egg("fun_caves:goblin_gold", "Goblin Egg (gold)", "default_mossycobble.png", 1)
|
|
|
|
|
|
local m = table.copy(minetest.registered_entities["fun_caves:goblin_digger"])
|
|
m.name = 'fun_caves:goblin_ice'
|
|
m.textures = { {"fun_caves_goblin_ice2.png"}, }
|
|
m.base_texture = m.textures[1]
|
|
m.drops = drops['ice']
|
|
minetest.registered_entities["fun_caves:goblin_ice"] = m
|
|
mobs.spawning_mobs["fun_caves:goblin_ice"] = true
|
|
|
|
mobs:register_spawn("fun_caves:goblin_ice", {"default:ice"}, 100, 0, 20 * spawn_frequency, 3, 2000)
|
|
mobs:register_egg("fun_caves:goblin_ice", "Goblin Egg (ice)", "default_mossycobble.png", 1)
|
|
|
|
|
|
local m = table.copy(minetest.registered_entities["fun_caves:goblin_digger"])
|
|
m.name = 'fun_caves:goblin_iron'
|
|
m.damage = 2
|
|
m.hp_min = 7
|
|
m.hp_max = 15
|
|
m.armor = 80
|
|
m.textures = { {"goblins_goblin_iron1.png"}, {"goblins_goblin_iron2.png"}, }
|
|
m.base_texture = m.textures[1]
|
|
m.drops = drops['iron']
|
|
minetest.registered_entities["fun_caves:goblin_iron"] = m
|
|
mobs.spawning_mobs["fun_caves:goblin_iron"] = true
|
|
|
|
mobs:register_spawn("fun_caves:goblin_iron", {"default:mossycobble"}, 100, 0, 5 * spawn_frequency, 3, 2000)
|
|
mobs:register_egg("fun_caves:goblin_iron", "Goblin Egg (iron)", "default_mossycobble.png", 1)
|
|
|
|
|
|
local m = table.copy(minetest.registered_entities["fun_caves:goblin_digger"])
|
|
m.name = 'fun_caves:goblin_king'
|
|
m.damage = 3
|
|
m.hp_min = 10
|
|
m.hp_max = 20
|
|
m.armor = 40
|
|
m.textures = { {"goblins_goblin_king.png"}, }
|
|
m.base_texture = m.textures[1]
|
|
m.drops = drops['king']
|
|
minetest.registered_entities["fun_caves:goblin_king"] = m
|
|
mobs.spawning_mobs["fun_caves:goblin_king"] = true
|
|
|
|
mobs:register_spawn("fun_caves:goblin_king", {"default:mossycobble"}, 100, 0, 9 * spawn_frequency, 3, 2000)
|
|
mobs:register_egg("fun_caves:goblin_king", "Goblin Egg (king)", "default_mossycobble.png", 1)
|
|
|
|
|
|
---------------------------------------------------------------
|
|
-- Traps
|
|
---------------------------------------------------------------
|
|
|
|
minetest.register_node("fun_caves:mossycobble_trap", {
|
|
description = "Messy Gobblestone",
|
|
tiles = {"default_mossycobble.png"},
|
|
is_ground_content = false,
|
|
groups = {cracky = 2, stone = 1, trap = 1},
|
|
sounds = default.node_sound_stone_defaults(),
|
|
paramtype = "light",
|
|
light_source = 4,
|
|
})
|
|
|
|
minetest.register_craft({
|
|
type = "cooking",
|
|
output = "default:stone",
|
|
recipe = "fun_caves:mossycobble_trap",
|
|
})
|
|
|
|
minetest.register_node("fun_caves:stone_with_coal_trap", {
|
|
description = "Coal Trap",
|
|
tiles = {"default_cobble.png^default_mineral_coal.png"},
|
|
groups = {cracky = 3, trap = 1},
|
|
drop = 'default:coal_lump',
|
|
is_ground_content = false,
|
|
sounds = default.node_sound_stone_defaults(),
|
|
})
|
|
|
|
if minetest.registered_nodes['tnt:tnt_burning'] then
|
|
-- 5... 4... 3... 2... 1...
|
|
fun_caves.diamond_trap = function(pos, player)
|
|
if not (pos and player) then
|
|
return
|
|
end
|
|
|
|
minetest.set_node(pos, {name="tnt:tnt_burning"})
|
|
local timer = minetest.get_node_timer(pos)
|
|
if timer then
|
|
timer:start(5)
|
|
end
|
|
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
|
end
|
|
else
|
|
-- wimpier trap for non-tnt settings
|
|
fun_caves.diamond_trap = function(pos, player)
|
|
if not (pos and player) then
|
|
return
|
|
end
|
|
|
|
minetest.set_node(pos, {name="default:lava_source"})
|
|
local hp = player:get_hp()
|
|
if hp > 0 then
|
|
player:set_hp(hp - 2)
|
|
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
|
end
|
|
end
|
|
end
|
|
|
|
minetest.register_node("fun_caves:stone_with_diamond_trap", {
|
|
description = "Diamond Trap",
|
|
tiles = {"default_cobble.png^(default_mineral_diamond.png^[colorize:#000000:160)"},
|
|
groups = {cracky = 3, trap = 1},
|
|
drop = 'default:diamond',
|
|
is_ground_content = false,
|
|
sounds = default.node_sound_stone_defaults(),
|
|
on_dig = function(pos, node, digger)
|
|
if not (pos and digger) then
|
|
return
|
|
end
|
|
|
|
if math.random(3) == 1 then
|
|
fun_caves.diamond_trap(pos, digger)
|
|
else
|
|
minetest.node_dig(pos, node, digger)
|
|
end
|
|
end
|
|
})
|
|
|
|
|
|
newnode = fun_caves.clone_node("default:lava_source")
|
|
newnode.description = "Molten Gold Source"
|
|
newnode.wield_image = "goblins_molten_gold.png"
|
|
newnode.tiles[1].name = "goblins_molten_gold_source_animated.png"
|
|
newnode.special_tiles[1].name = "goblins_molten_gold_source_animated.png"
|
|
newnode.liquid_alternative_flowing = "fun_caves:molten_gold_flowing"
|
|
newnode.liquid_alternative_source = "fun_caves:molten_gold_source"
|
|
newnode.liquid_renewable = false
|
|
newnode.post_effect_color = {a=192, r=255, g=64, b=0}
|
|
minetest.register_node("fun_caves:molten_gold_source", newnode)
|
|
|
|
newnode = fun_caves.clone_node("default:lava_flowing")
|
|
newnode.description = "Flowing Molten Gold"
|
|
newnode.wield_image = "goblins_molten_gold.png"
|
|
newnode.tiles = {"goblins_molten_gold.png"}
|
|
newnode.special_tiles[1].name = "goblins_molten_gold_flowing_animated.png"
|
|
newnode.liquid_alternative_flowing = "fun_caves:molten_gold_flowing"
|
|
newnode.liquid_alternative_source = "fun_caves:molten_gold_source"
|
|
newnode.liquid_renewable = false
|
|
newnode.post_effect_color = {a=192, r=255, g=64, b=0}
|
|
minetest.register_node("fun_caves:molten_gold_flowing", newnode)
|
|
|
|
bucket.register_liquid(
|
|
"fun_caves:molten_gold_source",
|
|
"fun_caves:molten_gold_flowing",
|
|
"fun_caves:bucket_molten_gold",
|
|
"fun_caves_bucket_molten_gold.png",
|
|
"Bucket of Molten Gold",
|
|
{}
|
|
)
|
|
|
|
fun_caves.gold_trap = function(pos, player)
|
|
if not (pos and player) then
|
|
return
|
|
end
|
|
|
|
minetest.set_node(pos, {name="fun_caves:molten_gold_source"})
|
|
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
|
local hp = player:get_hp()
|
|
if hp > 0 then
|
|
player:set_hp(hp - 2)
|
|
end
|
|
end
|
|
|
|
minetest.register_node("fun_caves:stone_with_gold_trap", {
|
|
description = "Gold Trap",
|
|
tiles = {"default_cobble.png^(default_mineral_gold.png^[colorize:#000000:160)"},
|
|
groups = {cracky = 3, trap = 1},
|
|
drop = 'default:gold_lump',
|
|
is_ground_content = false,
|
|
sounds = default.node_sound_stone_defaults(),
|
|
on_dig = function(pos, node, digger)
|
|
if not (pos and digger) then
|
|
return
|
|
end
|
|
|
|
if math.random(3) == 1 then
|
|
fun_caves.gold_trap(pos, digger)
|
|
else
|
|
minetest.node_dig(pos, node, digger)
|
|
end
|
|
end
|
|
})
|
|
|
|
|
|
fun_caves.ice_trap = function(pos, player)
|
|
if not (pos and player) then
|
|
return
|
|
end
|
|
|
|
local ppos = player:getpos()
|
|
if ppos then
|
|
ppos.y = ppos.y + 1
|
|
local p1 = vector.subtract(ppos, 2)
|
|
local p2 = vector.add(ppos, 2)
|
|
local nodes = minetest.find_nodes_in_area(p1, p2, 'air')
|
|
if not (nodes and type(nodes) == 'table') then
|
|
return
|
|
end
|
|
|
|
for _, npos in pairs(nodes) do
|
|
minetest.set_node(npos, {name="default:ice"})
|
|
end
|
|
|
|
minetest.set_node(pos, {name="default:ice"})
|
|
end
|
|
end
|
|
|
|
minetest.register_node("fun_caves:ice_trap", {
|
|
description = "Ice Trap",
|
|
tiles = {"default_ice.png^fun_caves_mineral_moonstone.png"},
|
|
groups = {cracky = 3, trap = 1},
|
|
drop = 'default:ice',
|
|
is_ground_content = false,
|
|
sounds = default.node_sound_stone_defaults(),
|
|
on_dig = function(pos, node, digger)
|
|
if not (pos and digger) then
|
|
return
|
|
end
|
|
|
|
if math.random(3) == 1 then
|
|
fun_caves.ice_trap(pos, digger)
|
|
else
|
|
minetest.node_dig(pos, node, digger)
|
|
end
|
|
end
|
|
})
|
|
|
|
|
|
local function lightning_effects(pos, radius)
|
|
if not (pos and radius) then
|
|
return
|
|
end
|
|
|
|
minetest.add_particlespawner({
|
|
amount = 30,
|
|
time = 1,
|
|
minpos = vector.subtract(pos, radius / 2),
|
|
maxpos = vector.add(pos, radius / 2),
|
|
minvel = {x=-10, y=-10, z=-10},
|
|
maxvel = {x=10, y=10, z=10},
|
|
minacc = vector.new(),
|
|
maxacc = vector.new(),
|
|
minexptime = 1,
|
|
maxexptime = 3,
|
|
minsize = 16,
|
|
maxsize = 32,
|
|
texture = "goblins_lightning.png",
|
|
})
|
|
end
|
|
|
|
fun_caves.copper_trap = function(pos, player)
|
|
if not (pos and player) then
|
|
return
|
|
end
|
|
|
|
local hp = player:get_hp()
|
|
if hp > 0 then
|
|
player:set_hp(hp - 1)
|
|
lightning_effects(pos, 3)
|
|
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
|
|
end
|
|
end
|
|
|
|
minetest.register_node("fun_caves:stone_with_copper_trap", {
|
|
description = "Copper Trap",
|
|
tiles = {"default_cobble.png^(default_mineral_copper.png^[colorize:#000000:160)"},
|
|
groups = {cracky = 3, trap = 1},
|
|
drop = 'default:copper_lump',
|
|
is_ground_content = false,
|
|
sounds = default.node_sound_stone_defaults(),
|
|
on_dig = function(pos, node, digger)
|
|
if not (pos and digger) then
|
|
return
|
|
end
|
|
|
|
if math.random(3) == 1 then
|
|
fun_caves.copper_trap(pos, digger)
|
|
else
|
|
minetest.node_dig(pos, node, digger)
|
|
end
|
|
end
|
|
})
|
|
|
|
|
|
-- summon a metallic goblin?
|
|
-- pit of iron razors?
|
|
minetest.register_node("fun_caves:stone_with_iron_trap", {
|
|
description = "Iron Trap",
|
|
tiles = {"default_cobble.png^(default_mineral_iron.png^[colorize:#000000:160)"},
|
|
groups = {cracky = 3, trap = 1},
|
|
drop = 'default:iron_lump',
|
|
is_ground_content = false,
|
|
sounds = default.node_sound_stone_defaults(),
|
|
on_dig = function(pos, node, digger)
|
|
if not (pos and digger) then
|
|
return
|
|
end
|
|
|
|
if math.random(3) == 1 then
|
|
fun_caves.copper_trap(pos, digger)
|
|
else
|
|
minetest.node_dig(pos, node, digger)
|
|
end
|
|
end
|
|
})
|