Compare commits

...

5 Commits

Author SHA1 Message Date
Juraj Vajda cdc4d15b89 new sounds 2018-10-18 17:05:53 -04:00
Juraj Vajda ac54bb4f73 pvp refactor 2018-10-16 21:59:45 -04:00
Juraj Vajda 9cbcf578b1 Revert "make sure unloaded bow is placed in the correct index to prevent dupes"
This reverts commit 6e9809a478.
2018-10-15 23:12:50 -04:00
Juraj Vajda 6e9809a478 make sure unloaded bow is placed in the correct index to prevent dupes 2018-10-14 02:06:35 +00:00
Juraj Vajda 9b68b8c674 remove trailing spaces and mixed tabs and spaces 2018-02-25 17:32:25 -05:00
7 changed files with 27 additions and 19 deletions

View File

@ -1,6 +1,6 @@
--~
--~
--~ Shot and reload system
--~
--~
local players = {}
@ -62,12 +62,17 @@ function throwing_unload (itemstack, player, unloaded, wear)
if wear >= 65535 then
player:set_wielded_item({})
else
player:set_wielded_item({name=unloaded, wear=wear})
if itemstack:get_name() == player:get_wielded_item():get_name() then
player:set_wielded_item({name=unloaded, wear=wear})
end
end
end
function throwing_reload (itemstack, player, pos, is_cross, loaded)
local playerName = player:get_player_name()
if not players[playerName] then
return
end
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
@ -92,7 +97,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
description = desc,
inventory_image = "throwing_" .. name .. ".png",
wield_scale = scale,
stack_max = 1,
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local pos = user:getpos()
local playerName = user:get_player_name()
@ -103,12 +108,12 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
return itemstack
end,
})
minetest.register_tool("throwing:" .. name .. "_loaded", {
description = desc,
inventory_image = "throwing_" .. name .. "_loaded.png",
wield_scale = scale,
stack_max = 1,
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
local wear = itemstack:get_wear()
if not minetest.settings:get_bool("creative_mode") then
@ -116,7 +121,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
end
local unloaded = "throwing:" .. name
throwing_shoot_arrow(itemstack, user, stiffness, is_cross)
minetest.after(0, throwing_unload, itemstack, user, unloaded, wear)
minetest.after(0, throwing_unload, itemstack, user, unloaded, wear)
return itemstack
end,
-- on_drop = function(itemstack, dropper, pointed_thing)
@ -126,7 +131,7 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
-- end,
groups = {not_in_creative_inventory=1},
})
minetest.register_craft({
output = 'throwing:' .. name,
recipe = craft

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3,7 +3,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
description = desc .. " arrow",
inventory_image = "throwing_arrow_" .. kind .. ".png",
})
minetest.register_node("throwing:arrow_" .. kind .. "_box", {
drawtype = "nodebox",
node_box = {
@ -19,7 +19,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
@ -29,7 +29,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
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,
@ -39,12 +39,12 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
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
@ -52,7 +52,10 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
if obj:is_player() then
local speed = vector.length(self.object:getvelocity())
local damage = ((speed + eq)^1.2)/10
obj:set_hp(obj:get_hp()-damage)
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=damage},
}, nil)
self.object:remove()
end
-- end player damage
@ -60,7 +63,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
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
local damage = ((speed + eq)^1.2)/10
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=damage},
@ -75,7 +78,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
end
end
end
if self.lastpos.x~=nil then
if node.name ~= "air" and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then
self.object:remove()
@ -88,16 +91,16 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
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 .. ' 9',
recipe = {
{'default:stick', 'default:stick', craft},
}
})
minetest.register_craft({
output = 'throwing:arrow_' .. kind .. ' 9',
recipe = {