mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-11 18:40:25 +01:00
remove spears, improve and fix bug in throwing mod
This commit is contained in:
parent
95afbebdd9
commit
f198c25db2
@ -69,9 +69,18 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
end
|
||||
end
|
||||
|
||||
if node.name ~= "air" and not string.find(node.name, "water_") and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "air"
|
||||
and not string.find(node.name, "water_")
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "ignore" and self.inventory and self.stack then
|
||||
if not minetest.is_protected(self.lastpos, "") and 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
|
||||
if not minetest.is_protected(self.lastpos, "")
|
||||
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()})
|
||||
|
@ -23,8 +23,3 @@ DISABLE_STEEL_ARROW = false
|
||||
DISABLE_DIAMOND_ARROW = false
|
||||
DISABLE_OBSIDIAN_ARROW = false
|
||||
|
||||
DISABLE_STONE_SPEAR = false
|
||||
DISABLE_STEEL_SPEAR = false
|
||||
DISABLE_DIAMOND_SPEAR = false
|
||||
DISABLE_OBSIDIAN_SPEAR = false
|
||||
DISABLE_MITHRIL_SPEAR = false
|
||||
|
@ -49,19 +49,30 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
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 throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
local damage = 1.5
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
if throwing_touch(pos, objpos) then
|
||||
local puncher = self.object
|
||||
if self.player and minetest.get_player_by_name(self.player) then
|
||||
puncher = minetest.get_player_by_name(self.player)
|
||||
end
|
||||
local damage = 1.5
|
||||
obj:punch(puncher, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
|
||||
minetest.add_item(pos, "throwing:arrow_dig")
|
||||
}, nil)
|
||||
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
|
||||
minetest.add_item(pos, "throwing:arrow_dig")
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
if node.name ~= "air" and not string.find(node.name, "water_") and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "air"
|
||||
and not string.find(node.name, "water_")
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "ignore" and minetest.get_item_group(node.name, "unbreakable") == 0
|
||||
and not minetest.is_protected(pos, self.player)
|
||||
and node.diggable ~= false then
|
||||
|
@ -48,10 +48,13 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
for k, obj in pairs(objs) do
|
||||
local objpos = obj:getpos()
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
if (pos.x - objpos.x < 0.5 and pos.x - objpos.x > -0.5) and (pos.z - objpos.z < 0.5 and pos.z - objpos.z > -0.5) then
|
||||
|
||||
if throwing_touch(pos, objpos) then
|
||||
local puncher = self.object
|
||||
if self.player and minetest.get_player_by_name(self.player) then
|
||||
puncher = minetest.get_player_by_name(self.player)
|
||||
end
|
||||
local damage = 4
|
||||
obj:punch(self.object, 1.0, {
|
||||
obj:punch(puncher, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
@ -64,7 +67,13 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
end
|
||||
end
|
||||
|
||||
if node.name ~= "air" and node.name ~= "throwing:light" and node.name ~= "fire:basic_flame" and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "air"
|
||||
and node.name ~= "throwing:light"
|
||||
and node.name ~= "fire:basic_flame"
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "ignore" then
|
||||
minetest.set_node(self.lastpos, {name="fire:basic_flame"})
|
||||
end
|
||||
|
@ -45,6 +45,15 @@ function throwing_get_trajectoire(self, newpos)
|
||||
return coord
|
||||
end
|
||||
|
||||
function throwing_touch(pos, objpos)
|
||||
local rx = pos.x - objpos.x
|
||||
local ry = pos.y - (objpos.y+1)
|
||||
local rz = pos.z - objpos.z
|
||||
if (ry < 1 and ry > -1) and (rx < 0.4 and rx > -0.4) and (rz < 0.4 and rz > -0.4) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function throwing_shoot_arrow (itemstack, player, stiffness, is_cross)
|
||||
if not player then return end
|
||||
@ -179,19 +188,3 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
|
||||
})
|
||||
end
|
||||
|
||||
-- Spears
|
||||
|
||||
function throwing_shoot_spear (itemstack, player)
|
||||
local spear = itemstack:get_name() .. '_entity'
|
||||
local playerpos = player:getpos()
|
||||
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear)
|
||||
local dir = player:get_look_dir()
|
||||
obj:setvelocity({x=dir.x*14, y=dir.y*14, z=dir.z*14})
|
||||
obj:setacceleration({x=-dir.x*1, y=-9.8, z=-dir.z*1})
|
||||
obj:setyaw(player:get_look_yaw()+math.pi)
|
||||
obj:get_luaentity().wear = itemstack:get_wear()
|
||||
obj:get_luaentity().player = player:get_player_name()
|
||||
obj:get_luaentity().lastpos = {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}
|
||||
minetest.sound_play("throwing_bow_sound", {pos=playerpos})
|
||||
return true
|
||||
end
|
||||
|
@ -32,7 +32,6 @@ dofile(minetest.get_modpath("throwing").."/crafts.lua")
|
||||
|
||||
dofile(minetest.get_modpath("throwing").."/standard_arrows.lua")
|
||||
|
||||
dofile(minetest.get_modpath("throwing").."/spears.lua")
|
||||
|
||||
if minetest.get_modpath('fire') and minetest.get_modpath('bucket') and not DISABLE_FIRE_ARROW then
|
||||
dofile(minetest.get_modpath("throwing").."/fire_arrow.lua")
|
||||
|
@ -90,7 +90,11 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
end
|
||||
end
|
||||
|
||||
if node.name ~= "air" and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') 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, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
boom(self.lastpos)
|
||||
self.object:remove()
|
||||
return
|
||||
|
@ -1,136 +0,0 @@
|
||||
function throwing_register_spear_standard (kind, desc, eq, toughness, craft)
|
||||
minetest.register_tool("throwing:spear_" .. kind, {
|
||||
description = desc .. " spear",
|
||||
inventory_image = "throwing_spear_" .. kind .. ".png",
|
||||
wield_scale= {x=2,y=1.5,z=1.5};
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "object" then
|
||||
local damage = eq --((eq + 20)^1.2)/10 --MFF crabman(28/09/2015) damage valeur equal eq
|
||||
pointed_thing.ref:punch(user, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/toughness)
|
||||
end
|
||||
else
|
||||
throwing_shoot_spear(itemstack, user)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("throwing:spear_" .. kind .. "_box", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-- Shaft
|
||||
{-60/16, -2/16, 2/16, 4, 1/16, -1/16},
|
||||
--Spitze
|
||||
{-4, -1/16, 1/16, -62/16, 0, 0},
|
||||
{-62/16, -1.5/16, 1.5/16, -60/16, 0.5/16, -0.5/16},
|
||||
}
|
||||
},
|
||||
tiles = {"throwing_spear_box.png"},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
local THROWING_SPEAR_ENTITY={
|
||||
physical = false,
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.1, y=0.1},
|
||||
textures = {"throwing:spear_" .. kind .. "_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
player = "",
|
||||
wear = 0,
|
||||
}
|
||||
|
||||
THROWING_SPEAR_ENTITY.on_step = function(self, dtime)
|
||||
if not self.wear then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
local newpos = self.object:getpos()
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
local node = minetest.get_node(pos)
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||
for k, obj in pairs(objs) do
|
||||
local objpos = obj:getpos()
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
if (pos.x - objpos.x < 0.5 and pos.x - objpos.x > -0.5) and (pos.z - objpos.z < 0.5 and pos.z - objpos.z > -0.5) then
|
||||
--local speed = vector.length(self.object:getvelocity()) --MFF crabman(28/09/2015) damage valeur equal eq
|
||||
local damage = eq --((speed + eq +5)^1.2)/10 --MFF crabman(28/09/2015) damage valeur equal eq
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
minetest.add_item(self.lastpos, {name='throwing:spear_' .. kind, count=1, wear=self.wear+65535/toughness, metadata=""})
|
||||
--if math.random() < toughness then
|
||||
--minetest.add_item(self.lastpos, 'throwing:spear_' .. kind)
|
||||
--else
|
||||
--minetest.add_item(self.lastpos, 'default:stick')
|
||||
--end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
if node.name ~= "air" and not string.find(node.name, 'water_') and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||
minetest.add_item(self.lastpos, {name='throwing:spear_' .. kind, count=1, wear=self.wear+65535/toughness, metadata=""})
|
||||
--if math.random() < toughness then
|
||||
--minetest.add_item(self.lastpos, 'throwing:spear_' .. kind)
|
||||
--else
|
||||
--minetest.add_item(self.lastpos, 'default:stick')
|
||||
--end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
end
|
||||
end
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
end
|
||||
|
||||
minetest.register_entity("throwing:spear_" .. kind .. "_entity", THROWING_SPEAR_ENTITY)
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:spear_' .. kind,
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', craft},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:spear_' .. kind,
|
||||
recipe = {
|
||||
{craft, 'group:wood', 'group:wood'},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
if not DISABLE_STONE_SPEAR then
|
||||
throwing_register_spear_standard ('stone', 'Stone (Hunter)', 3, 25, 'group:stone') --MFF crabman(28/09/2015) damage and wear
|
||||
end
|
||||
|
||||
if not DISABLE_STEEL_SPEAR then
|
||||
throwing_register_spear_standard ('steel', 'Steel (Hunter)', 4, 30, 'default:steel_ingot') --MFF crabman(28/09/2015) damage and wear
|
||||
end
|
||||
|
||||
if not DISABLE_DIAMOND_SPEAR then
|
||||
throwing_register_spear_standard ('diamond', 'Diamond (Hunter)', 7, 50, 'default:diamond') --MFF crabman(28/09/2015) damage and wear
|
||||
end
|
||||
|
||||
if not DISABLE_OBSIDIAN_SPEAR then
|
||||
throwing_register_spear_standard ('obsidian', 'Obsidian (Hunter)', 5, 40, 'default:obsidian') --MFF crabman(28/09/2015) damage and wear
|
||||
end
|
||||
|
||||
if not DISABLE_MITHRIL_SPEAR then
|
||||
throwing_register_spear_standard ('mithril', 'Mithril (Hunter)', 8, 200, 'moreores:mithril_ingot') --MFF crabman(28/09/2015) damage and wear
|
||||
end
|
||||
|
@ -50,11 +50,15 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
|
||||
for k, obj in pairs(objs) do
|
||||
local objpos = obj:getpos()
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
if (pos.x - objpos.x < 0.5 and pos.x - objpos.x > -0.5) and (pos.z - objpos.z < 0.5 and pos.z - objpos.z > -0.5) then
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=eq},
|
||||
}, nil)
|
||||
if throwing_touch(pos, objpos) then
|
||||
local puncher = self.object
|
||||
if self.player and minetest.get_player_by_name(self.player) then
|
||||
puncher = minetest.get_player_by_name(self.player)
|
||||
end
|
||||
obj:punch(puncher, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=eq},
|
||||
}, nil)
|
||||
if math.random() < toughness then
|
||||
if math.random(0,100) % 2 == 0 then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
|
||||
@ -67,7 +71,12 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
|
||||
end
|
||||
end
|
||||
end
|
||||
if node.name ~= "air" and not string.find(node.name, 'water_') and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||
if node.name ~= "air"
|
||||
and not string.find(node.name, 'water_')
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if math.random() < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
|
||||
else
|
||||
|
@ -58,7 +58,11 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
end
|
||||
end
|
||||
|
||||
if node.name ~= "air" and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') 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, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
if self.player ~= "" then
|
||||
local player = minetest.get_player_by_name(self.player)
|
||||
if player then
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 174 B |
Binary file not shown.
Before Width: | Height: | Size: 442 B |
Binary file not shown.
Before Width: | Height: | Size: 426 B |
Binary file not shown.
Before Width: | Height: | Size: 391 B |
Binary file not shown.
Before Width: | Height: | Size: 431 B |
Binary file not shown.
Before Width: | Height: | Size: 431 B |
@ -37,9 +37,3 @@ DISABLE_DIAMOND_ARROW = false
|
||||
DISABLE_MITHRIL_ARROW = false
|
||||
-- lesser damages to better damages
|
||||
|
||||
-- Spear
|
||||
DISABLE_STONE_SPEAR = false
|
||||
DISABLE_STEEL_SPEAR = false
|
||||
DISABLE_DIAMOND_SPEAR = false
|
||||
DISABLE_OBSIDIAN_SPEAR = false
|
||||
DISABLE_MITHRIL_SPEAR = false
|
||||
|
@ -48,21 +48,27 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 0.5)
|
||||
for k, obj in pairs(objs) do
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
local damage = 0.5
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
local toughness = 0.9
|
||||
if math.random() < toughness then
|
||||
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
|
||||
minetest.add_item(pos, 'throwing:arrow_torch')
|
||||
if throwing_touch(pos, objpos) then
|
||||
local puncher = self.object
|
||||
if self.player and minetest.get_player_by_name(self.player) then
|
||||
puncher = minetest.get_player_by_name(self.player)
|
||||
end
|
||||
else
|
||||
minetest.add_item(pos, 'default:stick')
|
||||
local damage = 0.5
|
||||
obj:punch(puncher, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
local toughness = 0.9
|
||||
if math.random() < toughness then
|
||||
if math.random(0,100) % 2 == 0 then -- 50% of chance to drop //MFF (Mg|07/27/15)
|
||||
minetest.add_item(pos, 'throwing:arrow_torch')
|
||||
end
|
||||
else
|
||||
minetest.add_item(pos, 'default:stick')
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@ -70,7 +76,12 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
if node.name == 'air' then
|
||||
minetest.add_node(pos, {name="throwing:torch_trail"})
|
||||
minetest.get_node_timer(pos):start(0.1)
|
||||
elseif node.name ~= "air" and not string.find(node.name, "trail") and not string.find(node.name, 'grass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||
elseif node.name ~= "air"
|
||||
and not string.find(node.name, "trail")
|
||||
and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt'))
|
||||
and not (string.find(node.name, 'farming:') and not string.find(node.name, 'soil'))
|
||||
and not string.find(node.name, 'flowers:')
|
||||
and not string.find(node.name, 'fire:') then
|
||||
local player = minetest.get_player_by_name(self.player)
|
||||
if not player then self.object:remove() return end
|
||||
if node.name ~= "ignore" and not string.find(node.name, "water_") and not string.find(node.name, "lava")
|
||||
|
Loading…
Reference in New Issue
Block a user