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

Add a way to use the "underwater camera effect" #1297

Open
PlatinMTA opened this issue Mar 16, 2020 · 11 comments · May be fixed by #3463
Open

Add a way to use the "underwater camera effect" #1297

PlatinMTA opened this issue Mar 16, 2020 · 11 comments · May be fixed by #3463
Labels
enhancement New feature or request

Comments

@PlatinMTA
Copy link
Contributor

Is your feature request related to a problem? Please describe.
It appears to be impossible to generate this effect without shaders or being underwater, and I think it would be a nice simple addition, and it's probably less consuming for the client.

Describe the solution you'd like
Create a function that would disable or enable this effect.

Describe alternatives you've considered
None, the real alternative is to use shaders.

Additional context
What I am talking about (you can see this effect if you get underwater):

image

Also I'm not entirely sure if this isn't really added to MTA, but I can't find any documentation on the wiki.

@PlatinMTA PlatinMTA added the enhancement New feature or request label Mar 16, 2020
@qaisjp
Copy link
Contributor

qaisjp commented Mar 16, 2020

Sounds reasonable. Do you have any suggestion for the API in case it's not obvious from how this would be implemented?

@PlatinMTA
Copy link
Contributor Author

Sounds reasonable. Do you have any suggestion for the API in case it's not obvious from how this would be implemented?

I wouldn't known. However I think that the intesity of the effect can be changed because it appears to be stronger the further down you go.

@Lpsd
Copy link
Member

Lpsd commented Mar 16, 2020

Shared functions:

-- Server
setUnderwaterEffectEnabled(element thePlayer, bool state)
setUnderwaterEffectStrength(element thePlayer, int strength) -- strength: 0-255

-- Client
setUnderwaterEffectEnabled(bool state)
setUnderwaterEffectStrength(int strength) -- strength: 0-255

If the underwater effect is disabled using setUnderwaterEffectEnabled, should using setUnderwaterEffectStrength re-enable it?

@qaisjp
Copy link
Contributor

qaisjp commented Mar 16, 2020

What if we just let 0 be disabled? (Assuming it actually has the same effect as being disabled.)

@Lpsd
Copy link
Member

Lpsd commented Mar 16, 2020

I agree.

I think we should also add a new function isPlayerUnderwater - imagine a scenario where you wanted the opposite effect (underwater effect when player is out of the water, and no effect when they're under the water) - I'll create a separate issue/PR for that.

There is an isElementInWater function but I doubt that lets you know if they're under the water, and I can't think of another way to detect this (with current Lua functions/methods).

@qaisjp
Copy link
Contributor

qaisjp commented Mar 16, 2020

Would this work? (untested)

-- Client side only
function isPlayerUnderwater(p)
    if not p.inWater then
        return false
    end
    local level = getWaterLevel(p.position)
    if not level then
        return false -- not close enough to the player
    end
    return p.position.z < level
end

@Lpsd
Copy link
Member

Lpsd commented Mar 16, 2020

Further to my last message, we can't simply let 0 be disabled.

Scenario:

Player is out of the water, you set the strength to 255 for a brief period, then back to 0 to stop the effect. Now the effect is completely disabled, and it won't happen when you get back under the water.

@Lpsd
Copy link
Member

Lpsd commented Mar 16, 2020

@qaisjp I'd imagine it'd be based on the player's camera being under the water, rather than the player itself. (aside from that it seems like it should work)

However come to think of it, your solution does satisfy the function name (isPlayerUnderwater) - so maybe we'd need two functions? (it could be useful to have these built into MTA and allow them to be shared between client and server).

@qaisjp
Copy link
Contributor

qaisjp commented Mar 16, 2020

Ok lets discuss this on the other issue, there's more edge cases than I realised

@Einheit-101
Copy link

The screen also gets dark when the camera moves under water, if we add "setUnderwaterEffectEnabled" we should add this parameter aswell, not just the screen distortion.
A while ago i wanted to create an underwater world but it was literally not possible because the screen always gets dark.

@Lpsd
Copy link
Member

Lpsd commented Mar 17, 2020

If that's the case we would add the parameters to setUnderwaterEffectStrength e.g:

setUnderwaterEffectStrength(int distortionStrength, int darkenStrength) --all values 0-255

@XJMLN XJMLN linked a pull request Jun 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants