From e8590aa8b3e57eb51c92f5cb6e8f71723a3392b0 Mon Sep 17 00:00:00 2001 From: FatalErr42O <58855799+FatalError42O@users.noreply.github.com> Date: Mon, 18 Mar 2024 20:07:48 -0700 Subject: [PATCH] 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 --- classes/Bullet_ray.lua | 2 +- classes/Gun.lua | 9 +++++---- classes/Player_model_handler.lua | 6 ++++-- guns4d_settings.conf | 1 - 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/classes/Bullet_ray.lua b/classes/Bullet_ray.lua index c6ec11d..0ecd57c 100644 --- a/classes/Bullet_ray.lua +++ b/classes/Bullet_ray.lua @@ -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() diff --git a/classes/Gun.lua b/classes/Gun.lua index 441284b..65edc21 100644 --- a/classes/Gun.lua +++ b/classes/Gun.lua @@ -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 diff --git a/classes/Player_model_handler.lua b/classes/Player_model_handler.lua index bb364fe..fed2a9f 100644 --- a/classes/Player_model_handler.lua +++ b/classes/Player_model_handler.lua @@ -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) diff --git a/guns4d_settings.conf b/guns4d_settings.conf index 56f42a0..e69de29 100644 --- a/guns4d_settings.conf +++ b/guns4d_settings.conf @@ -1 +0,0 @@ -interpret_initial_wear_as_ammo = true \ No newline at end of file