forked from mtcontrib/throwing
304 lines
9.1 KiB
Lua
304 lines
9.1 KiB
Lua
--~
|
|
--~ Bows
|
|
--~
|
|
|
|
if not DISABLE_WOODEN_BOW then
|
|
minetest.register_tool("throwing:bow_wood", {
|
|
description = "Wooden Bow",
|
|
inventory_image = "throwing_bow_wood.png",
|
|
wield_scale = {x=1, y=1, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local reload_time = 0.8
|
|
local loaded = "throwing:bow_wood_loaded"
|
|
local is_cross = false
|
|
local pos = user:getpos()
|
|
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
|
|
return itemstack
|
|
end,
|
|
})
|
|
|
|
minetest.register_tool("throwing:bow_wood_loaded", {
|
|
description = "Wooden Bow",
|
|
inventory_image = "throwing_bow_wood_loaded.png",
|
|
wield_scale = {x=1, y=1, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local stiffness = 11
|
|
local wear = itemstack:get_wear()
|
|
local is_cross = false
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
wear = wear + (65535/50)
|
|
end
|
|
local unloaded = "throwing:bow_wood"
|
|
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
|
|
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
|
|
return itemstack
|
|
end,
|
|
on_drop = function(itemstack, dropper, pointed_thing)
|
|
local wear = itemstack:get_wear()
|
|
local unloaded = "throwing:bow_wood"
|
|
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
|
|
end,
|
|
groups = {not_in_creative_inventory=1},
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:bow_wood',
|
|
recipe = {
|
|
{'', 'default:stick', ''},
|
|
{'farming:string', '', 'default:stick'},
|
|
{'', 'default:stick', ''},
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:bow_wood',
|
|
recipe = {
|
|
{'', 'default:stick', ''},
|
|
{'default:stick', '', 'farming:string'},
|
|
{'', 'default:stick', ''},
|
|
}
|
|
})
|
|
end
|
|
|
|
if not DISABLE_LONGBOW then
|
|
minetest.register_tool("throwing:longbow", {
|
|
description = "Longbow",
|
|
inventory_image = "throwing_longbow.png",
|
|
wield_scale = {x=1, y=2.5, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local reload_time = 1.8
|
|
local loaded = "throwing:longbow_loaded"
|
|
local is_cross = false
|
|
local pos = user:getpos()
|
|
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
|
|
return itemstack
|
|
end,
|
|
})
|
|
|
|
minetest.register_tool("throwing:longbow_loaded", {
|
|
description = "Longbow",
|
|
inventory_image = "throwing_longbow_loaded.png",
|
|
wield_scale = {x=1, y=2.5, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local stiffness = 17
|
|
local wear = itemstack:get_wear()
|
|
local is_cross = false
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
wear = wear + (65535/100)
|
|
end
|
|
local unloaded = "throwing:longbow"
|
|
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
|
|
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
|
|
return itemstack
|
|
end,
|
|
on_drop = function(itemstack, dropper, pointed_thing)
|
|
local wear = itemstack:get_wear()
|
|
local unloaded = "throwing:longbow"
|
|
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
|
|
end,
|
|
groups = {not_in_creative_inventory=1},
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:longbow',
|
|
recipe = {
|
|
{'farming:string', 'group:wood', ''},
|
|
{'farming:string', '', 'group:wood'},
|
|
{'farming:string', 'group:wood', ''},
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:longbow',
|
|
recipe = {
|
|
{'', 'group:wood', 'farming:string'},
|
|
{'group:wood', '', 'farming:string'},
|
|
{'', 'group:wood', 'farming:string'},
|
|
}
|
|
})
|
|
end
|
|
|
|
if not DISABLE_COMPOSITE_BOW then
|
|
minetest.register_tool("throwing:bow_composite", {
|
|
description = "Composite Bow",
|
|
inventory_image = "throwing_bow_composite.png",
|
|
wield_scale = {x=1, y=1.4, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local reload_time = 1
|
|
local loaded = "throwing:bow_composite_loaded"
|
|
local is_cross = false
|
|
local pos = user:getpos()
|
|
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
|
|
return itemstack
|
|
end,
|
|
})
|
|
|
|
minetest.register_tool("throwing:bow_composite_loaded", {
|
|
description = "Composite Bow",
|
|
inventory_image = "throwing_bow_composite_loaded.png",
|
|
wield_scale = {x=1, y=1.4, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local stiffness = 17
|
|
local wear = itemstack:get_wear()
|
|
local is_cross = false
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
wear = wear + (65535/150)
|
|
end
|
|
local unloaded = "throwing:bow_composite"
|
|
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
|
|
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
|
|
return itemstack
|
|
end,
|
|
on_drop = function(itemstack, dropper, pointed_thing)
|
|
local wear = itemstack:get_wear()
|
|
local unloaded = "throwing:bow_composite"
|
|
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
|
|
end,
|
|
groups = {not_in_creative_inventory=1},
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:bow_composite',
|
|
recipe = {
|
|
{'farming:string', 'group:wood', ''},
|
|
{'farming:string', '', 'default:steel_ingot'},
|
|
{'farming:string', 'group:wood', ''},
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:bow_composite',
|
|
recipe = {
|
|
{'', 'group:wood', 'farming:string'},
|
|
{'default:steel_ingot', '', 'farming:string'},
|
|
{'', 'group:wood', 'farming:string'},
|
|
}
|
|
})
|
|
end
|
|
|
|
if not DISABLE_STEEL_BOW then
|
|
minetest.register_tool("throwing:bow_steel", {
|
|
description = "Steel Bow",
|
|
inventory_image = "throwing_bow_steel.png",
|
|
wield_scale = {x=1, y=1.4, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local reload_time = 1.2
|
|
local loaded = "throwing:bow_steel_loaded"
|
|
local is_cross = false
|
|
local pos = user:getpos()
|
|
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
|
|
return itemstack
|
|
end,
|
|
})
|
|
|
|
minetest.register_tool("throwing:bow_steel_loaded", {
|
|
description = "Steel Bow",
|
|
inventory_image = "throwing_bow_steel_loaded.png",
|
|
wield_scale = {x=1, y=1.4, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local stiffness = 20
|
|
local wear = itemstack:get_wear()
|
|
local is_cross = false
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
wear = wear + (65535/250)
|
|
end
|
|
local unloaded = "throwing:bow_steel"
|
|
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
|
|
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
|
|
return itemstack
|
|
end,
|
|
on_drop = function(itemstack, dropper, pointed_thing)
|
|
local wear = itemstack:get_wear()
|
|
local unloaded = "throwing:bow_steel"
|
|
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
|
|
end,
|
|
groups = {not_in_creative_inventory=1},
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:bow_steel',
|
|
recipe = {
|
|
{'farming:string', 'default:steel_ingot', ''},
|
|
{'farming:string', '', 'default:steel_ingot'},
|
|
{'farming:string', 'default:steel_ingot', ''},
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:bow_steel',
|
|
recipe = {
|
|
{'', 'default:steel_ingot', 'farming:string'},
|
|
{'default:steel_ingot', '', 'farming:string'},
|
|
{'', 'default:steel_ingot', 'farming:string'},
|
|
}
|
|
})
|
|
end
|
|
|
|
if not DISABLE_ROYAL_BOW then
|
|
minetest.register_tool("throwing:bow_royal", {
|
|
description = "Royal Bow",
|
|
inventory_image = "throwing_bow_royal.png",
|
|
wield_scale = {x=1, y=1.4, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local reload_time = 1.2
|
|
local loaded = "throwing:bow_royal_loaded"
|
|
local is_cross = false
|
|
local pos = user:getpos()
|
|
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
|
|
return itemstack
|
|
end,
|
|
})
|
|
|
|
minetest.register_tool("throwing:bow_royal_loaded", {
|
|
description = "Royal Bow",
|
|
inventory_image = "throwing_bow_royal_loaded.png",
|
|
wield_scale = {x=1, y=1.4, z=0.5},
|
|
stack_max = 1,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
local stiffness = 18
|
|
local wear = itemstack:get_wear()
|
|
local is_cross = false
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
wear = wear + (65535/750)
|
|
end
|
|
local unloaded = "throwing:bow_royal"
|
|
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
|
|
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
|
|
return itemstack
|
|
end,
|
|
on_drop = function(itemstack, dropper, pointed_thing)
|
|
local wear = itemstack:get_wear()
|
|
local unloaded = "throwing:bow_royal"
|
|
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
|
|
end,
|
|
groups = {not_in_creative_inventory=1},
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:bow_royal',
|
|
recipe = {
|
|
{'farming:string', 'group:wood', 'default:diamond'},
|
|
{'farming:string', '', 'default:gold_ingot'},
|
|
{'farming:string', 'group:wood', 'default:diamond'},
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = 'throwing:bow_royal',
|
|
recipe = {
|
|
{'default:diamond', 'group:wood', 'farming:string'},
|
|
{'default:gold_ingot', '', 'farming:string'},
|
|
{'default:diamond', 'group:wood', 'farming:string'},
|
|
}
|
|
})
|
|
end
|