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 new world properties (time cycle and weather related features) #2989

Merged
merged 10 commits into from
Jun 30, 2024
166 changes: 166 additions & 0 deletions Client/game_sa/CWeatherSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,169 @@ void CWeatherSA::ResetAmountOfRain()
MemCpy((LPVOID)0x72BC92, &originalFstp1, 6);
MemCpy((LPVOID)0x72C686, &originalFstp2, 6);
}

float CWeatherSA::GetWetRoads() const
{
return *(float*)0xC81308;
samr46 marked this conversation as resolved.
Show resolved Hide resolved
}

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<float>(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;
samr46 marked this conversation as resolved.
Show resolved Hide resolved
}

bool CWeatherSA::SetFoggyness(float fAmount)
{
MemSet((LPVOID)(0x72BDF5 + 2), 0x90, 3);
MemSet((LPVOID)(0x72BDDD + 2), 0x90, 3);
MemSet((LPVOID)(0x72BE13 + 2), 0x90, 3);

MemPutFast<float>(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;
samr46 marked this conversation as resolved.
Show resolved Hide resolved
}

bool CWeatherSA::SetFog(float fAmount)
{
MemSet((LPVOID)(0x72BE37 + 2), 0x90, 3);
MemSet((LPVOID)(0x72BE1F + 2), 0x90, 3);
MemSet((LPVOID)(0x72BE4F + 2), 0x90, 3);

MemPutFast<float>(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;
samr46 marked this conversation as resolved.
Show resolved Hide resolved
}

bool CWeatherSA::SetRainFog(float fAmount)
{
MemSet((LPVOID)(0x72ADD8 + 2), 0x90, 3);
MemSet((LPVOID)(0x72ADE4 + 2), 0x90, 3);

MemPutFast<float>(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;
samr46 marked this conversation as resolved.
Show resolved Hide resolved
}

bool CWeatherSA::SetWaterFog(float fAmount)
{
MemSet((LPVOID)(0x72C35C + 2), 0x90, 3);
MemSet((LPVOID)(0x72C38E + 2), 0x90, 3);
MemSet((LPVOID)(0x72C36F + 2), 0x90, 3);

MemPutFast<float>(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;
samr46 marked this conversation as resolved.
Show resolved Hide resolved
}

bool CWeatherSA::SetSandstorm(float fAmount)
{
MemSet((LPVOID)(0x72A4B6 + 1), 0x90, 3);
MemSet((LPVOID)(0x72BCEB + 1), 0x90, 3);
MemSet((LPVOID)(0x72BD0B + 2), 0x90, 3);

MemPutFast<float>(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;
samr46 marked this conversation as resolved.
Show resolved Hide resolved
}

bool CWeatherSA::SetRainbow(float fAmount)
{
MemSet((LPVOID)(0x72BF51 + 2), 0x90, 3);
MemSet((LPVOID)(0x72BF59 + 2), 0x90, 3);

MemPutFast<float>(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;
}
35 changes: 35 additions & 0 deletions Client/game_sa/CWeatherSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
samr46 marked this conversation as resolved.
Show resolved Hide resolved
static float* VAR_CWeather__Rain;

};
22 changes: 22 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
23 changes: 23 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ DECLARE_ENUM_CLASS(_D3DFORMAT);
DECLARE_ENUM_CLASS(eRenderStage);
DECLARE_ENUM_CLASS(eFxParticleSystems);
DECLARE_ENUM(ePools);
DECLARE_ENUM(eWorldProperty);

class CRemoteCall;

Expand Down Expand Up @@ -497,6 +498,10 @@ inline SString GetClassTypeName(eSoundEffectParams::Reverb*)
{
return "soundeffect-params-reverb";
}
inline SString GetClassTypeName(eWorldProperty*)
{
return "world-property";
}

inline SString GetClassTypeName(CClientVectorGraphic*)
{
Expand Down
Loading
Loading