New throwing mod (tweaked the throwing.conf file)
0
mods/framedglass/textures/framedglass_blueglass_frame.png
Normal file → Executable file
Before Width: | Height: | Size: 660 B After Width: | Height: | Size: 660 B |
0
mods/framedglass/textures/framedglass_steelglass_face_clean_frame.png
Normal file → Executable file
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 358 B |
0
mods/framedglass/textures/framedglass_steelglass_face_streaks_frame.png
Normal file → Executable file
Before Width: | Height: | Size: 423 B After Width: | Height: | Size: 423 B |
0
mods/framedglass/textures/framedglass_woodenglass_face_clean_frame.png
Normal file → Executable file
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 285 B |
0
mods/framedglass/textures/framedglass_woodenglass_face_streaks_frame.png
Normal file → Executable file
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 344 B |
@ -1,47 +1,98 @@
|
||||
=== THROWING-MOD for MINETEST ===
|
||||
by PilzAdam
|
||||
=== THROWING ENHANCED for MINETEST ===
|
||||
|
||||
Inroduction:
|
||||
This mod adds bows and arrows to Minetest.
|
||||
This mod adds many bows and arrows to Minetest.
|
||||
It began as a fork of PilzAdam's throwing mod with some enhancements from me. Enjoy!
|
||||
Echoes91
|
||||
|
||||
How to install:
|
||||
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
||||
if you have a windows client or a linux run-in-place client. If you have
|
||||
a linux system-wide instalation place it in ~/.minetest/mods/minetest/.
|
||||
If you want to install this mod only in one world create the folder
|
||||
worldmods/ in your worlddirectory.
|
||||
For further information or help see:
|
||||
http://wiki.minetest.com/wiki/Installing_Mods
|
||||
|
||||
How to use the mod:
|
||||
Craft a bow with the strings from the farming mod:
|
||||
string wood
|
||||
string wood
|
||||
string wood
|
||||
Craft arrows with:
|
||||
stick stick steel
|
||||
Select the bow and shoot with left mouse click. Every shoot will take 1
|
||||
arrow from your inventory and wears out the bow (you have around 50
|
||||
shoots).
|
||||
Select the bow and place the arrows into the slot next to it; shoot with left mouse click.
|
||||
Every shoot will take 1 arrow from your inventory and wears out the bow.
|
||||
|
||||
License:
|
||||
This mod was originally published by Jeija.
|
||||
Sourcecode: WTFPL (see below)
|
||||
Grahpics: WTFPL (see below)
|
||||
This mod was originally published by Jeija and reworked by PilzAdam
|
||||
Sourcecode: LGPLv2.1 (see http://www.gnu.org/licenses/lgpl-2.1.html)
|
||||
Grahpics & sounds: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/legalcode)
|
||||
|
||||
See also:
|
||||
http://minetest.net/
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
Changelog:
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
Update 1.2:
|
||||
- Added arbalest
|
||||
- Defaults initialized
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
Update 1.1:
|
||||
- Added crossbow
|
||||
- Code shrink
|
||||
- Offensive arrows go through flora's and farming's
|
||||
- Small fixes
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
Update 1.0:
|
||||
- Definitive reload, unload and shot system based on tool metadata, new global functions, no more "throw" privilege
|
||||
- New textures for loaded bows
|
||||
- Fireworks arrows to celebrate!
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
Update 1.0rc2:
|
||||
- Fixed "compare nil with number" due to self.break not being retained
|
||||
- Filled conf.example's list
|
||||
- Added Royal bow
|
||||
|
||||
Update 1.0rc1:
|
||||
- Added longbow and removed golden bow, definitive bow set for stable release. Feature freeze
|
||||
- Fixed torch arrow recipe, thanks to Excalibur Zero
|
||||
- Removed config.lua, configuration now goes int throwing.config, see example
|
||||
|
||||
Update 0.9.8:
|
||||
- New damage calculation for offensive arrows based on arrow's speed and material. Beware that dependency is more than linear for both, so that differences between arrows will be enhanced if they're shot at higher speed.
|
||||
- Fixed bug that blocked ability to shot after shooting with empty arrow stack.
|
||||
- Removed annoying debug symbols
|
||||
|
||||
Update 0.9.7:
|
||||
- Added visual feedback for reload
|
||||
- Fixed reload for players who die while reloading and for multiplayer
|
||||
- Changed license for the code to LGPLv2
|
||||
|
||||
Update 0.9.6:
|
||||
- Any bow and arrow is now deactivable under config.lua, which won't be overwritten
|
||||
- Changed license for media to CC-BY
|
||||
|
||||
Update 0.9.5:
|
||||
- Added shell arrows
|
||||
- Revised sounds and some textures
|
||||
- General balancing of bow's statistics
|
||||
|
||||
Update 0.9.4:
|
||||
- New bow texture
|
||||
- Made recipes coherent
|
||||
|
||||
Update 0.9.3:
|
||||
- Added symmetric recipes, fixed golden bow recipe
|
||||
- Adjusted few parameters
|
||||
|
||||
Update 0.9.2:
|
||||
- Added a chance to break for many arrows, so they don't last forever and outclass any other tool
|
||||
- Build and torch arrows won't build on fluids and torches any more, build arrows won't place torches
|
||||
- TNT arrow digs instead if removing blocks, eventual indestructible nodes are safe
|
||||
- Added golden bow with possible new bow style
|
||||
- Changed the (bit OP) composite bow resistance and new recipe
|
||||
- New teleport arrow recipe, cheaper but single use
|
||||
|
||||
Update 0.9.1:
|
||||
- Good improvement for torch arrows, now they always attach and are often turned to the right direction
|
||||
- Git repository will make things nicer
|
||||
|
||||
Update 0.9:
|
||||
- Now bows have reload times! They depend on weight and quality, anyway no more machine-gun-style shell swarms
|
||||
- Fixed build arrow behavior, now it placed and consumes the node from the slot [b]right next to the arrow[/b] or drops the item beside it if not a node; no more disappearing nor 'CONTENT_IGNORE' errors
|
||||
- Code cleanup and rationalization
|
||||
|
||||
Update 0.8.1:
|
||||
- Fixed wrong texture reference which made some arrows get a bad color during flight.
|
||||
- Now bows have different stiffness besides wear resistances, which means that they shot arrows at different initial speed and learning to hit the target will become even harder.
|
||||
Get rid of the old .env: API
|
||||
Added new bows and new offensive, utility and harmful arrows (these are just my categories, they're not present into the code at all).
|
||||
Removed stone bow, at least as long as somebody discovers an elastic rock ;)
|
||||
Non-exploding arrows won't disappear any more after hitting target.
|
@ -1,99 +0,0 @@
|
||||
minetest.register_craftitem("throwing:arrow", {
|
||||
description = "Arrow",
|
||||
inventory_image = "throwing_arrow.png",
|
||||
stack_max = 200,
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:arrow_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.png", "throwing_arrow.png", "throwing_arrow_back.png", "throwing_arrow_front.png", "throwing_arrow_2.png", "throwing_arrow.png"},
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
})
|
||||
|
||||
local THROWING_ARROW_ENTITY = {
|
||||
physical = false,
|
||||
timer = 0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.125, y = 0.125},
|
||||
textures = {"throwing:arrow_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}, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "throwing:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local damage = 3
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups= {fleshy = damage},
|
||||
}, nil)
|
||||
minetest.sound_play("throwing_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
else
|
||||
local damage = 3
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups= {fleshy = damage},
|
||||
}, nil)
|
||||
minetest.sound_play("throwing_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x ~= nil then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
minetest.add_item(self.lastpos, "throwing:arrow")
|
||||
end
|
||||
minetest.sound_play("throwing_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
self.lastpos= {x = pos.x, y = pos.y, z = pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow 8",
|
||||
recipe = {
|
||||
{"default:stick", "default:stick", "group:ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow 8",
|
||||
recipe = {
|
||||
{"group:ingot", "default:stick", "default:stick"},
|
||||
}
|
||||
})
|
@ -10,10 +10,10 @@ minetest.register_node("throwing:arrow_build_box", {
|
||||
fixed = {
|
||||
-- Shaft
|
||||
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
|
||||
-- Spitze
|
||||
--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
|
||||
--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},
|
||||
@ -26,70 +26,79 @@ minetest.register_node("throwing:arrow_build_box", {
|
||||
}
|
||||
},
|
||||
tiles = {"throwing_arrow_build.png", "throwing_arrow_build.png", "throwing_arrow_build_back.png", "throwing_arrow_build_front.png", "throwing_arrow_build_2.png", "throwing_arrow_build.png"},
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
local THROWING_ARROW_ENTITY = {
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer = 0,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.125, y = 0.125},
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:arrow_build_box"},
|
||||
lastpos= {},
|
||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
node = "",
|
||||
}
|
||||
|
||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.timer = self.timer + 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)
|
||||
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
|
||||
if self.node ~= "" then
|
||||
minetest.set_node(self.lastpos, {name="default:obsidian_glass"})
|
||||
minetest.sound_play("throwing_build_arrow", {pos = self.lastpos})
|
||||
end
|
||||
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
|
||||
minetest.add_item(self.lastpos, {name=self.stack:get_name()})
|
||||
end
|
||||
local toughness = 0.95
|
||||
if math.random() < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_build')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
end
|
||||
else
|
||||
if self.node ~= "" then
|
||||
minetest.set_node(self.lastpos, {name="default:obsidian_glass"})
|
||||
minetest.sound_play("throwing_build_arrow", {pos = self.lastpos})
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x ~= nil then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
if self.node ~= "" then
|
||||
minetest.set_node(self.lastpos, {name="default:obsidian_glass"})
|
||||
minetest.sound_play("throwing_build_arrow", {pos = self.lastpos})
|
||||
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=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_build_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_build",
|
||||
output = 'throwing:arrow_build',
|
||||
recipe = {
|
||||
{"default:stick", "default:stick", "default:obsidian_glass"},
|
||||
{'default:stick', 'default:stick', 'default:shovel_steel'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_build",
|
||||
output = 'throwing:arrow_build',
|
||||
recipe = {
|
||||
{"default:obsidian_glass", "default:stick", "default:stick"},
|
||||
{'default:shovel_steel', 'default:stick', 'default:stick'},
|
||||
}
|
||||
})
|
||||
|
24
mods/throwing/defaults.lua
Executable file
@ -0,0 +1,24 @@
|
||||
DISABLE_WOODEN_BOW = false
|
||||
DISABLE_LONGBOW = false
|
||||
DISABLE_COMPOSITE_BOW = false
|
||||
DISABLE_STEEL_BOW = false
|
||||
DISABLE_ROYAL_BOW = false
|
||||
DISABLE_CROSSBOW = false
|
||||
DISABLE_ARBALEST = false
|
||||
DISABLE_AUTOMATED_ARBALEST = false
|
||||
|
||||
DISABLE_TELEPORT_ARROW = true
|
||||
DISABLE_DIG_ARROW = true
|
||||
DISABLE_BUILD_ARROW = true
|
||||
DISABLE_TNT_ARROW = true
|
||||
DISABLE_FIRE_ARROW = true
|
||||
DISABLE_TORCH_ARROW = false
|
||||
DISABLE_SHELL_ARROW = false
|
||||
|
||||
DISABLE_FIREWORKS_BLUE_ARROW = false
|
||||
DISABLE_FIREWORKS_RED_ARROW = false
|
||||
|
||||
DISABLE_STONE_ARROW = false
|
||||
DISABLE_STEEL_ARROW = false
|
||||
DISABLE_DIAMOND_ARROW = false
|
||||
DISABLE_OBSIDIAN_ARROW = false
|
@ -1,4 +1,6 @@
|
||||
default
|
||||
bucket
|
||||
fire
|
||||
farming
|
||||
dye
|
||||
bucket?
|
||||
fire?
|
||||
tnt?
|
||||
|
1
mods/throwing/description.txt
Executable file
@ -0,0 +1 @@
|
||||
This mod adds many bows and arrows to Minetest.
|
@ -10,10 +10,10 @@ minetest.register_node("throwing:arrow_dig_box", {
|
||||
fixed = {
|
||||
-- Shaft
|
||||
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
|
||||
-- Spitze
|
||||
--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
|
||||
--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},
|
||||
@ -26,81 +26,75 @@ minetest.register_node("throwing:arrow_dig_box", {
|
||||
}
|
||||
},
|
||||
tiles = {"throwing_arrow_dig.png", "throwing_arrow_dig.png", "throwing_arrow_dig_back.png", "throwing_arrow_dig_front.png", "throwing_arrow_dig_2.png", "throwing_arrow_dig.png"},
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
local THROWING_ARROW_ENTITY = {
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer = 0,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.125, y = 0.125},
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:arrow_dig_box"},
|
||||
lastpos= {},
|
||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
}
|
||||
|
||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.timer = self.timer + 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)
|
||||
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
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
minetest.add_item(pos, "throwing:arrow_dig")
|
||||
end
|
||||
local n = minetest.get_node(pos).name
|
||||
if n ~= "bedrock:bedrock" and n ~= "default:chest_locked" and n ~= "bones:bones" and n ~= "default:chest" and n ~= "default:furnace" then
|
||||
minetest.dig_node(pos)
|
||||
end
|
||||
minetest.sound_play("throwing_dig_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
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')
|
||||
end
|
||||
end
|
||||
else
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
minetest.add_item(pos, "throwing:arrow_dig")
|
||||
end
|
||||
local n = minetest.get_node(pos).name
|
||||
if n ~= "bedrock:bedrock" and n ~= "default:chest_locked" and n ~= "bones:bones" and n ~= "default:chest" and n ~= "default:furnace" then
|
||||
minetest.dig_node(pos)
|
||||
end
|
||||
minetest.sound_play("throwing_dig_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x ~= nil then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
minetest.add_item(self.lastpos, "throwing:arrow_dig")
|
||||
end
|
||||
local n = minetest.get_node(pos).name
|
||||
if n ~= "bedrock:bedrock" and n ~= "default:chest_locked" and n ~= "bones:bones" and n ~= "default:chest" and n ~= "default:furnace" then
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
if node.diggable ~= false then
|
||||
minetest.dig_node(pos)
|
||||
end
|
||||
minetest.sound_play("throwing_dig_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
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=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_dig_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_dig",
|
||||
output = 'throwing:arrow_dig',
|
||||
recipe = {
|
||||
{"default:stick", "default:stick", "default:pick_wood"},
|
||||
{'default:stick', 'default:stick', 'default:pick_steel'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_dig",
|
||||
output = 'throwing:arrow_dig',
|
||||
recipe = {
|
||||
{"default:pick_wood", "default:stick", "default:stick"},
|
||||
{'default:pick_steel', 'default:stick', 'default:stick'},
|
||||
}
|
||||
})
|
||||
|
@ -1,78 +0,0 @@
|
||||
minetest.register_craftitem("throwing:arrow_dig_admin", {
|
||||
description = "Admin Dig Arrow",
|
||||
inventory_image = "throwing_arrow_dig_admin.png",
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:arrow_dig_admin_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_dig_admin.png", "throwing_arrow_dig_admin.png", "throwing_arrow_dig_admin_back.png", "throwing_arrow_dig_admin_front.png", "throwing_arrow_dig_admin_2.png", "throwing_arrow_dig_admin.png"},
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
})
|
||||
|
||||
local THROWING_ARROW_ENTITY = {
|
||||
physical = false,
|
||||
timer = 0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.125, y = 0.125},
|
||||
textures = {"throwing:arrow_dig_admin_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}, 1)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "throwing:arrow_dig_admin_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local n = minetest.get_node(pos).name
|
||||
minetest.log("action", n .. " was removed using throwing:arrow_dig_admin at " .. pos_to_string(vector.round(pos)) .. ".")
|
||||
minetest.remove_node(pos)
|
||||
self.object:remove()
|
||||
end
|
||||
else
|
||||
local n = minetest.get_node(pos).name
|
||||
minetest.log("action", n .. " was removed using throwing:arrow_dig_admin at " .. pos_to_string(vector.round(pos)) .. ".")
|
||||
minetest.remove_node(pos)
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x ~= nil then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
local n = minetest.get_node(pos).name
|
||||
minetest.log("action", n .. " was removed using throwing:arrow_dig_admin at " .. pos_to_string(vector.round(pos)) .. ".")
|
||||
minetest.remove_node(pos)
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
self.lastpos= {x = pos.x, y = pos.y, z = pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_dig_admin_entity", THROWING_ARROW_ENTITY)
|
@ -1,5 +1,5 @@
|
||||
minetest.register_craftitem("throwing:arrow_fire", {
|
||||
description = "Torch Arrow",
|
||||
description = "Fire Arrow",
|
||||
inventory_image = "throwing_arrow_fire.png",
|
||||
})
|
||||
|
||||
@ -10,10 +10,10 @@ minetest.register_node("throwing:arrow_fire_box", {
|
||||
fixed = {
|
||||
-- Shaft
|
||||
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
|
||||
-- Spitze
|
||||
--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
|
||||
--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},
|
||||
@ -26,69 +26,100 @@ minetest.register_node("throwing:arrow_fire_box", {
|
||||
}
|
||||
},
|
||||
tiles = {"throwing_arrow_fire.png", "throwing_arrow_fire.png", "throwing_arrow_fire_back.png", "throwing_arrow_fire_front.png", "throwing_arrow_fire_2.png", "throwing_arrow_fire.png"},
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
local THROWING_ARROW_ENTITY = {
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer = 0,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.125, y = 0.125},
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:arrow_fire_box"},
|
||||
lastpos= {},
|
||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
}
|
||||
|
||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.timer = self.timer + 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)
|
||||
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
|
||||
if self.node ~= "" then
|
||||
minetest.set_node(self.lastpos, {name="default:torch"})
|
||||
minetest.sound_play("default_place_node", {pos = self.lastpos})
|
||||
end
|
||||
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
|
||||
else
|
||||
if self.node ~= "" then
|
||||
minetest.set_node(self.lastpos, {name="default:torch"})
|
||||
minetest.sound_play("default_place_node", {pos = self.lastpos})
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x ~= nil then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
if self.node ~= "" then
|
||||
minetest.set_node(self.lastpos, {name="default:torch"})
|
||||
minetest.sound_play("default_place_node", {pos = self.lastpos})
|
||||
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)
|
||||
end
|
||||
if minetest.get_node(pos).name == "air" then
|
||||
minetest.set_node(pos, {name="throwing:light"})
|
||||
end
|
||||
end
|
||||
end
|
||||
self.lastpos= {x = pos.x, y = pos.y, z = pos.z}
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_fire_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_fire 1",
|
||||
recipe = {
|
||||
{"default:stick", "default:stick", "default:torch"},
|
||||
minetest.register_node("throwing:light", {
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
tiles = {"throwing_empty.png"},
|
||||
light_source = LIGHT_MAX-4,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{0,0,0,0,0,0}
|
||||
}
|
||||
},
|
||||
groups = {not_in_creative_inventory=1}
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"throwing:light"},
|
||||
interval = 10,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_fire 1",
|
||||
output = 'throwing:arrow_fire 4',
|
||||
recipe = {
|
||||
{"default:torch", "default:stick", "default:stick"},
|
||||
{'default:stick', 'default:stick', 'bucket:bucket_lava'},
|
||||
},
|
||||
replacements = {
|
||||
{"bucket:bucket_lava", "bucket:bucket_empty"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:arrow_fire 4',
|
||||
recipe = {
|
||||
{'bucket:bucket_lava', 'default:stick', 'default:stick'},
|
||||
},
|
||||
replacements = {
|
||||
{"bucket:bucket_lava", "bucket:bucket_empty"}
|
||||
}
|
||||
})
|
||||
|
195
mods/throwing/fireworks_arrows.lua
Executable file
@ -0,0 +1,195 @@
|
||||
local function throwing_register_fireworks(color, desc)
|
||||
minetest.register_craftitem("throwing:arrow_fireworks_" .. color, {
|
||||
description = desc .. "fireworks arrow",
|
||||
inventory_image = "throwing_arrow_fireworks_" .. color .. ".png",
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:arrow_fireworks_" .. color .. "_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_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,
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:arrow_fireworks_" .. color .. "_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
}
|
||||
|
||||
local radius = 0.5
|
||||
|
||||
local function add_effects(pos, radius)
|
||||
minetest.add_particlespawner({
|
||||
amount = 256,
|
||||
time = 0.2,
|
||||
minpos = vector.subtract(pos, radius / 2),
|
||||
maxpos = vector.add(pos, radius / 2),
|
||||
minvel = {x=-5, y=-5, z=-5},
|
||||
maxvel = {x=5, y=5, z=5},
|
||||
minacc = {x=0, y=-8, z=0},
|
||||
--~ maxacc = {x=-20, y=-50, z=-50},
|
||||
minexptime = 2.5,
|
||||
maxexptime = 3,
|
||||
minsize = 1,
|
||||
maxsize = 2.5,
|
||||
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
|
||||
minetest.add_node(pos, {name="throwing:firework_boom"})
|
||||
minetest.get_node_timer(pos):start(0.2)
|
||||
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)
|
||||
if self.timer < 0.07 then
|
||||
minetest.sound_play("throwing_firework_launch", {pos=pos, gain=0.8, max_hear_distance=2*64})
|
||||
end
|
||||
minetest.add_particlespawner({
|
||||
amount = 16,
|
||||
time = 0.1,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = {x=-5, y=-5, z=-5},
|
||||
maxvel = {x=5, y=5, z=5},
|
||||
minacc = vector.new(),
|
||||
maxacc = vector.new(),
|
||||
minexptime = 0.3,
|
||||
maxexptime = 0.5,
|
||||
minsize = 0.5,
|
||||
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
|
||||
local damage = 2
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
boom(pos)
|
||||
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()
|
||||
boom(self.lastpos)
|
||||
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}
|
||||
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 = {
|
||||
{'dye:' .. color, 'tnt:gunpowder', 'default:stick'},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
--~ Arrows
|
||||
|
||||
if not DISABLE_FIREWORKS_BLUE_ARROW then
|
||||
throwing_register_fireworks('blue', 'Blue')
|
||||
end
|
||||
|
||||
if not DISABLE_FIREWORKS_RED_ARROW then
|
||||
throwing_register_fireworks('red', 'Red')
|
||||
end
|
||||
|
||||
--~ Nodes
|
||||
|
||||
minetest.register_node("throwing:firework_trail", {
|
||||
drawtype = "airlike",
|
||||
light_source = 9,
|
||||
walkable = false,
|
||||
drop = "",
|
||||
groups = {dig_immediate=3},
|
||||
on_timer = function(pos, elapsed)
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:firework_boom", {
|
||||
drawtype = "plantlike",
|
||||
tiles = {"throwing_sparkle.png"},
|
||||
light_source = default.LIGHT_MAX,
|
||||
walkable = false,
|
||||
drop = "",
|
||||
groups = {dig_immediate=3},
|
||||
on_timer = function(pos, elapsed)
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
minetest.set_node(pos, {name="throwing:firework_light"})
|
||||
minetest.get_node_timer(pos):start(3)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:firework_light", {
|
||||
drawtype = "airlike",
|
||||
light_source = default.LIGHT_MAX,
|
||||
walkable = false,
|
||||
drop = "",
|
||||
groups = {dig_immediate=3},
|
||||
on_timer = function(pos, elapsed)
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
})
|
131
mods/throwing/functions.lua
Executable file
@ -0,0 +1,131 @@
|
||||
--~
|
||||
--~ Shot and reload system
|
||||
--~
|
||||
|
||||
local players = {}
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local playerName = player:get_player_name()
|
||||
players[playerName] = {
|
||||
reloading=false,
|
||||
}
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local playerName = player:get_player_name()
|
||||
players[playerName] = nil
|
||||
end)
|
||||
|
||||
function throwing_shoot_arrow (itemstack, player, stiffness, is_cross)
|
||||
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)
|
||||
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=-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)
|
||||
return true
|
||||
end
|
||||
|
||||
function throwing_unload (itemstack, player, unloaded, wear)
|
||||
if itemstack:get_metadata() then
|
||||
for _,arrow in ipairs(throwing_arrows) do
|
||||
if itemstack:get_metadata() == arrow[2] then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
player:get_inventory():add_item("main", arrow[1])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if wear >= 65535 then
|
||||
player:set_wielded_item({})
|
||||
else
|
||||
player:set_wielded_item({name=unloaded, wear=wear})
|
||||
end
|
||||
end
|
||||
|
||||
function throwing_reload (itemstack, player, pos, is_cross, loaded)
|
||||
local playerName = player:get_player_name()
|
||||
players[playerName]['reloading'] = false
|
||||
if itemstack:get_name() == player:get_wielded_item():get_name() then
|
||||
if (pos.x == player:getpos().x and pos.y == player:getpos().y and pos.z == player:getpos().z) or not is_cross then
|
||||
local wear = itemstack:get_wear()
|
||||
for _,arrow in ipairs(throwing_arrows) do
|
||||
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
player:get_inventory():remove_item("main", arrow[1])
|
||||
end
|
||||
local meta = arrow[2]
|
||||
player:set_wielded_item({name=loaded, wear=wear, metadata=meta})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Bows and crossbows
|
||||
|
||||
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()
|
||||
local playerName = user:get_player_name()
|
||||
if not players[playerName]['reloading'] then
|
||||
players[playerName]['reloading'] = true
|
||||
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, "throwing:" .. name .. "_loaded")
|
||||
end
|
||||
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, 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, 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
|
@ -1,98 +0,0 @@
|
||||
minetest.register_craftitem("throwing:arrow_gold", {
|
||||
description = "Golden Arrow",
|
||||
inventory_image = "throwing_arrow_gold.png",
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:arrow_gold_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_gold.png", "throwing_arrow_gold.png", "throwing_arrow_gold_back.png", "throwing_arrow_gold_front.png", "throwing_arrow_gold_2.png", "throwing_arrow_gold.png"},
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
})
|
||||
|
||||
local THROWING_arrow_gold_ENTITY = {
|
||||
physical = false,
|
||||
timer = 0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.125, y = 0.125},
|
||||
textures = {"throwing:arrow_gold_box"},
|
||||
lastpos= {},
|
||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||
}
|
||||
|
||||
THROWING_arrow_gold_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_gold_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local damage = 5
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups= {fleshy = damage},
|
||||
}, nil)
|
||||
minetest.sound_play("throwing_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
else
|
||||
local damage = 5
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups= {fleshy = damage},
|
||||
}, nil)
|
||||
minetest.sound_play("throwing_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x ~= nil then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
minetest.add_item(self.lastpos, "throwing:arrow_gold")
|
||||
end
|
||||
minetest.sound_play("throwing_arrow", {pos = self.lastpos, gain = 0.8})
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
self.lastpos= {x = pos.x, y = pos.y, z = pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_gold_entity", THROWING_arrow_gold_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_gold 16",
|
||||
recipe = {
|
||||
{"default:stick", "default:stick", "default:gold_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_gold 16",
|
||||
recipe = {
|
||||
{"default:gold_ingot", "default:stick", "default:stick"},
|
||||
}
|
||||
})
|
@ -1,188 +1,66 @@
|
||||
arrows = {
|
||||
{"throwing:arrow", "throwing:arrow_entity"},
|
||||
{"throwing:arrow_gold", "throwing:arrow_gold_entity"},
|
||||
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_fire", "throwing:arrow_fire_entity"},
|
||||
{"throwing:arrow_teleport", "throwing:arrow_teleport_entity"},
|
||||
{"throwing:arrow_dig", "throwing:arrow_dig_entity"},
|
||||
{"throwing:arrow_dig_admin", "throwing:arrow_dig_admin_entity"},
|
||||
{"throwing:arrow_build", "throwing:arrow_build_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"},
|
||||
}
|
||||
|
||||
local throwing_shoot_arrow = function(itemstack, player)
|
||||
for _,arrow in ipairs(arrows) do
|
||||
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
player:get_inventory():remove_item("main", arrow[1])
|
||||
end
|
||||
local playerpos = player:getpos()
|
||||
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2])
|
||||
local dir = player:get_look_dir()
|
||||
obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19})
|
||||
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
|
||||
obj:setyaw(player:get_look_yaw()+math.pi)
|
||||
minetest.sound_play("throwing_sound", {pos=playerpos, gain = 0.5})
|
||||
if obj:get_luaentity().player == "" then
|
||||
obj:get_luaentity().player = player
|
||||
end
|
||||
obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
dofile(minetest.get_modpath("throwing").."/defaults.lua")
|
||||
|
||||
local input = io.open(minetest.get_modpath("throwing").."/throwing.conf", "r")
|
||||
if input then
|
||||
dofile(minetest.get_modpath("throwing").."/throwing.conf")
|
||||
input:close()
|
||||
input = nil
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("throwing").."/functions.lua")
|
||||
|
||||
minetest.register_tool("throwing:bow_wood", {
|
||||
description = "Wooden Bow",
|
||||
inventory_image = "throwing_bow_wood.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/25)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
dofile(minetest.get_modpath("throwing").."/tools.lua")
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:bow_wood",
|
||||
recipe = {
|
||||
{"farming:cotton", "default:wood", ""},
|
||||
{"farming:cotton", "", "default:wood"},
|
||||
{"farming:cotton", "default:wood", ""},
|
||||
}
|
||||
})
|
||||
dofile(minetest.get_modpath("throwing").."/standard_arrows.lua")
|
||||
|
||||
|
||||
|
||||
minetest.register_tool("throwing:bow_stone", {
|
||||
description = "Stone Bow",
|
||||
inventory_image = "throwing_bow_stone.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if throwing_shoot_arrow(item, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/75)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:bow_stone",
|
||||
recipe = {
|
||||
{"farming:cotton", "default:cobble", ""},
|
||||
{"farming:cotton", "", "default:cobble"},
|
||||
{"farming:cotton", "default:cobble", ""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_tool("throwing:bow_steel", {
|
||||
description = "Steel Bow",
|
||||
inventory_image = "throwing_bow_steel.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if throwing_shoot_arrow(item, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/200)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:bow_steel",
|
||||
recipe = {
|
||||
{"farming:cotton", "default:steel_ingot", ""},
|
||||
{"farming:cotton", "", "default:steel_ingot"},
|
||||
{"farming:cotton", "default:steel_ingot", ""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_tool("throwing:bow_bronze", {
|
||||
description = "Bronze Bow",
|
||||
inventory_image = "throwing_bow_bronze.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if throwing_shoot_arrow(item, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/250)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:bow_bronze",
|
||||
recipe = {
|
||||
{"farming:cotton", "default:bronze_ingot", ""},
|
||||
{"farming:cotton", "", "default:bronze_ingot"},
|
||||
{"farming:cotton", "default:bronze_ingot", ""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_tool("throwing:bow_mese", {
|
||||
description = "Mese Bow",
|
||||
inventory_image = "throwing_bow_mese.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if throwing_shoot_arrow(item, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/350)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:bow_mese",
|
||||
recipe = {
|
||||
{"farming:cotton", "default:mese_crystal", ""},
|
||||
{"farming:cotton", "", "default:mese_crystal"},
|
||||
{"farming:cotton", "default:mese_crystal", ""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_tool("throwing:bow_diamond", {
|
||||
description = "Diamond Bow",
|
||||
inventory_image = "throwing_bow_diamond.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if throwing_shoot_arrow(item, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/500)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:bow_diamond",
|
||||
recipe = {
|
||||
{"farming:cotton", "default:diamond", ""},
|
||||
{"farming:cotton", "", "default:diamond"},
|
||||
{"farming:cotton", "default:diamond", ""},
|
||||
}
|
||||
})
|
||||
|
||||
dofile(minetest.get_modpath("throwing") .. "/arrow.lua")
|
||||
dofile(minetest.get_modpath("throwing") .. "/golden_arrow.lua")
|
||||
dofile(minetest.get_modpath("throwing") .. "/fire_arrow.lua")
|
||||
dofile(minetest.get_modpath("throwing") .. "/teleport_arrow.lua")
|
||||
dofile(minetest.get_modpath("throwing") .. "/dig_arrow.lua")
|
||||
dofile(minetest.get_modpath("throwing") .. "/dig_arrow_admin.lua")
|
||||
dofile(minetest.get_modpath("throwing") .. "/build_arrow.lua")
|
||||
|
||||
if minetest.setting_getbool("log_mods") then
|
||||
minetest.log("action", "Carbone: [throwing] loaded.")
|
||||
if minetest.get_modpath('fire') and minetest.get_modpath('bucket') and not DISABLE_FIRE_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/fire_arrow.lua")
|
||||
end
|
||||
|
||||
if not DISABLE_TELEPORT_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/teleport_arrow.lua")
|
||||
end
|
||||
|
||||
if not DISABLE_DIG_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/dig_arrow.lua")
|
||||
end
|
||||
|
||||
if not DISABLE_BUILD_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/build_arrow.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath('fire') and minetest.get_modpath('tnt') and not DISABLE_TNT_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/tnt_arrow.lua")
|
||||
end
|
||||
|
||||
if not DISABLE_TORCH_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/torch_arrow.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath('tnt') and not DISABLE_SHELL_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/shell_arrow.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath('tnt') then
|
||||
dofile(minetest.get_modpath("throwing").."/fireworks_arrows.lua")
|
||||
end
|
||||
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.log("action", "throwing loaded")
|
||||
end
|
||||
|
BIN
mods/throwing/screenshot.png
Executable file
After Width: | Height: | Size: 737 KiB |
118
mods/throwing/shell_arrow.lua
Executable file
@ -0,0 +1,118 @@
|
||||
minetest.register_craftitem("throwing:arrow_shell", {
|
||||
description = "Shell arrow",
|
||||
inventory_image = "throwing_arrow_shell.png",
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:arrow_shell_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_shell.png", "throwing_arrow_shell.png", "throwing_arrow_shell_back.png", "throwing_arrow_shell_front.png", "throwing_arrow_shell_2.png", "throwing_arrow_shell.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_shell_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
}
|
||||
|
||||
local radius = 1
|
||||
|
||||
local function add_effects(pos, radius)
|
||||
minetest.add_particlespawner({
|
||||
amount = 8,
|
||||
time = 0.5,
|
||||
minpos = vector.subtract(pos, radius / 2),
|
||||
maxpos = vector.add(pos, radius / 2),
|
||||
minvel = {x=-10, y=-10, z=-10},
|
||||
maxvel = {x=10, y=10, z=10},
|
||||
minacc = vector.new(),
|
||||
maxacc = vector.new(),
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1,
|
||||
minsize = 0.5,
|
||||
maxsize = 1,
|
||||
texture = "tnt_smoke.png",
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
local function boom(pos)
|
||||
minetest.sound_play("shell_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
|
||||
minetest.set_node(pos, {name="tnt:boom"})
|
||||
minetest.get_node_timer(pos):start(0.1)
|
||||
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)
|
||||
|
||||
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 speed = vector.length(self.object:getvelocity())
|
||||
local damage = ((speed + 5)^1.2)/10 + 12
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
boom(pos)
|
||||
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()
|
||||
boom(self.lastpos)
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_shell_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:arrow_shell 8',
|
||||
recipe = {
|
||||
{'default:stick', 'tnt:gunpowder', 'default:bronze_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:arrow_shell 8',
|
||||
recipe = {
|
||||
{'default:bronze_ingot', 'tnt:gunpowder', 'default:stick'},
|
||||
}
|
||||
})
|
BIN
mods/throwing/sounds/throwing_bow_sound.ogg
Executable file
BIN
mods/throwing/sounds/throwing_crossbow_sound.ogg
Executable file
BIN
mods/throwing/sounds/throwing_firework_boom.ogg
Executable file
BIN
mods/throwing/sounds/throwing_firework_launch.ogg
Executable file
BIN
mods/throwing/sounds/throwing_shell_explode.ogg
Executable file
114
mods/throwing/standard_arrows.lua
Executable 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
|
@ -10,10 +10,10 @@ minetest.register_node("throwing:arrow_teleport_box", {
|
||||
fixed = {
|
||||
-- Shaft
|
||||
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
|
||||
-- Spitze
|
||||
--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
|
||||
--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},
|
||||
@ -26,79 +26,64 @@ minetest.register_node("throwing:arrow_teleport_box", {
|
||||
}
|
||||
},
|
||||
tiles = {"throwing_arrow_teleport.png", "throwing_arrow_teleport.png", "throwing_arrow_teleport_back.png", "throwing_arrow_teleport_front.png", "throwing_arrow_teleport_2.png", "throwing_arrow_teleport.png"},
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
local THROWING_ARROW_ENTITY = {
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer = 0,
|
||||
timer=0,
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.125, y = 0.125},
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:arrow_teleport_box"},
|
||||
lastpos= {},
|
||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
player = "",
|
||||
}
|
||||
|
||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.timer = self.timer + 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)
|
||||
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
|
||||
if self.player ~= "" then
|
||||
if not minetest.is_protected(pos, self.player:get_player_name()) then
|
||||
self.player:setpos(pos)
|
||||
end
|
||||
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
|
||||
minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos})
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
else
|
||||
if self.player ~= "" then
|
||||
if not minetest.is_protected(pos, self.player:get_player_name()) then
|
||||
if self.player ~= "" then
|
||||
self.player:setpos(pos)
|
||||
self.player:get_inventory():add_item("main", ItemStack("default:stick 2"))
|
||||
end
|
||||
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
|
||||
minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos})
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x ~= nil then
|
||||
if minetest.registered_nodes[node.name].walkable then
|
||||
if self.player ~= "" then
|
||||
if not minetest.is_protected(self.lastpos, self.player:get_player_name()) then
|
||||
self.player:setpos(self.lastpos)
|
||||
end
|
||||
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
|
||||
minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos})
|
||||
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"))
|
||||
end
|
||||
end
|
||||
end
|
||||
self.lastpos= {x = pos.x, y = pos.y, z = pos.z}
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:arrow_teleport_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_teleport",
|
||||
output = 'throwing:arrow_teleport',
|
||||
recipe = {
|
||||
{"default:stick", "default:stick", "default:diamond"},
|
||||
{'default:stick', 'default:stick', 'default:mese_crystal_fragment'}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "throwing:arrow_teleport",
|
||||
output = 'throwing:arrow_teleport',
|
||||
recipe = {
|
||||
{"default:diamond", "default:stick", "default:stick"},
|
||||
{'default:mese_crystal_fragment', 'default:stick', 'default:stick'}
|
||||
}
|
||||
})
|
||||
|
BIN
mods/throwing/textures/throwing_arbalest.png
Executable file
After Width: | Height: | Size: 730 B |
BIN
mods/throwing/textures/throwing_arbalest_loaded.png
Executable file
After Width: | Height: | Size: 740 B |
Before Width: | Height: | Size: 139 B |
Before Width: | Height: | Size: 141 B |
Before Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 213 B |
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 178 B |
BIN
mods/throwing/textures/throwing_arrow_diamond.png
Executable file
After Width: | Height: | Size: 196 B |
BIN
mods/throwing/textures/throwing_arrow_diamond_2.png
Executable file
After Width: | Height: | Size: 201 B |
BIN
mods/throwing/textures/throwing_arrow_diamond_back.png
Executable file
After Width: | Height: | Size: 210 B |
BIN
mods/throwing/textures/throwing_arrow_diamond_front.png
Executable file
After Width: | Height: | Size: 176 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 147 B |
Before Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 120 B |
Before Width: | Height: | Size: 146 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 190 B After Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 197 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 306 B |
BIN
mods/throwing/textures/throwing_arrow_fireworks_blue.png
Executable file
After Width: | Height: | Size: 212 B |
BIN
mods/throwing/textures/throwing_arrow_fireworks_blue_2.png
Executable file
After Width: | Height: | Size: 207 B |
BIN
mods/throwing/textures/throwing_arrow_fireworks_blue_back.png
Executable file
After Width: | Height: | Size: 232 B |
BIN
mods/throwing/textures/throwing_arrow_fireworks_blue_front.png
Executable file
After Width: | Height: | Size: 204 B |
BIN
mods/throwing/textures/throwing_arrow_fireworks_red.png
Executable file
After Width: | Height: | Size: 218 B |
BIN
mods/throwing/textures/throwing_arrow_fireworks_red_2.png
Executable file
After Width: | Height: | Size: 210 B |
BIN
mods/throwing/textures/throwing_arrow_fireworks_red_back.png
Executable file
After Width: | Height: | Size: 234 B |
BIN
mods/throwing/textures/throwing_arrow_fireworks_red_front.png
Executable file
After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 147 B |
Before Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 120 B |
BIN
mods/throwing/textures/throwing_arrow_obsidian.png
Executable file
After Width: | Height: | Size: 192 B |
BIN
mods/throwing/textures/throwing_arrow_obsidian_2.png
Executable file
After Width: | Height: | Size: 191 B |
BIN
mods/throwing/textures/throwing_arrow_obsidian_back.png
Executable file
After Width: | Height: | Size: 204 B |
BIN
mods/throwing/textures/throwing_arrow_obsidian_front.png
Executable file
After Width: | Height: | Size: 170 B |
BIN
mods/throwing/textures/throwing_arrow_shell.png
Executable file
After Width: | Height: | Size: 200 B |
BIN
mods/throwing/textures/throwing_arrow_shell_2.png
Executable file
After Width: | Height: | Size: 199 B |
BIN
mods/throwing/textures/throwing_arrow_shell_back.png
Executable file
After Width: | Height: | Size: 204 B |
BIN
mods/throwing/textures/throwing_arrow_shell_front.png
Executable file
After Width: | Height: | Size: 191 B |
BIN
mods/throwing/textures/throwing_arrow_steel.png
Executable file
After Width: | Height: | Size: 195 B |
BIN
mods/throwing/textures/throwing_arrow_steel_2.png
Executable file
After Width: | Height: | Size: 193 B |
BIN
mods/throwing/textures/throwing_arrow_steel_back.png
Executable file
After Width: | Height: | Size: 209 B |
BIN
mods/throwing/textures/throwing_arrow_steel_front.png
Executable file
After Width: | Height: | Size: 177 B |
BIN
mods/throwing/textures/throwing_arrow_stone.png
Executable file
After Width: | Height: | Size: 201 B |
BIN
mods/throwing/textures/throwing_arrow_stone_2.png
Executable file
After Width: | Height: | Size: 195 B |
BIN
mods/throwing/textures/throwing_arrow_stone_back.png
Executable file
After Width: | Height: | Size: 213 B |
BIN
mods/throwing/textures/throwing_arrow_stone_front.png
Executable file
After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 178 B |
BIN
mods/throwing/textures/throwing_arrow_tnt.png
Executable file
After Width: | Height: | Size: 206 B |
BIN
mods/throwing/textures/throwing_arrow_tnt_2.png
Executable file
After Width: | Height: | Size: 205 B |
BIN
mods/throwing/textures/throwing_arrow_tnt_back.png
Executable file
After Width: | Height: | Size: 211 B |
BIN
mods/throwing/textures/throwing_arrow_tnt_front.png
Executable file
After Width: | Height: | Size: 195 B |
BIN
mods/throwing/textures/throwing_arrow_torch.png
Executable file
After Width: | Height: | Size: 199 B |
BIN
mods/throwing/textures/throwing_arrow_torch_2.png
Executable file
After Width: | Height: | Size: 199 B |
BIN
mods/throwing/textures/throwing_arrow_torch_back.png
Executable file
After Width: | Height: | Size: 202 B |
BIN
mods/throwing/textures/throwing_arrow_torch_front.png
Executable file
After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 422 B |
BIN
mods/throwing/textures/throwing_bow_composite.png
Executable file
After Width: | Height: | Size: 646 B |