added traps
parent
c7af77673a
commit
f73e600bba
|
@ -0,0 +1,18 @@
|
|||
Minetest-Traps-Mod
|
||||
==================
|
||||
|
||||
This is a mod for Minetest-c55 that adds booby traps to the game. Made for the Hunger Games Server by "Rubenwardy"
|
||||
|
||||
|
||||
The Blocks
|
||||
==========
|
||||
|
||||
* Mine Trap - A mine disguised as a dirt_with_grass block
|
||||
-
|
||||
http://multa.bugs3.com/minetest/mods/traps_scrn_mine.jpg
|
||||
|
||||
|
||||
|
||||
* Cage Trap - A cage trap that traps the player and requires another player to resque them
|
||||
-
|
||||
http://multa.bugs3.com/minetest/mods/traps_scrn_cage.jpg
|
|
@ -0,0 +1,178 @@
|
|||
-- Rubenwardy's Trap Mod
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
-- Cage Trap
|
||||
|
||||
|
||||
minetest.register_node("traps:cage",{
|
||||
tile_images = {"default_grass.png", "default_dirt.png",
|
||||
"default_grass_side.png", "default_grass_side.png",
|
||||
"default_grass_side.png", "default_grass_side.png"},
|
||||
inventory_image = minetest.inventorycube("default_grass.png",
|
||||
"default_grass_side.png", "default_grass_side.png"),
|
||||
dug_item = '', -- Get nothing
|
||||
groups={immortal},
|
||||
description = "Cage Trap",
|
||||
})
|
||||
|
||||
minetest.register_node("traps:uncage",{
|
||||
tile_images = {"trap_uncage.png"},
|
||||
inventory_image = minetest.inventorycube("trap_uncage.png",
|
||||
"trap_uncage.png", "trap_uncage.png"),
|
||||
dug_item = '', -- Get nothing
|
||||
groups={immortal},
|
||||
description = "Cage Trap Release",
|
||||
})
|
||||
|
||||
local block_to_place="moreblocks:superglowglass"
|
||||
|
||||
minetest.register_abm(
|
||||
{nodenames = {"traps:cage"},
|
||||
interval = 0.2,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
print("HIT!")
|
||||
--local objpos=obj:getpos()
|
||||
|
||||
local tmp
|
||||
|
||||
minetest.env:add_node(pos,{name=block_to_place})
|
||||
|
||||
--Left
|
||||
print("Left")
|
||||
tmp={x=(pos.x+1),y=(pos.y+1),z=(pos.z)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Right
|
||||
print("right")
|
||||
tmp={x=(pos.x-1),y=(pos.y+1),z=(pos.z)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Front
|
||||
print("front")
|
||||
tmp={x=(pos.x),y=(pos.y+1),z=(pos.z+1)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Back
|
||||
print("back")
|
||||
tmp={x=(pos.x),y=(pos.y+1),z=(pos.z-1)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Left
|
||||
print("Left")
|
||||
tmp={x=(pos.x+1),y=(pos.y+2),z=(pos.z)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Right
|
||||
print("right")
|
||||
tmp={x=(pos.x-1),y=(pos.y+2),z=(pos.z)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Front
|
||||
print("front")
|
||||
tmp={x=(pos.x),y=(pos.y+2),z=(pos.z+1)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Back
|
||||
print("back")
|
||||
tmp={x=(pos.x),y=(pos.y+2),z=(pos.z-1)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Top
|
||||
print("top")
|
||||
tmp={x=(pos.x),y=(pos.y+3),z=(pos.z)}
|
||||
minetest.env:add_node(tmp,{name=block_to_place})
|
||||
|
||||
--Release
|
||||
print("release")
|
||||
tmp={x=(pos.x+1),y=(pos.y),z=(pos.z+1)}
|
||||
minetest.env:add_node(tmp,{name="traps:uncage"})
|
||||
|
||||
--if objpos.y>pos.y-1 and objpos.y<pos.y then
|
||||
-- local tmp
|
||||
-- minetest.env:add_node(tmp,{name=block_to_place})
|
||||
--end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Rubenwardy's Trap Mod
|
||||
--
|
||||
--
|
||||
--
|
||||
--
|
||||
-- Decage
|
||||
|
||||
local air_to_place="air"
|
||||
|
||||
minetest.register_abm(
|
||||
{nodenames = {"traps:uncage"},
|
||||
interval = 0.2,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
print("HIT!")
|
||||
--local objpos=obj:getpos()
|
||||
|
||||
local tmp
|
||||
|
||||
minetest.env:add_node(pos,{name="default:dirt"})
|
||||
|
||||
--Left
|
||||
print("Left")
|
||||
tmp={x=(pos.x),y=(pos.y+1),z=(pos.z-1)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
--Right
|
||||
print("right")
|
||||
tmp={x=(pos.x-2),y=(pos.y+1),z=(pos.z-1)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
--Front
|
||||
print("front")
|
||||
tmp={x=(pos.x-1),y=(pos.y+1),z=(pos.z)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
--Back
|
||||
print("back")
|
||||
tmp={x=(pos.x-1),y=(pos.y+1),z=(pos.z-2)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
--Left
|
||||
print("Left")
|
||||
tmp={x=(pos.x),y=(pos.y+2),z=(pos.z-1)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
--Right
|
||||
print("right")
|
||||
tmp={x=(pos.x-2),y=(pos.y+2),z=(pos.z-1)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
--Front
|
||||
print("front")
|
||||
tmp={x=(pos.x-1),y=(pos.y+2),z=(pos.z)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
--Back
|
||||
print("back")
|
||||
tmp={x=(pos.x-1),y=(pos.y+2),z=(pos.z-2)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
--Top
|
||||
print("top")
|
||||
tmp={x=(pos.x-1),y=(pos.y+3),z=(pos.z-1)}
|
||||
minetest.env:add_node(tmp,{name=air_to_place})
|
||||
|
||||
-- Floor
|
||||
print("release")
|
||||
tmp={x=(pos.x-1),y=(pos.y),z=(pos.z-1)}
|
||||
minetest.env:add_node(tmp,{name="default:dirt"})
|
||||
|
||||
end
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
moreblocks
|
|
@ -0,0 +1,18 @@
|
|||
dofile(minetest.get_modpath("traps").."/mine.lua")
|
||||
dofile(minetest.get_modpath("traps").."/cage.lua")
|
||||
|
||||
minetest.register_craft({
|
||||
output="traps:cage",
|
||||
recipe={
|
||||
{"","default:mese",""},
|
||||
{"","default:mese",""},
|
||||
{"","default:dirt",""}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output="traps:mine",
|
||||
recipe={
|
||||
{"","default:coal_lump",""},
|
||||
{"","default:coal_lump",""},
|
||||
{"default:mese","default:dirt","default:mese"}}
|
||||
})
|
|
@ -0,0 +1,100 @@
|
|||
function spawn_tnt(pos, entname)
|
||||
minetest.sound_play("nuke_ignite", {pos = pos,gain = 1.0,max_hear_distance = 8,})
|
||||
return minetest.env:add_entity(pos, entname)
|
||||
end
|
||||
|
||||
function activate_if_tnt(nname, np, tnt_np, tntr)
|
||||
if nname == "experimental:tnt" or nname == "traps:mine" or nname == "nuke:mese_tnt" or nname == "nuke:hardcore_iron_tnt" or nname == "nuke:hardcore_mese_tnt" then
|
||||
local e = spawn_tnt(np, nname)
|
||||
e:setvelocity({x=(np.x - tnt_np.x)*3+(tntr / 4), y=(np.y - tnt_np.y)*3+(tntr / 3), z=(np.z - tnt_np.z)*3+(tntr / 4)})
|
||||
end
|
||||
end
|
||||
|
||||
function do_tnt_physics(tnt_np,tntr)
|
||||
local objs = minetest.env:get_objects_inside_radius(tnt_np, tntr)
|
||||
for k, obj in pairs(objs) do
|
||||
local oname = obj:get_entity_name()
|
||||
local v = obj:getvelocity()
|
||||
local p = obj:getpos()
|
||||
if oname == "experimental:tnt" or oname == "traps:mine" or oname == "nuke:mese_tnt" or oname == "nuke:hardcore_iron_tnt" or oname == "nuke:hardcore_mese_tnt" then
|
||||
obj:setvelocity({x=(p.x - tnt_np.x) + (tntr / 2) + v.x, y=(p.y - tnt_np.y) + tntr + v.y, z=(p.z - tnt_np.z) + (tntr / 2) + v.z})
|
||||
else
|
||||
if v ~= nil then
|
||||
obj:setvelocity({x=(p.x - tnt_np.x) + (tntr / 4) + v.x, y=(p.y - tnt_np.y) + (tntr / 2) + v.y, z=(p.z - tnt_np.z) + (tntr / 4) + v.z})
|
||||
else
|
||||
if obj:get_player_name() ~= nil then
|
||||
obj:set_hp(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("traps:mine", {
|
||||
tile_images = {"default_grass.png", "default_dirt.png",
|
||||
"default_grass_side.png", "default_grass_side.png",
|
||||
"default_grass_side.png", "default_grass_side.png"},
|
||||
inventory_image = minetest.inventorycube("default_grass.png",
|
||||
"nuke_iron_tnt_side.png", "nuke_iron_tnt_side.png"),
|
||||
dug_item = '', -- Get nothing
|
||||
material = {
|
||||
diggability = "not",
|
||||
},
|
||||
description = "Minetrap",
|
||||
})
|
||||
|
||||
|
||||
|
||||
local IRON_TNT_RANGE = 3
|
||||
local IRON_TNT = {
|
||||
-- Static definition
|
||||
physical = true, -- Collides with things
|
||||
-- weight = 5,
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "cube",
|
||||
textures = {"nuke_iron_tnt_top.png", "nuke_iron_tnt_bottom.png",
|
||||
"nuke_iron_tnt_side.png", "nuke_iron_tnt_side.png",
|
||||
"nuke_iron_tnt_side.png", "nuke_iron_tnt_side.png"},
|
||||
-- Initial value for our timer
|
||||
timer = 0,
|
||||
-- Number of punches required to defuse
|
||||
health = 1,
|
||||
blinktimer = 0,
|
||||
blinkstatus = true,
|
||||
}
|
||||
|
||||
minetest.register_abm(
|
||||
{nodenames = {"traps:mine"},
|
||||
interval = 0.2,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
print("HIT!")
|
||||
|
||||
for x=-IRON_TNT_RANGE,IRON_TNT_RANGE do
|
||||
for y=-IRON_TNT_RANGE,IRON_TNT_RANGE do
|
||||
for z=-IRON_TNT_RANGE,IRON_TNT_RANGE do
|
||||
if x*x+y*y+z*z <= IRON_TNT_RANGE * IRON_TNT_RANGE + IRON_TNT_RANGE then
|
||||
local np={x=pos.x+x,y=pos.y+y,z=pos.z+z}
|
||||
local n = minetest.env:get_node(np)
|
||||
if n.name ~= "air" then
|
||||
minetest.env:remove_node(np)
|
||||
end
|
||||
--activate_if_tnt(n.name, np, pos, IRON_TNT_RANGE)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if obj:get_player_name() ~= nil then
|
||||
obj:set_hp(obj:get_hp() - 10)
|
||||
end
|
||||
minetest.env:add_node(pos,{name="air"})
|
||||
--self.object:remove()
|
||||
--minetest.env:remove_node(pos)
|
||||
--spawn_tnt(pos, "nuke:iron_tnt")
|
||||
--nodeupdate(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 978 B |
Binary file not shown.
After Width: | Height: | Size: 604 B |
Loading…
Reference in New Issue