Mobs place bones on death add oerkki
This commit is contained in:
parent
43bd4b7afc
commit
340a7d105b
@ -1,4 +1,4 @@
|
||||
-- Minetest 0.4 mod: bones
|
||||
-- Minetest 0.5 mod: bones
|
||||
-- See README.txt for licensing and other information.
|
||||
--REVISED 20151117 by maikerumine for adding bones to inventory after punch
|
||||
|
||||
@ -22,7 +22,8 @@ bones.bones_formspec =
|
||||
"list[current_player;main;0,6.08;8,3;8]"..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
|
||||
local share_bones_time = tonumber(minetest.setting_get("share_bones_time") or 1200)
|
||||
--local share_bones_time = tonumber(minetest.setting_get("share_bones_time") or 1200)--ORIGINAL TIME
|
||||
local share_bones_time = tonumber(minetest.setting_get("share_bones_time") or 600)--DEBUGGING TIME
|
||||
local share_bones_time_early = tonumber(minetest.setting_get("share_bones_time_early") or (share_bones_time/4))
|
||||
|
||||
minetest.register_node("bones:bones", {
|
||||
@ -36,7 +37,8 @@ minetest.register_node("bones:bones", {
|
||||
"bones_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {dig_immediate=2},
|
||||
groups = {cracky = 2, oddly_breakable_by_hand = 2},
|
||||
-- groups = {dig_immediate=1},
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_gravel_footstep", gain=0.5},
|
||||
dug = {name="default_gravel_footstep", gain=1.0},
|
||||
@ -107,14 +109,12 @@ minetest.register_node("bones:bones", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
local time = meta:get_int("time") + elapsed--swap this
|
||||
if time >= share_bones_time then
|
||||
--BEGIN TIME
|
||||
|
||||
local time = os.date("*t");--for this on new map
|
||||
meta:set_string("infotext", "The old corpse of ".. meta:get_string("owner").." at ".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..":" .. time.sec..")");
|
||||
|
||||
--meta:set_string("infotext", meta:get_string("owner").."'s old bones")
|
||||
meta:set_string("owner", "")
|
||||
|
||||
--BEGIN TIME AFTER BONE EXPIRE
|
||||
local time = os.date("*t");--for this on new map
|
||||
meta:set_string("infotext", "R.I.P. ".. meta:get_string("owner").." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..")");--new old bones code
|
||||
--meta:set_string("infotext", meta:get_string("owner").."'s old bones")--org old bones code
|
||||
meta:set_string("owner", "")
|
||||
else
|
||||
meta:set_int("time", time)
|
||||
return true
|
||||
@ -212,17 +212,16 @@ minetest.register_on_dieplayer(function(player)
|
||||
player_inv:set_list("main", {})
|
||||
player_inv:set_list("craft", {})
|
||||
|
||||
--BEGIN TIME STRING
|
||||
--BEGIN TIME AT TIME OF DEATH
|
||||
--ref local time = os.date("*t");
|
||||
--ref meta:set_string("infotext", self.name.."'s fresh corpse ".. meta:get_string("owner").." at ".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..":" .. time.sec..")");
|
||||
--END TIME STRING
|
||||
|
||||
meta:set_string("formspec", bones.bones_formspec)
|
||||
meta:set_string("owner", player_name)
|
||||
|
||||
if share_bones_time ~= 0 then
|
||||
local time = os.date("*t");
|
||||
meta:set_string("infotext", player_name.."'s fresh corpse. :-( R.I.P. ".. meta:get_string("owner").." at ".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..":" .. time.sec..")");
|
||||
meta:set_string("infotext", player_name.." was killed".." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..")");
|
||||
--meta:set_string("infotext", player_name.."'s fresh corpse. :-( R.I.P. ".. meta:get_string("owner").." at ".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..")");
|
||||
--meta:set_string("infotext", player_name.."'s fresh bones")--old bones code
|
||||
|
||||
if share_bones_time_early == 0 or not minetest.is_protected(pos, player_name) then
|
||||
|
@ -941,49 +941,61 @@ function bp:register_mob(name, def)
|
||||
end
|
||||
--------END ORIG ON PUNCH CODE
|
||||
--------ADDING LAGS MOBS BONES HERE
|
||||
|
||||
--on_punch = function(self, hitter)
|
||||
--mob killed
|
||||
if self.object:get_hp() <= 0 then
|
||||
if hitter and hitter:is_player() and hitter:get_inventory() then
|
||||
for _,drop in ipairs(self.drops) do
|
||||
if math.random(1, drop.chance) == 1 then
|
||||
hitter:get_inventory():add_item("main", ItemStack(drop.name.." "..math.random(drop.min, drop.max)))
|
||||
end
|
||||
----------
|
||||
-- --THIS CODE GIVES YOU THE DROP INSTANT ON DEATH--removed to place drops in bones.
|
||||
-- if math.random(1, drop.chance) == 1 then
|
||||
-- hitter:get_inventory():add_item("main", ItemStack(drop.name.." "..math.random(drop.min, drop.max)))
|
||||
-- end
|
||||
----------
|
||||
end
|
||||
--mob bones, like player bones
|
||||
if math.random(1, 1) == 1 --[[and self.path_blocked_count < 1]] then --mob was free, not in cage or something
|
||||
|
||||
--mob bones, like player bones added by Andrei modified by maikerumine
|
||||
if math.random(1, 1) == 1 then
|
||||
local pos = self.object:getpos()
|
||||
local nn = minetest.get_node(pos).name
|
||||
local spaceforbones=nil
|
||||
if nn=="air" or nn=="default:water_flowing" or nn=="default:water_source" or nn=="default:lava_source" or nn=="default:lava_flowing" then
|
||||
spaceforbones=pos
|
||||
minetest.add_node(spaceforbones, {name="bones:bones"} )
|
||||
minetest.add_node(spaceforbones, {name="bones:bones"} )
|
||||
local meta = minetest.get_meta(spaceforbones)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
|
||||
--DROPS FILL BONE
|
||||
for _,drop in ipairs(self.drops) do
|
||||
if math.random(1, drop.chance) == 1 then
|
||||
local stack = ItemStack(drop.name.." "..math.random(drop.min, drop.max)) --This seems to not work right
|
||||
local stack = ItemStack(drop.name.." "..math.random(drop.min, drop.max))
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
-----------------------------------------------------------------
|
||||
-------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
meta:set_string("formspec", "size[8,9;]"..
|
||||
"list[current_name;main;0,0;8,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
--[[
|
||||
--lags orig mob bone code for ref
|
||||
meta:set_string("infotext", self.full_name.."'s fresh bones")
|
||||
meta:set_string("owner", "Stone monster")
|
||||
meta:set_int("bonetime_counter", 0)
|
||||
local timer = minetest.get_node_timer(spaceforbones)
|
||||
timer:start(10)
|
||||
]]
|
||||
|
||||
--BEGIN TIME STRING
|
||||
local time = os.date("*t");
|
||||
meta:set_string("infotext", self.name.."'s fresh corpse ".. meta:get_string("owner").." at ".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..":" .. time.sec..")");
|
||||
--END TIME STRING
|
||||
--meta:set_string("infotext", self.name.."'s fresh bones")--CHANGED TO ABOVE WITH TIME
|
||||
meta:set_string( "R.I.P mob, you put up a good fight.")
|
||||
local time = os.date("*t");--this keeps the bones meta to turn old
|
||||
|
||||
--CHOOSE OPTION BELOW:
|
||||
meta:set_string("infotext", self.name.." slain".. meta:get_string("owner").." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..")"); --SHOW TIME AT DEATH
|
||||
-- meta:set_string("infotext", self.name.."'s fresh bones") --SHOW TIME AT BONE EXPIRE
|
||||
--CHOOSE OPTION BELOW:
|
||||
meta:set_string( "owner", "Extreme Survival Mob R.I.P.") --SET OWNER FOR TIMER
|
||||
-- meta:set_string("owner") --SET NO OWNER NO TIMER
|
||||
meta:set_int("bonetime_counter", 0)
|
||||
local timer = minetest.get_node_timer(spaceforbones)
|
||||
timer:start(10)
|
||||
@ -994,8 +1006,7 @@ function bp:register_mob(name, def)
|
||||
self.object:remove()
|
||||
return
|
||||
elseif self.object:get_hp() == 4 or self.object:get_hp() == 6 or self.object:get_hp() == 10 then
|
||||
-- self.path_blocked_count = self.path_blocked_count - 1; --REMOVED DUE TO CRASH WITH NIL
|
||||
self.state="walk"
|
||||
self.state="run"
|
||||
else
|
||||
self.v_start=true
|
||||
if hitter and hitter:is_player() and hitter:get_wielded_item() then
|
||||
@ -1004,7 +1015,7 @@ function bp:register_mob(name, def)
|
||||
hitter:set_wielded_item( tool )
|
||||
end
|
||||
end
|
||||
--end,
|
||||
--end,--use if using original punch code.
|
||||
|
||||
end,
|
||||
-------END ON PUNCH FULL CODE
|
||||
@ -1048,7 +1059,8 @@ function bp:spawn_specific(name, nodes, neighbors, min_light, max_light, interva
|
||||
local nod = minetest.get_node_or_nil(pos)
|
||||
if not nod or not nod.name or not minetest.registered_nodes[nod.name]
|
||||
or minetest.registered_nodes[nod.name].walkable == true then return end
|
||||
pos.y = pos.y + 1
|
||||
pos.y = pos.y + 3--test to see if prevent mineshaft spawn
|
||||
-- pos.y = pos.y + 1--original
|
||||
nod = minetest.get_node_or_nil(pos)
|
||||
if not nod or not nod.name or not minetest.registered_nodes[nod.name]
|
||||
or minetest.registered_nodes[nod.name].walkable == true then return end
|
||||
@ -1165,7 +1177,8 @@ function check_for_death(self)
|
||||
end
|
||||
return
|
||||
end
|
||||
--MIGRATE TO BONES
|
||||
|
||||
--USE THIS CODE TO HAVE VISIBLE DROPS AND COMMENT OUT THE MOBS BONES
|
||||
--[[
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y + 1.5 -- drop items half a block higher
|
||||
@ -1181,8 +1194,46 @@ function check_for_death(self)
|
||||
end
|
||||
|
||||
]]
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------
|
||||
------------------------------------------------------MOBS BONES ON DIE
|
||||
if self.object:get_hp() <= 0 then
|
||||
local pos = self.object:getpos()
|
||||
local nn = minetest.get_node(pos).name
|
||||
local spaceforbones=nil
|
||||
if nn=="air" or nn=="default:water_flowing" or nn=="default:water_source" or nn=="default:lava_source" or nn=="default:lava_flowing" then
|
||||
spaceforbones=pos
|
||||
minetest.add_node(spaceforbones, {name="bones:bones"} )
|
||||
local meta = minetest.get_meta(spaceforbones)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
for _,drop in ipairs(self.drops) do
|
||||
if math.random(1, drop.chance) == 1 then
|
||||
local stack = ItemStack(drop.name.." "..math.random(drop.min, drop.max))
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
meta:set_string("formspec", "size[8,9;]"..
|
||||
"list[current_name;main;0,0;8,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
local time = os.date("*t");--this keeps the bones meta to turn old
|
||||
meta:set_string("infotext", self.name.." slain".. meta:get_string("owner").." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..")"); --SHOW TIME AT DEATH
|
||||
meta:set_string( "owner", "Extreme Survival Mob R.I.P.") --SET OWNER FOR TIMER
|
||||
meta:set_int("bonetime_counter", 0)
|
||||
local timer = minetest.get_node_timer(spaceforbones)
|
||||
timer:start(10)
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
--end--UNCOMMENT IF RE-ADDING VISIBLE DROPS
|
||||
------------------------------------------------------
|
||||
------------------------------------------------------
|
||||
------------------------------------------------------
|
||||
|
||||
if self.sounds.death ~= nil then
|
||||
minetest.sound_play(self.sounds.death,{object = self.object})
|
||||
end
|
||||
@ -1191,83 +1242,7 @@ function check_for_death(self)
|
||||
self.on_die(self, pos)
|
||||
|
||||
end
|
||||
end --COMMENT THIS END OUT IF ADDING BELOW CODE
|
||||
|
||||
|
||||
--[[
|
||||
--BONES FOR MOBS v0.0.1-maikerumine please use bones modified.
|
||||
local function is_owner(pos, name)
|
||||
local owner = minetest.get_meta(pos):get_string("owner")
|
||||
if owner == "" or owner == name then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function may_replace(pos,player)
|
||||
--local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
||||
local node_name = minetest.get_node(pos).name
|
||||
local node_definition = minetest.registered_nodes[node_name]
|
||||
|
||||
|
||||
-- if the node is unknown, we let the protection mod decide
|
||||
-- this is consistent with when a player could dig or not dig it
|
||||
-- unknown decoration would often be removed
|
||||
-- while unknown building materials in use would usually be left
|
||||
if not node_definition then
|
||||
-- only replace nodes that are not protected
|
||||
return not minetest.is_protected(pos, player:get_player_name())
|
||||
end
|
||||
|
||||
-- allow replacing air and liquids
|
||||
if node_name == "air" or node_definition.liquidtype ~= "none" then
|
||||
return true
|
||||
end
|
||||
|
||||
-- don't replace filled chests and other nodes that don't allow it
|
||||
local can_dig_func = node_definition.can_dig
|
||||
|
||||
|
||||
--THIS CAUSED CRASHES
|
||||
|
||||
if can_dig_func and not can_dig_func(pos, player) then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- default to each nodes buildable_to; if a placed block would replace it, why shouldn't bones?
|
||||
-- flowers being squished by bones are more realistical than a squished stone, too
|
||||
-- exception are of course any protected buildable_to
|
||||
return node_definition.buildable_to and not minetest.is_protected(pos, player())
|
||||
end
|
||||
|
||||
pos.x = math.floor(pos.x+0.5)
|
||||
pos.y = math.floor(pos.y+0.5)
|
||||
pos.z = math.floor(pos.z+0.5)
|
||||
|
||||
if (not may_replace(pos, player)) then
|
||||
if (may_replace({x=pos.x, y=pos.y+1, z=pos.z}, player)) then
|
||||
-- drop one node above if there's space
|
||||
-- this should solve most cases of protection related deaths in which players dig straight down
|
||||
-- yet keeps the bones reachable
|
||||
pos.y = pos.y+0
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
minetest.set_node(pos, {name="bones:bones"})
|
||||
|
||||
--local meta = minetest.get_meta(pos)
|
||||
if not player then return end
|
||||
end
|
||||
|
||||
|
||||
]]
|
||||
--ABORTED BONES CODE.. PLEASE SEE ABOVE
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- from TNT mod
|
||||
function calc_velocity(pos1, pos2, old_vel, power)
|
||||
|
33
mods/esmobs/bones.lua
Normal file
33
mods/esmobs/bones.lua
Normal file
@ -0,0 +1,33 @@
|
||||
--esmobs v0.0.1
|
||||
--maikerumine
|
||||
--made for Extreme Survival game
|
||||
|
||||
|
||||
|
||||
minetest.register_node("esmobs:bones", {
|
||||
description = "Bones",
|
||||
tiles = {
|
||||
"bones_top.png",
|
||||
"bones_bottom.png",
|
||||
"bones_side.png",
|
||||
"bones_side.png",
|
||||
"bones_rear.png",
|
||||
"bones_front.png"
|
||||
},
|
||||
waving = 1,
|
||||
visual_scale = 1.0,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {dig_immediate=2},
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_gravel_footstep", gain=0.5},
|
||||
dug = {name="default_gravel_footstep", gain=1.0},
|
||||
}),
|
||||
--end,
|
||||
})
|
@ -1,3 +1,4 @@
|
||||
default
|
||||
bones?
|
||||
intllib?
|
||||
es?
|
@ -67,7 +67,7 @@ bp:register_mob("esmobs:dirt", {
|
||||
|
||||
|
||||
|
||||
bp:register_spawn("esmobs:dirt2", {"default:dirt_with_grass","default:stone", "default:stonebrick","default:cobble"}, 12, 4, 5000, 7, -102)
|
||||
bp:register_spawn("esmobs:dirt2", {"default:dirt_with_grass","default:stone", "default:stonebrick","default:cobble"}, 5, 4, 5000, 7, -102)
|
||||
bp:register_mob("esmobs:dirt2", {
|
||||
type = "monster",
|
||||
hp_min = 30,
|
||||
@ -98,7 +98,7 @@ bp:register_mob("esmobs:dirt2", {
|
||||
drawtype = "front",
|
||||
water_damage = 20,
|
||||
lava_damage = 40,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
|
@ -45,7 +45,7 @@ bp:register_mob("esmobs:badplayer2", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 110,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -98,7 +98,7 @@ bp:register_mob("esmobs:badplayer3", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 110,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -151,7 +151,7 @@ bp:register_mob("esmobs:badplayer4", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 110,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -205,7 +205,7 @@ bp:register_mob("esmobs:badplayer6", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -258,7 +258,7 @@ bp:register_mob("esmobs:badplayer7", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -311,7 +311,7 @@ bp:register_mob("esmobs:badplayer8", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -364,7 +364,7 @@ bp:register_mob("esmobs:badplayer9", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 11,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -417,7 +417,7 @@ bp:register_mob("esmobs:badplayer10", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 5,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -470,7 +470,7 @@ bp:register_mob("esmobs:badplayer11", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -523,7 +523,7 @@ bp:register_mob("esmobs:badplayer12", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -577,7 +577,7 @@ bp:register_mob("esmobs:badplayer16", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -631,7 +631,7 @@ bp:register_mob("esmobs:badplayer18", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -686,7 +686,7 @@ bp:register_mob("esmobs:badplayer22", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 11,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -744,7 +744,7 @@ bp:register_mob("esmobs:badplayer23", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 11,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -797,7 +797,7 @@ bp:register_mob("esmobs:badplayer24", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -850,7 +850,7 @@ bp:register_mob("esmobs:badplayer25", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -903,7 +903,7 @@ bp:register_mob("esmobs:badplayer26", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 10,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -956,7 +956,7 @@ bp:register_mob("esmobs:badplayer27", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 11,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -1009,7 +1009,7 @@ bp:register_mob("esmobs:badplayer28", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 11,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -1062,7 +1062,7 @@ bp:register_mob("esmobs:badplayer29", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 11,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -1115,7 +1115,7 @@ bp:register_mob("esmobs:badplayer30", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 12,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -1169,7 +1169,7 @@ bp:register_mob("esmobs:badplayer31", {
|
||||
drawtype = "front",
|
||||
water_damage = 0,
|
||||
lava_damage = 50,
|
||||
light_damage = 12,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -1225,7 +1225,7 @@ bp:register_mob("esmobs:badplayer35", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 11,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
|
@ -44,7 +44,7 @@ bp:register_mob("esmobs:tree_monster", {
|
||||
},
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 22,
|
||||
light_damage = 2,
|
||||
fall_damage = 0,
|
||||
animation = {
|
||||
speed_normal = 15, speed_run = 15,
|
||||
@ -65,9 +65,6 @@ if not minetest.get_modpath("ethereal") then
|
||||
minetest.register_alias("ethereal:jungle_tree_sapling", "default:junglesapling")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- Sand Monster by PilzAdam
|
||||
|
||||
bp:register_mob("esmobs:sand_monster", {
|
||||
@ -77,7 +74,7 @@ bp:register_mob("esmobs:sand_monster", {
|
||||
damage = 2,
|
||||
hp_min = 17,
|
||||
hp_max = 35,
|
||||
armor = 100,
|
||||
armor = 90,
|
||||
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_sand_monster.x",
|
||||
@ -101,7 +98,7 @@ bp:register_mob("esmobs:sand_monster", {
|
||||
},
|
||||
water_damage = 3,
|
||||
lava_damage = 4,
|
||||
light_damage = 20,
|
||||
light_damage = 0,
|
||||
animation = {
|
||||
speed_normal = 15, speed_run = 15,
|
||||
stand_start = 0, stand_end = 39,
|
||||
@ -111,10 +108,7 @@ bp:register_mob("esmobs:sand_monster", {
|
||||
},
|
||||
})
|
||||
|
||||
bp:register_spawn("esmobs:sand_monster", {"default:sand", "meru:stone","group:sand"},20, -1, 8000, 2, 31000)
|
||||
|
||||
|
||||
|
||||
bp:register_spawn("esmobs:sand_monster", {"default:sand", "meru:stone","group:sand"},4, -1, 8000, 2, 31000)
|
||||
|
||||
-- Stone Monster by PilzAdam
|
||||
|
||||
@ -152,7 +146,7 @@ bp:register_mob("esmobs:stone_monster", {
|
||||
},
|
||||
water_damage = 0,
|
||||
lava_damage = 1,
|
||||
light_damage = 21,
|
||||
light_damage = 1,
|
||||
animation = {
|
||||
speed_normal = 15, speed_run = 15,
|
||||
stand_start = 0, stand_end = 14,
|
||||
@ -167,13 +161,6 @@ bp:register_spawn("esmobs:stone_monster", {"default:stone"}, 5, 0, 1000, 10, 310
|
||||
--bp:register_egg("esmobs:stone_monster", "Stone Monster", "default_stone.png", 1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- Spider by AspireMint (fishyWET (CC-BY-SA 3.0 license for texture)
|
||||
|
||||
bp:register_mob("esmobs:spider", {
|
||||
@ -239,8 +226,8 @@ minetest.register_node("esmobs:cobweb", {
|
||||
sunlight_propagates = true,
|
||||
liquid_viscosity = 11,
|
||||
liquidtype = "source",
|
||||
liquid_alternative_flowing = "mobs:cobweb",
|
||||
liquid_alternative_source = "mobs:cobweb",
|
||||
liquid_alternative_flowing = "esmobs:cobweb",
|
||||
liquid_alternative_source = "esmobs:cobweb",
|
||||
liquid_renewable = false,
|
||||
liquid_range = 0,
|
||||
walkable = false,
|
||||
@ -259,6 +246,57 @@ minetest.register_craft({
|
||||
})
|
||||
|
||||
|
||||
-- Oerkki by PilzAdam
|
||||
|
||||
bp:register_mob("esmobs:oerkkii", {
|
||||
type = "monster",
|
||||
passive = false,
|
||||
attack_type = "dogfight",
|
||||
damage = 4,
|
||||
hp_min = 8,
|
||||
hp_max = 34,
|
||||
armor = 100,
|
||||
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_oerkki.x",
|
||||
textures = {
|
||||
{"mobs_oerkki.png"},
|
||||
{"mobs_oerkki2.png"},
|
||||
},
|
||||
visual_size = {x=5, y=5},
|
||||
makes_footstep_sound = false,
|
||||
sounds = {
|
||||
random = "mobs_oerkki",
|
||||
},
|
||||
walk_velocity = 1,
|
||||
run_velocity = 3,
|
||||
view_range = 10,
|
||||
jump = true,
|
||||
drops = {
|
||||
{name = "default:obsidian",
|
||||
chance = 3, min = 1, max = 2,},
|
||||
},
|
||||
water_damage = 2,
|
||||
lava_damage = 4,
|
||||
light_damage = 1,
|
||||
animation = {
|
||||
stand_start = 0, stand_end = 23,
|
||||
walk_start = 24, walk_end = 36,
|
||||
run_start = 37, run_end = 49,
|
||||
punch_start = 37, punch_end = 49,
|
||||
speed_normal = 15, speed_run = 15,
|
||||
},
|
||||
replace_rate = 40,
|
||||
replace_what = {"default:torch"},
|
||||
replace_with = "air",
|
||||
replace_offset = -1,
|
||||
})
|
||||
|
||||
bp:register_spawn("mobs:oerkkii", {"default:stone"}, 5, 0, 7000, 1, -10)
|
||||
|
||||
--mobs:register_egg("mobs:oerkki", "Oerkki", "default_obsidian.png", 1)
|
||||
|
||||
--Applmons by maikerumine
|
||||
bp:register_mob("esmobs:applmons", {
|
||||
type = "monster",
|
||||
hp_min = 20,
|
||||
@ -283,7 +321,7 @@ bp:register_mob("esmobs:applmons", {
|
||||
drawtype = "front",
|
||||
water_damage = 10,
|
||||
lava_damage = 50,
|
||||
light_damage = 6,
|
||||
light_damage = 0,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
|
@ -39,7 +39,7 @@ bp:register_mob("esmobs:icemon", {
|
||||
drawtype = "front",
|
||||
water_damage = 0,
|
||||
lava_damage = 50,
|
||||
light_damage = 20,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -85,7 +85,7 @@ bp:register_mob("esmobs:snowmon", {
|
||||
drawtype = "front",
|
||||
water_damage = 20,
|
||||
lava_damage = 50,
|
||||
light_damage = 20,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
@ -103,7 +103,7 @@ bp:register_mob("esmobs:snowmon", {
|
||||
|
||||
})
|
||||
|
||||
bp:register_spawn("esmobs:watermon", {"default:water_source","default:water_flowing"}, 20, -1, 9000, 1, 120)
|
||||
bp:register_spawn("esmobs:watermon", {"default:water_source","default:water_flowing"}, 5, -1, 9000, 1, 120)
|
||||
bp:register_mob("esmobs:watermon", {
|
||||
type = "monster",
|
||||
hp_min = 35,
|
||||
@ -136,7 +136,7 @@ bp:register_mob("esmobs:watermon", {
|
||||
drawtype = "front",
|
||||
water_damage = 0,
|
||||
lava_damage = 50,
|
||||
light_damage = 20,
|
||||
light_damage = 1,
|
||||
on_rightclick = nil,
|
||||
attack_type = "dogfight",
|
||||
animation = {
|
||||
|
@ -22,9 +22,11 @@ if es then
|
||||
dofile(minetest.get_modpath("esmobs").."/esnpc2.lua")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--[[if bones then
|
||||
donotfile(minetest.get_modpath("esmobs").."/bones.lua")
|
||||
end
|
||||
dofile(minetest.get_modpath("esmobs").."/bones.lua")
|
||||
]]
|
||||
--dofile(minetest.get_modpath("esmobs").."/esconfig.lua")
|
||||
|
||||
|
||||
|
BIN
mods/esmobs/textures/bones_bottom.png
Normal file
BIN
mods/esmobs/textures/bones_bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 284 B |
BIN
mods/esmobs/textures/bones_front.png
Normal file
BIN
mods/esmobs/textures/bones_front.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 300 B |
BIN
mods/esmobs/textures/bones_rear.png
Normal file
BIN
mods/esmobs/textures/bones_rear.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 306 B |
BIN
mods/esmobs/textures/bones_side.png
Normal file
BIN
mods/esmobs/textures/bones_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 289 B |
BIN
mods/esmobs/textures/bones_top.png
Normal file
BIN
mods/esmobs/textures/bones_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 279 B |
@ -6,21 +6,8 @@ local statspawn = (minetest.setting_get_pos("static_spawnpoint") or {x = 0, y =
|
||||
protector = {}
|
||||
protector.mod = "redo"
|
||||
protector.radius = (tonumber(minetest.setting_get("protector_radius")) or 3)
|
||||
protector.pvp = true -- minetest.setting_getbool("protector_pvp")
|
||||
protector.pvp = minetest.setting_getbool("protector_pvp")
|
||||
protector.spawn = (tonumber(minetest.setting_get("protector_pvp_spawn")) or 0)
|
||||
protector.version = "11/12/2015 r3";
|
||||
|
||||
-- luxury settings
|
||||
|
||||
protector.luxury_centers = {statspawn} -- simply add points here, for example { spawn, {x=0,y=100,z=0} }
|
||||
protector.luxury_radius = 75; -- outside this radius around luxury centers players can place protectors normally without worrying about upgrading
|
||||
-- outside 2x this radius players can spam protectors with lower extra cost
|
||||
protector.luxury_border_cost = 4; -- protector placement cost at luxury radius
|
||||
protector.luxury_center_cost = 100; -- cost at luxury center
|
||||
protector.maxcount = 10; -- allowed count in a group before update cost required
|
||||
protector.maxcount_price = 1; -- extra costs parameter for placing protectors
|
||||
protector.discount = {}; -- table of discouns, basically when you dig protector you get cost back - temporary!
|
||||
|
||||
|
||||
protector.get_member_list = function(meta)
|
||||
return meta:get_string("members"):split(" ")
|
||||
@ -61,16 +48,11 @@ end
|
||||
|
||||
protector.generate_formspec = function(meta)
|
||||
|
||||
local kill = meta:get_int("kill");
|
||||
local warn = meta:get_int("warn");
|
||||
|
||||
local formspec = "size[8,7]"
|
||||
..default.gui_bg..default.gui_bg_img..default.gui_slots
|
||||
.."label[2.5,0;-- Protector interface, mod version " .. protector.version .. " --]"
|
||||
.."label[0,0.5;PUNCH node to show protected area or USE for area check]"
|
||||
.."label[0,1;warn] label[1,1;kill] label[2,1.5; Here you can choose what to do with intruders]"
|
||||
.."button[0,1.25;1,1;warn;"..warn.."] button[1,1.25;1,1;kill;"..kill.."]"
|
||||
.."label[0,2.25;Members: (type player name then press Enter to add)]"
|
||||
.."label[2.5,0;-- Protector interface --]"
|
||||
.."label[0,1;PUNCH node to show protected area or USE for area check]"
|
||||
.."label[0,2;Members: (type player name then press Enter to add)]"
|
||||
|
||||
local members = protector.get_member_list(meta)
|
||||
local npp = 12
|
||||
@ -86,7 +68,7 @@ protector.generate_formspec = function(meta)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
|
||||
if i < npp then
|
||||
formspec = formspec .. "field[" .. (i % 4 * 2 + 1 / 3) .. ","
|
||||
.. (math.floor(i / 4 + 3) + 1 / 3) .. ";1.433,.5;protector_add_member;;]"
|
||||
@ -126,7 +108,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||
local positions = minetest.find_nodes_in_area(
|
||||
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
|
||||
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
|
||||
{"protector:protect"})
|
||||
{"protector:protect", "protector:protect2","coreprotector:protect2"})
|
||||
|
||||
local meta, owner, members
|
||||
for _, pos in ipairs(positions) do
|
||||
@ -134,35 +116,17 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||
owner = meta:get_string("owner")
|
||||
members = meta:get_string("members")
|
||||
|
||||
if owner ~= digger then
|
||||
if owner ~= digger then
|
||||
if onlyowner or not protector.is_member(meta, digger) then
|
||||
|
||||
if infolevel == 1 then
|
||||
minetest.chat_send_player(digger,
|
||||
"This area is owned by " .. owner .. " !")
|
||||
|
||||
local warn = meta:get_int("warn");local kill = meta:get_int("kill");
|
||||
local player = minetest.get_player_by_name(digger); if not player then return end
|
||||
if kill==1 then
|
||||
player:set_hp(0);
|
||||
minetest.after(1, function()
|
||||
local inv = player:get_inventory();
|
||||
inv:set_list("main", {});inv:set_list("craft", {})
|
||||
end)
|
||||
minetest.chat_send_player(digger, "PROTECTOR: You died inside protected area at " .. minetest.pos_to_string(pos) .. ". Next time try not to dig or hit players.");
|
||||
return false end
|
||||
if warn==1 then
|
||||
local form = "size [2,2] textarea[0,0;2.7,2;help;WARNING;This area belongs to " .. meta:get_string("owner") .."]" ..
|
||||
"button_exit[0.5,1.5;1.5,1;close;Close]"
|
||||
minetest.show_formspec(digger, "protector_warn", form)
|
||||
return false
|
||||
end
|
||||
|
||||
elseif infolevel == 2 then
|
||||
minetest.chat_send_player(digger,
|
||||
"This area is owned by " .. owner .. ".")
|
||||
minetest.chat_send_player(digger,
|
||||
"Protection located at: " .. minetest.pos_to_string(pos) .. ", upgrade price was " .. meta:get_int("cost") .. ", protector count is " .. meta:get_int("count") .. ", settings: kill ".. meta:get_int("kill") .. " warn " .. meta:get_int("warn"))
|
||||
"Protection located at: " .. minetest.pos_to_string(pos))
|
||||
if members ~= "" then
|
||||
minetest.chat_send_player(digger,
|
||||
"Members: " .. members .. ".")
|
||||
@ -177,7 +141,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel)
|
||||
minetest.chat_send_player(digger,
|
||||
"This area is owned by " .. owner .. ".")
|
||||
minetest.chat_send_player(digger,
|
||||
"Protection located at: " .. minetest.pos_to_string(pos) .. ", upgrade price was " .. meta:get_int("cost") .. ", protector count is " .. meta:get_int("count"))
|
||||
"Protection located at: " .. minetest.pos_to_string(pos))
|
||||
if members ~= "" then
|
||||
minetest.chat_send_player(digger,
|
||||
"Members: " .. members .. ".")
|
||||
@ -206,6 +170,11 @@ protector.old_is_protected = minetest.is_protected
|
||||
function minetest.is_protected(pos, digger)
|
||||
|
||||
if not protector.can_dig(protector.radius, pos, digger, false, 1) then
|
||||
|
||||
-- hurt player here if required
|
||||
--player = minetest.get_player_by_name(digger)
|
||||
--player:set_hp(player:get_hp() - 2)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -236,76 +205,6 @@ end
|
||||
|
||||
--= Protection Block
|
||||
|
||||
function protector.check_luxury(pos) -- return minimal block distance to luxury_centers
|
||||
local n = #(protector.luxury_centers);
|
||||
local mindist = protector.luxury_radius;
|
||||
local dist = mindist;
|
||||
for i = 1,n do
|
||||
local p = protector.luxury_centers[i];
|
||||
dist = math.max(math.abs(pos.x-p.x),math.abs(pos.y-p.y),math.abs(pos.z-p.z))
|
||||
if dist<mindist then mindist = dist end
|
||||
end
|
||||
|
||||
return mindist
|
||||
|
||||
end
|
||||
|
||||
-- count the protectors in the neighborhood and update counts.
|
||||
--two neigborhoods will be considered separate if their protectors are at least 15 apart
|
||||
function protector.count(pos, mode)
|
||||
|
||||
-- mode 0: return protector count, mode 1: add new protector, mode 2: remove protector
|
||||
|
||||
local r = 4*protector.radius+2; -- radius 14, P = protector, PAAABBBPAAABBBP
|
||||
|
||||
local positions = minetest.find_nodes_in_area(
|
||||
{x = pos.x - r, y = pos.y - 0.5*r, z = pos.z - r},
|
||||
{x = pos.x + r, y = pos.y + 0.5*r, z = pos.z + r},
|
||||
{"protector:protect"})
|
||||
|
||||
local meta, p, maxcount, count -- protector count in the neighborhood
|
||||
|
||||
if mode == 3 then -- manual reset counts to 0 by admin
|
||||
for _, p in ipairs(positions) do
|
||||
meta = minetest.get_meta(p)
|
||||
meta:set_int("count", 0)
|
||||
end
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
if mode == 2 then -- reduce neighbor counts since protector is removed
|
||||
for _, p in ipairs(positions) do
|
||||
meta = minetest.get_meta(p)
|
||||
|
||||
count = meta:get_int("count")-1;if count<0 then count = 0 end
|
||||
meta:set_int("count", count)
|
||||
end
|
||||
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
maxcount = 0; count = 0; -- find maximum nearby count
|
||||
local maxpos = {x=pos.x,y=pos.y,z=pos.z}; -- position of protector with maxcount
|
||||
for _, p in ipairs(positions) do
|
||||
meta = minetest.get_meta(p)
|
||||
count = meta:get_int("count");
|
||||
if count>maxcount then maxcount = count; maxpos.x=p.x;maxpos.y=p.y; maxpos.z=p.z; end
|
||||
end
|
||||
|
||||
if mode == 0 then return maxcount,maxpos end -- just return the count and position of protector with maxcount
|
||||
|
||||
--update counts, mode = 1
|
||||
maxcount = maxcount + 1;
|
||||
for _, p in ipairs(positions) do
|
||||
meta = minetest.get_meta(p)
|
||||
meta:set_int("count", maxcount)
|
||||
end
|
||||
return maxcount;
|
||||
end
|
||||
|
||||
|
||||
minetest.register_node("protector:protect", {
|
||||
description = "Protection Block",
|
||||
drawtype = "nodebox",
|
||||
@ -318,7 +217,7 @@ minetest.register_node("protector:protect", {
|
||||
groups = {dig_immediate = 2, unbreakable = 1},
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
light_source = 4,
|
||||
light_source = 7,
|
||||
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -329,48 +228,11 @@ minetest.register_node("protector:protect", {
|
||||
|
||||
on_place = protector.check_overlap,
|
||||
|
||||
after_place_node = function(pos, placer) -- rnd
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local count,maxpos;
|
||||
count = protector.count(pos, 0); -- just read the counts
|
||||
local luxury_dist = protector.check_luxury(pos);
|
||||
|
||||
if luxury_dist>=protector.luxury_radius and count< protector.maxcount then -- normal placement outside luxury radius or below maxcount
|
||||
meta:set_string("owner", placer:get_player_name() or "");
|
||||
local time = os.date("*t");
|
||||
meta:set_string("infotext", "Protection (placed by ".. meta:get_string("owner").." at ".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..":" .. time.sec..")");
|
||||
protector.count(pos, 1); -- update counts of nearby protectors after successful "upgrade"
|
||||
return
|
||||
end
|
||||
|
||||
minetest.chat_send_player(placer:get_player_name(), " PROTECTOR: please right click me to UPGRADE or punch to DIG me.");
|
||||
meta:set_string("owner", ""); -- initially owner is ""
|
||||
meta:set_string("placer", placer:get_player_name() or ""); -- who placed it
|
||||
local cost = 0;
|
||||
|
||||
if luxury_dist<protector.luxury_radius then -- extra cost because too close to luxury center
|
||||
cost = math.pow(luxury_dist/protector.luxury_radius,2); -- this is 0 at center and 1 at borders of luxury,1/4 at halfway
|
||||
cost = protector.luxury_border_cost/(cost+1/protector.luxury_center_cost);
|
||||
cost = cost + math.ceil(cost);
|
||||
end
|
||||
|
||||
if count>=protector.maxcount then -- extra costs due to exceeded protector count
|
||||
if luxury_dist< 2*protector.luxury_radius then
|
||||
cost = cost + math.pow(count-protector.maxcount+1,2)*protector.maxcount_price;
|
||||
else
|
||||
cost = cost + math.pow(count-protector.maxcount+1)*protector.maxcount_price;
|
||||
end
|
||||
end
|
||||
|
||||
cost = math.ceil(cost);
|
||||
meta:set_int("cost",cost);
|
||||
|
||||
meta:set_string("infotext", "Protection (placed by ".. meta:get_string("placer") .. ". Please rightclick to upgrade with cost ".. cost .." or dig it. ");
|
||||
meta:set_int("upgrade",1); -- indicates protector is not yet upgraded
|
||||
meta:set_int("place_time", minetest.get_gametime());
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", "Protection (owned by " .. meta:get_string("owner") .. ")")
|
||||
meta:set_string("members", "")
|
||||
return
|
||||
end,
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
@ -378,125 +240,24 @@ minetest.register_node("protector:protect", {
|
||||
protector.can_dig(protector.radius, pointed_thing.under, user:get_player_name(), false, 2)
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack) -- rnd
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local upgrade = meta:get_int("upgrade");
|
||||
if upgrade==1 then -- only upgrade if not already
|
||||
|
||||
local name = clicker:get_player_name();
|
||||
local permitgiver = meta:get_string("permitgiver");
|
||||
|
||||
if name == permitgiver and upgrade==1 then
|
||||
local cost = meta:get_int("cost");
|
||||
minetest.chat_send_player(name, "PROTECTOR: you have just given permission to upgrade this protector for free. Upgrade costs were " .. cost);
|
||||
meta:set_string("infotext", name .. " has given permission to upgrade with cost 0");
|
||||
meta:set_string("permitgiver","");
|
||||
meta:set_int("cost",0);
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if name == meta:get_string("placer") then -- upgrade to full protector
|
||||
|
||||
local count,maxpos;
|
||||
count,maxpos = protector.count(pos, 0); -- just read the counts and position of protector with max count
|
||||
local maxname = minetest.get_meta(maxpos):get_string("owner");
|
||||
local permittext = "";
|
||||
|
||||
local ip1 = minetest.get_player_ip(name);
|
||||
local ip2 = minetest.get_player_ip(maxname);
|
||||
|
||||
if name~=maxname and ip1 and ip2 then
|
||||
|
||||
if ip1~=ip2 then -- are those really 2 different players?
|
||||
if maxname == "" then
|
||||
permittext = "\n\nThere is detector with count " .. count .. " without owner at "..maxpos.x .. " " .. maxpos.y .. " " .. maxpos.z;
|
||||
else
|
||||
permittext = "\n\nYou can also try to get the owner of protector with count ".. count .. " (his name is " .. maxname .. ") located at "..
|
||||
" "..maxpos.x .. " " .. maxpos.y .. " " .. maxpos.z .. " to upgrade protector for you by rightclicking it. ";
|
||||
end
|
||||
meta:set_string("permitgiver", maxname);
|
||||
end
|
||||
|
||||
else
|
||||
meta:set_string("permitgiver","");
|
||||
end
|
||||
|
||||
|
||||
--protector.check_luxury(pos)>=protector.luxury_radius
|
||||
local cost = meta:get_int("cost");
|
||||
|
||||
local text = "You are either trying to build close to luxury center or there are too many nearby protectors."..
|
||||
"You will need to upgrade protector to be usable. "..
|
||||
"\n\n Make sure you have " .. cost .. " mese in your inventory. "..
|
||||
"If price is too high dig protector, find a spot farther away and try again. ".. permittext ..
|
||||
"\n\nADVICE: try to place protector at least 15 blocks away from large groups of protectors to keep update cost low.";
|
||||
|
||||
local formspec = "size[4.5,5]"
|
||||
..default.gui_bg..default.gui_bg_img..default.gui_slots..
|
||||
"textarea[0,0;5.,5;help;-- Protector upgrade --;".. text .. "]"..
|
||||
"button[ 0,4.5;2,1;upgrade_protector;UPGRADE]"
|
||||
|
||||
minetest.show_formspec(clicker:get_player_name(),
|
||||
"protector:upgrade_" .. minetest.pos_to_string(pos), formspec)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if protector.can_dig(1, pos,clicker:get_player_name(), true, 1) then
|
||||
minetest.show_formspec(clicker:get_player_name(),
|
||||
minetest.show_formspec(clicker:get_player_name(),
|
||||
"protector:node_" .. minetest.pos_to_string(pos), protector.generate_formspec(meta))
|
||||
end
|
||||
|
||||
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, puncher)
|
||||
if not protector.can_dig(1, pos, puncher:get_player_name(), true, 1) then
|
||||
if not protector.can_dig(1, pos, puncher:get_player_name(), true, 1) then
|
||||
return
|
||||
end
|
||||
minetest.add_entity(pos, "protector:display")
|
||||
end,
|
||||
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
|
||||
local candig = (meta:get_int("upgrade") == 1); -- protector not yet upgraded?
|
||||
local name = player:get_player_name();
|
||||
if candig then
|
||||
if name~=meta:get_string("placer") then -- non placer can only dig after 5 minutes passed
|
||||
local t = minetest.get_gametime();
|
||||
local t1 = meta:get_int("place_time");
|
||||
if math.abs(t-t1)< 300 then candig = false
|
||||
minetest.chat_send_player(name," Only placer can dig unupgraded protection before 5 minutes passed.");
|
||||
return false;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local owner = meta:get_string("owner");
|
||||
if owner == name then
|
||||
if not protector.discount[name] then protector.discount[name] = 0 end
|
||||
local cost = meta:get_int("cost");
|
||||
if cost>0 then
|
||||
protector.discount[name] = protector.discount[name] +cost;
|
||||
minetest.chat_send_player(name," Protector's upgrade value can be used for discount when upgrading protectors, current credits are ".. protector.discount[name] );
|
||||
end
|
||||
end
|
||||
|
||||
if candig then -- dig it if its not upgraded
|
||||
local inv = player:get_inventory();
|
||||
inv:add_item("main", ItemStack("protector:protect"));
|
||||
minetest.set_node(pos,{name = "air"});
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
if owner~="" then protector.count(pos,2); end-- update counts after removal of protector with real owner only
|
||||
return protector.can_dig(1, pos, player:get_player_name(), true, 1)
|
||||
return protector.can_dig(1, pos, player:get_player_name(), true, 1)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
@ -508,62 +269,76 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
--= Protection Logo
|
||||
|
||||
--[[minetest.register_node("protector:protect2", {
|
||||
description = "Protection Logo",
|
||||
tiles = {"protector_logo.png"},
|
||||
wield_image = "protector_logo.png",
|
||||
inventory_image = "protector_logo.png",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
groups = {dig_immediate = 2, unbreakable = 1},
|
||||
paramtype = 'light',
|
||||
paramtype2 = "wallmounted",
|
||||
light_source = 7,
|
||||
drawtype = "nodebox",
|
||||
sunlight_propagates = true,
|
||||
walkable = true,
|
||||
node_box = {
|
||||
type = "wallmounted",
|
||||
wall_top = {-0.375, 0.4375, -0.5, 0.375, 0.5, 0.5},
|
||||
wall_bottom = {-0.375, -0.5, -0.5, 0.375, -0.4375, 0.5},
|
||||
wall_side = {-0.5, -0.5, -0.375, -0.4375, 0.5, 0.375},
|
||||
},
|
||||
selection_box = {type = "wallmounted"},
|
||||
|
||||
-- If name entered or button press on protector
|
||||
on_place = protector.check_overlap,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", "Protection (owned by " .. meta:get_string("owner") .. ")")
|
||||
meta:set_string("members", "")
|
||||
end,
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then return end
|
||||
protector.can_dig(protector.radius, pointed_thing.under, user:get_player_name(), false, 2)
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if protector.can_dig(1, pos, clicker:get_player_name(), true, 1) then
|
||||
minetest.show_formspec(clicker:get_player_name(),
|
||||
"protector:node_" .. minetest.pos_to_string(pos), protector.generate_formspec(meta))
|
||||
end
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, puncher)
|
||||
if not protector.can_dig(1, pos, puncher:get_player_name(), true, 1) then
|
||||
return
|
||||
end
|
||||
minetest.add_entity(pos, "protector:display")
|
||||
end,
|
||||
|
||||
can_dig = function(pos, player)
|
||||
return protector.can_dig(1, pos, player:get_player_name(), true, 1)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "protector:protect2 4",
|
||||
recipe = {
|
||||
{"default:stone", "default:stone", "default:stone"},
|
||||
{"default:stone", "default:copper_ingot", "default:stone"},
|
||||
{"default:stone", "default:stone", "default:stone"},
|
||||
}
|
||||
})]]
|
||||
|
||||
-- If name entered or button press
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
|
||||
-- protector upgrade
|
||||
|
||||
if string.sub(formname, 0, string.len("protector:upgrade_")) == "protector:upgrade_" then
|
||||
|
||||
if fields.upgrade_protector == "UPGRADE" then
|
||||
|
||||
local pos_s = string.sub(formname, string.len("protector:upgrade_") + 1)
|
||||
local pos = minetest.string_to_pos(pos_s)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
if meta:get_int("upgrade")==1 then
|
||||
local cost = math.floor(meta:get_int("cost"));
|
||||
local name = player:get_player_name();
|
||||
|
||||
if not protector.discount[name] then protector.discount[name] = 0 end
|
||||
local cost1 = math.max(cost - protector.discount[name],0);
|
||||
|
||||
if cost1<cost then
|
||||
minetest.chat_send_player(player:get_player_name(), "PROTECTOR: cost with discount " .. cost1 .. ". Current discount is " .. protector.discount[name]);
|
||||
end
|
||||
|
||||
--check player inventory for mese
|
||||
local inv = player:get_inventory();
|
||||
if not inv:contains_item("main", ItemStack("default:mese_crystal "..cost1)) then
|
||||
minetest.chat_send_player(player:get_player_name(),"PROTECTOR: you need at least " .. cost1 .. " mese for upgrade ");
|
||||
return
|
||||
end
|
||||
|
||||
protector.discount[name]=protector.discount[name]-(cost-cost1);
|
||||
inv:remove_item("main", ItemStack("default:mese_crystal "..cost1));
|
||||
|
||||
meta:set_string("owner", player:get_player_name() or "");
|
||||
meta:set_int("upgrade",0); -- protector is now upgraded
|
||||
protector.count(pos, 1); -- update counts of nearby protectors after successful upgrade
|
||||
|
||||
meta:set_string("placer","");
|
||||
local time = os.date("*t");
|
||||
meta:set_string("infotext", "Protection (upgraded by ".. meta:get_string("owner").." at ".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..":" .. time.sec..")");
|
||||
minetest.chat_send_player(player:get_player_name(),"PROTECTOR: successfuly upgraded");
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- protector setup
|
||||
if string.sub(formname, 0, string.len("protector:node_")) == "protector:node_" then
|
||||
|
||||
local pos_s = string.sub(formname, string.len("protector:node_") + 1)
|
||||
@ -585,15 +360,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
protector.del_member(meta, string.sub(field,string.len("protector_del_member_") + 1))
|
||||
end
|
||||
end
|
||||
|
||||
if fields.warn then
|
||||
meta:set_int("warn", 1-meta:get_int("warn"))
|
||||
end
|
||||
|
||||
if fields.kill then
|
||||
meta:set_int("kill", 1-meta:get_int("kill"))
|
||||
end
|
||||
|
||||
if not fields.close_me then
|
||||
minetest.show_formspec(player:get_player_name(), formname, protector.generate_formspec(meta))
|
||||
end
|
||||
@ -658,6 +425,8 @@ minetest.register_node("protector:display_node", {
|
||||
drop = "",
|
||||
})
|
||||
|
||||
|
||||
|
||||
-- Protected Chest
|
||||
|
||||
minetest.register_node("protector:chest", {
|
||||
@ -750,7 +519,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
elseif fields.todn then
|
||||
|
||||
-- copy contents of chest to players inventory
|
||||
@ -825,16 +594,10 @@ if minetest.setting_getbool("enable_pvp") and protector.pvp then
|
||||
return true
|
||||
end
|
||||
|
||||
local hitter_can_build = not minetest.is_protected(pos, hitter:get_player_name());
|
||||
local player_can_build = not minetest.is_protected(pos, player:get_player_name());
|
||||
|
||||
--can hurt: hitter_can_build OR (NOT hitter_can_build AND NOT player_can_build)
|
||||
|
||||
|
||||
if hitter_can_build or ((not player_can_build) and (not hitter_can_build)) then -- attacker can hurt player where he can build or if both cant build
|
||||
return false -- can hurt
|
||||
if minetest.is_protected(pos, hitter:get_player_name()) then
|
||||
return true
|
||||
else
|
||||
return true -- can not hurt
|
||||
return false
|
||||
end
|
||||
|
||||
end)
|
||||
@ -847,16 +610,3 @@ else
|
||||
end
|
||||
|
||||
print ("[MOD] Protector Redo loaded")
|
||||
|
||||
|
||||
|
||||
minetest.register_chatcommand("resetprotect", {
|
||||
description = "Resets protector count in neighborhood to 0 to reduce costs to default.",
|
||||
privs = {privs=true},
|
||||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local pos = player:getpos();
|
||||
protector.count(pos, 3); -- reset counts to 0
|
||||
minetest.chat_send_player(player:get_player_name(),"PROTECTOR: counts in neighborhood ( 15 blocks around ) reset to 0.");
|
||||
end,
|
||||
})
|
BIN
mods/protector/initrnd.zip
Normal file
BIN
mods/protector/initrnd.zip
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user