1.0 definitive shot/reload & fireworks!

This commit is contained in:
echoes91 2015-03-27 15:22:12 +01:00
parent 715367837d
commit 74f021572b
24 changed files with 585 additions and 118 deletions

View File

@ -20,9 +20,15 @@ Grahpics & sounds: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/leg
Changelog:
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!
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

270
bows.lua
View File

@ -1,77 +1,3 @@
--~
--~ Shot and reload system
--~
local stiffness= 0
local reload = 0
minetest.register_on_joinplayer(function(player)
local playername = player:get_player_name()
local privs = minetest.get_player_privs(playername)
privs.throw = true
minetest.set_player_privs(playername, privs)
end)
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
local playername = player:get_player_name()
if minetest.get_player_privs(playername).throw then
local privs = minetest.get_player_privs(playername)
privs.throw = nil
minetest.set_player_privs(playername, privs)
local privs = minetest.get_player_privs(playername)
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*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)
minetest.sound_play("throwing_bow_sound", {pos=playerpos})
if obj:get_luaentity().player == "" then
obj:get_luaentity().player = player
end
obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()+2)
obj:get_luaentity().inventory = player:get_inventory()
return true
end
end
end
return false
end
local function reloaded (player, id)
local playername = player:get_player_name()
local privs = minetest.get_player_privs(playername)
privs.throw = true
minetest.set_player_privs(playername, privs)
player:hud_change(id, "number", 0x00FF00)
player:hud_change(id, "text", "Ready!")
player:hud_change(id, "position", {x=0.6,y=0.515})
minetest.after(0.5, function(player, id)
player:hud_remove(id)
end, player, id)
end
local function reloading (player)
minetest.register_on_dieplayer(function(player)
local playername = player:get_player_name()
local privs = minetest.get_player_privs(playername)
privs.throw = true
minetest.set_player_privs(playername, privs)
end)
local throwing_hud = player:hud_add({
hud_elem_type = "text",
position = {x=0.6,y=0.5},
text = "Reloading...",
number = 0xFF0000,
})
minetest.after(reload, reloaded, player, throwing_hud)
end
--~
--~ Bows
--~
@ -81,20 +7,42 @@ if not DISABLE_WOODEN_BOW then
description = "Wooden Bow",
inventory_image = "throwing_bow_wood.png",
wield_scale = {x=1, y=1, z=0.5},
stack_max = 1,
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
stiffness = 11
reload = 1.2
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
reloading(user)
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/50)
end
end
local reload_time = 0.8
local loaded = "throwing:bow_wood_loaded"
local is_cross = false
local pos = user:getpos()
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
return itemstack
end,
})
minetest.register_tool("throwing:bow_wood_loaded", {
description = "Wooden Bow",
inventory_image = "throwing_bow_wood_loaded.png",
wield_scale = {x=1, y=1, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local stiffness = 11
local wear = itemstack:get_wear()
local is_cross = false
if not minetest.setting_getbool("creative_mode") then
wear = wear + (65535/50)
end
local unloaded = "throwing:bow_wood"
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
return itemstack
end,
on_drop = function(itemstack, dropper, pointed_thing)
local wear = itemstack:get_wear()
local unloaded = "throwing:bow_wood"
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
end,
groups = {not_in_creative_inventory=1},
})
minetest.register_craft({
output = 'throwing:bow_wood',
recipe = {
@ -121,17 +69,39 @@ if not DISABLE_LONGBOW then
wield_scale = {x=1, y=2.5, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
stiffness = 18
reload = 2.5
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
reloading(user)
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/100)
end
end
local reload_time = 1.8
local loaded = "throwing:longbow_loaded"
local is_cross = false
local pos = user:getpos()
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
return itemstack
end,
})
minetest.register_tool("throwing:longbow_loaded", {
description = "Longbow",
inventory_image = "throwing_longbow_loaded.png",
wield_scale = {x=1, y=2.5, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local stiffness = 17
local wear = itemstack:get_wear()
local is_cross = false
if not minetest.setting_getbool("creative_mode") then
wear = wear + (65535/100)
end
local unloaded = "throwing:longbow"
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
return itemstack
end,
on_drop = function(itemstack, dropper, pointed_thing)
local wear = itemstack:get_wear()
local unloaded = "throwing:longbow"
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
end,
groups = {not_in_creative_inventory=1},
})
minetest.register_craft({
output = 'throwing:longbow',
@ -159,18 +129,40 @@ if not DISABLE_COMPOSITE_BOW then
wield_scale = {x=1, y=1.4, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
stiffness = 18
reload = 1.5
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
reloading(user)
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/150)
end
end
local reload_time = 1
local loaded = "throwing:bow_composite_loaded"
local is_cross = false
local pos = user:getpos()
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
return itemstack
end,
})
minetest.register_tool("throwing:bow_composite_loaded", {
description = "Composite Bow",
inventory_image = "throwing_bow_composite_loaded.png",
wield_scale = {x=1, y=1.4, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local stiffness = 17
local wear = itemstack:get_wear()
local is_cross = false
if not minetest.setting_getbool("creative_mode") then
wear = wear + (65535/150)
end
local unloaded = "throwing:bow_composite"
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
return itemstack
end,
on_drop = function(itemstack, dropper, pointed_thing)
local wear = itemstack:get_wear()
local unloaded = "throwing:bow_composite"
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
end,
groups = {not_in_creative_inventory=1},
})
minetest.register_craft({
output = 'throwing:bow_composite',
recipe = {
@ -197,18 +189,40 @@ if not DISABLE_STEEL_BOW then
wield_scale = {x=1, y=1.4, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
stiffness = 20
reload = 1.7
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
reloading(user)
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/250)
end
end
local reload_time = 1.2
local loaded = "throwing:bow_steel_loaded"
local is_cross = false
local pos = user:getpos()
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
return itemstack
end,
})
minetest.register_tool("throwing:bow_steel_loaded", {
description = "Steel Bow",
inventory_image = "throwing_bow_steel_loaded.png",
wield_scale = {x=1, y=1.4, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local stiffness = 20
local wear = itemstack:get_wear()
local is_cross = false
if not minetest.setting_getbool("creative_mode") then
wear = wear + (65535/250)
end
local unloaded = "throwing:bow_steel"
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
return itemstack
end,
on_drop = function(itemstack, dropper, pointed_thing)
local wear = itemstack:get_wear()
local unloaded = "throwing:bow_steel"
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
end,
groups = {not_in_creative_inventory=1},
})
minetest.register_craft({
output = 'throwing:bow_steel',
recipe = {
@ -235,18 +249,40 @@ if not DISABLE_ROYAL_BOW then
wield_scale = {x=1, y=1.4, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
stiffness = 16
reload = 1.6
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
reloading(user)
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/1000)
end
end
local reload_time = 1.2
local loaded = "throwing:bow_royal_loaded"
local is_cross = false
local pos = user:getpos()
minetest.after(reload_time, throwing_reload, itemstack, user, pos, is_cross, loaded)
return itemstack
end,
})
minetest.register_tool("throwing:bow_royal_loaded", {
description = "Royal Bow",
inventory_image = "throwing_bow_royal_loaded.png",
wield_scale = {x=1, y=1.4, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local stiffness = 18
local wear = itemstack:get_wear()
local is_cross = false
if not minetest.setting_getbool("creative_mode") then
wear = wear + (65535/750)
end
local unloaded = "throwing:bow_royal"
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
minetest.after(0.01, throwing_unload, itemstack, user, unloaded, wear)
return itemstack
end,
on_drop = function(itemstack, dropper, pointed_thing)
local wear = itemstack:get_wear()
local unloaded = "throwing:bow_royal"
minetest.after(0.01, throwing_unload, itemstack, dropper, unloaded, wear)
end,
groups = {not_in_creative_inventory=1},
})
minetest.register_craft({
output = 'throwing:bow_royal',
recipe = {

177
fireworks_blue_arrow.lua Normal file
View File

@ -0,0 +1,177 @@
minetest.register_craftitem("throwing:arrow_fireworks_blue", {
description = "Blue fireworks arrow",
inventory_image = "throwing_arrow_fireworks_blue.png",
})
minetest.register_node("throwing:arrow_fireworks_blue_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_blue.png", "throwing_arrow_fireworks_blue.png", "throwing_arrow_fireworks_blue_back.png", "throwing_arrow_fireworks_blue_front.png", "throwing_arrow_fireworks_blue_2.png", "throwing_arrow_fireworks_blue.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_blue_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_blue.png",
})
end
local function boom(pos)
minetest.sound_play("throwing_firework_boom", {pos=pos, gain=1, max_hear_distance=2*64})
minetest.set_node(pos, {name="throwing:firework_boom"})
minetest.get_node_timer(pos):start(0.2)
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_blue_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
minetest.add_node(pos, {name="throwing:firework_trail"})
minetest.get_node_timer(pos):start(0.2)
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("throwing:arrow_fireworks_blue_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_fireworks_blue 8',
recipe = {
{'default:stick', 'tnt:gunpowder', 'dye:blue'},
}
})
minetest.register_craft({
output = 'throwing:arrow_fireworks_blue 8',
recipe = {
{'dye:blue', 'tnt:gunpowder', 'default:stick'},
}
})
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,
})

177
fireworks_red_arrow.lua Normal file
View File

@ -0,0 +1,177 @@
minetest.register_craftitem("throwing:arrow_fireworks_red", {
description = "Red fireworks arrow",
inventory_image = "throwing_arrow_fireworks_red.png",
})
minetest.register_node("throwing:arrow_fireworks_red_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_red.png", "throwing_arrow_fireworks_red.png", "throwing_arrow_fireworks_red_back.png", "throwing_arrow_fireworks_red_front.png", "throwing_arrow_fireworks_red_2.png", "throwing_arrow_fireworks_red.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_red_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_red.png",
})
end
local function boom(pos)
minetest.sound_play("throwing_firework_boom", {pos=pos, gain=1, max_hear_distance=2*64})
minetest.set_node(pos, {name="throwing:firework_boom"})
minetest.get_node_timer(pos):start(0.2)
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_red_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
minetest.add_node(pos, {name="throwing:firework_trail"})
minetest.get_node_timer(pos):start(0.2)
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("throwing:arrow_fireworks_red_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_fireworks_red 8',
recipe = {
{'default:stick', 'tnt:gunpowder', 'dye:red'},
}
})
minetest.register_craft({
output = 'throwing:arrow_fireworks_red 8',
recipe = {
{'dye:red', 'tnt:gunpowder', 'default:stick'},
}
})
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,
})

60
functions.lua Normal file
View File

@ -0,0 +1,60 @@
--~
--~ Shot and reload system
--~
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
if obj:get_luaentity().player == "" then
obj:get_luaentity().player = player
end
obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()+2)
obj:get_luaentity().inventory = player:get_inventory()
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)
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
meta = arrow[2]
player:set_wielded_item({name=loaded, wear=wear, metadata=meta})
end
end
end
end
end

View File

@ -1,4 +1,4 @@
arrows = {
throwing_arrows = {
{"throwing:arrow_steel", "throwing:arrow_steel_entity"},
{"throwing:arrow_stone", "throwing:arrow_stone_entity"},
{"throwing:arrow_obsidian", "throwing:arrow_obsidian_entity"},
@ -11,6 +11,7 @@ arrows = {
{"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 input = io.open(minetest.get_modpath("throwing").."/throwing.conf", "r")
@ -20,6 +21,8 @@ if input then
input = nil
end
dofile(minetest.get_modpath("throwing").."/functions.lua")
dofile(minetest.get_modpath("throwing").."/bows.lua")
if not DISABLE_STEEL_ARROW then
@ -66,6 +69,14 @@ if not DISABLE_SHELL_ARROW then
dofile(minetest.get_modpath("throwing").."/shell_arrow.lua")
end
if not DISABLE_FIREWORKS_BLUE_ARROW then
dofile(minetest.get_modpath("throwing").."/fireworks_blue_arrow.lua")
end
if not DISABLE_FIREWORKS_RED_ARROW then
dofile(minetest.get_modpath("throwing").."/fireworks_red_arrow.lua")
end
if minetest.setting_get("log_mods") then
minetest.log("action", "throwing loaded")
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B