version 0.21
48
mods/throwing/README.txt
Normal file
|
@ -0,0 +1,48 @@
|
|||
=== THROWING-MOD for MINETEST-C55 ===
|
||||
by PilzAdam
|
||||
|
||||
Inroduction:
|
||||
This mod adds bows and arrows to Minetest.
|
||||
|
||||
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:
|
||||
wood string
|
||||
wood string
|
||||
wood string
|
||||
Craft arrows with:
|
||||
flint
|
||||
stick
|
||||
paper
|
||||
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 385
|
||||
shoots).
|
||||
|
||||
License:
|
||||
This mod was originally published by Jeija.
|
||||
Sourcecode: WTFPL (see below)
|
||||
|
||||
See also:
|
||||
http://minetest.net/
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
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.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
89
mods/throwing/arrow.lua
Normal file
|
@ -0,0 +1,89 @@
|
|||
minetest.register_craftitem("throwing:arrow", {
|
||||
description = "Arrow",
|
||||
inventory_image = "throwing_arrow_inv.png",
|
||||
})
|
||||
|
||||
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.4, y=0.4},
|
||||
--textures = {"throwing:arrow_box"},
|
||||
textures = {"throwing_arrow_back.png"},
|
||||
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.env:get_node(pos)
|
||||
|
||||
if self.timer>0.2 then
|
||||
local objs = minetest.env: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_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)
|
||||
self.object:remove()
|
||||
end
|
||||
else
|
||||
local damage = 3
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
minetest.env:add_item(self.lastpos, 'throwing:arrow')
|
||||
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 4',
|
||||
recipe = {
|
||||
{'default:flint'},
|
||||
{'default:stick'},
|
||||
{'default:paper'}
|
||||
}
|
||||
})
|
1
mods/throwing/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
default
|
123
mods/throwing/init.lua
Normal file
|
@ -0,0 +1,123 @@
|
|||
|
||||
dofile(minetest.get_modpath("throwing").."/arrow.lua")
|
||||
|
||||
arrows = {
|
||||
{"throwing:arrow", "throwing:arrow_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
|
||||
player:get_inventory():remove_item("main", arrow[1])
|
||||
local playerpos = player:getpos()
|
||||
local obj = minetest.env: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})
|
||||
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
|
||||
end
|
||||
|
||||
minetest.register_tool("throwing:bow", {
|
||||
description = "Bow",
|
||||
inventory_image = "throwing_bow.png",
|
||||
stack_max = 1,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
wear = itemstack:get_wear()
|
||||
itemstack:replace("throwing:bow_0")
|
||||
itemstack:add_wear(wear)
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
wear = itemstack:get_wear()
|
||||
itemstack:add_wear(wear)
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/385)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("throwing:bow_0", {
|
||||
description = "Bow",
|
||||
inventory_image = "throwing_bow_0.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
wear = itemstack:get_wear()
|
||||
itemstack:replace("throwing:bow_1")
|
||||
itemstack:add_wear(wear)
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
wear = itemstack:get_wear()
|
||||
itemstack:add_wear(wear)
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/385)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("throwing:bow_1", {
|
||||
description = "Bow",
|
||||
inventory_image = "throwing_bow_1.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
wear = itemstack:get_wear()
|
||||
itemstack:replace("throwing:bow_2")
|
||||
itemstack:add_wear(wear)
|
||||
return itemstack
|
||||
end,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
wear = itemstack:get_wear()
|
||||
itemstack:add_wear(wear)
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/385)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("throwing:bow_2", {
|
||||
description = "Bow",
|
||||
inventory_image = "throwing_bow_2.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
wear = itemstack:get_wear()
|
||||
itemstack:replace("throwing:bow")
|
||||
itemstack:add_wear(wear)
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/385)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:bow',
|
||||
recipe = {
|
||||
{'', 'group:wood', 'default:string'},
|
||||
{'group:wood', '', 'default:string'},
|
||||
{'', 'group:wood', 'default:string'},
|
||||
}
|
||||
})
|
||||
|
BIN
mods/throwing/sounds/throwing_sound.ogg
Normal file
BIN
mods/throwing/textures/throwing_arrow.png
Normal file
After Width: | Height: | Size: 298 B |
BIN
mods/throwing/textures/throwing_arrow_2.png
Normal file
After Width: | Height: | Size: 315 B |
BIN
mods/throwing/textures/throwing_arrow_back.png
Normal file
After Width: | Height: | Size: 193 B |
BIN
mods/throwing/textures/throwing_arrow_front.png
Normal file
After Width: | Height: | Size: 180 B |
BIN
mods/throwing/textures/throwing_arrow_inv.png
Normal file
After Width: | Height: | Size: 259 B |
BIN
mods/throwing/textures/throwing_arrow_tnt.png
Normal file
After Width: | Height: | Size: 412 B |
BIN
mods/throwing/textures/throwing_bow.png
Normal file
After Width: | Height: | Size: 305 B |
BIN
mods/throwing/textures/throwing_bow_0.png
Normal file
After Width: | Height: | Size: 381 B |
BIN
mods/throwing/textures/throwing_bow_1.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
mods/throwing/textures/throwing_bow_2.png
Normal file
After Width: | Height: | Size: 351 B |
BIN
mods/throwing/textures/throwing_empty.png
Normal file
After Width: | Height: | Size: 178 B |
BIN
mods/throwing/textures/throwing_string.png
Normal file
After Width: | Height: | Size: 382 B |