forked from mtcontrib/spears
Update 2.2
This commit is contained in:
parent
40994cd49f
commit
a6ca632829
@ -1,3 +1,7 @@
|
|||||||
|
Version 2.2:
|
||||||
|
- "Hit detection" based on spearhead position
|
||||||
|
- Spears go through buildable_to nodes (snow)
|
||||||
|
- Ugly fix to not collide in air above slabs (works only if slabs are not rotated)
|
||||||
|
|
||||||
Version 2.1:
|
Version 2.1:
|
||||||
- Spears ding hard blocks (cracky < 3)
|
- Spears ding hard blocks (cracky < 3)
|
||||||
|
@ -23,31 +23,3 @@ This mod contains the word "spear" more than 100 times, if you want the exact nu
|
|||||||
If you feel clever, throw a spear right above you and look at it to see what happens.
|
If you feel clever, throw a spear right above you and look at it to see what happens.
|
||||||
You can even throw a spear from above down to your foes, it's even easier to hit.
|
You can even throw a spear from above down to your foes, it's even easier to hit.
|
||||||
Someone once reported to have hit its own foot but it takes practice to do that.
|
Someone once reported to have hit its own foot but it takes practice to do that.
|
||||||
|
|
||||||
|
|
||||||
CHANGELOG
|
|
||||||
|
|
||||||
2.1:
|
|
||||||
- Spears ding hard blocks (cracky < 3)
|
|
||||||
- Fixed stick-into-node position to avoid spears turning black (#2467)
|
|
||||||
- Player velocity added to throw (it's physics baby)
|
|
||||||
|
|
||||||
2.0:
|
|
||||||
- Cleaner, streamlined code without deprecated functions
|
|
||||||
- Spears hurt players
|
|
||||||
- Spears animated in flight
|
|
||||||
- Spears stick into nodes
|
|
||||||
- New textures
|
|
||||||
- New sound when hitting flesh
|
|
||||||
- New receipt to fit with default tools
|
|
||||||
- Drag depends on fluid
|
|
||||||
- Improved instructions
|
|
||||||
- New gold-plated spear to celebrate
|
|
||||||
|
|
||||||
1.1:
|
|
||||||
- Make use of new on_secondary_use API, requires Minetest 5.2.0
|
|
||||||
|
|
||||||
|
|
||||||
License:
|
|
||||||
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)
|
|
@ -21,7 +21,7 @@ function spears_throw (itemstack, player, pointed_thing)
|
|||||||
-- Avoid hitting yourself and throw
|
-- Avoid hitting yourself and throw
|
||||||
local throw_speed = 12
|
local throw_speed = 12
|
||||||
while vector.distance(player_pos, throw_pos) < 1.2 do
|
while vector.distance(player_pos, throw_pos) < 1.2 do
|
||||||
throw_pos = vector.add(throw_pos, vector.multiply(direction,0.1))
|
throw_pos = vector.add(throw_pos, vector.multiply(direction, 0.1))
|
||||||
end
|
end
|
||||||
local player_vel = player:get_player_velocity()
|
local player_vel = player:get_player_velocity()
|
||||||
local spear_object = minetest.add_entity(throw_pos, spear)
|
local spear_object = minetest.add_entity(throw_pos, spear)
|
||||||
@ -66,18 +66,18 @@ function spears_set_entity(spear_type, base_damage, toughness)
|
|||||||
local velocity = self.object:get_velocity()
|
local velocity = self.object:get_velocity()
|
||||||
local speed = vector.length(velocity)
|
local speed = vector.length(velocity)
|
||||||
-- Spear is stuck ?
|
-- Spear is stuck ?
|
||||||
if self._stickpos and not self._sticknode then
|
if self._stickpos then
|
||||||
local node = minetest.get_node(self._stickpos)
|
local node = minetest.get_node(self._stickpos)
|
||||||
local stick_cracky = minetest.registered_nodes[node.name].groups.cracky
|
local node_cracky = minetest.registered_nodes[node.name].groups.cracky
|
||||||
if stick_cracky and stick_cracky < 3 then
|
if node_cracky and node_cracky < 3 then
|
||||||
minetest.sound_play("default_metal_footstep", {pos = pos}, true)
|
minetest.sound_play("default_metal_footstep", {pos = pos}, true)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
minetest.add_item(self.object:get_pos(), {name='spears:spear_' .. spear_type, wear = self._wear})
|
minetest.add_item(self.object:get_pos(), {name='spears:spear_' .. spear_type, wear = self._wear})
|
||||||
elseif not self._stick_walkable then
|
elseif not self._node_walkable then
|
||||||
minetest.sound_play("default_place_node", {pos = throw_pos}, true)
|
minetest.sound_play("default_place_node", {pos = throw_pos}, true)
|
||||||
end
|
end
|
||||||
self._stick_walkable = minetest.registered_nodes[node.name].walkable
|
self._node_walkable = minetest.registered_nodes[node.name].walkable
|
||||||
if not node or not self._stick_walkable then -- Fall when node is removed
|
if not node or not self._node_walkable then -- Fall when node is removed
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
minetest.add_item(self.object:get_pos(), {name='spears:spear_' .. spear_type, wear = self._wear})
|
minetest.add_item(self.object:get_pos(), {name='spears:spear_' .. spear_type, wear = self._wear})
|
||||||
return
|
return
|
||||||
@ -87,11 +87,11 @@ function spears_set_entity(spear_type, base_damage, toughness)
|
|||||||
local yaw = minetest.dir_to_yaw(direction)
|
local yaw = minetest.dir_to_yaw(direction)
|
||||||
local pitch = math.acos(velocity.y/speed) - math.pi/3
|
local pitch = math.acos(velocity.y/speed) - math.pi/3
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local next_pos = vector.add(pos, vector.multiply(velocity, dtime))
|
local spearhead_pos = vector.add(pos, vector.multiply(direction, 0.5))
|
||||||
local node = minetest.get_node(next_pos)
|
local node = minetest.get_node(spearhead_pos)
|
||||||
self.object:set_rotation({x = 0, y = yaw + math.pi/2, z = pitch})
|
self.object:set_rotation({x = 0, y = yaw + math.pi/2, z = pitch})
|
||||||
-- Hit someone?
|
-- Hit someone?
|
||||||
local objects_in_radius = minetest.get_objects_inside_radius(next_pos, 0.6)
|
local objects_in_radius = minetest.get_objects_inside_radius(spearhead_pos, 0.6)
|
||||||
for _,object in ipairs(objects_in_radius) do
|
for _,object in ipairs(objects_in_radius) do
|
||||||
if object:get_luaentity() ~= self and object:get_armor_groups().fleshy then
|
if object:get_luaentity() ~= self and object:get_armor_groups().fleshy then
|
||||||
local damage = (speed + base_damage)^1.15 - 20
|
local damage = (speed + base_damage)^1.15 - 20
|
||||||
@ -103,22 +103,19 @@ function spears_set_entity(spear_type, base_damage, toughness)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Hit a node?
|
-- Hit a node?
|
||||||
if node then
|
if node and minetest.registered_nodes[node.name].walkable
|
||||||
if minetest.registered_nodes[node.name].walkable then -- Stick
|
and not minetest.registered_nodes[node.name].buildable_to
|
||||||
|
and not (minetest.registered_nodes[node.name].groups.slab and spearhead_pos.y % 1 < 0.5)
|
||||||
|
then -- Stick
|
||||||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
||||||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||||
-- Correct position if went too deep to aboid disappearing or turning black
|
|
||||||
while minetest.registered_nodes[minetest.get_node(pos).name].walkable do
|
|
||||||
pos = vector.add(pos, vector.multiply(direction, - 0.002))
|
|
||||||
end
|
|
||||||
self.object:set_pos(pos)
|
|
||||||
self._wear = self._wear + 65535/toughness
|
self._wear = self._wear + 65535/toughness
|
||||||
if self._wear >= 65535 then
|
if self._wear >= 65535 then
|
||||||
minetest.sound_play("default_tool_breaks", {pos = pos}, true)
|
minetest.sound_play("default_tool_breaks", {pos = pos}, true)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self._stickpos = next_pos
|
self._stickpos = spearhead_pos
|
||||||
else -- Get drag
|
else -- Get drag
|
||||||
local drag = math.max(minetest.registered_nodes[node.name].liquid_viscosity, 0.1)
|
local drag = math.max(minetest.registered_nodes[node.name].liquid_viscosity, 0.1)
|
||||||
local acceleration = vector.multiply(velocity, -drag)
|
local acceleration = vector.multiply(velocity, -drag)
|
||||||
@ -126,7 +123,6 @@ function spears_set_entity(spear_type, base_damage, toughness)
|
|||||||
self.object:set_acceleration(acceleration)
|
self.object:set_acceleration(acceleration)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
return SPEAR_ENTITY
|
return SPEAR_ENTITY
|
||||||
|
BIN
spears_screenshot.png
Normal file
BIN
spears_screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 301 KiB |
Loading…
Reference in New Issue
Block a user