fixed bug with punching with player and not gun not working properly, account for visual_size of the player in gun pos and arm calcs

This commit is contained in:
FatalErr42O 2024-03-18 20:07:48 -07:00
parent 10a4f50007
commit e8590aa8b3
4 changed files with 10 additions and 8 deletions

View File

@ -225,7 +225,7 @@ function ray:apply_damage(object, sharp_pen, blunt_pen)
for i, v in pairs(self.sharp_damage_groups) do
damage_values[i] = v*sharp_ratio
end
object:punch(self.gun.entity, 1000, {damage_groups=damage_values}, self.dir)
object:punch((Guns4d.config.punch_from_player_not_gun and self.player) or self.gun.entity, 1000, {damage_groups=damage_values}, self.dir)
end
--punch SUCKS for this, apparently armor can only have flat rates of protection, which is sort of the worst thing i've ever heard.
--object:punch()

View File

@ -535,18 +535,19 @@ function gun_default:get_pos(added_pos, relative, debug)
local handler = self.handler
local bone_location
local gun_offset
local pprops = handler:get_properties()
if handler.control_handler.ads then
gun_offset = self.properties.ads.offset
bone_location = player:get_eye_offset() or vector.zero()
bone_location.y = bone_location.y + handler:get_properties().eye_height
bone_location.y = bone_location.y + pprops.eye_height
bone_location.x = handler.horizontal_offset
else
--minetest is really wacky.
gun_offset = self.properties.hip.offset
bone_location = vector.new(handler.player_model_handler.offsets.global.hipfire)
bone_location.x = bone_location.x / 10
bone_location.z = bone_location.z / 10
bone_location.y = bone_location.y / 10
bone_location.x = (bone_location.x / 10)*pprops.visual_size.x
bone_location.y = (bone_location.y / 10)*pprops.visual_size.y
bone_location.z = (bone_location.z / 10)*pprops.visual_size.z
end
if added_pos then
gun_offset = gun_offset+added_pos

View File

@ -63,7 +63,8 @@ function player_model:update(dt)
--gun bones:
local first, second = player:get_eye_offset()
local eye_pos = vector.new(0, handler:get_properties().eye_height*10, 0)+first
local pprops = handler:get_properties()
local eye_pos = vector.new(0, (pprops.eye_height*10)/pprops.visual_size.y, 0)+first
if handler.control_handler.ads then
eye_pos.x = handler.horizontal_offset*10
end
@ -86,7 +87,8 @@ function player_model:update_arm_bones(dt)
local handler = self.handler
local gun = handler.gun
local left_bone, right_bone = self.offsets.global.arm_left, self.offsets.global.arm_right
local pprops = handler:get_properties()
local left_bone, right_bone = vector.multiply(self.offsets.global.arm_left, pprops.visual_size), vector.multiply(self.offsets.global.arm_right, pprops.visual_size)
local left_trgt, right_trgt = gun:get_arm_aim_pos() --this gives us our offsets relative to the gun.
--get the real position of the gun's bones relative to the player (2nd param true)
left_trgt = gun:get_pos(left_trgt, true)

View File

@ -1 +0,0 @@
interpret_initial_wear_as_ammo = true