mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Add new functions related to underwater effects

Open XJMLN opened this issue 1 year ago • 5 comments

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

XJMLN avatar Jun 12 '24 00:06 XJMLN

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

Proxy-99 avatar Jun 12 '24 05:06 Proxy-99

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.

XJMLN avatar Jun 12 '24 07:06 XJMLN

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

Proxy-99 avatar Jun 12 '24 07:06 Proxy-99

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

Proxy-99 avatar Jun 12 '24 15:06 Proxy-99

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

TheNormalnij avatar Jun 12 '24 18:06 TheNormalnij

Good job, but please address the requested changed

Fernando-A-Rocha avatar Nov 06 '24 11:11 Fernando-A-Rocha

Bump?

YSAFE avatar Jan 20 '25 17:01 YSAFE

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 

Proxy-99 avatar Feb 07 '25 08:02 Proxy-99