Make ricochet configurable.

This commit is contained in:
Lars 2022-05-03 20:15:46 -07:00
parent 7d2844ae12
commit aaf861e497
2 changed files with 28 additions and 21 deletions

@ -176,31 +176,35 @@ end
if minetest.get_item_group(minetest.get_node(moveresult.collisions[1].node_pos).name, "level") > 1 then
self.object:set_velocity(moveresult.collisions[1].old_velocity)
if minetest.settings:get_bool("rangedweapons_bullet_ricochet", true) then
self.object:set_velocity(moveresult.collisions[1].old_velocity)
if sparks > 0 then
make_sparks(self.object:get_pos())
end
if sparks > 0 then
make_sparks(self.object:get_pos())
end
local objVel = moveresult.collisions[1].old_velocity
local objRot = self.object:get_rotation()
local objVel = moveresult.collisions[1].old_velocity
local objRot = self.object:get_rotation()
if objRot and objVel then
if moveresult.collisions[1].axis == "x" then
self.object:set_rotation({x=0,y=objRot.y,z=objRot.z+3})
self.object:set_velocity({x=objVel.x*-1,y=objVel.y,z=objVel.z})
end
if objRot and objVel then
if moveresult.collisions[1].axis == "x" then
self.object:set_rotation({x=0,y=objRot.y,z=objRot.z+3})
self.object:set_velocity({x=objVel.x*-1,y=objVel.y,z=objVel.z})
end
if moveresult.collisions[1].axis == "z" then
self.object:set_rotation({x=0,y=objRot.y,z=objRot.z+3})
self.object:set_velocity({x=objVel.x,y=objVel.y,z=objVel.z*-1})
end
if moveresult.collisions[1].axis == "y" then
self.object:set_rotation({x=0,y=objRot.y+3,z=objRot.z+3})
self.object:set_velocity({x=objVel.x,y=objVel.y*-1,z=objVel.z})
end end
if moveresult.collisions[1].axis == "z" then
self.object:set_rotation({x=0,y=objRot.y,z=objRot.z+3})
self.object:set_velocity({x=objVel.x,y=objVel.y,z=objVel.z*-1})
end
if moveresult.collisions[1].axis == "y" then
self.object:set_rotation({x=0,y=objRot.y+3,z=objRot.z+3})
self.object:set_velocity({x=objVel.x,y=objVel.y*-1,z=objVel.z})
end
end
else
self.object:remove()
end
else

@ -37,9 +37,12 @@ rangedweapons_min_gun_efficiency (Minimum Gun Skill) int 40
# Use particles on bullet impact (disabling can improve server lag)
rangedweapons_impact_particles (Particles on impact) bool true
# Animate Empty Shells ascEntities (disabling can improve server lag)
# Animate Empty Shells as Entities (disabling can improve server lag)
rangedweapons_animate_empty_shells (Animate Empty Shells) bool true
# Bullet ricochet (disabling can improve server lag)
rangedweapons_bullet_ricochet (Bullets Ricocet) bool true
rangedweapons_shurikens (Enable Shurikens) bool true
rangedweapons_handguns (Enable Handgus) bool true