forked from mtcontrib/spears
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
3c174db494 | |||
00d86908d8 | |||
5a214d3b44 | |||
2c0ebde983 |
@ -1,4 +1,6 @@
|
|||||||
DISABLE_STONE_SPEAR = false
|
DISABLE_STONE_SPEAR = false
|
||||||
DISABLE_STEEL_SPEAR = false
|
DISABLE_STEEL_SPEAR = false
|
||||||
|
DISABLE_COPPER_SPEAR = false
|
||||||
|
DISABLE_BRONZE_SPEAR = false
|
||||||
DISABLE_DIAMOND_SPEAR = false
|
DISABLE_DIAMOND_SPEAR = false
|
||||||
DISABLE_OBSIDIAN_SPEAR = false
|
DISABLE_OBSIDIAN_SPEAR = false
|
||||||
|
@ -3,7 +3,7 @@ function spears_shot (itemstack, player)
|
|||||||
local playerpos = player:getpos()
|
local playerpos = player:getpos()
|
||||||
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear)
|
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear)
|
||||||
local dir = player:get_look_dir()
|
local dir = player:get_look_dir()
|
||||||
local sp = 14
|
local sp = 16
|
||||||
local dr = .3
|
local dr = .3
|
||||||
local gravity = 9.8
|
local gravity = 9.8
|
||||||
obj:setvelocity({x=dir.x*sp, y=dir.y*sp, z=dir.z*sp})
|
obj:setvelocity({x=dir.x*sp, y=dir.y*sp, z=dir.z*sp})
|
||||||
@ -14,19 +14,19 @@ function spears_shot (itemstack, player)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function spears_set_entity(kind, eq, toughness)
|
function spears_set_entity(spear_type, base_damage, toughness)
|
||||||
local SPEAR_ENTITY={
|
local SPEAR_ENTITY={
|
||||||
physical = false,
|
physical = false,
|
||||||
timer=0,
|
timer=0,
|
||||||
visual = "wielditem",
|
visual = "wielditem",
|
||||||
visual_size = {x=0.15, y=0.1},
|
visual_size = {x=0.15, y=0.1},
|
||||||
textures = {"spears:spear_" .. kind},
|
textures = {"spears:spear_" .. spear_type},
|
||||||
lastpos={},
|
lastpos={},
|
||||||
collisionbox = {0,0,0,0,0,0},
|
collisionbox = {0,0,0,0,0,0},
|
||||||
on_punch = function(self, puncher)
|
on_punch = function(self, puncher)
|
||||||
if puncher then
|
if puncher then
|
||||||
if puncher:is_player() then
|
if puncher:is_player() then
|
||||||
local stack = {name='spears:spear_' .. kind, wear=self.wear+65535/toughness}
|
local stack = {name='spears:spear_' .. spear_type, wear=self.wear+65535/toughness}
|
||||||
local inv = puncher:get_inventory()
|
local inv = puncher:get_inventory()
|
||||||
if inv:room_for_item("main", stack) then
|
if inv:room_for_item("main", stack) then
|
||||||
inv:add_item("main", stack)
|
inv:add_item("main", stack)
|
||||||
@ -49,22 +49,22 @@ function spears_set_entity(kind, eq, toughness)
|
|||||||
if node.name ~= "air" and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then
|
if node.name ~= "air" and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
if self.wear+65535/toughness < 65535 then
|
if self.wear+65535/toughness < 65535 then
|
||||||
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
|
minetest.add_item(self.lastpos, {name='spears:spear_' .. spear_type, wear=self.wear+65535/toughness})
|
||||||
end
|
end
|
||||||
elseif self.timer>0.2 then
|
elseif self.timer>0.2 then
|
||||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
|
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
|
||||||
for k, obj in pairs(objs) do
|
for k, obj in pairs(objs) do
|
||||||
if obj:get_luaentity() ~= nil then
|
if obj:get_luaentity() ~= nil then
|
||||||
if obj:get_luaentity().name ~= "spears:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
if obj:get_luaentity().name ~= "spears:spear_" .. spear_type .. "_entity" and obj:get_luaentity().name ~= "_builtin:item" then
|
||||||
local speed = vector.length(self.object:getvelocity())
|
local speed = vector.length(self.object:getvelocity())
|
||||||
local damage = (speed + eq)^1.12-20
|
local damage = (speed + base_damage)^1.12-20
|
||||||
obj:punch(self.object, 1.0, {
|
obj:punch(self.object, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
damage_groups={fleshy=damage},
|
damage_groups={fleshy=damage},
|
||||||
}, nil)
|
}, nil)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
if self.wear+65535/toughness < 65535 then
|
if self.wear+65535/toughness < 65535 then
|
||||||
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
|
minetest.add_item(self.lastpos, {name='spears:spear_' .. spear_type, wear=self.wear+65535/toughness})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
6
spears.conf.example
Normal file
6
spears.conf.example
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
DISABLE_STONE_SPEAR = true
|
||||||
|
DISABLE_STEEL_SPEAR = true
|
||||||
|
DISABLE_COPPER_SPEAR = true
|
||||||
|
DISABLE_BRONZE_SPEAR = true
|
||||||
|
DISABLE_DIAMOND_SPEAR = true
|
||||||
|
DISABLE_OBSIDIAN_SPEAR = true
|
BIN
textures/spears_spear_bronze.png
Normal file
BIN
textures/spears_spear_bronze.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 247 B |
BIN
textures/spears_spear_copper.png
Normal file
BIN
textures/spears_spear_copper.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 256 B |
34
tools.lua
34
tools.lua
@ -1,46 +1,40 @@
|
|||||||
function spears_register_spear(kind, desc, eq, toughness, material)
|
function spears_register_spear(spear_type, desc, base_damage, toughness, material)
|
||||||
|
|
||||||
minetest.register_tool("spears:spear_" .. kind, {
|
minetest.register_tool("spears:spear_" .. spear_type, {
|
||||||
description = desc .. " spear",
|
description = desc .. " spear",
|
||||||
inventory_image = "spears_spear_" .. kind .. ".png",
|
wield_image = "spears_spear_" .. spear_type .. ".png",
|
||||||
|
inventory_image = "spears_spear_" .. spear_type .. ".png^[transform4",
|
||||||
wield_scale= {x=2,y=1,z=1},
|
wield_scale= {x=2,y=1,z=1},
|
||||||
on_drop = function(itemstack, user, pointed_thing)
|
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||||
spears_shot(itemstack, user)
|
spears_shot(itemstack, user)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
on_place = function(itemstack, user, pointed_thing)
|
|
||||||
minetest.add_item(pointed_thing.above, itemstack)
|
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
end,
|
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
full_punch_interval = 1.5,
|
full_punch_interval = 1.5,
|
||||||
max_drop_level=1,
|
max_drop_level=1,
|
||||||
groupcaps={
|
groupcaps={
|
||||||
cracky = {times={[3]=2}, uses=toughness, maxlevel=1},
|
cracky = {times={[3]=2}, uses=toughness, maxlevel=1},
|
||||||
},
|
},
|
||||||
damage_groups = {fleshy=eq},
|
damage_groups = {fleshy=base_damage},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
SPEAR_ENTITY=spears_set_entity(kind, eq, toughness)
|
local SPEAR_ENTITY=spears_set_entity(spear_type, base_damage, toughness)
|
||||||
|
|
||||||
minetest.register_entity("spears:spear_" .. kind .. "_entity", SPEAR_ENTITY)
|
minetest.register_entity("spears:spear_" .. spear_type .. "_entity", SPEAR_ENTITY)
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'spears:spear_' .. kind,
|
output = 'spears:spear_' .. spear_type,
|
||||||
recipe = {
|
recipe = {
|
||||||
{'group:wood', 'group:wood', material},
|
{'group:wood', 'group:wood', material},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'spears:spear_' .. kind,
|
output = 'spears:spear_' .. spear_type,
|
||||||
recipe = {
|
recipe = {
|
||||||
{material, 'group:wood', 'group:wood'},
|
{material, 'group:wood', 'group:wood'},
|
||||||
}
|
}
|
||||||
@ -55,6 +49,14 @@ if not DISABLE_STEEL_SPEAR then
|
|||||||
spears_register_spear('steel', 'Steel', 6, 30, 'default:steel_ingot')
|
spears_register_spear('steel', 'Steel', 6, 30, 'default:steel_ingot')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not DISABLE_COPPER_SPEAR then
|
||||||
|
spears_register_spear('copper', 'Copper', 5, 35, 'default:copper_ingot')
|
||||||
|
end
|
||||||
|
|
||||||
|
if not DISABLE_BRONZE_SPEAR then
|
||||||
|
spears_register_spear('bronze', 'Bronze', 6, 35, 'default:bronze_ingot')
|
||||||
|
end
|
||||||
|
|
||||||
if not DISABLE_OBSIDIAN_SPEAR then
|
if not DISABLE_OBSIDIAN_SPEAR then
|
||||||
spears_register_spear('obsidian', 'Obsidian', 8, 30, 'default:obsidian')
|
spears_register_spear('obsidian', 'Obsidian', 8, 30, 'default:obsidian')
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user