add city block jail support
parent
4f05652871
commit
af5d562f9a
39
ball.lua
39
ball.lua
|
@ -8,11 +8,11 @@
|
|||
basic_machines.ball = {};
|
||||
basic_machines.ball.maxdamage = 10; -- player health 20
|
||||
basic_machines.ball.bounce_materials = { -- to be used with bounce setting 2 in ball spawner: 1: bounce in x direction, 2: bounce in z direction, otherwise it bounces in y direction
|
||||
["default:wood"]=1,
|
||||
["xpanes:bar_2"]=1,
|
||||
["xpanes:bar_10"]=1,
|
||||
["darkage:iron_bars"]=1,
|
||||
["default:glass"] = 2,
|
||||
["default:wood"]=1,
|
||||
["xpanes:bar_2"]=1,
|
||||
["xpanes:bar_10"]=1,
|
||||
["darkage:iron_bars"]=1,
|
||||
["default:glass"] = 2,
|
||||
};
|
||||
|
||||
-- END OF SETTINGS
|
||||
|
@ -143,7 +143,7 @@ minetest.register_entity("basic_machines:ball",{
|
|||
local origin = self.origin;
|
||||
|
||||
local r = 30;-- maximal distance when balls disappear
|
||||
local dist = math.max(math.abs(pos.x-origin.x), math.abs(pos.y-origin.y), math.abs(pos.z-origin.z));
|
||||
local dist = math.max(math.abs(pos.x-origin.x), math.abs(pos.y-origin.y), math.abs(pos.z-origin.z));
|
||||
if dist>r then -- remove if it goes too far
|
||||
local count = ballcount[self.owner] or 1; count=count-1; ballcount[self.owner] = count;
|
||||
self.object:remove()
|
||||
|
@ -154,7 +154,7 @@ minetest.register_entity("basic_machines:ball",{
|
|||
local walkable = false;
|
||||
if nodename ~= "air" then
|
||||
walkable = minetest.registered_nodes[nodename].walkable;
|
||||
if nodename == "basic_machines:ball_spawner" and dist>0.5 then walkable = true end -- ball can activate spawner, just not originating one
|
||||
if nodename == "basic_machines:ball_spawner" and dist>0.5 then walkable = true end -- ball can activate spawner, just not originating one
|
||||
end
|
||||
if not walkable then
|
||||
self.lastpos = pos
|
||||
|
@ -169,17 +169,24 @@ minetest.register_entity("basic_machines:ball",{
|
|||
--if minetest.is_protected(p,self.owner) then return end
|
||||
if math.abs(p.x)<32 and math.abs(p.y)<32 and math.abs(p.z)<32 then return end -- no damage around spawn
|
||||
|
||||
if obj:is_player() then --player
|
||||
if obj:is_player() then -- player
|
||||
if obj:get_player_name()==self.owner then break end -- dont hurt owner
|
||||
|
||||
local hp = obj:get_hp()
|
||||
local newhp = hp-self.hurt;
|
||||
if newhp<=0 and boneworld and boneworld.killxp then
|
||||
local killxp = boneworld.killxp[self.owner];
|
||||
if killxp then
|
||||
boneworld.killxp[self.owner] = killxp + 0.01;
|
||||
end
|
||||
|
||||
-- jail time
|
||||
if minetest.global_exists("city_block") then
|
||||
city_block.register_on_punchplayer(
|
||||
obj, -- player
|
||||
minetest.get_player_by_name(self.owner), --hitter
|
||||
nil, -- time_from_last_punch
|
||||
nil, -- tool_capabilities
|
||||
nil, -- dir
|
||||
self.hurt -- damage
|
||||
)
|
||||
end
|
||||
|
||||
obj:set_hp(newhp)
|
||||
else -- non player
|
||||
local lua_entity = obj:get_luaentity();
|
||||
|
@ -196,9 +203,6 @@ minetest.register_entity("basic_machines:ball",{
|
|||
if newhp<=0 then obj:remove() else obj:set_hp(newhp) end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
local count = ballcount[self.owner] or 1; count=count-1; ballcount[self.owner] = count;
|
||||
self.object:remove();
|
||||
return
|
||||
|
@ -212,7 +216,6 @@ minetest.register_entity("basic_machines:ball",{
|
|||
if walkable then -- we hit a node
|
||||
--minetest.chat_send_all(" hit node at " .. minetest.pos_to_string(pos))
|
||||
|
||||
|
||||
local node = minetest.get_node(pos);
|
||||
local table = minetest.registered_nodes[node.name];
|
||||
if table and table.mesecons and table.mesecons.effector then -- activate target
|
||||
|
@ -331,7 +334,7 @@ minetest.register_entity("basic_machines:ball",{
|
|||
|
||||
end
|
||||
end
|
||||
return
|
||||
return
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue