add shark_buoy
This commit is contained in:
parent
69f7e27788
commit
5fb8a49cc2
3
api.lua
3
api.lua
@ -534,9 +534,10 @@ function water_life.water_depth(pos,max)
|
||||
local type = minetest.registered_nodes[node.name]["liquidtype"]
|
||||
local found = false
|
||||
|
||||
if type ~= "source" then -- start in none liquid try to find surface
|
||||
if type == "none" then -- start in none liquid try to find surface
|
||||
|
||||
local under = water_life.find_collision(pos,{x=pos.x, y=pos.y - max, z=pos.z}, true)
|
||||
--minetest.chat_send_all(dump(under).." "..dump(node.name))
|
||||
if under then
|
||||
local check = {x=pos.x, y=pos.y - under-1, z=pos.z}
|
||||
if minetest.registered_nodes[minetest.get_node(check).name]["liquidtype"] == "source" then
|
||||
|
127
crafts.lua
127
crafts.lua
@ -47,59 +47,53 @@ minetest.register_alias("mobs:magic_lasso", "water_life:lasso")
|
||||
--minetest.register_alias("petz:lasso", "water_life:lasso")
|
||||
|
||||
|
||||
--[[
|
||||
minetest.register_node("water_life:sharknet", {
|
||||
description = "Sharknet",
|
||||
|
||||
minetest.register_node("water_life:shark_buoy", {
|
||||
description = "Shark-buoy, keeps off sharks in radius of 10 nodes",
|
||||
drawtype = "plantlike_rooted",
|
||||
waving = 1,
|
||||
tiles = {"water_life_shark_net_top.png","default_tinblock.png","default_tinblock.png","default_tinblock.png","default_tinblock.png","default_tinblock.png"},
|
||||
tiles = {"water_life_shark_net_top.png","default_tin_block.png","default_tin_block.png","default_tin_block.png","default_tin_block.png","default_tin_block.png"},
|
||||
special_tiles = {{name = "water_life_sharknet.png", tileable_vertical = true}},
|
||||
inventory_image = "water_life_sharknet_item.png",
|
||||
inventory_image = "water_life_shark_buoy_item.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "leveled",
|
||||
groups = {snappy = 3},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 1, level = 2},
|
||||
walkable = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 5.5, 0.5}
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
{-0.1, 0.5, -0.1, 0.1, 2.0, 0.1}
|
||||
}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 5.5, 0.5}
|
||||
}
|
||||
},
|
||||
node_dig_prediction = "air",
|
||||
node_placement_prediction = "",
|
||||
sounds = default.node_sound_sand_defaults({
|
||||
dig = {name = "default_dig_snappy", gain = 0.2},
|
||||
dug = {name = "default_grass_footstep", gain = 0.25},
|
||||
}),
|
||||
|
||||
node_dig_prediction = "default:water",
|
||||
node_placement_prediction = "water_life:shark_buoy",
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
|
||||
local pos = pointed_thing.above
|
||||
local depth = water_life.water_depth(pos,8)
|
||||
local height = depth.depth -1
|
||||
local depth = water_life.water_depth(pos,10)
|
||||
local height = depth.depth-1
|
||||
local pos_top = {x = pos.x, y = pos.y + height, z = pos.z}
|
||||
local node_top = minetest.get_node(pos_top)
|
||||
local node_top = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
local def_top = minetest.registered_nodes[node_top.name]
|
||||
local player_name = placer:get_player_name()
|
||||
minetest.chat_send_all(dump(height))
|
||||
--minetest.chat_send_all(dump(height))
|
||||
|
||||
if def_top and def_top.liquidtype == "source" and
|
||||
minetest.get_item_group(node_top.name, "water") > 0 then
|
||||
if not minetest.is_protected(pos, player_name) and
|
||||
not minetest.is_protected(pos_top, player_name) then
|
||||
minetest.set_node(pos, {name = "water_life:sharknet",
|
||||
param2 = height * 16 })
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(player_name)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
if def_top and def_top.liquidtype == "source" and height > 1 and height < 11 and minetest.get_item_group(node_top.name, "water") > 0 then
|
||||
if not minetest.is_protected(pos, player_name) and not minetest.is_protected(pos_top, player_name) then
|
||||
|
||||
minetest.set_node(pos, {name = "water_life:shark_buoy",param2 = height * 16 })
|
||||
minetest.add_entity({x=pos.x, y=pos.y+height, z=pos.z},"water_life:buoy")
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("buoy", height)
|
||||
if not (creative and creative.is_enabled_for and creative.is_enabled_for(player_name)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player_name, "Node is protected")
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
@ -107,10 +101,73 @@ minetest.register_node("water_life:sharknet", {
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
local meta=minetest.get_meta(pos)
|
||||
if meta then
|
||||
local height = meta:get_int("buoy")
|
||||
if height then
|
||||
local cpos = {x=pos.x, y= pos.y + height, z=pos.z}
|
||||
local object = minetest.get_objects_inside_radius(cpos, 1)
|
||||
|
||||
for _,obj in ipairs(object) do
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and entity.name == "water_life:buoy" then
|
||||
obj:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmeta, digger)
|
||||
minetest.set_node(pos, {name = "default:water_source"})
|
||||
end
|
||||
})
|
||||
]]
|
||||
|
||||
minetest.register_entity("water_life:buoy",{
|
||||
-- common props
|
||||
physical = true,
|
||||
stepheight = 0.5,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.2, -0.2, -0.2, 0.2, 0.2, 0.2},
|
||||
visual = "mesh",
|
||||
mesh = "water_life_buoy.b3d",
|
||||
textures = {"water_life_buoy.png"},
|
||||
visual_size = {x = 5, y = 5},
|
||||
static_save = true,
|
||||
makes_footstep_sound = false,
|
||||
on_step = mobkit.stepfunc, -- required
|
||||
on_activate = mobkit.actfunc, -- required
|
||||
get_staticdata = mobkit.statfunc,
|
||||
springiness=0,
|
||||
buoyancy = 0.93, -- portion of hitbox submerged
|
||||
max_speed = 0,
|
||||
jump_height = 0,
|
||||
view_range = 16,
|
||||
-- lung_capacity = 0, -- seconds
|
||||
max_hp = 65535,
|
||||
timeout = 0,
|
||||
brainfunc = function(self) return end,
|
||||
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
return
|
||||
end,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
return
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "water_life:shark_buoy",
|
||||
recipe = {
|
||||
{"default:tin_ingot", "dye:orange", "default:tin_ingot"},
|
||||
{"default:tin_ingot", "default:diamond", "default:tin_ingot"},
|
||||
{"default:tin_ingot", "default:tin_ingot", "default:tin_ingot"}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- revive corals if a living one is around
|
||||
|
2
init.lua
2
init.lua
@ -1,5 +1,5 @@
|
||||
water_life = {}
|
||||
water_life.version = "180220"
|
||||
water_life.version = "200220"
|
||||
water_life.shark_food = {}
|
||||
water_life.petz = minetest.get_modpath("petz")
|
||||
water_life.abr = tonumber(minetest.settings:get('active_block_range')) or 2
|
||||
|
BIN
models/water_life_buoy.b3d
Normal file
BIN
models/water_life_buoy.b3d
Normal file
Binary file not shown.
@ -21,7 +21,7 @@ end
|
||||
|
||||
|
||||
local function piranha_brain(self)
|
||||
if self.hp <= 0 then
|
||||
if not mobkit.is_alive(self) then
|
||||
mobkit.clear_queue_high(self)
|
||||
water_life.handle_drops(self)
|
||||
mobkit.hq_die(self)
|
||||
|
@ -11,7 +11,7 @@ water_life.urchinspawn = {
|
||||
|
||||
local function urchin_brain(self)
|
||||
|
||||
if self.hp <= 0 then
|
||||
if not mobkit.is_alive(self) then
|
||||
mobkit.clear_queue_high(self)
|
||||
water_life.handle_drops(self)
|
||||
mobkit.hq_die(self)
|
||||
|
14
shark.lua
14
shark.lua
@ -23,6 +23,8 @@ local function shark_brain(self)
|
||||
if mobkit.timer(self,1) then
|
||||
|
||||
local whale = mobkit.get_closest_entity(self,"water_life:whale")
|
||||
local buoy = mobkit.get_closest_entity(self,"water_life:buoy")
|
||||
|
||||
if whale then
|
||||
local spos = self.object:get_pos()
|
||||
local wpos = whale:get_pos()
|
||||
@ -33,6 +35,18 @@ local function shark_brain(self)
|
||||
mobkit.hq_aqua_turn(self,40,yaw+(pi/2),5)
|
||||
end
|
||||
end
|
||||
|
||||
if buoy then
|
||||
local spos = self.object:get_pos()
|
||||
local wpos = buoy:get_pos()
|
||||
local distance = math.floor(vector.distance(spos,wpos))
|
||||
if distance < 10 then
|
||||
local yaw = self.object:get_yaw()
|
||||
mobkit.clear_queue_high(self)
|
||||
mobkit.hq_aqua_turn(self,45,yaw+(pi/2),5)
|
||||
end
|
||||
end
|
||||
|
||||
local prty = mobkit.get_queue_priority(self)
|
||||
if prty < 20 then
|
||||
local target = mobkit.get_nearby_player(self)
|
||||
|
BIN
textures/water_life_buoy.png
Normal file
BIN
textures/water_life_buoy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
textures/water_life_shark_buoy_item.png
Normal file
BIN
textures/water_life_shark_buoy_item.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 342 B |
Binary file not shown.
Before Width: | Height: | Size: 598 B After Width: | Height: | Size: 601 B |
Binary file not shown.
Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 477 B |
Loading…
x
Reference in New Issue
Block a user