Version MFF.
0
README.txt
Normal file → Executable file
78
build_arrow.lua
Normal file → Executable file
@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_build_box", {
|
||||
{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},
|
||||
@ -38,56 +38,66 @@ local THROWING_ARROW_ENTITY={
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
node = "",
|
||||
player = "",
|
||||
inventory = false,
|
||||
stack = false,
|
||||
bow_damage = 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 not self.inventory or not self.stack then
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
if self.timer>0.2 then
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "throwing:arrow_build_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
self.object:remove()
|
||||
local newpos = self.object:getpos()
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
local node = minetest.get_node(pos)
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
if self.inventory and self.stack and not minetest.setting_getbool("creative_mode") then
|
||||
self.inventory:remove_item("main", {name=self.stack:get_name()})
|
||||
end
|
||||
if self.stack then
|
||||
minetest.add_item(self.lastpos, {name=self.stack:get_name()})
|
||||
minetest.add_item(pos, {name=self.stack:get_name()})
|
||||
end
|
||||
local toughness = 0.95
|
||||
if math.random() < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_build')
|
||||
minetest.add_item(pos, 'throwing:arrow_build')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
minetest.add_item(pos, 'default:stick')
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if node.name ~= "air"
|
||||
and not string.find(node.name, "water_")
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "ignore" and self.inventory and self.stack then
|
||||
if not minetest.is_protected(self.lastpos, "")
|
||||
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
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
self.inventory:remove_item("main", {name=self.stack:get_name()})
|
||||
end
|
||||
end
|
||||
minetest.add_item(self.lastpos, 'default:shovel_steel')
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
if self.inventory and self.stack and not minetest.setting_getbool("creative_mode") then
|
||||
self.inventory:remove_item("main", {name=self.stack:get_name()})
|
||||
end
|
||||
if self.stack 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
|
||||
end
|
||||
minetest.add_item(self.lastpos, 'default:shovel_steel')
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_build_entity", THROWING_ARROW_ENTITY)
|
||||
|
13
crafts.lua
Executable file
@ -0,0 +1,13 @@
|
||||
-- Craft recipe of the "Mithril String"
|
||||
minetest.register_craft({
|
||||
output = "throwing:string_mithril",
|
||||
description = "Mithril String",
|
||||
inventory_image = "string_mithril.png",
|
||||
type = "shapeless",
|
||||
recipe = {"default:mithril_ingot", "farming:string"},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("throwing:string_mithril", {
|
||||
inventory_image = "throwing_string_mithril.png",
|
||||
description = "Mithril String",
|
||||
})
|
4
defaults.lua
Normal file → Executable file
@ -23,7 +23,3 @@ DISABLE_STEEL_ARROW = false
|
||||
DISABLE_DIAMOND_ARROW = false
|
||||
DISABLE_OBSIDIAN_ARROW = false
|
||||
|
||||
DISABLE_STONE_SPEAR = false
|
||||
DISABLE_STEEL_SPEAR = false
|
||||
DISABLE_DIAMOND_SPEAR = false
|
||||
DISABLE_OBSIDIAN_SPEAR = false
|
||||
|
0
depends.txt
Normal file → Executable file
0
description.txt
Normal file → Executable file
83
dig_arrow.lua
Normal file → Executable file
@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_dig_box", {
|
||||
{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},
|
||||
@ -37,50 +37,59 @@ local THROWING_ARROW_ENTITY={
|
||||
textures = {"throwing:arrow_dig_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
player = "",
|
||||
bow_damage = 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}, 1)
|
||||
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()
|
||||
local toughness = 0.9
|
||||
if math.random() < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_dig')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
local newpos = self.object:getpos()
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
local node = minetest.get_node(pos)
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
if throwing_touch(pos, obj:getpos()) then
|
||||
local puncher = self.object
|
||||
if self.player and minetest.get_player_by_name(self.player) then
|
||||
puncher = minetest.get_player_by_name(self.player)
|
||||
end
|
||||
local damage = 1.5
|
||||
if self.bow_damage and self.bow_damage > 0 then
|
||||
damage = damage + (self.bow_damage/12)
|
||||
end
|
||||
obj:punch(puncher, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
|
||||
minetest.add_item(pos, "throwing:arrow_dig")
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
if node.name ~= "air"
|
||||
and not string.find(node.name, "water_")
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "ignore" and minetest.get_item_group(node.name, "unbreakable") == 0
|
||||
and not minetest.is_protected(pos, self.player)
|
||||
and node.diggable ~= false then
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
minetest.add_item(pos, node.name)
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
if node.diggable ~= false then
|
||||
minetest.dig_node(pos)
|
||||
end
|
||||
local toughness = 0.65
|
||||
if math.random() < 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}
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_dig_entity", THROWING_ARROW_ENTITY)
|
||||
|
80
fire_arrow.lua
Normal file → Executable file
@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_fire_box", {
|
||||
{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},
|
||||
@ -31,53 +31,73 @@ minetest.register_node("throwing:arrow_fire_box", {
|
||||
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:arrow_fire_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
player = "",
|
||||
bow_damage = 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_fire_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
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')
|
||||
local newpos = self.object:getpos()
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
local node = minetest.get_node(pos)
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||
for k, obj in pairs(objs) do
|
||||
local objpos = obj:getpos()
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
if throwing_touch(pos, objpos) then
|
||||
local puncher = self.object
|
||||
if self.player and minetest.get_player_by_name(self.player) then
|
||||
puncher = minetest.get_player_by_name(self.player)
|
||||
end
|
||||
local damage = 4
|
||||
if self.bow_damage and self.bow_damage > 0 then
|
||||
damage = damage + (self.bow_damage/12)
|
||||
end
|
||||
obj:punch(puncher, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
|
||||
minetest.add_item(pos, 'default:stick')
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" and node.name ~= "throwing:light" then
|
||||
minetest.set_node(self.lastpos, {name="fire:basic_flame"})
|
||||
self.object:remove()
|
||||
end
|
||||
if math.floor(self.lastpos.x+0.5) ~= math.floor(pos.x+0.5) or math.floor(self.lastpos.y+0.5) ~= math.floor(pos.y+0.5) or math.floor(self.lastpos.z+0.5) ~= math.floor(pos.z+0.5) then
|
||||
if minetest.get_node(self.lastpos).name == "throwing:light" then
|
||||
minetest.remove_node(self.lastpos)
|
||||
if node.name ~= "air"
|
||||
and node.name ~= "throwing:light"
|
||||
and node.name ~= "fire:basic_flame"
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "ignore" then
|
||||
minetest.set_node(self.lastpos, {name="fire:basic_flame"})
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_node(pos).name == "air" then
|
||||
minetest.set_node(pos, {name="throwing:light"})
|
||||
end
|
||||
if minetest.get_node(self.lastpos).name == "throwing:light" then
|
||||
minetest.remove_node(self.lastpos)
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
end
|
||||
|
||||
|
||||
minetest.register_entity("throwing:arrow_fire_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
minetest.register_node("throwing:light", {
|
||||
@ -85,7 +105,7 @@ minetest.register_node("throwing:light", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
tiles = {"throwing_empty.png"},
|
||||
light_source = LIGHT_MAX-4,
|
||||
light_source = default.LIGHT_MAX-4,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
|
74
fireworks_arrows.lua
Normal file → Executable file
@ -3,7 +3,7 @@ local function throwing_register_fireworks(color, desc)
|
||||
description = desc .. "fireworks arrow",
|
||||
inventory_image = "throwing_arrow_fireworks_" .. color .. ".png",
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("throwing:arrow_fireworks_" .. color .. "_box", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -19,7 +19,7 @@ local function throwing_register_fireworks(color, desc)
|
||||
{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},
|
||||
@ -29,7 +29,7 @@ local function throwing_register_fireworks(color, desc)
|
||||
tiles = {"throwing_arrow_fireworks_" .. color .. ".png", "throwing_arrow_fireworks_" .. color .. ".png", "throwing_arrow_fireworks_" .. color .. "_back.png", "throwing_arrow_fireworks_" .. color .. "_front.png", "throwing_arrow_fireworks_" .. color .. "_2.png", "throwing_arrow_fireworks_" .. color .. ".png"},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
@ -38,10 +38,12 @@ local function throwing_register_fireworks(color, desc)
|
||||
textures = {"throwing:arrow_fireworks_" .. color .. "_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
player = "",
|
||||
bow_damage = 0,
|
||||
}
|
||||
|
||||
|
||||
local radius = 0.5
|
||||
|
||||
|
||||
local function add_effects(pos, radius)
|
||||
minetest.add_particlespawner({
|
||||
amount = 256,
|
||||
@ -59,8 +61,8 @@ local function throwing_register_fireworks(color, desc)
|
||||
texture = "throwing_sparkle_" .. color .. ".png",
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
local function boom(pos)
|
||||
minetest.sound_play("throwing_firework_boom", {pos=pos, gain=1, max_hear_distance=2*64})
|
||||
if minetest.get_node(pos).name == 'air' or minetest.get_node(pos).name == 'throwing:firework_trail' then
|
||||
@ -69,21 +71,20 @@ local function throwing_register_fireworks(color, desc)
|
||||
end
|
||||
add_effects(pos, radius)
|
||||
end
|
||||
|
||||
|
||||
-- Back to the arrow
|
||||
|
||||
|
||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos)
|
||||
local newpos = self.object:getpos()
|
||||
if self.timer < 0.07 then
|
||||
minetest.sound_play("throwing_firework_launch", {pos=pos, gain=0.8, max_hear_distance=2*64})
|
||||
minetest.sound_play("throwing_firework_launch", {pos=newpos, gain=0.8, max_hear_distance=2*64})
|
||||
end
|
||||
minetest.add_particlespawner({
|
||||
amount = 16,
|
||||
time = 0.1,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minpos = newpos,
|
||||
maxpos = newpos,
|
||||
minvel = {x=-5, y=-5, z=-5},
|
||||
maxvel = {x=5, y=5, z=5},
|
||||
minacc = vector.new(),
|
||||
@ -94,48 +95,49 @@ local function throwing_register_fireworks(color, desc)
|
||||
maxsize = 1,
|
||||
texture = "throwing_sparkle.png",
|
||||
})
|
||||
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_fireworks_" .. color .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
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 throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
local damage = 2
|
||||
if self.bow_damage and self.bow_damage > 0 then
|
||||
damage = damage + (self.bow_damage/12)
|
||||
end
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
boom(pos)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.timer > 2 then
|
||||
self.object:remove()
|
||||
boom(self.lastpos)
|
||||
end
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" and node.name ~= "throwing:firework_trail" then
|
||||
self.object:remove()
|
||||
local node = minetest.get_node(newpos)
|
||||
if self.timer > 2 or node.name ~= "air" and node.name ~= "throwing:firework_trail" then
|
||||
boom(self.lastpos)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
if node.name == 'air' then
|
||||
minetest.add_node(newpos, {name="throwing:firework_trail"})
|
||||
minetest.get_node_timer(newpos):start(0.1)
|
||||
end
|
||||
end
|
||||
if node.name == 'air' then
|
||||
minetest.add_node(pos, {name="throwing:firework_trail"})
|
||||
minetest.get_node_timer(pos):start(0.1)
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
end
|
||||
|
||||
|
||||
|
||||
minetest.register_entity("throwing:arrow_fireworks_" .. color .. "_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:arrow_fireworks_' .. color .. ' 8',
|
||||
recipe = {
|
||||
{'default:stick', 'tnt:gunpowder', 'dye:' .. color},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:arrow_fireworks_' .. color .. ' 8',
|
||||
recipe = {
|
||||
|
103
functions.lua
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
--~
|
||||
--~
|
||||
--~ Shot and reload system
|
||||
--~
|
||||
--~
|
||||
|
||||
local players = {}
|
||||
|
||||
@ -16,24 +16,69 @@ minetest.register_on_leaveplayer(function(player)
|
||||
players[playerName] = nil
|
||||
end)
|
||||
|
||||
function throwing_is_player(name, obj)
|
||||
return (obj:is_player() and obj:get_player_name() ~= name)
|
||||
end
|
||||
|
||||
function throwing_is_entity(obj)
|
||||
return (obj:get_luaentity() ~= nil
|
||||
and not string.find(obj:get_luaentity().name, "throwing:")
|
||||
and obj:get_luaentity().name ~= "__builtin:item"
|
||||
and obj:get_luaentity().name ~= "gauges:hp_bar"
|
||||
and obj:get_luaentity().name ~= "signs:text")
|
||||
end
|
||||
|
||||
function throwing_get_trajectoire(self, newpos)
|
||||
if self.lastpos.x == nil then
|
||||
return {newpos}
|
||||
end
|
||||
local coord = {}
|
||||
local nx = (newpos["x"] - self.lastpos["x"])/3
|
||||
local ny = (newpos["y"] - self.lastpos["y"])/3
|
||||
local nz = (newpos["z"] - self.lastpos["z"])/3
|
||||
|
||||
if nx and ny and nz then
|
||||
table.insert(coord, {x=self.lastpos["x"]+nx, y=self.lastpos["y"]+ny ,z=self.lastpos["z"]+nz })
|
||||
table.insert(coord, {x=newpos["x"]-nx, y=newpos["y"]-ny ,z=newpos["z"]-nz })
|
||||
end
|
||||
table.insert(coord, newpos)
|
||||
return coord
|
||||
end
|
||||
|
||||
function throwing_touch(pos, objpos)
|
||||
local rx = pos.x - objpos.x
|
||||
local ry = pos.y - (objpos.y+1)
|
||||
local rz = pos.z - objpos.z
|
||||
if (ry < 1 and ry > -1) and (rx < 1 and rx > -1) and (rz < 1 and rz > -1) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function throwing_shoot_arrow (itemstack, player, stiffness, is_cross)
|
||||
if not player then return end
|
||||
local arrow = itemstack:get_metadata()
|
||||
itemstack:set_metadata("")
|
||||
player:set_wielded_item(itemstack)
|
||||
local playerpos = player:getpos()
|
||||
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow)
|
||||
if not obj then return end
|
||||
local dir = player:get_look_dir()
|
||||
obj:setvelocity({x=dir.x*stiffness, y=dir.y*stiffness, z=dir.z*stiffness})
|
||||
obj:setacceleration({x=dir.x*-3, y=-8.5, z=dir.z*-3})
|
||||
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
|
||||
obj:setyaw(player:get_look_yaw()+math.pi)
|
||||
if is_cross then
|
||||
minetest.sound_play("throwing_crossbow_sound", {pos=playerpos})
|
||||
else
|
||||
minetest.sound_play("throwing_bow_sound", {pos=playerpos})
|
||||
end
|
||||
obj:get_luaentity().player = player
|
||||
obj:get_luaentity().inventory = player:get_inventory()
|
||||
obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()-1)
|
||||
if obj:get_luaentity() then
|
||||
obj:get_luaentity().player = player:get_player_name()
|
||||
obj:get_luaentity().inventory = player:get_inventory()
|
||||
obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()-1)
|
||||
obj:get_luaentity().lastpos = {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}
|
||||
obj:get_luaentity().bow_damage = stiffness
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@ -44,6 +89,7 @@ function throwing_unload (itemstack, player, unloaded, wear)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
player:get_inventory():add_item("main", arrow[1])
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -67,6 +113,7 @@ function throwing_reload (itemstack, player, pos, is_cross, loaded)
|
||||
end
|
||||
local meta = arrow[2]
|
||||
player:set_wielded_item({name=loaded, wear=wear, metadata=meta})
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -80,7 +127,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
|
||||
description = desc,
|
||||
inventory_image = "throwing_" .. name .. ".png",
|
||||
wield_scale = scale,
|
||||
stack_max = 1,
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local pos = user:getpos()
|
||||
local playerName = user:get_player_name()
|
||||
@ -91,7 +138,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_tool("throwing:" .. name .. "_loaded", {
|
||||
description = desc,
|
||||
inventory_image = "throwing_" .. name .. "_loaded.png",
|
||||
@ -104,7 +151,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
|
||||
end
|
||||
local unloaded = "throwing:" .. name
|
||||
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
|
||||
minetest.after(0, throwing_unload, itemstack, user, unloaded, wear)
|
||||
minetest.after(0, throwing_unload, itemstack, user, unloaded, wear)
|
||||
return itemstack
|
||||
end,
|
||||
on_drop = function(itemstack, dropper, pointed_thing)
|
||||
@ -114,33 +161,31 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
|
||||
end,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:' .. name,
|
||||
recipe = craft
|
||||
})
|
||||
|
||||
local craft_width = 1
|
||||
-- Since # isn't stable especially when there are nils in the table, count by hand
|
||||
for _,v in ipairs(craft) do
|
||||
for i,__ in ipairs(v) do
|
||||
if i > craft_width then
|
||||
craft_width = i
|
||||
end
|
||||
end
|
||||
end
|
||||
local rev_craft = {}
|
||||
for i,y in ipairs(craft) do
|
||||
rev_craft[i] = {}
|
||||
for j,x in ipairs(y) do
|
||||
rev_craft[i][craft_width-j+1] = x
|
||||
end
|
||||
end
|
||||
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]},
|
||||
}
|
||||
recipe = rev_craft
|
||||
})
|
||||
end
|
||||
|
||||
-- Spears
|
||||
|
||||
function throwing_shoot_spear (itemstack, player)
|
||||
local spear = itemstack:get_name() .. '_entity'
|
||||
local playerpos = player:getpos()
|
||||
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear)
|
||||
local dir = player:get_look_dir()
|
||||
obj:setvelocity({x=dir.x*14, y=dir.y*14, z=dir.z*14})
|
||||
obj:setacceleration({x=-dir.x*1, y=-9.8, z=-dir.z*1})
|
||||
obj:setyaw(player:get_look_yaw()+math.pi)
|
||||
minetest.sound_play("throwing_bow_sound", {pos=playerpos})
|
||||
obj:get_luaentity().wear = itemstack:get_wear()
|
||||
return true
|
||||
end
|
||||
|
6
init.lua
Normal file → Executable file
@ -2,13 +2,14 @@ throwing_arrows = {
|
||||
{"throwing:arrow_steel", "throwing:arrow_steel_entity"},
|
||||
{"throwing:arrow_stone", "throwing:arrow_stone_entity"},
|
||||
{"throwing:arrow_obsidian", "throwing:arrow_obsidian_entity"},
|
||||
{"throwing:arrow_diamond", "throwing:arrow_diamond_entity"},
|
||||
{"throwing:arrow_mithril", "throwing:arrow_mithril_entity"}, --MFF : Only for Hunters
|
||||
{"throwing:arrow_fire", "throwing:arrow_fire_entity"},
|
||||
{"throwing:arrow_teleport", "throwing:arrow_teleport_entity"},
|
||||
{"throwing:arrow_dig", "throwing:arrow_dig_entity"},
|
||||
{"throwing:arrow_build", "throwing:arrow_build_entity"},
|
||||
{"throwing:arrow_tnt", "throwing:arrow_tnt_entity"},
|
||||
{"throwing:arrow_torch", "throwing:arrow_torch_entity"},
|
||||
{"throwing:arrow_diamond", "throwing:arrow_diamond_entity"},
|
||||
{"throwing:arrow_shell", "throwing:arrow_shell_entity"},
|
||||
{"throwing:arrow_fireworks_blue", "throwing:arrow_fireworks_blue_entity"},
|
||||
{"throwing:arrow_fireworks_red", "throwing:arrow_fireworks_red_entity"},
|
||||
@ -27,9 +28,10 @@ dofile(minetest.get_modpath("throwing").."/functions.lua")
|
||||
|
||||
dofile(minetest.get_modpath("throwing").."/tools.lua")
|
||||
|
||||
dofile(minetest.get_modpath("throwing").."/crafts.lua")
|
||||
|
||||
dofile(minetest.get_modpath("throwing").."/standard_arrows.lua")
|
||||
|
||||
dofile(minetest.get_modpath("throwing").."/spears.lua")
|
||||
|
||||
if minetest.get_modpath('fire') and minetest.get_modpath('bucket') and not DISABLE_FIRE_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/fire_arrow.lua")
|
||||
|
BIN
screenshot.png
Before Width: | Height: | Size: 737 KiB |
44
shell_arrow.lua
Normal file → Executable file
@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_shell_box", {
|
||||
{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},
|
||||
@ -37,6 +37,8 @@ local THROWING_ARROW_ENTITY={
|
||||
textures = {"throwing:arrow_shell_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
player = "",
|
||||
bow_damage = 0,
|
||||
}
|
||||
|
||||
local radius = 1
|
||||
@ -70,35 +72,41 @@ end
|
||||
-- Back to the arrow
|
||||
|
||||
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_shell_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local newpos = self.object:getpos()
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
local node = minetest.get_node(pos)
|
||||
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 throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
local speed = vector.length(self.object:getvelocity())
|
||||
local damage = ((speed + 5)^1.2)/10 + 12
|
||||
if self.bow_damage and self.bow_damage > 0 then
|
||||
damage = damage + (self.bow_damage/12)
|
||||
end
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
boom(pos)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x~=nil 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()
|
||||
boom(self.lastpos)
|
||||
if node.name ~= "air"
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
boom(self.lastpos)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_shell_entity", THROWING_ARROW_ENTITY)
|
||||
|
BIN
sounds/throwing_bow_sound.ogg
Normal file → Executable file
BIN
sounds/throwing_crossbow_sound.ogg
Normal file → Executable file
BIN
sounds/throwing_firework_boom.ogg
Normal file → Executable file
BIN
sounds/throwing_firework_launch.ogg
Normal file → Executable file
BIN
sounds/throwing_shell_explode.ogg
Normal file → Executable file
129
spears.lua
@ -1,129 +0,0 @@
|
||||
function throwing_register_spear_standard (kind, desc, eq, toughness, craft)
|
||||
minetest.register_tool("throwing:spear_" .. kind, {
|
||||
description = desc .. " spear",
|
||||
inventory_image = "throwing_spear_" .. kind .. ".png",
|
||||
wield_scale= {x=2,y=1.5,z=1.5};
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "object" then
|
||||
local damage = ((eq + 20)^1.2)/10
|
||||
pointed_thing.ref:punch(user, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/toughness)
|
||||
end
|
||||
else
|
||||
throwing_shoot_spear(itemstack, user)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:spear_" .. kind .. "_box", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-- Shaft
|
||||
{-60/16, -2/16, 2/16, 4, 1/16, -1/16},
|
||||
--Spitze
|
||||
{-4, -1/16, 1/16, -62/16, 0, 0},
|
||||
{-62/16, -1.5/16, 1.5/16, -60/16, 0.5/16, -0.5/16},
|
||||
}
|
||||
},
|
||||
tiles = {"throwing_spear_box.png"},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
local THROWING_SPEAR_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:spear_" .. kind .. "_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
}
|
||||
|
||||
THROWING_SPEAR_ENTITY.on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos)
|
||||
if not self.wear then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
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:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local speed = vector.length(self.object:getvelocity())
|
||||
local damage = ((speed + eq +5)^1.2)/10
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
minetest.add_item(self.lastpos, {name='throwing:spear_' .. kind, count=1, wear=self.wear+65535/toughness, metadata=""})
|
||||
--if math.random() < toughness then
|
||||
--minetest.add_item(self.lastpos, 'throwing:spear_' .. 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, '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()
|
||||
minetest.add_item(self.lastpos, {name='throwing:spear_' .. kind, count=1, wear=self.wear+65535/toughness, metadata=""})
|
||||
--if math.random() < toughness then
|
||||
--minetest.add_item(self.lastpos, 'throwing:spear_' .. 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:spear_" .. kind .. "_entity", THROWING_SPEAR_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:spear_' .. kind,
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', craft},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:spear_' .. kind,
|
||||
recipe = {
|
||||
{craft, 'group:wood', 'group:wood'},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
if not DISABLE_STONE_SPEAR then
|
||||
throwing_register_spear_standard ('stone', 'Stone', 0, 20, 'group:stone')
|
||||
end
|
||||
|
||||
if not DISABLE_STEEL_SPEAR then
|
||||
throwing_register_spear_standard ('steel', 'Steel', 5, 30, 'default:steel_ingot')
|
||||
end
|
||||
|
||||
if not DISABLE_DIAMOND_SPEAR then
|
||||
throwing_register_spear_standard ('diamond', 'Diamond', 10, 40, 'default:diamond')
|
||||
end
|
||||
|
||||
if not DISABLE_OBSIDIAN_SPEAR then
|
||||
throwing_register_spear_standard ('obsidian', 'Obsidian', 15, 30, 'default:obsidian')
|
||||
end
|
114
standard_arrows.lua
Normal file → Executable file
@ -3,7 +3,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
|
||||
description = desc .. " arrow",
|
||||
inventory_image = "throwing_arrow_" .. kind .. ".png",
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("throwing:arrow_" .. kind .. "_box", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -19,76 +19,92 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
|
||||
{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"},
|
||||
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},
|
||||
player = "",
|
||||
bow_damage = 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')
|
||||
local newpos = self.object:getpos()
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
local node = minetest.get_node(pos)
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||
for k, obj in pairs(objs) do
|
||||
local objpos = obj:getpos()
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
if throwing_touch(pos, objpos) then
|
||||
local puncher = self.object
|
||||
if self.player and minetest.get_player_by_name(self.player) then
|
||||
puncher = minetest.get_player_by_name(self.player)
|
||||
end
|
||||
local damage = eq
|
||||
if self.bow_damage and self.bow_damage > 0 then
|
||||
damage = damage + (self.bow_damage/12)
|
||||
end
|
||||
obj:punch(puncher, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
if math.random() < toughness then
|
||||
if math.random(0,100) % 2 == 0 then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
|
||||
end
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x~=nil 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()
|
||||
if math.random() < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
if node.name ~= "air"
|
||||
and not string.find(node.name, 'water_')
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if math.random() < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.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 = {
|
||||
@ -98,17 +114,21 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
|
||||
end
|
||||
|
||||
if not DISABLE_STONE_ARROW then
|
||||
throwing_register_arrow_standard ('stone', 'Stone', 0, 0.88, 'group:stone')
|
||||
throwing_register_arrow_standard ('stone', 'Stone', 4, 0.40, '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')
|
||||
throwing_register_arrow_standard ('steel', 'Steel', 5, 0.50, 'default:steel_ingot')
|
||||
end
|
||||
|
||||
if not DISABLE_OBSIDIAN_ARROW then
|
||||
throwing_register_arrow_standard ('obsidian', 'Obsidian', 15, 0.88, 'default:obsidian')
|
||||
throwing_register_arrow_standard ('obsidian', 'Obsidian', 6, 0.60, 'default:obsidian')
|
||||
end
|
||||
|
||||
if not DISABLE_DIAMOND_ARROW then
|
||||
throwing_register_arrow_standard ('diamond', 'Diamond', 7, 0.70, 'default:diamond')
|
||||
end
|
||||
|
||||
if not DISABLE_MITHRIL_ARROW then
|
||||
throwing_register_arrow_standard ('mithril', 'Mithril (Hunter)', 8, 0.80, 'default:mithril_ingot')
|
||||
end
|
||||
|
56
teleport_arrow.lua
Normal file → Executable file
@ -18,7 +18,7 @@ minetest.register_node("throwing:arrow_teleport_box", {
|
||||
{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},
|
||||
@ -31,48 +31,52 @@ minetest.register_node("throwing:arrow_teleport_box", {
|
||||
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:arrow_teleport_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
player = "",
|
||||
bow_damage = 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 not self.player then
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
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_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
self.object:remove()
|
||||
local newpos = self.object:getpos()
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
local node = minetest.get_node(pos)
|
||||
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 throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
if self.player ~= "" then
|
||||
self.player:setpos(pos)
|
||||
self.player:get_inventory():add_item("main", ItemStack("default:stick 2"))
|
||||
local player = minetest.get_player_by_name(self.player)
|
||||
if player then
|
||||
player:setpos(self.lastpos)
|
||||
end
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
if self.player ~= "" then
|
||||
self.player:setpos(self.lastpos)
|
||||
self.player:get_inventory():add_item("main", ItemStack("default:stick 2"))
|
||||
if node.name ~= "air"
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if self.player ~= "" then
|
||||
local player = minetest.get_player_by_name(self.player)
|
||||
if player then
|
||||
player:setpos(self.lastpos)
|
||||
end
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_teleport_entity", THROWING_ARROW_ENTITY)
|
||||
|
BIN
textures/___BOW_LOAD.PNG
Executable file
After Width: | Height: | Size: 241 B |
BIN
textures/throwing_arbalest.png
Normal file → Executable file
Before Width: | Height: | Size: 760 B After Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 739 B After Width: | Height: | Size: 421 B |
Before Width: | Height: | Size: 798 B After Width: | Height: | Size: 417 B |
BIN
textures/throwing_arbalest_loaded.png
Normal file → Executable file
Before Width: | Height: | Size: 807 B After Width: | Height: | Size: 449 B |
BIN
textures/throwing_arrow_build.png
Normal file → Executable file
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 131 B |
BIN
textures/throwing_arrow_build_2.png
Normal file → Executable file
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 132 B |
BIN
textures/throwing_arrow_build_back.png
Normal file → Executable file
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_build_front.png
Normal file → Executable file
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 133 B |
BIN
textures/throwing_arrow_diamond.png
Normal file → Executable file
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 131 B |
BIN
textures/throwing_arrow_diamond_2.png
Normal file → Executable file
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 132 B |
BIN
textures/throwing_arrow_diamond_back.png
Normal file → Executable file
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_diamond_front.png
Normal file → Executable file
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 133 B |
BIN
textures/throwing_arrow_dig.png
Normal file → Executable file
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 131 B |
BIN
textures/throwing_arrow_dig_2.png
Normal file → Executable file
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 132 B |
BIN
textures/throwing_arrow_dig_back.png
Normal file → Executable file
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_dig_front.png
Normal file → Executable file
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 133 B |
BIN
textures/throwing_arrow_fire.png
Normal file → Executable file
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 196 B |
BIN
textures/throwing_arrow_fire_2.png
Normal file → Executable file
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 192 B |
BIN
textures/throwing_arrow_fire_back.png
Normal file → Executable file
Before Width: | Height: | Size: 268 B After Width: | Height: | Size: 204 B |
BIN
textures/throwing_arrow_fire_front.png
Normal file → Executable file
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 232 B |
BIN
textures/throwing_arrow_fireworks_blue.png
Normal file → Executable file
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_fireworks_blue_2.png
Normal file → Executable file
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_fireworks_blue_back.png
Normal file → Executable file
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 161 B |
BIN
textures/throwing_arrow_fireworks_blue_front.png
Normal file → Executable file
Before Width: | Height: | Size: 207 B After Width: | Height: | Size: 143 B |
BIN
textures/throwing_arrow_fireworks_red.png
Normal file → Executable file
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_fireworks_red_2.png
Normal file → Executable file
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_fireworks_red_back.png
Normal file → Executable file
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 161 B |
BIN
textures/throwing_arrow_fireworks_red_front.png
Normal file → Executable file
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 143 B |
BIN
textures/throwing_arrow_mithril.png
Normal file
After Width: | Height: | Size: 131 B |
BIN
textures/throwing_arrow_mithril_2.png
Normal file
After Width: | Height: | Size: 132 B |
BIN
textures/throwing_arrow_mithril_back.png
Normal file
After Width: | Height: | Size: 143 B |
BIN
textures/throwing_arrow_mithril_front.png
Normal file
After Width: | Height: | Size: 133 B |
BIN
textures/throwing_arrow_model.png
Executable file
After Width: | Height: | Size: 191 B |
BIN
textures/throwing_arrow_obsidian.png
Normal file → Executable file
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 131 B |
BIN
textures/throwing_arrow_obsidian_2.png
Normal file → Executable file
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 132 B |
BIN
textures/throwing_arrow_obsidian_back.png
Normal file → Executable file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_obsidian_front.png
Normal file → Executable file
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 133 B |
BIN
textures/throwing_arrow_shell.png
Normal file → Executable file
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_shell_2.png
Normal file → Executable file
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_shell_back.png
Normal file → Executable file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_shell_front.png
Normal file → Executable file
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 145 B |
BIN
textures/throwing_arrow_steel.png
Normal file → Executable file
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 131 B |
BIN
textures/throwing_arrow_steel_2.png
Normal file → Executable file
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 132 B |
BIN
textures/throwing_arrow_steel_back.png
Normal file → Executable file
Before Width: | Height: | Size: 209 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_steel_front.png
Normal file → Executable file
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 133 B |
BIN
textures/throwing_arrow_stone.png
Normal file → Executable file
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 131 B |
BIN
textures/throwing_arrow_stone_2.png
Normal file → Executable file
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 132 B |
BIN
textures/throwing_arrow_stone_back.png
Normal file → Executable file
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_stone_front.png
Normal file → Executable file
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 133 B |
BIN
textures/throwing_arrow_teleport.png
Normal file → Executable file
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 131 B |
BIN
textures/throwing_arrow_teleport_2.png
Normal file → Executable file
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 132 B |
BIN
textures/throwing_arrow_teleport_back.png
Normal file → Executable file
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_teleport_front.png
Normal file → Executable file
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 133 B |
BIN
textures/throwing_arrow_tnt.png
Normal file → Executable file
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_tnt_2.png
Normal file → Executable file
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_tnt_back.png
Normal file → Executable file
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_tnt_front.png
Normal file → Executable file
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 145 B |
BIN
textures/throwing_arrow_torch.png
Normal file → Executable file
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_torch_2.png
Normal file → Executable file
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 136 B |
BIN
textures/throwing_arrow_torch_back.png
Normal file → Executable file
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 153 B |
BIN
textures/throwing_arrow_torch_front.png
Normal file → Executable file
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 133 B |
BIN
textures/throwing_bow_composite.png
Normal file → Executable file
Before Width: | Height: | Size: 646 B After Width: | Height: | Size: 329 B |
BIN
textures/throwing_bow_composite_loaded.png
Normal file → Executable file
Before Width: | Height: | Size: 692 B After Width: | Height: | Size: 457 B |
BIN
textures/throwing_bow_minotaur_horn.png
Executable file
After Width: | Height: | Size: 472 B |
BIN
textures/throwing_bow_minotaur_horn_improved.png
Executable file
After Width: | Height: | Size: 303 B |
BIN
textures/throwing_bow_minotaur_horn_improved_loaded.png
Executable file
After Width: | Height: | Size: 407 B |
BIN
textures/throwing_bow_minotaur_horn_loaded.png
Executable file
After Width: | Height: | Size: 431 B |
BIN
textures/throwing_bow_royal.png
Normal file → Executable file
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 374 B |
BIN
textures/throwing_bow_royal_loaded.png
Normal file → Executable file
Before Width: | Height: | Size: 660 B After Width: | Height: | Size: 488 B |
BIN
textures/throwing_bow_steel.png
Normal file → Executable file
Before Width: | Height: | Size: 633 B After Width: | Height: | Size: 336 B |
BIN
textures/throwing_bow_steel_loaded.png
Normal file → Executable file
Before Width: | Height: | Size: 683 B After Width: | Height: | Size: 461 B |
BIN
textures/throwing_bow_wood.png
Normal file → Executable file
Before Width: | Height: | Size: 581 B After Width: | Height: | Size: 252 B |
BIN
textures/throwing_bow_wood_loaded.png
Normal file → Executable file
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 373 B |
BIN
textures/throwing_crossbow.png
Normal file → Executable file
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 350 B |
BIN
textures/throwing_crossbow_loaded.png
Normal file → Executable file
Before Width: | Height: | Size: 677 B After Width: | Height: | Size: 429 B |
BIN
textures/throwing_empty.png
Normal file → Executable file
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 67 B |
BIN
textures/throwing_longbow.png
Normal file → Executable file
Before Width: | Height: | Size: 661 B After Width: | Height: | Size: 212 B |
BIN
textures/throwing_longbow_loaded.png
Normal file → Executable file
Before Width: | Height: | Size: 674 B After Width: | Height: | Size: 336 B |