Goblins make traps!

master
FreeLikeGNU 2015-09-06 10:02:57 -07:00
parent 71617992a1
commit b3abdac5a8
6 changed files with 183 additions and 13 deletions

View File

@ -29,6 +29,7 @@ http://creativecommons.org/licenses/by-sa/3.0/
* Sound files by:
* artisticdude http://opengameart.org/content/goblins-sound-pack CC0-license
* Ogrebane http://opengameart.org/content/monster-sound-pack-volume-1 CC0-license
* spookymodem http://opengameart.org/content/mining-pick CC-BY 3.0
* Thanks to Napiophelios for the goblin king skin
https://forum.minetest.net/viewtopic.php?f=9&t=13004#p186921

23
api.lua
View File

@ -77,6 +77,9 @@ function mobs_goblins:register_mob(name, def)
-- what nodes will be replaced?
replace_what = def.replace_what,
replace_with = def.replace_with,
-- or maybe something different?
replace_rate_secondary = def.replace_rate_secondary or 0,
replace_with_secondary = def.replace_with_secondary or def.replace_with,
timer = 0,
env_damage_timer = 0, -- only if state = "attack"
attack = {player=nil, dist=nil},
@ -249,10 +252,22 @@ function mobs_goblins:register_mob(name, def)
for key,value in pairs(nodelist) do
-- ok we see some nodes around us, are we going to replace them?
if math.random(1,self.replace_rate) == 1 then
if self.debugging_goblins == true then
print(self.replace_with.." placed")
end
minetest.set_node(value, {name = self.replace_with})
minetest.after(.1, function()
if math.random(1,self.replace_rate_secondary) == 1 then
minetest.set_node(value, {name = self.replace_with_secondary})
else
minetest.set_node(value, {name = self.replace_with})
end
if self.debugging_goblins == true then
print(self.replace_with.." placed")
end
minetest.sound_play(self.sounds.replace, {
object = self.object,
max_hear_distance = self.sounds.distance })
end)
--wait self.replace_delay
end
end
end

140
goblin_traps.lua Normal file
View File

@ -0,0 +1,140 @@
--[[some nasty things goblins can do]]
minetest.register_node("mobs_goblins:mossycobble_trap", {
description = "Messy Gobblestone",
tiles = {"default_mossycobble.png"},
is_ground_content = false,
groups = {cracky = 2, stone = 1},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("mobs_goblins:stone_with_coal_trap", {
description = "Iron Gore",
tiles = {"default_cobble.png^default_mineral_coal.png"},
groups = {cracky = 1, level = 2},
drop = 'default:iron_lump',
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("mobs_goblins:stone_with_iron_trap", {
description = "Iron Gore",
tiles = {"default_cobble.png^default_mineral_iron.png"},
groups = {cracky = 1, level = 2},
drop = 'default:iron_lump',
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("mobs_goblins:stone_with_gold_trap", {
description = "Gold Gore",
tiles = {"default_cobble.png^default_mineral_gold.png"},
groups = {cracky = 1,level = 2},
drop = 'default:gold_lump',
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("mobs_goblins:stone_with_diamond_trap", {
description = "Diamond Gore",
tiles = {"default_cobble.png^default_mineral_diamond.png"},
groups = {cracky = 1, level = 3},
drop = 'default:diamond',
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
--[[ too bad we can't keep track of what physics are set too by other mods...]]
minetest.register_abm({
nodenames = {"mobs_goblins:mossycobble_trap"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
--pos.y =pos.y-0.4
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 15.1/16)) do -- IDKWTF this is but it works
if object:is_player() then
--player_speed = object:get_physics_override({speed}) -- this can get out of control
object:set_physics_override({speed = .1})
minetest.after(1, function() -- this effect is temporary
object:set_physics_override({speed = 1}) -- we'll just set it to 1 and be done.
end)
end
end
end})
--[[ based on dwarves cactus]]
minetest.register_abm({
nodenames = {"mobs_goblins:stone_with_coal_trap"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
--pos.y =pos.y-0.4
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do--1.3
if object:is_player() then
if object:get_hp() > 0 then
object:set_hp(object:get_hp()-1)
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
end
end
--elseif not object:is_player() and object:get_hp() == 0 and object:get_luaentity().name ~= "__builtin:item" then
-- object:remove()
--end
end
end})
minetest.register_abm({
nodenames = {"mobs_goblins:stone_with_iron_trap"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
--pos.y =pos.y-0.4
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do--1.3
if object:is_player() then
if object:get_hp() > 0 then
object:set_hp(object:get_hp()-1)
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
end
end
--elseif not object:is_player() and object:get_hp() == 0 and object:get_luaentity().name ~= "__builtin:item" then
-- object:remove()
--end
end
end})
minetest.register_abm({
nodenames = {"mobs_goblins:stone_with_gold_trap"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
--pos.y =pos.y-0.4
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do--1.3
if object:is_player() then
if object:get_hp() > 0 then
object:set_hp(object:get_hp()-2)
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
end
end
--elseif not object:is_player() and object:get_hp() == 0 and object:get_luaentity().name ~= "__builtin:item" then
-- object:remove()
--end
end
end})
minetest.register_abm({
nodenames = {"mobs_goblins:stone_with_diamond_trap"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
--pos.y =pos.y-0.4
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do--1.3
if object:is_player() then
if object:get_hp() > 0 then
object:set_hp(object:get_hp()-2)
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5, max_hear_distance = 10})
end
end
--elseif not object:is_player() and object:get_hp() == 0 and object:get_luaentity().name ~= "__builtin:item" then
-- object:remove()
--end
end
end})

View File

@ -1,4 +1,4 @@
-- Npc by TenPlus1 converted for FLG Goblins :D
mobs_goblins.goblin_drops = {
@ -31,6 +31,7 @@ mobs_goblins:register_mob("mobs_goblins:goblin_cobble", {
attack = "goblins_goblin_attack",
damage = "goblins_goblin_damage",
death = "goblins_goblin_death",
replace = "goblins_goblin_pick",
distance = 15,
},
walk_velocity = 2,
@ -59,6 +60,8 @@ mobs_goblins:register_mob("mobs_goblins:goblin_cobble", {
replace_rate = 5,
replace_what = {"default:stone","default:desert_stone","default:torch"},
replace_with = "default:mossycobble",
replace_rate_secondary = 3,
replace_with_secondary = "mobs_goblins:mossycobble_trap",
view_range = 15,
owner = "",
@ -149,6 +152,7 @@ mobs_goblins:register_mob("mobs_goblins:goblin_digger", {
attack = "goblins_goblin_attack",
damage = "goblins_goblin_damage",
death = "goblins_goblin_death",
replace = "goblins_goblin_pick",
distance = 15,
},
walk_velocity = 2,
@ -269,6 +273,7 @@ mobs_goblins:register_mob("mobs_goblins:goblin_coal", {
attack = "goblins_goblin_attack",
damage = "goblins_goblin_damage",
death = "goblins_goblin_death",
replace = "goblins_goblin_pick",
distance = 15,
},
walk_velocity = 2,
@ -296,7 +301,8 @@ mobs_goblins:register_mob("mobs_goblins:goblin_coal", {
replace_rate = 5,
replace_what = {"default:torch","default:stone_with_coal","default:stone", "default:dessert_stone"},
replace_with = "air",
replace_rate_secondary = 3, --or maybe just set a nasty trap
replace_with_secondary = "mobs_goblins:stone_with_coal_trap",
view_range = 15,
owner = "",
order = "follow",
@ -387,6 +393,7 @@ mobs_goblins:register_mob("mobs_goblins:goblin_iron", {
attack = "goblins_goblin_attack",
damage = "goblins_goblin_damage",
death = "goblins_goblin_death",
replace = "goblins_goblin_pick",
distance = 15,
},
walk_velocity = 2,
@ -413,7 +420,9 @@ mobs_goblins:register_mob("mobs_goblins:goblin_iron", {
search_offset_above = 2,
replace_rate = 5,
replace_what = {"default:torch","default:stone_with_iron", "default:stone", "default:dessert_stone"},
replace_with = "air",
replace_with = "air", --steal outright
replace_rate_secondary = 3, --or maybe just set a nasty trap
replace_with_secondary = "mobs_goblins:stone_with_iron_trap",
view_range = 15,
owner = "",
@ -505,6 +514,7 @@ mobs_goblins:register_mob("mobs_goblins:goblin_gold", {
attack = "goblins_goblin_attack",
damage = "goblins_goblin_damage",
death = "goblins_goblin_death",
replace = "goblins_goblin_pick",
distance = 15,
},
walk_velocity = 2,
@ -532,7 +542,8 @@ mobs_goblins:register_mob("mobs_goblins:goblin_gold", {
replace_rate = 5,
replace_what = {"default:torch","default:stone_with_gold", "default:stone", "default:dessert_stone"},
replace_with = "air",
replace_rate_secondary = 4, --or maybe just set a nasty trap
replace_with_secondary = "mobs_goblins:stone_with_gold_trap",
view_range = 15,
owner = "",
order = "follow",
@ -623,6 +634,7 @@ mobs_goblins:register_mob("mobs_goblins:goblin_diamond", {
attack = "goblins_goblin_attack",
damage = "goblins_goblin_damage",
death = "goblins_goblin_death",
replace = "goblins_goblin_pick",
distance = 15,
},
walk_velocity = 2,
@ -650,7 +662,8 @@ mobs_goblins:register_mob("mobs_goblins:goblin_diamond", {
replace_rate = 5,
replace_what = {"default:torch","default:stone_with_diamond", "default:stone", "default:dessert_stone"},
replace_with = "air",
replace_rate_secondary = 3, --or maybe just set a nasty trap
replace_with_secondary = "mobs_goblins:stone_with_diamond_trap",
view_range = 15,
owner = "",
order = "follow",
@ -740,6 +753,7 @@ mobs_goblins:register_mob("mobs_goblins:goblin_king", {
attack = "goblins_goblin_attack",
damage = "goblins_goblin_damage",
death = "goblins_goblin_death",
replace = "goblins_goblin_pick",
distance = 15,
},
walk_velocity = 2,
@ -766,7 +780,7 @@ mobs_goblins:register_mob("mobs_goblins:goblin_king", {
search_offset_above = 2,
replace_rate = 5,
replace_what = {"default:torch", "group:stone"},
replace_with = "default:mossycobble",
replace_with = "default:mossycobble_trap",
view_range = 15,
owner = "",
@ -836,8 +850,8 @@ mobs_goblins:register_mob("mobs_goblins:goblin_king", {
-- spawn at or below 0 near ore and dungeons and goblin lairs (areas of mossy cobble), except diggers that will dig out caves from stone and cobble goblins who create goblin lairs near stone.
--function mobs_goblins:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height)
mobs_goblins:register_spawn("mobs_goblins:goblin_cobble", {"group:stone"}, 100, 0, 20, 3, 0)
mobs_goblins:register_spawn("mobs_goblins:goblin_digger", {"group:stone"}, 100, 0, 20, 3, 0)
mobs_goblins:register_spawn("mobs_goblins:goblin_cobble", {"group:stone"}, 100, 0, 20, 4, 0)
mobs_goblins:register_spawn("mobs_goblins:goblin_digger", {"group:stone"}, 100, 0, 20, 4, 0)
mobs_goblins:register_spawn("mobs_goblins:goblin_coal", {"default:stone_with_coal"}, 100, 0, 1, 3, 0)
mobs_goblins:register_spawn("mobs_goblins:goblin_iron", {"default:stone_with_iron"}, 100, 0, 1, 3, 0)
mobs_goblins:register_spawn("mobs_goblins:goblin_gold", {"default:stone_with_gold" }, 100, 0, 1, 2, 0)

View File

@ -4,7 +4,7 @@ local path = minetest.get_modpath("mobs_goblins")
dofile(path.."/api.lua")
dofile(path.."/goblins.lua") -- TenPlus1 and FreeLikeGNU
dofile(path.."/goblin_traps.lua")
--if minetest.setting_get("log_mods") then
minetest.log("action", "GOBLINS is lowdids!")

Binary file not shown.