forked from mtcontrib/throwing
Update 0.9.2: Introduced chance to break for many arrows, added golden bow
This commit is contained in:
parent
bdc555c290
commit
ff044fb1f1
33
bows.lua
33
bows.lua
@ -22,6 +22,7 @@ local throwing_shoot_arrow = function(itemstack, player)
|
||||
end
|
||||
obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()+2)
|
||||
obj:get_luaentity().inventory = player:get_inventory()
|
||||
obj:get_luaentity().breaks = math.random()
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -67,7 +68,7 @@ minetest.register_tool("throwing:bow_steel", {
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
stiffness = 20
|
||||
reload = 1.4
|
||||
reload = 1.5
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
reloading()
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
@ -97,7 +98,7 @@ minetest.register_tool("throwing:bow_composite", {
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
reloading()
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/300)
|
||||
itemstack:add_wear(65535/250)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
@ -108,7 +109,33 @@ minetest.register_craft({
|
||||
output = 'throwing:bow_composite',
|
||||
recipe = {
|
||||
{'farming:string', 'default:steel_ingot', 'group:wood'},
|
||||
{'farming:string', 'group:wood', 'default:steel_ingot'},
|
||||
{'farming:string', 'group:wood', 'default:bronze_ingot'},
|
||||
{'farming:string', 'default:steel_ingot', 'group:wood'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_tool("throwing:bow_gold", {
|
||||
description = "Golden Bow",
|
||||
inventory_image = "throwing_bow_gold.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
stiffness = 20
|
||||
reload = 1.5
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
reloading()
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/1000)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:bow_composite',
|
||||
recipe = {
|
||||
{'farming:string', 'default:gold_ingot', ''},
|
||||
{'farming:string', 'group:wood', 'default:gold_ingot'},
|
||||
{'farming:string', 'default:steel_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
@ -54,12 +54,13 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
self.inventory:remove_item("main", {name=self.stack:get_name()})
|
||||
end
|
||||
if self.stack:get_definition().type == "node" and self.stack:get_name() ~= "default:torch" then
|
||||
minetest.place_node(self.lastpos, {name=self.stack:get_name()})
|
||||
else
|
||||
minetest.add_item(self.lastpos, {name=self.stack:get_name()})
|
||||
end
|
||||
local toughness = 0.95
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_build')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -71,12 +72,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
self.inventory:remove_item("main", {name=self.stack:get_name()})
|
||||
end
|
||||
if self.stack:get_definition().type == "node" and self.stack:get_name() ~= "default:torch" then
|
||||
if not string.find(node.name, "water") and not string.find(node.name, "lava") and not string.find(node.name, "torch") and self.stack:get_definition().type == "node" and self.stack:get_name() ~= "default:torch" then
|
||||
minetest.place_node(self.lastpos, {name=self.stack:get_name()})
|
||||
else
|
||||
minetest.add_item(self.lastpos, {name=self.stack:get_name()})
|
||||
end
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_build')
|
||||
minetest.add_item(self.lastpos, 'default:shovel_steel')
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
|
@ -55,7 +55,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
local toughness = 0.97
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_diamond')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -64,7 +69,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
local toughness = 0.95
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_diamond')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
|
@ -49,9 +49,18 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "throwing:arrow_dig_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local damage = 1.5
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
minetest.add_item(pos, 'throwing:arrow_dig')
|
||||
minetest.dig_node(pos)
|
||||
local toughness = 0.9
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_dig')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -60,9 +69,16 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_dig')
|
||||
if node.diggable ~= false then
|
||||
minetest.dig_node(pos)
|
||||
end
|
||||
local toughness = 0.65
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'default:pick_steel')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
|
@ -49,12 +49,13 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "throwing:arrow_fire_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local damage = 5
|
||||
local damage = 4
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -55,7 +55,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
local toughness = 0.94
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_obsidian')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -64,7 +69,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
local toughness = 0.88
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_obsidian')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
|
@ -55,7 +55,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
local toughness = 0.95
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_steel')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -64,7 +69,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
local toughness = 0.9
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_steel')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
|
@ -55,7 +55,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
local toughness = 0.94
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_stone')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -64,7 +69,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
local toughness = 0.88
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_stone')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
|
@ -53,7 +53,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.object:remove()
|
||||
if self.player ~= "" then
|
||||
self.player:setpos(pos)
|
||||
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
|
||||
self.player:get_inventory():add_item("main", ItemStack("defautl:mese_crystal_fragment"))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -65,7 +65,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.object:remove()
|
||||
if self.player ~= "" then
|
||||
self.player:setpos(self.lastpos)
|
||||
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
|
||||
self.player:get_inventory():add_item("main", ItemStack("defautl:mese_crystal_fragment"))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -77,6 +77,6 @@ minetest.register_entity("throwing:arrow_teleport_entity", THROWING_ARROW_ENTITY
|
||||
minetest.register_craft({
|
||||
output = 'throwing:arrow_teleport',
|
||||
recipe = {
|
||||
{'default:stick', 'default:stick', 'default:mese'},
|
||||
{'default:stick', 'default:stick', 'default:mese_crystal_fragment 2'},
|
||||
}
|
||||
})
|
||||
|
@ -116,7 +116,7 @@ local function destroy(drops, pos, cid)
|
||||
if def and def.flammable then
|
||||
minetest.set_node(pos, fire_node)
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
minetest.dig_node(pos)
|
||||
if def then
|
||||
local node_drops = minetest.get_node_drops(def.name, "")
|
||||
for _, item in ipairs(node_drops) do
|
||||
@ -156,7 +156,7 @@ local function entity_physics(pos, radius)
|
||||
obj_vel, radius * 10))
|
||||
end
|
||||
|
||||
local damage = (4 / dist) * radius
|
||||
local damage = (5 / dist) * radius
|
||||
obj:set_hp(obj:get_hp() - damage)
|
||||
end
|
||||
end
|
||||
@ -254,7 +254,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "throwing:arrow_tnt_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
self.object:remove()
|
||||
boom(self.lastpos)
|
||||
boom(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -56,6 +56,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
local toughness = 0.9
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_diamond')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -64,9 +70,55 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
local dir={x=pos.x-self.lastpos.x, y=pos.y-self.lastpos.y, z=pos.z-self.lastpos.z}
|
||||
if not string.find(node.name, "water") and not string.find(node.name, "lava") and not string.find(node.name, "torch") then
|
||||
local dir=vector.direction(self.lastpos, pos)
|
||||
local wall=minetest.dir_to_wallmounted(dir)
|
||||
minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
|
||||
--~ if wall == 0 then Check doesn't help :(
|
||||
--~ local check_pos={self.lastpos.x, self.lastpos.y+0.5, self.lastpos.z}
|
||||
--~ if minetest.get_node(check_pos).name ~= "air" then
|
||||
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
|
||||
--~ self.object:remove()
|
||||
--~ end
|
||||
--~ elseif wall == 1 then
|
||||
--~ local check_pos={self.lastpos.x, self.lastpos.y-0.5, self.lastpos.z}
|
||||
--~ if minetest.get_node(check_pos).name ~= "air" then
|
||||
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
|
||||
--~ self.object:remove()
|
||||
--~ end
|
||||
--~ elseif wall == 2 then
|
||||
--~ local check_pos={self.lastpos.x+0.5, self.lastpos.y, self.lastpos.z}
|
||||
--~ if minetest.get_node(check_pos).name ~= "air" then
|
||||
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
|
||||
--~ self.object:remove()
|
||||
--~ end
|
||||
--~ elseif wall == 3 then
|
||||
--~ local check_pos={self.lastpos.x-0.5, self.lastpos.y, self.lastpos.z}
|
||||
--~ if minetest.get_node(check_pos).name ~= "air" then
|
||||
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
|
||||
--~ self.object:remove()
|
||||
--~ end
|
||||
--~ elseif wall == 4 then
|
||||
--~ local check_pos={self.lastpos.x, self.lastpos.y, self.lastpos.z+0.5}
|
||||
--~ if minetest.get_node(check_pos).name ~= "air" then
|
||||
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
|
||||
--~ self.object:remove()
|
||||
--~ end
|
||||
--~ elseif wall == 5 then
|
||||
--~ local check_pos={self.lastpos.x, self.lastpos.y, self.lastpos.z-0.5}
|
||||
--~ if minetest.get_node(check_pos).name ~= "air" then
|
||||
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
|
||||
--~ self.object:remove()
|
||||
--~ end
|
||||
--~ end
|
||||
else
|
||||
local toughness = 0.9
|
||||
if self.breaks < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_torch')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
|
Loading…
Reference in New Issue
Block a user