diff --git a/Client/game_sa/CWeatherSA.cpp b/Client/game_sa/CWeatherSA.cpp index 7fdb856bfb..c549aa08e1 100644 --- a/Client/game_sa/CWeatherSA.cpp +++ b/Client/game_sa/CWeatherSA.cpp @@ -62,3 +62,169 @@ void CWeatherSA::ResetAmountOfRain() MemCpy((LPVOID)0x72BC92, &originalFstp1, 6); MemCpy((LPVOID)0x72C686, &originalFstp2, 6); } + +float CWeatherSA::GetWetRoads() const +{ + return *(float*)0xC81308; +} + +bool CWeatherSA::SetWetRoads(float fAmount) +{ + MemSet((LPVOID)(0x72BB9F + 2), 0x90, 3); + MemSet((LPVOID)(0x72BBB7 + 2), 0x90, 3); + MemSet((LPVOID)(0x72BBD0 + 1), 0x90, 3); + MemSet((LPVOID)(0x72BBD7 + 2), 0x90, 3); + + MemPutFast(0xC81308, fAmount); + return true; +} + +bool CWeatherSA::ResetWetRoads() +{ + BYTE originalCodes[3] = {0x08, 0x13, 0xC8}; + MemCpy((LPVOID)(0x72BB9F + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72BBB7 + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72BBD0 + 1), &originalCodes, 3); + MemCpy((LPVOID)(0x72BBD7 + 2), &originalCodes, 3); + return true; +} + +float CWeatherSA::GetFoggyness() const +{ + return *(float*)0xC81300; +} + +bool CWeatherSA::SetFoggyness(float fAmount) +{ + MemSet((LPVOID)(0x72BDF5 + 2), 0x90, 3); + MemSet((LPVOID)(0x72BDDD + 2), 0x90, 3); + MemSet((LPVOID)(0x72BE13 + 2), 0x90, 3); + + MemPutFast(0xC81300, fAmount); + return true; +} + +bool CWeatherSA::ResetFoggyness() +{ + BYTE originalCodes[3] = {0x00, 0x13, 0xC8}; + MemCpy((LPVOID)(0x72BDF5 + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72BDDD + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72BE13 + 2), &originalCodes, 3); + return true; +} + +float CWeatherSA::GetFog() const +{ + return *(float*)0xC812FC; +} + +bool CWeatherSA::SetFog(float fAmount) +{ + MemSet((LPVOID)(0x72BE37 + 2), 0x90, 3); + MemSet((LPVOID)(0x72BE1F + 2), 0x90, 3); + MemSet((LPVOID)(0x72BE4F + 2), 0x90, 3); + + MemPutFast(0xC812FC, fAmount); + return true; +} + +bool CWeatherSA::ResetFog() +{ + BYTE originalCodes[3] = {0xFC, 0x12, 0xC8}; + MemCpy((LPVOID)(0x72BE37 + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72BE1F + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72BE4F + 2), &originalCodes, 3); + return true; +} + +float CWeatherSA::GetRainFog() const +{ + return *(float*)0xC81410; +} + +bool CWeatherSA::SetRainFog(float fAmount) +{ + MemSet((LPVOID)(0x72ADD8 + 2), 0x90, 3); + MemSet((LPVOID)(0x72ADE4 + 2), 0x90, 3); + + MemPutFast(0xC81410, fAmount); + return true; +} + +bool CWeatherSA::ResetRainFog() +{ + BYTE originalCodes[3] = {0x10, 0x14, 0xC8}; + MemCpy((LPVOID)(0x72ADD8 + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72ADE4 + 2), &originalCodes, 3); + return true; +} + +float CWeatherSA::GetWaterFog() const +{ + return *(float*)0xC81338; +} + +bool CWeatherSA::SetWaterFog(float fAmount) +{ + MemSet((LPVOID)(0x72C35C + 2), 0x90, 3); + MemSet((LPVOID)(0x72C38E + 2), 0x90, 3); + MemSet((LPVOID)(0x72C36F + 2), 0x90, 3); + + MemPutFast(0xC81338, fAmount); + return true; +} + +bool CWeatherSA::ResetWaterFog() +{ + BYTE originalCodes[3] = {0x38, 0x13, 0xC8}; + MemCpy((LPVOID)(0x72C35C + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72C38E + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72C36F + 2), &originalCodes, 3); + return true; +} + +float CWeatherSA::GetSandstorm() const +{ + return *(float*)0xC812F4; +} + +bool CWeatherSA::SetSandstorm(float fAmount) +{ + MemSet((LPVOID)(0x72A4B6 + 1), 0x90, 3); + MemSet((LPVOID)(0x72BCEB + 1), 0x90, 3); + MemSet((LPVOID)(0x72BD0B + 2), 0x90, 3); + + MemPutFast(0xC812F4, fAmount); + return true; +} + +bool CWeatherSA::ResetSandstorm() +{ + BYTE originalCodes[3] = {0xF4, 0x12, 0xC8}; + MemCpy((LPVOID)(0x72A4B6 + 1), &originalCodes, 3); + MemCpy((LPVOID)(0x72BCEB + 1), &originalCodes, 3); + MemCpy((LPVOID)(0x72BD0B + 2), &originalCodes, 3); + return true; +} + +float CWeatherSA::GetRainbow() const +{ + return *(float*)0xC812E4; +} + +bool CWeatherSA::SetRainbow(float fAmount) +{ + MemSet((LPVOID)(0x72BF51 + 2), 0x90, 3); + MemSet((LPVOID)(0x72BF59 + 2), 0x90, 3); + + MemPutFast(0xC812E4, fAmount); + return true; +} + +bool CWeatherSA::ResetRainbow() +{ + BYTE originalCodes[3] = {0xE4, 0x12, 0xC8}; + MemCpy((LPVOID)(0x72BF51 + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x72BF59 + 2), &originalCodes, 3); + return true; +} diff --git a/Client/game_sa/CWeatherSA.h b/Client/game_sa/CWeatherSA.h index 32e501166c..8e6d970d1d 100644 --- a/Client/game_sa/CWeatherSA.h +++ b/Client/game_sa/CWeatherSA.h @@ -26,4 +26,39 @@ class CWeatherSA : public CWeather float GetAmountOfRain(); void SetAmountOfRain(float fAmount); void ResetAmountOfRain(); + + float GetWetRoads() const; + bool SetWetRoads(float fAmount); + bool ResetWetRoads(); + + float GetFoggyness() const; + bool SetFoggyness(float fAmount); + bool ResetFoggyness(); + + float GetFog() const; + bool SetFog(float fAmount); + bool ResetFog(); + + float GetRainFog() const; + bool SetRainFog(float fAmount); + bool ResetRainFog(); + + float GetWaterFog() const; + bool SetWaterFog(float fAmount); + bool ResetWaterFog(); + + float GetSandstorm() const; + bool SetSandstorm(float fAmount); + bool ResetSandstorm(); + + float GetRainbow() const; + bool SetRainbow(float fAmount); + bool ResetRainbow(); + +private: + static unsigned char* VAR_CWeather__ForcedWeatherType; + static unsigned char* VAR_CWeather__OldWeatherType; + static unsigned char* VAR_CWeather__NewWeatherType; + static float* VAR_CWeather__Rain; + }; diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index 41c5cd4e3e..d89255c548 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -5522,6 +5522,28 @@ void CClientGame::ResetMapInfo() // Moon size g_pMultiplayer->ResetMoonSize(); + // World properties + g_pMultiplayer->ResetAmbientColor(); + g_pMultiplayer->ResetAmbientObjectColor(); + g_pMultiplayer->ResetDirectionalColor(); + g_pMultiplayer->ResetSpriteSize(); + g_pMultiplayer->ResetSpriteBrightness(); + g_pMultiplayer->ResetPoleShadowStrength(); + g_pMultiplayer->ResetShadowStrength(); + g_pMultiplayer->ResetShadowsOffset(); + g_pMultiplayer->ResetLightsOnGroundBrightness(); + g_pMultiplayer->ResetLowCloudsColor(); + g_pMultiplayer->ResetBottomCloudsColor(); + g_pMultiplayer->ResetCloudsAlpha1(); + g_pMultiplayer->ResetIllumination(); + g_pGame->GetWeather()->ResetWetRoads(); + g_pGame->GetWeather()->ResetFoggyness(); + g_pGame->GetWeather()->ResetFog(); + g_pGame->GetWeather()->ResetRainFog(); + g_pGame->GetWeather()->ResetWaterFog(); + g_pGame->GetWeather()->ResetSandstorm(); + g_pGame->GetWeather()->ResetRainbow(); + // Disable the change of any player stats g_pMultiplayer->SetLocalStatsStatic(true); diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp index 2ff7d9bd7d..7090203704 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp @@ -873,6 +873,29 @@ ADD_ENUM(eFxParticleSystems::PRT_WHEELDIRT, "wheel_dirt") ADD_ENUM(eFxParticleSystems::PRT_GLASS, "glass") IMPLEMENT_ENUM_CLASS_END("particle-system") +IMPLEMENT_ENUM_BEGIN(eWorldProperty) +ADD_ENUM(AMBIENT_COLOR, "AmbientColor") +ADD_ENUM(AMBIENT_OBJ_COLOR, "AmbientObjColor") +ADD_ENUM(DIRECTIONAL_COLOR, "DirectionalColor") +ADD_ENUM(SPRITE_SIZE, "SpriteSize") +ADD_ENUM(SPRITE_BRIGHTNESS, "SpriteBrightness") +ADD_ENUM(POLE_SHADOW_STRENGTH, "PoleShadowStrength") +ADD_ENUM(SHADOW_STRENGTH, "ShadowStrength") +ADD_ENUM(SHADOWS_OFFSET, "ShadowsOffset") +ADD_ENUM(LIGHTS_ON_GROUND, "LightsOnGround") +ADD_ENUM(LOW_CLOUDS_COLOR, "LowCloudsColor") +ADD_ENUM(BOTTOM_CLOUDS_COLOR, "BottomCloudsColor") +ADD_ENUM(CLOUDS_ALPHA1, "CloudsAlpha") +ADD_ENUM(ILLUMINATION, "Illumination") +ADD_ENUM(WEATHER_WET_ROADS, "WetRoads") +ADD_ENUM(WEATHER_FOGGYNESS, "Foggyness") +ADD_ENUM(WEATHER_FOG, "Fog") +ADD_ENUM(WEATHER_RAIN_FOG, "RainFog") +ADD_ENUM(WEATHER_WATER_FOG, "WaterFog") +ADD_ENUM(WEATHER_SANDSTORM, "Sandstorm") +ADD_ENUM(WEATHER_RAINBOW, "Rainbow") +IMPLEMENT_ENUM_END("world-property") + // // CResource from userdata // diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h index aae4e759e5..9b93980d85 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h @@ -84,6 +84,7 @@ DECLARE_ENUM_CLASS(_D3DFORMAT); DECLARE_ENUM_CLASS(eRenderStage); DECLARE_ENUM_CLASS(eFxParticleSystems); DECLARE_ENUM(ePools); +DECLARE_ENUM(eWorldProperty); class CRemoteCall; @@ -497,6 +498,10 @@ inline SString GetClassTypeName(eSoundEffectParams::Reverb*) { return "soundeffect-params-reverb"; } +inline SString GetClassTypeName(eWorldProperty*) +{ + return "world-property"; +} inline SString GetClassTypeName(CClientVectorGraphic*) { diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp index 40f5b345da..96dd447921 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp @@ -58,6 +58,7 @@ void CLuaWorldDefs::LoadFunctions() {"getFPSLimit", GetFPSLimit}, {"getBirdsEnabled", GetBirdsEnabled}, {"getCoronaReflectionsEnabled", ArgumentParser}, + {"getWorldProperty", ArgumentParser}, // World set funcs {"setTime", SetTime}, @@ -73,7 +74,7 @@ void CLuaWorldDefs::LoadFunctions() {"setWaveHeight", SetWaveHeight}, {"setMinuteDuration", SetMinuteDuration}, {"setGarageOpen", SetGarageOpen}, - {"setWorldSpecialPropertyEnabled", ArgumentParserWarn}, + {"setWorldSpecialPropertyEnabled", ArgumentParser}, {"setBlurLevel", SetBlurLevel}, {"setJetpackMaxHeight", SetJetpackMaxHeight}, {"setCloudsEnabled", SetCloudsEnabled}, @@ -98,6 +99,7 @@ void CLuaWorldDefs::LoadFunctions() {"setMoonSize", SetMoonSize}, {"setFPSLimit", SetFPSLimit}, {"setCoronaReflectionsEnabled", ArgumentParser}, + {"setWorldProperty", ArgumentParser}, {"removeWorldModel", RemoveWorldBuilding}, {"restoreAllWorldModels", RestoreWorldBuildings}, {"restoreWorldModel", RestoreWorldBuilding}, @@ -122,6 +124,7 @@ void CLuaWorldDefs::LoadFunctions() {"resetSunSize", ResetSunSize}, {"resetMoonSize", ResetMoonSize}, {"resetBlurLevel", ResetBlurLevel}, + {"resetWorldProperty", ArgumentParserWarn}, // World check funcs {"areTrafficLightsLocked", AreTrafficLightsLocked}, @@ -2060,3 +2063,174 @@ bool CLuaWorldDefs::ResetCoronaReflectionsEnabled() g_pGame->GetSettings()->ResetCoronaReflectionsEnabled(); return true; } + +std::variant> CLuaWorldDefs::GetWorldProperty(eWorldProperty property) +{ + switch (property) + { + case eWorldProperty::AMBIENT_COLOR: + { + float red, green, blue; + g_pMultiplayer->GetAmbientColor(red, green, blue); + return std::make_tuple((int16)(red * 255), (int16)(green * 255), (int16)(blue * 255)); + } + case eWorldProperty::AMBIENT_OBJ_COLOR: + { + float red, green, blue; + g_pMultiplayer->GetAmbientObjectColor(red, green, blue); + return std::make_tuple((int16)(red * 255), (int16)(green * 255), (int16)(blue * 255)); + } + case eWorldProperty::DIRECTIONAL_COLOR: + { + float red, green, blue; + g_pMultiplayer->GetDirectionalColor(red, green, blue); + return std::make_tuple((int16)(red * 255), (int16)(green * 255), (int16)(blue * 255)); + } + case eWorldProperty::SPRITE_SIZE: + return g_pMultiplayer->GetSpriteSize(); + case eWorldProperty::SPRITE_BRIGHTNESS: + return g_pMultiplayer->GetSpriteBrightness(); + case eWorldProperty::POLE_SHADOW_STRENGTH: + return (float)g_pMultiplayer->GetPoleShadowStrength(); + case eWorldProperty::SHADOW_STRENGTH: + return (float)g_pMultiplayer->GetShadowStrength(); + case eWorldProperty::SHADOWS_OFFSET: + return g_pMultiplayer->GetShadowsOffset(); + case eWorldProperty::LIGHTS_ON_GROUND: + return g_pMultiplayer->GetLightsOnGroundBrightness(); + case eWorldProperty::LOW_CLOUDS_COLOR: + { + int16 red, green, blue; + g_pMultiplayer->GetLowCloudsColor(red, green, blue); + return std::make_tuple(red, green, blue); + } + case eWorldProperty::BOTTOM_CLOUDS_COLOR: + { + int16 red, green, blue; + g_pMultiplayer->GetBottomCloudsColor(red, green, blue); + return std::make_tuple(red, green, blue); + } + case eWorldProperty::CLOUDS_ALPHA1: + return g_pMultiplayer->GetCloudsAlpha1(); + case eWorldProperty::ILLUMINATION: + return g_pMultiplayer->GetIllumination(); + case eWorldProperty::WEATHER_WET_ROADS: + return g_pGame->GetWeather()->GetWetRoads(); + case eWorldProperty::WEATHER_FOGGYNESS: + return g_pGame->GetWeather()->GetFoggyness(); + case eWorldProperty::WEATHER_FOG: + return g_pGame->GetWeather()->GetFog(); + case eWorldProperty::WEATHER_RAIN_FOG: + return g_pGame->GetWeather()->GetRainFog(); + case eWorldProperty::WEATHER_WATER_FOG: + return g_pGame->GetWeather()->GetWaterFog(); + case eWorldProperty::WEATHER_SANDSTORM: + return g_pGame->GetWeather()->GetSandstorm(); + case eWorldProperty::WEATHER_RAINBOW: + return g_pGame->GetWeather()->GetRainbow(); + } + return false; +} + +bool CLuaWorldDefs::SetWorldProperty(eWorldProperty property, float arg1, std::optional arg2, std::optional arg3) +{ + if (arg2.has_value() && arg3.has_value()) + { + switch (property) + { + case eWorldProperty::AMBIENT_COLOR: + return g_pMultiplayer->SetAmbientColor(arg1 / 255, arg2.value() / 255, arg3.value() / 255); + case eWorldProperty::AMBIENT_OBJ_COLOR: + return g_pMultiplayer->SetAmbientObjectColor(arg1 / 255, arg2.value() / 255, arg3.value() / 255); + case eWorldProperty::DIRECTIONAL_COLOR: + return g_pMultiplayer->SetDirectionalColor(arg1 / 255, arg2.value() / 255, arg3.value() / 255); + case eWorldProperty::LOW_CLOUDS_COLOR: + return g_pMultiplayer->SetLowCloudsColor((int16)arg1, (int16)arg2.value(), (int16)arg3.value()); + case eWorldProperty::BOTTOM_CLOUDS_COLOR: + return g_pMultiplayer->SetBottomCloudsColor((int16)arg1, (int16)arg2.value(), (int16)arg3.value()); + } + return false; + } + switch (property) + { + case eWorldProperty::SPRITE_SIZE: + return g_pMultiplayer->SetSpriteSize(arg1); + case eWorldProperty::SPRITE_BRIGHTNESS: + return g_pMultiplayer->SetSpriteBrightness(arg1); + case eWorldProperty::POLE_SHADOW_STRENGTH: + return g_pMultiplayer->SetPoleShadowStrength(arg1); + case eWorldProperty::SHADOW_STRENGTH: + return g_pMultiplayer->SetShadowStrength(arg1); + case eWorldProperty::SHADOWS_OFFSET: + return g_pMultiplayer->SetShadowsOffset(arg1); + case eWorldProperty::LIGHTS_ON_GROUND: + return g_pMultiplayer->SetLightsOnGroundBrightness(arg1); + case eWorldProperty::CLOUDS_ALPHA1: + return g_pMultiplayer->SetCloudsAlpha1(arg1); + case eWorldProperty::ILLUMINATION: + return g_pMultiplayer->SetIllumination(arg1); + case eWorldProperty::WEATHER_WET_ROADS: + return g_pGame->GetWeather()->SetWetRoads(arg1); + case eWorldProperty::WEATHER_FOGGYNESS: + return g_pGame->GetWeather()->SetFoggyness(arg1); + case eWorldProperty::WEATHER_FOG: + return g_pGame->GetWeather()->SetFog(arg1); + case eWorldProperty::WEATHER_RAIN_FOG: + return g_pGame->GetWeather()->SetRainFog(arg1); + case eWorldProperty::WEATHER_WATER_FOG: + return g_pGame->GetWeather()->SetWaterFog(arg1); + case eWorldProperty::WEATHER_SANDSTORM: + return g_pGame->GetWeather()->SetSandstorm(arg1); + case eWorldProperty::WEATHER_RAINBOW: + return g_pGame->GetWeather()->SetRainbow(arg1); + } + return false; +} + +bool CLuaWorldDefs::ResetWorldProperty(eWorldProperty property) +{ + switch (property) + { + case eWorldProperty::AMBIENT_COLOR: + return g_pMultiplayer->ResetAmbientColor(); + case eWorldProperty::AMBIENT_OBJ_COLOR: + return g_pMultiplayer->ResetAmbientObjectColor(); + case eWorldProperty::DIRECTIONAL_COLOR: + return g_pMultiplayer->ResetDirectionalColor(); + case eWorldProperty::SPRITE_SIZE: + return g_pMultiplayer->ResetSpriteSize(); + case eWorldProperty::SPRITE_BRIGHTNESS: + return g_pMultiplayer->ResetSpriteBrightness(); + case eWorldProperty::POLE_SHADOW_STRENGTH: + return g_pMultiplayer->ResetPoleShadowStrength(); + case eWorldProperty::SHADOW_STRENGTH: + return g_pMultiplayer->ResetShadowStrength(); + case eWorldProperty::SHADOWS_OFFSET: + return g_pMultiplayer->ResetShadowsOffset(); + case eWorldProperty::LIGHTS_ON_GROUND: + return g_pMultiplayer->ResetLightsOnGroundBrightness(); + case eWorldProperty::LOW_CLOUDS_COLOR: + return g_pMultiplayer->ResetLowCloudsColor(); + case eWorldProperty::BOTTOM_CLOUDS_COLOR: + return g_pMultiplayer->ResetBottomCloudsColor(); + case eWorldProperty::CLOUDS_ALPHA1: + return g_pMultiplayer->ResetCloudsAlpha1(); + case eWorldProperty::ILLUMINATION: + return g_pMultiplayer->ResetIllumination(); + case eWorldProperty::WEATHER_WET_ROADS: + return g_pGame->GetWeather()->ResetWetRoads(); + case eWorldProperty::WEATHER_FOGGYNESS: + return g_pGame->GetWeather()->ResetFoggyness(); + case eWorldProperty::WEATHER_FOG: + return g_pGame->GetWeather()->ResetFog(); + case eWorldProperty::WEATHER_RAIN_FOG: + return g_pGame->GetWeather()->ResetRainFog(); + case eWorldProperty::WEATHER_WATER_FOG: + return g_pGame->GetWeather()->ResetWaterFog(); + case eWorldProperty::WEATHER_SANDSTORM: + return g_pGame->GetWeather()->ResetSandstorm(); + case eWorldProperty::WEATHER_RAINBOW: + return g_pGame->GetWeather()->ResetRainbow(); + } + return false; +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h index bc90a4745e..fc1d6bb3a1 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h @@ -126,4 +126,8 @@ class CLuaWorldDefs : public CLuaDefs static bool SetCoronaReflectionsEnabled(uchar ucEnabled); static uchar GetCoronaReflectionsEnabled(); static bool ResetCoronaReflectionsEnabled(); + + static std::variant> GetWorldProperty(eWorldProperty property); + static bool SetWorldProperty(eWorldProperty property, float arg1, std::optional arg2, std::optional arg3); + static bool ResetWorldProperty(eWorldProperty property); }; diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index 8da1a019ed..36e6d088d8 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -327,6 +327,32 @@ BYTE ucSkyGradientTopB = 0; BYTE ucSkyGradientBottomR = 0; BYTE ucSkyGradientBottomG = 0; BYTE ucSkyGradientBottomB = 0; + +bool bUsingCustomAmbientColor = false; +float fAmbientColorR = 0.0F; +float fAmbientColorG = 0.0F; +float fAmbientColorB = 0.0F; + +bool bUsingCustomAmbientObjectColor = false; +float fAmbientObjectColorR = 0.0F; +float fAmbientObjectColorG = 0.0F; +float fAmbientObjectColorB = 0.0F; + +bool bUsingCustomDirectionalColor = false; +float fDirectionalColorR = 0.0F; +float fDirectionalColorG = 0.0F; +float fDirectionalColorB = 0.0F; + +bool bUsingCustomLowCloudsColor = false; +int16 iLowCloudsColorR = 0; +int16 iLowCloudsColorG = 0; +int16 iLowCloudsColorB = 0; + +bool bUsingCustomBottomCloudsColor = false; +int16 iBottomCloudsColorR = 0; +int16 iBottomCloudsColorG = 0; +int16 iBottomCloudsColorB = 0; + bool bUsingCustomWaterColor = false; float fWaterColorR = 0.0F; float fWaterColorG = 0.0F; @@ -1488,7 +1514,7 @@ void CMultiplayerSA::InitHooks() fDuckingHealthThreshold = 0; // Lower the GTA shadows offset closer to ground/floor level - m_fShadowsOffset = 0.013f; // GTA default = 0.06f + m_fShadowsOffset = DEFAULT_SHADOWS_OFFSET; for (auto uiAddr : shadowAddr) MemPut(uiAddr, &m_fShadowsOffset); @@ -2234,6 +2260,302 @@ void CMultiplayerSA::ResetWater() MemPut(0x7051D7, 184); } +void CMultiplayerSA::GetAmbientColor(float& red, float& green, float& blue) const +{ + if (bUsingCustomAmbientColor) + red = fAmbientColorR, green = fAmbientColorG, blue = fAmbientColorB; + else + red = *(float*)0xB7C4A0, green = *(float*)0xB7C4A4, blue = *(float*)0xB7C4A8; +} + +bool CMultiplayerSA::SetAmbientColor(float red, float green, float blue) +{ + bUsingCustomAmbientColor = true; + fAmbientColorR = red; + fAmbientColorG = green; + fAmbientColorB = blue; + return true; +} + +bool CMultiplayerSA::ResetAmbientColor() +{ + bUsingCustomAmbientColor = false; + return true; +} + +void CMultiplayerSA::GetAmbientObjectColor(float& red, float& green, float& blue) const +{ + if (bUsingCustomAmbientObjectColor) + red = fAmbientObjectColorR, green = fAmbientObjectColorG, blue = fAmbientObjectColorB; + else + red = *(float*)0xB7C4AC, green = *(float*)0xB7C4B0, blue = *(float*)0xB7C4B4; +} + +bool CMultiplayerSA::SetAmbientObjectColor(float red, float green, float blue) +{ + bUsingCustomAmbientObjectColor = true; + fAmbientObjectColorR = red; + fAmbientObjectColorG = green; + fAmbientObjectColorB = blue; + return true; +} + +bool CMultiplayerSA::ResetAmbientObjectColor() +{ + bUsingCustomAmbientObjectColor = false; + return true; +} + +void CMultiplayerSA::GetDirectionalColor(float& red, float& green, float& blue) const +{ + if (bUsingCustomDirectionalColor) + red = fDirectionalColorR, green = fDirectionalColorG, blue = fDirectionalColorB; + else + red = *(float*)0xB7C4B8, green = *(float*)0xB7C4BC, blue = *(float*)0xB7C4C0; +} + +bool CMultiplayerSA::SetDirectionalColor(float red, float green, float blue) +{ + bUsingCustomDirectionalColor = true; + fDirectionalColorR = red; + fDirectionalColorG = green; + fDirectionalColorB = blue; + return true; +} + +bool CMultiplayerSA::ResetDirectionalColor() +{ + bUsingCustomDirectionalColor = false; + return true; +} + +float CMultiplayerSA::GetSpriteSize() const +{ + return *(float*)0xB7C4E0; +} + +bool CMultiplayerSA::SetSpriteSize(float size) +{ + MemPut(0x55FC21, 0xDD); + MemPut(0x55FC22, 0xD8); + MemPut(0x55FC23, 0x90); + + MemPutFast(0xB7C4E0, size); + return true; +} + +bool CMultiplayerSA::ResetSpriteSize() +{ + MemPut(0x55FC21, 0xD9); + MemPut(0x55FC22, 0x5E); + MemPut(0x55FC23, 0x40); + return true; +} + +float CMultiplayerSA::GetSpriteBrightness() const +{ + return *(float*)0xB7C4E4; +} + +bool CMultiplayerSA::SetSpriteBrightness(float brightness) +{ + MemPut(0x55FC34, 0xDD); + MemPut(0x55FC35, 0xD8); + MemPut(0x55FC36, 0x90); + + MemPutFast(0xB7C4E4, brightness); + return true; +} + +bool CMultiplayerSA::ResetSpriteBrightness() +{ + MemPut(0x55FC34, 0xD9); + MemPut(0x55FC35, 0x5E); + MemPut(0x55FC36, 0x44); + return true; +} + +int16 CMultiplayerSA::GetPoleShadowStrength() const +{ + return *(int16*)0xB7C4EC; +} + +bool CMultiplayerSA::SetPoleShadowStrength(int16 strength) +{ + MemSet((LPVOID)0x55FCB8, 0x90, 4); + MemSet((LPVOID)(0x56023A + 2), 0x90, 3); + MemSet((LPVOID)(0x5602A6 + 2), 0x90, 3); + + MemPutFast(0xB7C4EC, strength); + return true; +} + +bool CMultiplayerSA::ResetPoleShadowStrength() +{ + BYTE originalMov[4] = {0x66, 0x89, 0x46, 0x4C}; + MemCpy((LPVOID)0x55FCB8, &originalMov, 4); + + BYTE originalCodes[3] = {0xEC, 0xC4, 0xB7}; + MemCpy((LPVOID)(0x56023A + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x5602A6 + 2), &originalCodes, 3); + return true; +} + +int16 CMultiplayerSA::GetShadowStrength() const +{ + return *(int16*)0xB7C4E8; +} + +bool CMultiplayerSA::SetShadowStrength(int16 strength) +{ + MemSet((LPVOID)0x55FC5E, 0x90, 4); + MemSet((LPVOID)(0x56022E + 2), 0x90, 3); + MemSet((LPVOID)(0x560234 + 2), 0x90, 3); + MemSet((LPVOID)(0x56029A + 2), 0x90, 3); + MemSet((LPVOID)(0x5602A0 + 2), 0x90, 3); + + MemPutFast(0xB7C4E8, strength); + return true; +} + +bool CMultiplayerSA::ResetShadowStrength() +{ + BYTE originalMov[4] = {0x66, 0x89, 0x46, 0x48}; + MemCpy((LPVOID)0x55FC5E, &originalMov, 4); + + BYTE originalCodes[3] = {0xE8, 0xC4, 0xB7}; + MemCpy((LPVOID)(0x56022E + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x560234 + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x56029A + 2), &originalCodes, 3); + MemCpy((LPVOID)(0x5602A0 + 2), &originalCodes, 3); + return true; +} + +float CMultiplayerSA::GetShadowsOffset() const +{ + return m_fShadowsOffset; +} + +bool CMultiplayerSA::SetShadowsOffset(float offset) +{ + m_fShadowsOffset = offset; + return true; +} + +bool CMultiplayerSA::ResetShadowsOffset() +{ + m_fShadowsOffset = DEFAULT_SHADOWS_OFFSET; + return true; +} + +float CMultiplayerSA::GetLightsOnGroundBrightness() const +{ + return *(float*)0xB7C4F8; +} + +bool CMultiplayerSA::SetLightsOnGroundBrightness(float brightness) +{ + MemPut(0x55FDBC, 0xDD); + MemPut(0x55FDBD, 0xD8); + MemPut(0x55FDBE, 0x90); + MemSet((LPVOID)(0x5602AC + 2), 0x90, 3); + + MemPutFast(0xB7C4F8, brightness); + return true; +} + +bool CMultiplayerSA::ResetLightsOnGroundBrightness() +{ + BYTE originalFstp[3] = {0xD9, 0x5E, 0x58}; + MemCpy((LPVOID)0x55FDBC, &originalFstp, 3); + + BYTE originalCodes[3] = {0xF8, 0xC4, 0xB7}; + MemCpy((LPVOID)(0x5602AC + 2), &originalCodes, 3); + return true; +} + +void CMultiplayerSA::GetLowCloudsColor(int16& red, int16& green, int16& blue) const +{ + if (bUsingCustomLowCloudsColor) + red = iLowCloudsColorR, green = iLowCloudsColorG, blue = iLowCloudsColorB; + else + red = *(int16*)0xB7C4FC, green = *(int16*)0xB7C4FE, blue = *(int16*)0xB7C500; +} + +bool CMultiplayerSA::SetLowCloudsColor(int16 red, int16 green, int16 blue) +{ + bUsingCustomLowCloudsColor = true; + iLowCloudsColorR = red; + iLowCloudsColorG = green; + iLowCloudsColorB = blue; + return true; +} + +bool CMultiplayerSA::ResetLowCloudsColor() +{ + bUsingCustomLowCloudsColor = false; + return true; +} + +void CMultiplayerSA::GetBottomCloudsColor(int16& red, int16& green, int16& blue) const +{ + if (bUsingCustomBottomCloudsColor) + red = iBottomCloudsColorR, green = iBottomCloudsColorG, blue = iBottomCloudsColorB; + else + red = *(int16*)0xB7C502, green = *(int16*)0xB7C504, blue = *(int16*)0xB7C506; +} + +bool CMultiplayerSA::SetBottomCloudsColor(int16 red, int16 green, int16 blue) +{ + bUsingCustomBottomCloudsColor = true; + iBottomCloudsColorR = red; + iBottomCloudsColorG = green; + iBottomCloudsColorB = blue; + return true; +} + +bool CMultiplayerSA::ResetBottomCloudsColor() +{ + bUsingCustomBottomCloudsColor = false; + return true; +} + +float CMultiplayerSA::GetCloudsAlpha1() const +{ + return *(float*)0xB7C538; +} + +bool CMultiplayerSA::SetCloudsAlpha1(float alpha) +{ + MemPut(0x55FDD5, 0xD8); + MemPutFast(0xB7C538, alpha); + return true; +} + +bool CMultiplayerSA::ResetCloudsAlpha1() +{ + MemPut(0x55FDD5, 0xD9); + return true; +} + +float CMultiplayerSA::GetIllumination() const +{ + return *(float*)0xB7C544; +} + +bool CMultiplayerSA::SetIllumination(float illumination) +{ + MemPut(0x55FE46, 0xD8); + MemPutFast(0xB7C544, illumination); + return true; +} + +bool CMultiplayerSA::ResetIllumination() +{ + MemPut(0x55FE46, 0xD9); + return true; +} + bool CMultiplayerSA::GetExplosionsDisabled() { return m_bExplosionsDisabled; @@ -3567,6 +3889,36 @@ void _cdecl DoEndWorldColorsPokes() MemPutFast(0xB7C4CC, ucSkyGradientBottomG); MemPutFast(0xB7C4CE, ucSkyGradientBottomB); } + if (bUsingCustomAmbientColor) + { + MemPutFast(0xB7C4A0, fAmbientColorR); + MemPutFast(0xB7C4A4, fAmbientColorG); + MemPutFast(0xB7C4A8, fAmbientColorB); + } + if (bUsingCustomAmbientObjectColor) + { + MemPutFast(0xB7C4AC, fAmbientObjectColorR); + MemPutFast(0xB7C4B0, fAmbientObjectColorG); + MemPutFast(0xB7C4B4, fAmbientObjectColorB); + } + if (bUsingCustomDirectionalColor) + { + MemPutFast(0xB7C4B8, fDirectionalColorR); + MemPutFast(0xB7C4BC, fDirectionalColorG); + MemPutFast(0xB7C4C0, fDirectionalColorB); + } + if (bUsingCustomLowCloudsColor) + { + MemPutFast(0xB7C4FC, iLowCloudsColorR); + MemPutFast(0xB7C4FE, iLowCloudsColorG); + MemPutFast(0xB7C500, iLowCloudsColorB); + } + if (bUsingCustomBottomCloudsColor) + { + MemPutFast(0xB7C502, iBottomCloudsColorR); + MemPutFast(0xB7C504, iBottomCloudsColorG); + MemPutFast(0xB7C506, iBottomCloudsColorB); + } if (bUsingCustomWaterColor) { MemPutFast(0xB7C508, fWaterColorR); diff --git a/Client/multiplayer_sa/CMultiplayerSA.h b/Client/multiplayer_sa/CMultiplayerSA.h index 12daeb26be..65a7afb715 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.h +++ b/Client/multiplayer_sa/CMultiplayerSA.h @@ -20,6 +20,7 @@ class CRemoteDataSA; #define DEFAULT_NEAR_CLIP_DISTANCE ( 0.3f ) +#define DEFAULT_SHADOWS_OFFSET ( 0.013f ) // GTA default = 0.06f enum eRadioStationID { @@ -196,6 +197,58 @@ class CMultiplayerSA : public CMultiplayer int GetMoonSize(); void ResetMoonSize(); + void GetAmbientColor(float& red, float& green, float& blue) const; + bool SetAmbientColor(float red, float green, float blue); + bool ResetAmbientColor(); + + void GetAmbientObjectColor(float& red, float& green, float& blue) const; + bool SetAmbientObjectColor(float red, float green, float blue); + bool ResetAmbientObjectColor(); + + void GetDirectionalColor(float& red, float& green, float& blue) const; + bool SetDirectionalColor(float red, float green, float blue); + bool ResetDirectionalColor(); + + float GetSpriteSize() const; + bool SetSpriteSize(float size); + bool ResetSpriteSize(); + + float GetSpriteBrightness() const; + bool SetSpriteBrightness(float brightness); + bool ResetSpriteBrightness(); + + int16 GetPoleShadowStrength() const; + bool SetPoleShadowStrength(int16 strength); + bool ResetPoleShadowStrength(); + + int16 GetShadowStrength() const; + bool SetShadowStrength(int16 strength); + bool ResetShadowStrength(); + + float GetShadowsOffset() const; + bool SetShadowsOffset(float offset); + bool ResetShadowsOffset(); + + float GetLightsOnGroundBrightness() const; + bool SetLightsOnGroundBrightness(float brightness); + bool ResetLightsOnGroundBrightness(); + + void GetLowCloudsColor(int16& red, int16& green, int16& blue) const; + bool SetLowCloudsColor(int16 red, int16 green, int16 blue); + bool ResetLowCloudsColor(); + + void GetBottomCloudsColor(int16& red, int16& green, int16& blue) const; + bool SetBottomCloudsColor(int16 red, int16 green, int16 blue); + bool ResetBottomCloudsColor(); + + float GetCloudsAlpha1() const; + bool SetCloudsAlpha1(float alpha); + bool ResetCloudsAlpha1(); + + float GetIllumination() const; + bool SetIllumination(float illumination); + bool ResetIllumination(); + void SetNightVisionEnabled(bool bEnabled, bool bNoiseEnabled); void SetThermalVisionEnabled(bool bEnabled, bool bNoiseEnabled); bool IsNightVisionEnabled(); diff --git a/Client/sdk/game/CWeather.h b/Client/sdk/game/CWeather.h index 36fbf0dd78..41461142e7 100644 --- a/Client/sdk/game/CWeather.h +++ b/Client/sdk/game/CWeather.h @@ -23,4 +23,32 @@ class CWeather virtual float GetAmountOfRain() = 0; virtual void SetAmountOfRain(float fAmount) = 0; virtual void ResetAmountOfRain() = 0; + + virtual float GetWetRoads() const = 0; + virtual bool SetWetRoads(float fAmount) = 0; + virtual bool ResetWetRoads() = 0; + + virtual float GetFoggyness() const = 0; + virtual bool SetFoggyness(float fAmount) = 0; + virtual bool ResetFoggyness() = 0; + + virtual float GetFog() const = 0; + virtual bool SetFog(float fAmount) = 0; + virtual bool ResetFog() = 0; + + virtual float GetRainFog() const = 0; + virtual bool SetRainFog(float fAmount) = 0; + virtual bool ResetRainFog() = 0; + + virtual float GetWaterFog() const = 0; + virtual bool SetWaterFog(float fAmount) = 0; + virtual bool ResetWaterFog() = 0; + + virtual float GetSandstorm() const = 0; + virtual bool SetSandstorm(float fAmount) = 0; + virtual bool ResetSandstorm() = 0; + + virtual float GetRainbow() const = 0; + virtual bool SetRainbow(float fAmount) = 0; + virtual bool ResetRainbow() = 0; }; diff --git a/Client/sdk/game/Common.h b/Client/sdk/game/Common.h index d746ddb93e..0dbaf7c021 100644 --- a/Client/sdk/game/Common.h +++ b/Client/sdk/game/Common.h @@ -1620,3 +1620,27 @@ enum class eFxParticleSystems PRT_WHEELDIRT, PRT_GLASS, }; + +enum eWorldProperty +{ + AMBIENT_COLOR, + AMBIENT_OBJ_COLOR, + DIRECTIONAL_COLOR, + SPRITE_SIZE, + SPRITE_BRIGHTNESS, + POLE_SHADOW_STRENGTH, + SHADOW_STRENGTH, + SHADOWS_OFFSET, + LIGHTS_ON_GROUND, + LOW_CLOUDS_COLOR, + BOTTOM_CLOUDS_COLOR, + CLOUDS_ALPHA1, + ILLUMINATION, + WEATHER_WET_ROADS, + WEATHER_FOGGYNESS, + WEATHER_FOG, + WEATHER_RAIN_FOG, + WEATHER_WATER_FOG, + WEATHER_SANDSTORM, + WEATHER_RAINBOW, +}; diff --git a/Client/sdk/multiplayer/CMultiplayer.h b/Client/sdk/multiplayer/CMultiplayer.h index 48f1f3246c..75fff4801f 100644 --- a/Client/sdk/multiplayer/CMultiplayer.h +++ b/Client/sdk/multiplayer/CMultiplayer.h @@ -310,6 +310,58 @@ class CMultiplayer virtual int GetMoonSize() = 0; virtual void ResetMoonSize() = 0; + virtual void GetAmbientColor(float& red, float& green, float& blue) const = 0; + virtual bool SetAmbientColor(float red, float green, float blue) = 0; + virtual bool ResetAmbientColor() = 0; + + virtual void GetAmbientObjectColor(float& red, float& green, float& blue) const = 0; + virtual bool SetAmbientObjectColor(float red, float green, float blue) = 0; + virtual bool ResetAmbientObjectColor() = 0; + + virtual void GetDirectionalColor(float& red, float& green, float& blue) const = 0; + virtual bool SetDirectionalColor(float red, float green, float blue) = 0; + virtual bool ResetDirectionalColor() = 0; + + virtual float GetSpriteSize() const = 0; + virtual bool SetSpriteSize(float size) = 0; + virtual bool ResetSpriteSize() = 0; + + virtual float GetSpriteBrightness() const = 0; + virtual bool SetSpriteBrightness(float brightness) = 0; + virtual bool ResetSpriteBrightness() = 0; + + virtual int16 GetPoleShadowStrength() const = 0; + virtual bool SetPoleShadowStrength(int16 strength) = 0; + virtual bool ResetPoleShadowStrength() = 0; + + virtual int16 GetShadowStrength() const = 0; + virtual bool SetShadowStrength(int16 strength) = 0; + virtual bool ResetShadowStrength() = 0; + + virtual float GetShadowsOffset() const = 0; + virtual bool SetShadowsOffset(float offset) = 0; + virtual bool ResetShadowsOffset() = 0; + + virtual float GetLightsOnGroundBrightness() const = 0; + virtual bool SetLightsOnGroundBrightness(float brightness) = 0; + virtual bool ResetLightsOnGroundBrightness() = 0; + + virtual void GetLowCloudsColor(int16& red, int16& green, int16& blue) const = 0; + virtual bool SetLowCloudsColor(int16 red, int16 green, int16 blue) = 0; + virtual bool ResetLowCloudsColor() = 0; + + virtual void GetBottomCloudsColor(int16& red, int16& green, int16& blue) const = 0; + virtual bool SetBottomCloudsColor(int16 red, int16 green, int16 blue) = 0; + virtual bool ResetBottomCloudsColor() = 0; + + virtual float GetCloudsAlpha1() const = 0; + virtual bool SetCloudsAlpha1(float alpha) = 0; + virtual bool ResetCloudsAlpha1() = 0; + + virtual float GetIllumination() const = 0; + virtual bool SetIllumination(float illumination) = 0; + virtual bool ResetIllumination() = 0; + virtual void DisableEnterExitVehicleKey(bool bDisabled) = 0; virtual void SetNightVisionEnabled(bool bEnabled, bool bNoiseEnabled) = 0;