Skip to content

Add new functions related to underwater effects#3463

Open
XJMLN wants to merge 13 commits into
multitheftauto:masterfrom
XJMLN:feature/underwater-effect
Open

Add new functions related to underwater effects#3463
XJMLN wants to merge 13 commits into
multitheftauto:masterfrom
XJMLN:feature/underwater-effect

Conversation

@XJMLN

@XJMLN XJMLN commented Jun 12, 2024

Copy link
Copy Markdown
Contributor

Client functions

  • setCameraUnderwaterEffectEnabled(bool state) - Enable or disable the underwater effect. This function does not affect the default diving behavior.
  • setCameraUnderwaterEffectSpeed(float speed, float frequency) - Change the speed and frequency of the underwater effect
  • setCameraUnderwaterDarkness(bool state, float maxDarknessDepth) - Enable or disable the screen getting darker as we dive deeper underwater. We can also set the depth at which the screen goes completely dark.
  • getCameraUnderwaterEffect() -> bool enabled, float speed, float frequency
  • getCameraUnderwaterDarkness() -> bool enabled, float maxDarknessDepth
  • resetCameraUnderwaterEffect() - Reset the underwater effect state, speed and frequency to their default values
  • resetCameraUnderwaterDarkness() - Reset the underwater darkness effect state and maximum darkness depth to their default values

Resolves #1297

@Proxy-99

Proxy-99 commented Jun 12, 2024

Copy link
Copy Markdown
Contributor

Great! We can fix #2598 by checking if the underwater effect is on, maybe after this PR merged?

@XJMLN

XJMLN commented Jun 12, 2024

Copy link
Copy Markdown
Contributor Author

Currently, getCameraUnderwaterEffect will return true only if it was enabled by setCameraUnderwaterEffectEnabled. I don't know if this is valid; maybe I should additionally check the value of CWeather::UnderWaterness(0xC8132C), which is used to enable this effect and changing the weather to ID 20 while underwater. Then getCameraUnderwaterEffect would return true in that case.

@Proxy-99

Proxy-99 commented Jun 12, 2024

Copy link
Copy Markdown
Contributor

Currently, getCameraUnderwaterEffect will return true only if it was enabled by setCameraUnderwaterEffectEnabled. I don't know if this is valid; maybe I should additionally check the value of CWeather::UnderWaterness(0xC8132C), which is used to enable this effect and changing the weather to ID 20 while underwater. Then getCameraUnderwaterEffect would return true in that case.

I think we should be able to check the effect anytime without relying on setCameraUnderwaterEffectEnabled

Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
@Proxy-99

Proxy-99 commented Jun 12, 2024

Copy link
Copy Markdown
Contributor

resetCameraUnderwaterEffect() should not this also reset darkness too

and getCameraUnderwaterEffect() should not also get the darkness level too
instead of calling another function to check

@TheNormalnij

Copy link
Copy Markdown
Member

Nice job!
Reset effects when a player connect to a new server. please

Comment thread Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h Outdated
Comment thread Client/mods/deathmatch/logic/CClientGame.cpp Outdated
Comment thread Client/sdk/multiplayer/CMultiplayer.h Outdated
Comment thread Client/sdk/multiplayer/CMultiplayer.h Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA.h Outdated
Comment thread Client/mods/deathmatch/logic/CClientGame.cpp Outdated
@XJMLN XJMLN requested a review from botder June 26, 2024 21:40
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp Outdated
Comment thread Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp Outdated
Comment thread Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp Outdated
Comment thread Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
Comment thread Client/multiplayer_sa/CMultiplayerSA_Postprocess.cpp Outdated
@Fernando-A-Rocha

Copy link
Copy Markdown
Contributor

Good job, but please address the requested changed

@ghost

ghost commented Jan 20, 2025

Copy link
Copy Markdown

Bump?

@Proxy-99

Proxy-99 commented Feb 7, 2025

Copy link
Copy Markdown
Contributor

can you fix the build @XJMLN

    D:\a\mtasa-blue\mtasa-blue\Client\multiplayer_sa\CMultiplayerSA.h(260,10): error C3668: 'CMultiplayerSA::SetUnderwaterEffectEnabled': method with override specifier 'override' did not override any base class methods [D:\a\mtasa-blue\mtasa-blue\Build\Multiplayer SA.vcxproj]
         D:\a\mtasa-blue\mtasa-blue\Client\multiplayer_sa\CMultiplayerSA.h(261,10): error C3668: 'CMultiplayerSA::SetUnderwaterEffectSpeed': method with override specifier 'override' did not override any base class methods [D:\a\mtasa-blue\mtasa-blue\Build\Multiplayer SA.vcxproj]


       "D:\a\mtasa-blue\mtasa-blue\Build\MTASA.sln" (default target) (1) ->
       "D:\a\mtasa-blue\mtasa-blue\Build\Client Deathmatch.vcxproj" (default target) (18) ->
         D:\a\mtasa-blue\mtasa-blue\Client\mods\deathmatch\logic\luadefs\CLuaCameraDefs.cpp(509,22): error C2511: 'bool CLuaCameraDefs::SetCameraUnderwaterEffectSpeed(float,std::optional<float>)': overloaded member function not found in 'CLuaCameraDefs' [D:\a\mtasa-blue\mtasa-blue\Build\Client 

@FileEX FileEX added enhancement New feature or request feedback Further information is requested labels Aug 24, 2025
return true;
}

bool CLuaCameraDefs::SetCameraUnderwaterEffectSpeed(float fSpeed, std::optional<float> fFrequency)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incompatible with the declaration given in the header: static bool SetCameraUnderwaterEffectSpeed(float speed, float frequency);

@tederis

tederis commented Sep 24, 2025

Copy link
Copy Markdown
Member

@XJMLN Please, fix the project build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feedback Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a way to use the "underwater camera effect"

8 participants