From 51b78340ec1876a2d8219559c2eb8dbcf688404d Mon Sep 17 00:00:00 2001 From: FatalErr42O <58855799+FatalError42O@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:27:08 -0700 Subject: [PATCH] overted engine bug that creates unrecoverable greyscreen by setting minimum FOV transition time, added config setting for FOV, added compatibility for spriteguns crosshair and wielditem flag issues. --- classes/Player_handler.lua | 15 ++++++++++----- init.lua | 21 +++++++++++++++++---- mod.conf | 3 ++- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/classes/Player_handler.lua b/classes/Player_handler.lua index 70c5df4..11bc672 100644 --- a/classes/Player_handler.lua +++ b/classes/Player_handler.lua @@ -10,9 +10,10 @@ local player_handler = { look_rotation = {x=0, y=0}, look_offset = Vec.new(), ads_location = 0, --interpolation scalar for gun aiming location - default_fov = 80, - fov = 80, - horizontal_offset = 0 + default_fov = Guns4d.config.default_fov, + fov = Guns4d.config.default_fov, + horizontal_offset = 0, + unreliability_update_timer = 1, --update for server unreliabilities or issues. } function player_handler:update(dt) assert(self.instance, "attempt to call object method on a class") @@ -73,7 +74,9 @@ function player_handler:update(dt) --delete model handler object (this resets the player model) self.player_model_handler:prepare_deletion() self.player_model_handler = nil - player:hud_set_flags({wielditem = true, crosshair = true}) --reenable hud elements + if (not spriteguns) or (spriteguns and (not spriteguns.registered_guns[player:get_wielded_item():get_name()])) then + player:hud_set_flags({wielditem = true, crosshair = true}) --reenable hud elements + end end @@ -139,7 +142,9 @@ function player_handler:set_fov(val, transition) end function player_handler:unset_fov(transition) self.fov_lock = false - Guns4d.old_set_fov(self.player, self.default_fov, nil, transition) + --minetest.chat_send_all(transition) + --https://github.com/minetest/minetest/issues/14499, setting a transition time seems to fix it + Guns4d.old_set_fov(self.player, self.default_fov, false, Guns4d.math.clamp(transition or 0, .15, math.huge)) end --doubt I'll ever use this... but just in case I don't want to forget. function player_handler:get_pos() diff --git a/init.lua b/init.lua index 35ba5b9..e900a28 100644 --- a/init.lua +++ b/init.lua @@ -19,6 +19,7 @@ Guns4d.config = { vertical_rotation_factor = 10, simple_headshot = true, --holdover feature before a more complex system is implemented simple_headshot_body_ratio = .75, --percentage of hitbox height that is body. + default_fov = 80, headshot_damage_factor = 1.75 --`["official_content.replace_ads_with_bloom"] = false, --`["official_content.uses_magazines"] = true @@ -69,20 +70,32 @@ minetest.register_on_joinplayer(function(player) Guns4d.handler_by_ObjRef[player] = Guns4d.players[pname] --set the FOV to a predictable value - player:set_fov(80) + player:set_fov(Guns4d.config.default_fov) --ObjRef overrides will be integrated into MTUL (eventually TM) if not objref_mtable then objref_mtable = getmetatable(player) local old_set_fov = objref_mtable.set_fov - Guns4d.old_set_fov = old_set_fov + Guns4d.old_set_fov = function(...) + minetest.chat_send_all(dump({...})) + old_set_fov(...) + end + local new_old_set = Guns4d.old_set_fov function objref_mtable.set_fov(self, ...) local handler = Guns4d.handler_by_ObjRef[self] + local fov = select(1, ...) if handler then --check, just in case it's not a player (and thus should throw an error) - handler.default_fov = select(1, ...) + if fov == 0 then + fov = Guns4d.config.default_fov + elseif select(2, ...) == true then + fov = Guns4d.config.default_fov*fov + end + handler.default_fov = fov if handler.fov_lock then return end end - old_set_fov(self, ...) + local args = {...} + args[1] = fov --basically permenantly set the player's fov to 80, making multipliers and resets return there. + new_old_set(self, unpack(args)) end local old_get_pos = objref_mtable.get_pos diff --git a/mod.conf b/mod.conf index 587e56a..91e0ef4 100644 --- a/mod.conf +++ b/mod.conf @@ -2,4 +2,5 @@ name = guns4d title = guns4d description = Adds a library for 3d guns author = FatalError42O -depends = mtul_b3d, mtul_cpml, mtul_filesystem \ No newline at end of file +depends = mtul_b3d, mtul_cpml, mtul_filesystem +optional_depends = spriteguns \ No newline at end of file