mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-12 11:00:25 +01:00
update throwing mod
add spear original + add spear mithril improve arrows
This commit is contained in:
parent
aa9647ff4e
commit
303a724cda
@ -9,8 +9,9 @@ How to install:
|
|||||||
http://wiki.minetest.com/wiki/Installing_Mods
|
http://wiki.minetest.com/wiki/Installing_Mods
|
||||||
|
|
||||||
How to use the mod:
|
How to use the mod:
|
||||||
Select the bow and place the arrows into the slot next to it; shoot with left mouse click.
|
Select a bow and place the arrows into the slot next to it; shoot with left mouse click.
|
||||||
Every shoot will take 1 arrow from your inventory and wears out the bow.
|
Every shoot will take 1 arrow from your inventory and wears out the bow.
|
||||||
|
Select a spear and attack with left mouse click; it will be used as a melee weapon if pointing any target, otherwise it will be thrown.
|
||||||
|
|
||||||
License:
|
License:
|
||||||
This mod was originally published by Jeija and reworked by PilzAdam
|
This mod was originally published by Jeija and reworked by PilzAdam
|
||||||
@ -20,6 +21,15 @@ Grahpics & sounds: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/leg
|
|||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
|
||||||
|
Update 1.4.1:
|
||||||
|
- Fixed spears not retaining wear
|
||||||
|
- Improved textures
|
||||||
|
- Torch arrows have light trail
|
||||||
|
|
||||||
|
Update 1.4:
|
||||||
|
- Added spears, capable of melee and ranged attacks
|
||||||
|
- Improved arrows textures
|
||||||
|
|
||||||
Update 1.3:
|
Update 1.3:
|
||||||
- Added automated arbalest, the ultimate weapon
|
- Added automated arbalest, the ultimate weapon
|
||||||
- New arbalest texture coherent with steel color
|
- New arbalest texture coherent with steel color
|
||||||
|
@ -69,7 +69,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name ~= "air" 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, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||||
if node.name ~= "ignore" and self.inventory and self.stack 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, "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
|
||||||
minetest.place_node(self.lastpos, {name=self.stack:get_name()})
|
minetest.place_node(self.lastpos, {name=self.stack:get_name()})
|
||||||
|
@ -22,3 +22,9 @@ DISABLE_STONE_ARROW = false
|
|||||||
DISABLE_STEEL_ARROW = false
|
DISABLE_STEEL_ARROW = false
|
||||||
DISABLE_DIAMOND_ARROW = false
|
DISABLE_DIAMOND_ARROW = false
|
||||||
DISABLE_OBSIDIAN_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
|
||||||
|
@ -61,7 +61,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if node.name ~= "air" and not string.find(node.name, "water_") 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, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||||
if node.name ~= "ignore" and minetest.get_item_group(node.name, "unbreakable") == 0
|
if node.name ~= "ignore" and minetest.get_item_group(node.name, "unbreakable") == 0
|
||||||
and not minetest.is_protected(pos, self.player)
|
and not minetest.is_protected(pos, self.player)
|
||||||
and node.diggable ~= false then
|
and node.diggable ~= false then
|
||||||
|
@ -64,7 +64,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name ~= "air" and node.name ~= "throwing:light" and node.name ~= "fire:basic_flame" 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, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||||
if node.name ~= "ignore" then
|
if node.name ~= "ignore" then
|
||||||
minetest.set_node(self.lastpos, {name="fire:basic_flame"})
|
minetest.set_node(self.lastpos, {name="fire:basic_flame"})
|
||||||
end
|
end
|
||||||
|
@ -22,11 +22,12 @@ end
|
|||||||
|
|
||||||
function throwing_is_entity(obj)
|
function throwing_is_entity(obj)
|
||||||
return (obj:get_luaentity() ~= nil
|
return (obj:get_luaentity() ~= nil
|
||||||
and not string.find(obj:get_luaentity().name, "throwing:arrow_")
|
and not string.find(obj:get_luaentity().name, "throwing:")
|
||||||
and obj:get_luaentity().name ~= "__builtin:item"
|
and obj:get_luaentity().name ~= "__builtin:item"
|
||||||
and obj:get_luaentity().name ~= "gauges:hp_bar"
|
and obj:get_luaentity().name ~= "gauges:hp_bar"
|
||||||
and obj:get_luaentity().name ~= "signs:text")
|
and obj:get_luaentity().name ~= "signs:text")
|
||||||
end
|
end
|
||||||
|
|
||||||
function throwing_get_trajectoire(self, newpos)
|
function throwing_get_trajectoire(self, newpos)
|
||||||
if self.lastpos.x == nil then
|
if self.lastpos.x == nil then
|
||||||
return {newpos}
|
return {newpos}
|
||||||
@ -175,3 +176,20 @@ function throwing_register_bow (name, desc, scale, stiffness, reload_time, tough
|
|||||||
recipe = rev_craft
|
recipe = rev_craft
|
||||||
})
|
})
|
||||||
end
|
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,6 +32,8 @@ dofile(minetest.get_modpath("throwing").."/crafts.lua")
|
|||||||
|
|
||||||
dofile(minetest.get_modpath("throwing").."/standard_arrows.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
|
if minetest.get_modpath('fire') and minetest.get_modpath('bucket') and not DISABLE_FIRE_ARROW then
|
||||||
dofile(minetest.get_modpath("throwing").."/fire_arrow.lua")
|
dofile(minetest.get_modpath("throwing").."/fire_arrow.lua")
|
||||||
end
|
end
|
||||||
|
@ -90,7 +90,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name ~= "air" and not string.find(node.name, 'default:grass') and not string.find(node.name, 'default:junglegrass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then
|
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
|
||||||
boom(self.lastpos)
|
boom(self.lastpos)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
|
136
mods/throwing/spears.lua
Normal file
136
mods/throwing/spears.lua
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
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 + 20)^1.2)/10
|
||||||
|
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 = "",
|
||||||
|
}
|
||||||
|
|
||||||
|
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())
|
||||||
|
local damage = ((speed + eq +5)^1.2)/10
|
||||||
|
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, 'flowers:') and not string.find(node.name, 'fire:') and (node.drawtype and not string.find(node.drawtype, 'plantlike')) 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)', 0, 20, 'group:stone')
|
||||||
|
end
|
||||||
|
|
||||||
|
if not DISABLE_STEEL_SPEAR then
|
||||||
|
throwing_register_spear_standard ('steel', 'Steel (Hunter)', 5, 30, 'default:steel_ingot')
|
||||||
|
end
|
||||||
|
|
||||||
|
if not DISABLE_DIAMOND_SPEAR then
|
||||||
|
throwing_register_spear_standard ('diamond', 'Diamond (Hunter)', 10, 40, 'default:diamond')
|
||||||
|
end
|
||||||
|
|
||||||
|
if not DISABLE_OBSIDIAN_SPEAR then
|
||||||
|
throwing_register_spear_standard ('obsidian', 'Obsidian (Hunter)', 15, 30, 'default:obsidian')
|
||||||
|
end
|
||||||
|
|
||||||
|
if not DISABLE_MITHRIL_SPEAR then
|
||||||
|
throwing_register_spear_standard ('mithril', 'Mithril (Hunter)', 20, 50, 'moreores:mithril_ingot')
|
||||||
|
end
|
||||||
|
|
@ -67,7 +67,7 @@ function throwing_register_arrow_standard (kind, desc, eq, toughness, craft)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if node.name ~= "air" and not string.find(node.name, 'water_') and not string.find(node.name, 'default:grass') and not string.find(node.name, 'default:junglegrass') and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') 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, 'flowers:') and not string.find(node.name, 'farming:') and not string.find(node.name, 'fire:') then
|
||||||
if math.random() < toughness then
|
if math.random() < toughness then
|
||||||
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
|
minetest.add_item(self.lastpos, 'throwing:arrow_' .. kind)
|
||||||
else
|
else
|
||||||
|
@ -58,7 +58,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name ~= "air" then
|
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 self.player ~= "" then
|
if self.player ~= "" then
|
||||||
local player = minetest.get_player_by_name(self.player)
|
local player = minetest.get_player_by_name(self.player)
|
||||||
if player then
|
if player then
|
||||||
|
BIN
mods/throwing/textures/throwing_spear_box.png
Executable file
BIN
mods/throwing/textures/throwing_spear_box.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 174 B |
BIN
mods/throwing/textures/throwing_spear_diamond.png
Executable file
BIN
mods/throwing/textures/throwing_spear_diamond.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 314 B |
BIN
mods/throwing/textures/throwing_spear_mithril.png
Executable file
BIN
mods/throwing/textures/throwing_spear_mithril.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 291 B |
BIN
mods/throwing/textures/throwing_spear_obsidian.png
Executable file
BIN
mods/throwing/textures/throwing_spear_obsidian.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 310 B |
BIN
mods/throwing/textures/throwing_spear_steel.png
Executable file
BIN
mods/throwing/textures/throwing_spear_steel.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 317 B |
BIN
mods/throwing/textures/throwing_spear_stone.png
Executable file
BIN
mods/throwing/textures/throwing_spear_stone.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 317 B |
@ -36,3 +36,10 @@ DISABLE_OBSIDIAN_ARROW = false
|
|||||||
DISABLE_DIAMOND_ARROW = false
|
DISABLE_DIAMOND_ARROW = false
|
||||||
DISABLE_MITHRIL_ARROW = false
|
DISABLE_MITHRIL_ARROW = false
|
||||||
-- lesser damages to better damages
|
-- 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
|
||||||
|
@ -66,7 +66,11 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name ~= "air" then
|
|
||||||
|
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
|
||||||
local player = minetest.get_player_by_name(self.player)
|
local player = minetest.get_player_by_name(self.player)
|
||||||
if not player then self.object:remove() return end
|
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")
|
if node.name ~= "ignore" and not string.find(node.name, "water_") and not string.find(node.name, "lava")
|
||||||
@ -107,3 +111,14 @@ minetest.register_craft({
|
|||||||
{'group:coal', 'default:stick', 'default:stick'},
|
{'group:coal', 'default:stick', 'default:stick'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("throwing:torch_trail", {
|
||||||
|
drawtype = "airlike",
|
||||||
|
light_source = default.LIGHT_MAX-1,
|
||||||
|
walkable = false,
|
||||||
|
drop = "",
|
||||||
|
groups = {dig_immediate=3},
|
||||||
|
on_timer = function(pos, elapsed)
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user