Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gamedata/scripts/lua_help_ex.script
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@
float get_weather_weight()
void set_weather_weight(float)
void set_weather_smooth(string)
void set_rain_wetness(float) // 0 to 1, read with level.rain_wetness()

// Camera, position is x,y,z vector, direction is head,pitch,roll vector in RADIANS
void set_cam_custom_position_direction(Fvector position, Fvector direction, int smoothing, bool hudDraw, bool hudAffect)
Expand Down
7 changes: 5 additions & 2 deletions src/xrEngine/Environment_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ extern float ps_r2_sun_shafts_min;
extern float ps_r2_sun_shafts_value;
extern Fvector3 ssfx_wetness_multiplier;

// seconds to fully wet or dry at multiplier 1
static const float WETNESS_CHANGE_TIME = 166.f;

void CEnvModifier::load(IReader* fs, u32 version)
{
use_flags.one();
Expand Down Expand Up @@ -521,9 +524,9 @@ void CEnvDescriptorMixer::lerp(CEnvironment* env, CEnvDescriptor& A, CEnvDescrip
sun_color.lerp(A.sun_color, B.sun_color, f);

if (rain_density > 0.f)
env->wetness_factor += ( rain_density * ssfx_wetness_multiplier.x) / 10000.f;
env->wetness_factor += rain_density * ssfx_wetness_multiplier.x * Device.fTimeDelta / WETNESS_CHANGE_TIME;
else
env->wetness_factor -= 0.0001f * ssfx_wetness_multiplier.y;
env->wetness_factor -= ssfx_wetness_multiplier.y * Device.fTimeDelta / WETNESS_CHANGE_TIME;

clamp(env->wetness_factor, 0.f, 1.f);

Expand Down
7 changes: 7 additions & 0 deletions src/xrGame/level_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ float rain_wetness()
return (g_pGamePersistent->Environment().wetness_factor);
}

void set_rain_wetness(float val)
{
clamp(val, 0.f, 1.f);
g_pGamePersistent->Environment().wetness_factor = val;
}

float rain_hemi()
{
CEffect_Rain* rain = g_pGamePersistent->pEnvironment->eff_Rain;
Expand Down Expand Up @@ -2728,6 +2734,7 @@ void CLevel::script_register(lua_State* L)
def("vertex_in_direction", vertex_in_direction),
def("rain_factor", rain_factor),
def("rain_wetness", rain_wetness),
def("set_rain_wetness", set_rain_wetness),
def("rain_hemi", rain_hemi),
def("patrol_path_exists", patrol_path_exists),
def("vertex_position", vertex_position),
Expand Down
Loading