Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix underwater detection #4

Merged
merged 2 commits into from
Jun 2, 2023

Conversation

stanleyqubit
Copy link
Contributor

Guess checking for looping underwater sound in addition to tes3.mobilePlayer.underwater was a dumb idea after all. Even though it was more precise and it worked with Water Breathing, it's prone to false positives when other mods use the underwater sound as a sound effect even when the player isn't underwater (e.g. attached via an activator in Balmora Waterworks).

@tewlwolow
Copy link
Owner

tewlwolow commented Jun 2, 2023

Thanks! I was about to ask actually, after that Discord report. Will test if it still covers all cases.
If not, perhaps you can take a look here (it's supposed to be doing the same.):

local underwaterPrev
---@param e simulateEventData
local function underWaterCheck(e)
        local mp = tes3.mobilePlayer
        if mp then
                if mp.isSwimming and not underwaterPrev then
                        underwaterPrev = true
                        event.trigger("VAPOURMIST:enteredUnderwater")
                        return
                end

                if not mp.isSwimming and underwaterPrev then
                        underwaterPrev = false
                        event.trigger("VAPOURMIST:exitedUnderwater")
                end
        end
end
event.unregister(tes3.event.simulate, underWaterCheck)
event.register(tes3.event.simulate, underWaterCheck)

@tewlwolow tewlwolow merged commit ecd63fb into tewlwolow:main Jun 2, 2023
@stanleyqubit
Copy link
Contributor Author

stanleyqubit commented Jun 2, 2023

Yeah, tes3.mobilePlayer.isSwimming works with Water Breathing but has the disadvantage of activating even when not fully submerged. (e.g. swimming at the surface of the water with your head out in 1st person view)

tes3.mobilePlayer.underwater doesn't work with Water Breathing but only activates when UI breath meter pops up.

also forgot to nil check tes3.mobilePlayer in pre-condition 🏅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
  翻译: