This commit is contained in:
Andrea Plati 2015-10-13 21:44:45 +02:00
parent 510ab936b8
commit 4826788d02
4 changed files with 23 additions and 134 deletions

View File

@ -6,102 +6,8 @@ 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:
Spear work similarly to other tools such as swords, even if being a little slower. Moreover, a spear can be thrown using the drop key ('Q') or Spear work similarly to other tools such as swords, even if being a little slower. Moreover, a spear can be thrown using the drop key ('Q') or placed on a node using the place key ('right click'); they have also limited digging capabilities.
License: License:
This mod was originally published by Jeija and reworked by PilzAdam
Sourcecode: LGPLv2.1 (see http://www.gnu.org/licenses/lgpl-2.1.html) Sourcecode: LGPLv2.1 (see http://www.gnu.org/licenses/lgpl-2.1.html)
Grahpics & sounds: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/legalcode) Grahpics & sounds: CC-BY 3.0 (see http://creativecommons.org/licenses/by/3.0/legalcode)
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:
- Added automated arbalest, the ultimate weapon
- New arbalest texture coherent with steel color
Update 1.2:
- Added arbalest
- Defaults initialized
Update 1.1:
- Added crossbow
- Code shrink
- Offensive arrows go through flora's and farming's
- Small fixes
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
- Fixed torch arrow recipe, thanks to Excalibur Zero
- Removed config.lua, configuration now goes int throwing.config, see example
Update 0.9.8:
- New damage calculation for offensive arrows based on arrow's speed and material. Beware that dependency is more than linear for both, so that differences between arrows will be enhanced if they're shot at higher speed.
- Fixed bug that blocked ability to shot after shooting with empty arrow stack.
- Removed annoying debug symbols
Update 0.9.7:
- Added visual feedback for reload
- Fixed reload for players who die while reloading and for multiplayer
- Changed license for the code to LGPLv2
Update 0.9.6:
- Any bow and arrow is now deactivable under config.lua, which won't be overwritten
- Changed license for media to CC-BY
Update 0.9.5:
- Added shell arrows
- Revised sounds and some textures
- General balancing of bow's statistics
Update 0.9.4:
- New bow texture
- Made recipes coherent
Update 0.9.3:
- Added symmetric recipes, fixed golden bow recipe
- Adjusted few parameters
Update 0.9.2:
- Added a chance to break for many arrows, so they don't last forever and outclass any other tool
- Build and torch arrows won't build on fluids and torches any more, build arrows won't place torches
- TNT arrow digs instead if removing blocks, eventual indestructible nodes are safe
- Added golden bow with possible new bow style
- Changed the (bit OP) composite bow resistance and new recipe
- New teleport arrow recipe, cheaper but single use
Update 0.9.1:
- Good improvement for torch arrows, now they always attach and are often turned to the right direction
- Git repository will make things nicer
Update 0.9:
- Now bows have reload times! They depend on weight and quality, anyway no more machine-gun-style shell swarms
- Fixed build arrow behavior, now it placed and consumes the node from the slot [b]right next to the arrow[/b] or drops the item beside it if not a node; no more disappearing nor 'CONTENT_IGNORE' errors
- Code cleanup and rationalization
Update 0.8.1:
- Fixed wrong texture reference which made some arrows get a bad color during flight.
- Now bows have different stiffness besides wear resistances, which means that they shot arrows at different initial speed and learning to hit the target will become even harder.
Get rid of the old .env: API
Added new bows and new offensive, utility and harmful arrows (these are just my categories, they're not present into the code at all).
Removed stone bow, at least as long as somebody discovers an elastic rock ;)
Non-exploding arrows won't disappear any more after hitting target.

View File

@ -1,12 +1,13 @@
function spears_shot (itemstack, player) function spears_shot (itemstack, player)
local spear = itemstack:get_name() .. '_entity' local spear = itemstack:get_name() .. '_entity'
local playerpos = player:getpos() local playerpos = player:getpos()
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear) local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, spear)
local dir = player:get_look_dir() local dir = player:get_look_dir()
obj:setvelocity({x=dir.x*14, y=dir.y*14, z=dir.z*14}) local sp = .14
obj:setacceleration({x=-dir.x*.5, y=-9.8, z=-dir.z*.5}) local dr = 0-- .2
local gravity = 0--9.8
obj:setvelocity({x=dir.x*sp, y=dir.y*sp, z=dir.z*sp})
obj:setacceleration({x=-dir.x*dr, y=-gravity, z=-dir.z*dr})
obj:setyaw(player:get_look_yaw()+math.pi) obj:setyaw(player:get_look_yaw()+math.pi)
minetest.sound_play("spears_sound", {pos=playerpos}) minetest.sound_play("spears_sound", {pos=playerpos})
obj:get_luaentity().wear = itemstack:get_wear() obj:get_luaentity().wear = itemstack:get_wear()

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

View File

@ -28,22 +28,6 @@ function spears_register_spear(kind, desc, eq, toughness, craft)
} }
}) })
--minetest.register_node("spears: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 = {"spears_spear_box.png"},
--groups = {not_in_creative_inventory=1},
--})
local SPEAR_ENTITY={ local SPEAR_ENTITY={
physical = false, physical = false,
timer=0, timer=0,
@ -75,28 +59,26 @@ function spears_register_spear(kind, desc, eq, toughness, craft)
return return
end end
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 ~= "spears:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
local speed = vector.length(self.object:getvelocity())
local damage = (speed + eq)^1.12-20
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=damage},
}, nil)
self.object:remove()
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
end
end
end
end
if self.lastpos.x~=nil then 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 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() self.object:remove()
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness}) minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
elseif self.timer>0.2 then
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 obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "spears:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
local speed = vector.length(self.object:getvelocity())
local damage = (speed + eq)^1.12-20
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=damage},
}, nil)
self.object:remove()
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
end
end
end
end end
end end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} self.lastpos={x=pos.x, y=pos.y, z=pos.z}