Organize mods into modpacks for better overview
50
mods/ITEMS/mcl_throwing/README.txt
Normal file
|
@ -0,0 +1,50 @@
|
|||
=== 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 strings:
|
||||
stick string
|
||||
stick string
|
||||
stick 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
|
||||
shots).
|
||||
|
||||
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.
|
91
mods/ITEMS/mcl_throwing/arrow.lua
Normal file
|
@ -0,0 +1,91 @@
|
|||
minetest.register_craftitem("mcl_throwing:arrow", {
|
||||
description = "Arrow",
|
||||
inventory_image = "mcl_throwing_arrow_inv.png",
|
||||
groups = { ammo=1, ammo_bow=1 },
|
||||
})
|
||||
|
||||
minetest.register_node("mcl_throwing:arrow_box", {
|
||||
drawtype = "nodebox",
|
||||
is_ground_content = false,
|
||||
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 = {"mcl_throwing_arrow.png", "mcl_throwing_arrow.png", "mcl_throwing_arrow_back.png", "mcl_throwing_arrow_front.png", "mcl_throwing_arrow_2.png", "mcl_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 = {"mcl_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}, 2)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "mcl_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
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if (def and def.walkable) or not def then
|
||||
minetest.add_item(self.lastpos, 'mcl_throwing:arrow')
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("mcl_throwing:arrow_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'mcl_throwing:arrow 4',
|
||||
recipe = {
|
||||
{'mcl_core:flint'},
|
||||
{'mcl_core:stick'},
|
||||
{'mcl_mobitems:feather'}
|
||||
}
|
||||
})
|
1
mods/ITEMS/mcl_throwing/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
mcl_core
|
151
mods/ITEMS/mcl_throwing/init.lua
Normal file
|
@ -0,0 +1,151 @@
|
|||
mcl_throwing = {}
|
||||
|
||||
dofile(minetest.get_modpath("mcl_throwing").."/arrow.lua")
|
||||
dofile(minetest.get_modpath("mcl_throwing").."/throwable.lua")
|
||||
|
||||
local arrows = {
|
||||
["mcl_throwing:arrow"] = "mcl_throwing:arrow_entity",
|
||||
}
|
||||
|
||||
local GRAVITY = 9.81
|
||||
|
||||
mcl_throwing.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter)
|
||||
local obj = minetest.add_entity({x=pos.x,y=pos.y,z=pos.z}, arrows[arrow_item])
|
||||
obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19})
|
||||
obj:setacceleration({x=dir.x*-3, y=-GRAVITY, z=dir.z*-3})
|
||||
obj:setyaw(yaw+math.pi/2)
|
||||
minetest.sound_play("mcl_throwing_bow_shoot", {pos=pos})
|
||||
if shooter ~= nil then
|
||||
if obj:get_luaentity().player == "" then
|
||||
obj:get_luaentity().player = shooter
|
||||
end
|
||||
obj:get_luaentity().node = shooter:get_inventory():get_stack("main", 1):get_name()
|
||||
end
|
||||
return obj
|
||||
end
|
||||
|
||||
local player_shoot_arrow = function(itemstack, player)
|
||||
for arrow_item, arrow_entity in pairs(arrows) do
|
||||
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow_item then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
player:get_inventory():remove_item("main", arrow_item)
|
||||
end
|
||||
local playerpos = player:getpos()
|
||||
local dir = player:get_look_dir()
|
||||
local yaw = player:get_look_horizontal()
|
||||
|
||||
mcl_throwing.shoot_arrow(arrow_item, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local powerup_function = function(nextbow)
|
||||
return function(itemstack, placer, pointed_thing)
|
||||
local wear = itemstack:get_wear()
|
||||
itemstack:replace(nextbow)
|
||||
itemstack:add_wear(wear)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_tool("mcl_throwing:bow", {
|
||||
description = "Bow",
|
||||
inventory_image = "mcl_throwing_bow.png",
|
||||
stack_max = 1,
|
||||
on_place = powerup_function("mcl_throwing:bow_0"),
|
||||
on_secondary_use = powerup_function("mcl_throwing:bow_0"),
|
||||
groups = {weapon=1,weapon_ranged=1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local wear = itemstack:get_wear()
|
||||
itemstack:add_wear(wear)
|
||||
if player_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("mcl_throwing:bow_0", {
|
||||
description = "Bow",
|
||||
inventory_image = "mcl_throwing_bow_0.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
|
||||
on_place = powerup_function("mcl_throwing:bow_1"),
|
||||
on_secondary_use = powerup_function("mcl_throwing:bow_1"),
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local wear = itemstack:get_wear()
|
||||
itemstack:replace("mcl_throwing:bow")
|
||||
itemstack:add_wear(wear)
|
||||
if player_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("mcl_throwing:bow_1", {
|
||||
description = "Bow",
|
||||
inventory_image = "mcl_throwing_bow_1.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
|
||||
on_place = powerup_function("mcl_throwing:bow_2"),
|
||||
on_secondary_use = powerup_function("mcl_throwing:bow_2"),
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local wear = itemstack:get_wear()
|
||||
itemstack:replace("mcl_throwing:bow")
|
||||
itemstack:add_wear(wear)
|
||||
if player_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("mcl_throwing:bow_2", {
|
||||
description = "Bow",
|
||||
inventory_image = "mcl_throwing_bow_2.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local wear = itemstack:get_wear()
|
||||
itemstack:replace("mcl_throwing:bow")
|
||||
itemstack:add_wear(wear)
|
||||
if player_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 = 'mcl_throwing:bow',
|
||||
recipe = {
|
||||
{'', 'mcl_core:stick', 'mcl_mobitems:string'},
|
||||
{'mcl_core:stick', '', 'mcl_mobitems:string'},
|
||||
{'', 'mcl_core:stick', 'mcl_mobitems:string'},
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = 'mcl_throwing:bow',
|
||||
recipe = {
|
||||
{'mcl_mobitems:string', 'mcl_core:stick', ''},
|
||||
{'mcl_mobitems:string', '', 'mcl_core:stick'},
|
||||
{'mcl_mobitems:string', 'mcl_core:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "mcl_throwing:bow",
|
||||
burntime = 15,
|
||||
})
|
1
mods/ITEMS/mcl_throwing/mod.conf
Normal file
|
@ -0,0 +1 @@
|
|||
name = mcl_throwing
|
BIN
mods/ITEMS/mcl_throwing/sounds/mcl_throwing_bow_shoot.ogg
Normal file
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_arrow.png
Normal file
After Width: | Height: | Size: 185 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_arrow_2.png
Normal file
After Width: | Height: | Size: 184 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_arrow_back.png
Normal file
After Width: | Height: | Size: 124 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_arrow_front.png
Normal file
After Width: | Height: | Size: 113 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_arrow_inv.png
Normal file
After Width: | Height: | Size: 196 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_bow.png
Normal file
After Width: | Height: | Size: 244 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_bow_0.png
Normal file
After Width: | Height: | Size: 318 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_bow_1.png
Normal file
After Width: | Height: | Size: 323 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_bow_2.png
Normal file
After Width: | Height: | Size: 311 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_egg.png
Normal file
After Width: | Height: | Size: 254 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_ender_pearl.png
Normal file
After Width: | Height: | Size: 338 B |
BIN
mods/ITEMS/mcl_throwing/textures/mcl_throwing_snowball.png
Normal file
After Width: | Height: | Size: 365 B |
185
mods/ITEMS/mcl_throwing/throwable.lua
Normal file
|
@ -0,0 +1,185 @@
|
|||
--
|
||||
-- Snowballs and other throwable items
|
||||
--
|
||||
|
||||
local GRAVITY = tonumber(minetest.setting_get("movement_gravity"))
|
||||
|
||||
local entity_mapping = {
|
||||
["mcl_throwing:snowball"] = "mcl_throwing:snowball_entity",
|
||||
["mcl_throwing:egg"] = "mcl_throwing:egg_entity",
|
||||
["mcl_throwing:ender_pearl"] = "mcl_throwing:ender_pearl_entity",
|
||||
}
|
||||
|
||||
local velocities = {
|
||||
["mcl_throwing:snowball_entity"] = 22,
|
||||
["mcl_throwing:egg_entity"] = 22,
|
||||
["mcl_throwing:ender_pearl_entity"] = 22,
|
||||
}
|
||||
|
||||
mcl_throwing.throw = function(throw_item, pos, dir, velocity)
|
||||
if velocity == nil then
|
||||
velocity = velocities[entity_name]
|
||||
end
|
||||
if velocity == nil then
|
||||
velocity = 22
|
||||
end
|
||||
|
||||
local itemstring = ItemStack(throw_item):get_name()
|
||||
local obj = minetest.add_entity(pos, entity_mapping[itemstring])
|
||||
obj:setvelocity({x=dir.x*velocity, y=dir.y*velocity, z=dir.z*velocity})
|
||||
obj:setacceleration({x=dir.x*-3, y=-GRAVITY, z=dir.z*-3})
|
||||
return obj
|
||||
end
|
||||
|
||||
-- Throw item
|
||||
local throw_function = function(entity_name, velocity)
|
||||
local func = function(item, player, pointed_thing)
|
||||
local playerpos = player:getpos()
|
||||
local dir = player:get_look_dir()
|
||||
local obj = mcl_throwing.throw(item, {x=playerpos.x, y=playerpos.y+1.5, z=playerpos.z}, dir, velocity)
|
||||
obj:get_luaentity()._thrower = player:get_player_name()
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
item:take_item()
|
||||
end
|
||||
return item
|
||||
end
|
||||
return func
|
||||
end
|
||||
|
||||
-- Staticdata handling because objects may want to be reloaded
|
||||
local get_staticdata = function(self)
|
||||
local data = {
|
||||
_lastpos = self._lastpos,
|
||||
_thrower = self._thrower,
|
||||
}
|
||||
return minetest.serialize(data)
|
||||
end
|
||||
|
||||
local on_activate = function(self, staticdata, dtime_s)
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if data then
|
||||
self._lastpos = data._lastpos
|
||||
self._thrower = data._thrower
|
||||
end
|
||||
end
|
||||
|
||||
-- The snowball entity
|
||||
local snowball_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
textures = {"mcl_throwing_snowball.png"},
|
||||
visual_size = {x=0.5, y=0.5},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
|
||||
get_staticdata = get_staticdata,
|
||||
on_activate = on_activate,
|
||||
|
||||
_lastpos={},
|
||||
}
|
||||
local egg_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
textures = {"mcl_throwing_egg.png"},
|
||||
visual_size = {x=0.45, y=0.45},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
|
||||
get_staticdata = get_staticdata,
|
||||
on_activate = on_activate,
|
||||
|
||||
_lastpos={},
|
||||
}
|
||||
-- Ender pearl entity
|
||||
local pearl_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
textures = {"mcl_throwing_ender_pearl.png"},
|
||||
visual_size = {x=0.9, y=0.9},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
|
||||
get_staticdata = get_staticdata,
|
||||
on_activate = on_activate,
|
||||
|
||||
_lastpos={},
|
||||
_thrower = nil, -- Player ObjectRef of the player who threw the ender pearl
|
||||
}
|
||||
|
||||
-- Snowball and egg entity on_step()--> called when snowball is moving.
|
||||
local on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
|
||||
-- Destroy when hitting a solid node
|
||||
if self._lastpos.x~=nil then
|
||||
if (def and def.walkable) or not def then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
self._lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set _lastpos-->Node will be added at last pos outside the node
|
||||
end
|
||||
|
||||
-- Movement function of ender pearl
|
||||
local pearl_on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
|
||||
-- Destroy when hitting a solid node
|
||||
if self._lastpos.x~=nil then
|
||||
if (def and def.walkable) or not def then
|
||||
local player = minetest.get_player_by_name(self._thrower)
|
||||
if player then
|
||||
-- Teleport and hurt player
|
||||
player:setpos(pos)
|
||||
player:set_hp(player:get_hp() - 5)
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
self._lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Node will be added at last pos outside the node
|
||||
end
|
||||
|
||||
snowball_ENTITY.on_step = on_step
|
||||
egg_ENTITY.on_step = on_step
|
||||
pearl_ENTITY.on_step = pearl_on_step
|
||||
|
||||
minetest.register_entity("mcl_throwing:snowball_entity", snowball_ENTITY)
|
||||
minetest.register_entity("mcl_throwing:egg_entity", egg_ENTITY)
|
||||
minetest.register_entity("mcl_throwing:ender_pearl_entity", pearl_ENTITY)
|
||||
|
||||
-- Snowball
|
||||
minetest.register_craftitem("mcl_throwing:snowball", {
|
||||
description = "Snowball",
|
||||
inventory_image = "mcl_throwing_snowball.png",
|
||||
stack_max = 16,
|
||||
on_use = throw_function("mcl_throwing:snowball_entity"),
|
||||
on_construct = function(pos)
|
||||
pos.y = pos.y - 1
|
||||
if minetest.get_node(pos).name == "default:dirt_with_grass" then
|
||||
minetest.set_node(pos, {name="default:dirt_with_snow"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Egg
|
||||
minetest.register_craftitem("mcl_throwing:egg", {
|
||||
description = "Egg",
|
||||
inventory_image = "mcl_throwing_egg.png",
|
||||
stack_max = 16,
|
||||
on_use = throw_function("mcl_throwing:egg_entity"),
|
||||
groups = { craftitem = 1 },
|
||||
})
|
||||
|
||||
-- Ender Pearl
|
||||
minetest.register_craftitem("mcl_throwing:ender_pearl", {
|
||||
description = "Ender Pearl",
|
||||
wield_image = "mcl_throwing_ender_pearl.png",
|
||||
inventory_image = "mcl_throwing_ender_pearl.png",
|
||||
stack_max = 16,
|
||||
on_use = throw_function("mcl_throwing:ender_pearl_entity"),
|
||||
})
|
||||
|