Update 1.1

This commit is contained in:
echoes91 2015-03-31 20:14:46 +02:00
parent b64a278837
commit d80bd11ee2
2 changed files with 212 additions and 0 deletions

114
standard_arrows.lua Normal file
View File

@ -0,0 +1,114 @@
function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
minetest.register_craftitem("throwing:arrow_" .. kind, {
description = desc .. " arrow",
inventory_image = "throwing_arrow_" .. kind .. ".png",
})
minetest.register_node("throwing:arrow_" .. kind .. "_box", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-- Shaft
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
--Spitze
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
--Federn
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = {"throwing_arrow_" .. kind .. ".png", "throwing_arrow_" .. kind .. ".png", "throwing_arrow_" .. kind .. "_back.png", "throwing_arrow_" .. kind .. "_front.png", "throwing_arrow_" .. kind .. "_2.png", "throwing_arrow_" .. kind .. ".png"},
groups = {not_in_creative_inventory=1},
})
local THROWING_ARROW_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.1, y=0.1},
textures = {"throwing:arrow_" .. kind .. "_box"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.get_node(pos)
if self.timer>0.2 then
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
local speed = vector.length(self.object:getvelocity())
local damage = ((speed + eq)^1.2)/10
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=damage},
}, nil)
self.object:remove()
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
else
minetest.add_item(self.lastpos, 'default:stick')
end
end
end
end
end
if self.lastpos.x~=nil then
if node.name ~= "air" and not string.find(node.name, 'default:grass') and not string.find(node.name, 'default:junglegrass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then
self.object:remove()
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
else
minetest.add_item(self.lastpos, 'default:stick')
end
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("throwing:arrow_" .. kind .. "_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_' .. kind .. ' 16',
recipe = {
{'default:stick', 'default:stick', craft},
}
})
minetest.register_craft({
output = 'throwing:arrow_' .. kind .. ' 16',
recipe = {
{craft, 'default:stick', 'default:stick'},
}
})
end
if not DISABLE_STONE_ARROW then
throwing_register_arrow_standard ('stone', 'Stone', 0, 0.88, 'group:stone')
end
if not DISABLE_STEEL_ARROW then
throwing_register_arrow_standard ('steel', 'Steel', 5, 0.94, 'default:steel_ingot')
end
if not DISABLE_DIAMOND_ARROW then
throwing_register_arrow_standard ('diamond', 'Diamond', 10, 0.97, 'default:diamond')
end
if not DISABLE_OBSIDIAN_ARROW then
throwing_register_arrow_standard ('obsidian', 'Obsidian', 15, 0.88, 'default:obsidian')
end

98
tools.lua Normal file
View File

@ -0,0 +1,98 @@
function throwing_register_bow (name, desc, scale, stiffness, reload_time, toughness, is_cross, craft)
minetest.register_tool("throwing:" .. name, {
description = desc,
inventory_image = "throwing_" .. name .. ".png",
wield_scale = scale,
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local pos = user:getpos()
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, "throwing:" .. name .. "_loaded")
return itemstack
end,
})
minetest.register_tool("throwing:" .. name .. "_loaded", {
description = desc,
inventory_image = "throwing_" .. name .. "_loaded.png",
wield_scale = scale,
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local wear = itemstack:get_wear()
if not minetest.setting_getbool("creative_mode") then
wear = wear + (65535/toughness)
end
local unloaded = "throwing:" .. name
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:" .. name
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
end,
groups = {not_in_creative_inventory=1},
})
minetest.register_craft({
output = 'throwing:' .. name,
recipe = craft
})
minetest.register_craft({
output = 'throwing:' .. name,
recipe = {
{craft[1][3], craft[1][2], craft[1][1]},
{craft[2][3], craft[2][2], craft[2][1]},
{craft[3][3], craft[3][2], craft[3][1]},
}
})
end
if not DISABLE_WOODEN_BOW then
throwing_register_bow ('bow_wood', 'Wooden bow', {x=1, y=1, z=0.5}, 11, 0.8, 50, false, {
{'', 'default:stick', ''},
{'farming:string', '', 'default:stick'},
{'', 'default:stick', ''},
})
end
if not DISABLE_LONGBOW then
throwing_register_bow ('longbow', 'Longbow', {x=1, y=2.5, z=0.5}, 17, 1.8, 100, false, {
{'farming:string', 'group:wood', ''},
{'farming:string', '', 'group:wood'},
{'farming:string', 'group:wood', ''},
})
end
if not DISABLE_COMPOSITE_BOW then
throwing_register_bow ('bow_composite', 'Composite bow', {x=1, y=1.4, z=0.5}, 17, 1, 150, false, {
{'farming:string', 'group:wood', ''},
{'farming:string', '', 'default:steel_ingot'},
{'farming:string', 'group:wood', ''},
})
end
if not DISABLE_STEEL_BOW then
throwing_register_bow ('bow_steel', 'Steel bow', {x=1, y=1.4, z=0.5}, 20, 1.3, 250, false, {
{'farming:string', 'default:steel_ingot', ''},
{'farming:string', '', 'default:steel_ingot'},
{'farming:string', 'default:steel_ingot', ''},
})
end
if not DISABLE_ROYAL_BOW then
throwing_register_bow ('bow_royal', 'Royal bow', {x=1, y=1.5, z=0.5}, 18, 1.4, 750, false, {
{'farming:string', 'group:wood', 'default:diamond'},
{'farming:string', '', 'default:gold_ingot'},
{'farming:string', 'group:wood', 'default:diamond'},
})
end
if not DISABLE_CROSSBOW then
throwing_register_bow ('crossbow', 'Crossbow', {x=1, y=1, z=0.5}, 28, 5, 80, true, {
{'group:wood', 'farming:string', ''},
{'default:steel_ingot', 'farming:string', 'group:wood'},
{'group:wood', 'farming:string', ''},
})
end