|
|
@ -1,425 +1,425 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
* ============================================================================
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Zombie:Reloaded
|
|
|
|
* Zombie:Reloaded
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* File: visualambience.inc
|
|
|
|
* File: visualambience.inc
|
|
|
|
* Type: Module
|
|
|
|
* Type: Module
|
|
|
|
* Description: Fog, light style, sky, sun rendering, etc
|
|
|
|
* Description: Fog, light style, sky, sun rendering, etc
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Greyscale, Richard Helgeby
|
|
|
|
* Copyright (C) 2009 Greyscale, Richard Helgeby
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Default sky of current map.
|
|
|
|
* Default sky of current map.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
new String:g_VAmbienceDefaultSky[PLATFORM_MAX_PATH];
|
|
|
|
new String:g_VAmbienceDefaultSky[PLATFORM_MAX_PATH];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Validate cvar data.
|
|
|
|
* Validate cvar data.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAmbienceLoad()
|
|
|
|
VAmbienceLoad()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Apply all visual effects now
|
|
|
|
// Apply all visual effects now
|
|
|
|
VAmbienceApplyAll();
|
|
|
|
VAmbienceApplyAll();
|
|
|
|
|
|
|
|
|
|
|
|
// Find map's default sky.
|
|
|
|
// Find map's default sky.
|
|
|
|
new Handle:hSkyname = FindConVar("sv_skyname");
|
|
|
|
new Handle:hSkyname = FindConVar("sv_skyname");
|
|
|
|
if (hSkyname != INVALID_HANDLE)
|
|
|
|
if (hSkyname != INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Store map's default sky before applying new one.
|
|
|
|
// Store map's default sky before applying new one.
|
|
|
|
GetConVarString(hSkyname, g_VAmbienceDefaultSky, sizeof(g_VAmbienceDefaultSky));
|
|
|
|
GetConVarString(hSkyname, g_VAmbienceDefaultSky, sizeof(g_VAmbienceDefaultSky));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If sky is disabled, then stop.
|
|
|
|
// If sky is disabled, then stop.
|
|
|
|
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
|
|
|
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
|
|
|
if (!sky)
|
|
|
|
if (!sky)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
decl String:downloadpath[PLATFORM_MAX_PATH];
|
|
|
|
decl String:downloadpath[PLATFORM_MAX_PATH];
|
|
|
|
decl String:skypath[PLATFORM_MAX_PATH];
|
|
|
|
decl String:skypath[PLATFORM_MAX_PATH];
|
|
|
|
|
|
|
|
|
|
|
|
// Get sky path.
|
|
|
|
// Get sky path.
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], skypath, sizeof(skypath));
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], skypath, sizeof(skypath));
|
|
|
|
|
|
|
|
|
|
|
|
// Prepend materials/skybox to the path.
|
|
|
|
// Prepend materials/skybox to the path.
|
|
|
|
Format(downloadpath, sizeof(downloadpath), "materials/skybox/%s", skypath);
|
|
|
|
Format(downloadpath, sizeof(downloadpath), "materials/skybox/%s", skypath);
|
|
|
|
|
|
|
|
|
|
|
|
// Add skybox file to downloads table.
|
|
|
|
// Add skybox file to downloads table.
|
|
|
|
AddFileToDownloadsTable(downloadpath);
|
|
|
|
AddFileToDownloadsTable(downloadpath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Hook zr_veffects_* cvar changes.
|
|
|
|
* Hook zr_veffects_* cvar changes.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param unhook If true, cvars will be unhooked, false to hook cvars.
|
|
|
|
* @param unhook If true, cvars will be unhooked, false to hook cvars.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAmbienceCvarsHook(bool:unhook = false)
|
|
|
|
VAmbienceCvarsHook(bool:unhook = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If unhook is true, then continue.
|
|
|
|
// If unhook is true, then continue.
|
|
|
|
if (unhook)
|
|
|
|
if (unhook)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Unhook lightstyle cvars.
|
|
|
|
// Unhook lightstyle cvars.
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VAmbienceCvarsHookLightStyle);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VAmbienceCvarsHookLightStyle);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VAmbienceCvarsHookLightStyle);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VAmbienceCvarsHookLightStyle);
|
|
|
|
|
|
|
|
|
|
|
|
// Unhook sky cvars.
|
|
|
|
// Unhook sky cvars.
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VAmbienceCvarsHookSky);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VAmbienceCvarsHookSky);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VAmbienceCvarsHookSky);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VAmbienceCvarsHookSky);
|
|
|
|
|
|
|
|
|
|
|
|
// Unhook sun cvars.
|
|
|
|
// Unhook sun cvars.
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VAmbienceCvarsHookSunDisable);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VAmbienceCvarsHookSunDisable);
|
|
|
|
|
|
|
|
|
|
|
|
// Unhook fog cvars.
|
|
|
|
// Unhook fog cvars.
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VAmbienceCvarsHookFog);
|
|
|
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VAmbienceCvarsHookFog);
|
|
|
|
|
|
|
|
|
|
|
|
// Stop after unhooking cvars.
|
|
|
|
// Stop after unhooking cvars.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Hook lightstyle cvars.
|
|
|
|
// Hook lightstyle cvars.
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VAmbienceCvarsHookLightStyle);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VAmbienceCvarsHookLightStyle);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VAmbienceCvarsHookLightStyle);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VAmbienceCvarsHookLightStyle);
|
|
|
|
|
|
|
|
|
|
|
|
// Hook sky cvars.
|
|
|
|
// Hook sky cvars.
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VAmbienceCvarsHookSky);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VAmbienceCvarsHookSky);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VAmbienceCvarsHookSky);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VAmbienceCvarsHookSky);
|
|
|
|
|
|
|
|
|
|
|
|
// Hook sun cvars.
|
|
|
|
// Hook sun cvars.
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VAmbienceCvarsHookSunDisable);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VAmbienceCvarsHookSunDisable);
|
|
|
|
|
|
|
|
|
|
|
|
// Hook fog cvars.
|
|
|
|
// Hook fog cvars.
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VAmbienceCvarsHookFog);
|
|
|
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VAmbienceCvarsHookFog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Cvar hook callback (zr_veffects_lightstyle, zr_veffects_lightstyle_value)
|
|
|
|
* Cvar hook callback (zr_veffects_lightstyle, zr_veffects_lightstyle_value)
|
|
|
|
* Updated server to cvar values.
|
|
|
|
* Updated server to cvar values.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param convar The cvar handle.
|
|
|
|
* @param convar The cvar handle.
|
|
|
|
* @param oldvalue The value before change.
|
|
|
|
* @param oldvalue The value before change.
|
|
|
|
* @param newvalue The new value.
|
|
|
|
* @param newvalue The new value.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public VAmbienceCvarsHookLightStyle(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
|
|
|
public VAmbienceCvarsHookLightStyle(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If lightstyle is disabled, then disable.
|
|
|
|
// If lightstyle is disabled, then disable.
|
|
|
|
new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]);
|
|
|
|
new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]);
|
|
|
|
|
|
|
|
|
|
|
|
// Apply light style.
|
|
|
|
// Apply light style.
|
|
|
|
VAmbienceApplyLightStyle(!lightstyle);
|
|
|
|
VAmbienceApplyLightStyle(!lightstyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Cvar hook callback (zr_veffects_sky, zr_veffects_sky_path)
|
|
|
|
* Cvar hook callback (zr_veffects_sky, zr_veffects_sky_path)
|
|
|
|
* Updated server to cvar values.
|
|
|
|
* Updated server to cvar values.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param convar The cvar handle.
|
|
|
|
* @param convar The cvar handle.
|
|
|
|
* @param oldvalue The value before change.
|
|
|
|
* @param oldvalue The value before change.
|
|
|
|
* @param newvalue The new value.
|
|
|
|
* @param newvalue The new value.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public VAmbienceCvarsHookSky(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
|
|
|
public VAmbienceCvarsHookSky(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If sky is disabled, then disable.
|
|
|
|
// If sky is disabled, then disable.
|
|
|
|
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
|
|
|
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
|
|
|
|
|
|
|
|
|
|
|
// Apply new sky.
|
|
|
|
// Apply new sky.
|
|
|
|
VAmbienceApplySky(!sky);
|
|
|
|
VAmbienceApplySky(!sky);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Cvar hook callback (zr_veffects_sun_disable)
|
|
|
|
* Cvar hook callback (zr_veffects_sun_disable)
|
|
|
|
* Updated server to cvar values.
|
|
|
|
* Updated server to cvar values.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param convar The cvar handle.
|
|
|
|
* @param convar The cvar handle.
|
|
|
|
* @param oldvalue The value before change.
|
|
|
|
* @param oldvalue The value before change.
|
|
|
|
* @param newvalue The new value.
|
|
|
|
* @param newvalue The new value.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public VAmbienceCvarsHookSunDisable(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
|
|
|
public VAmbienceCvarsHookSunDisable(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If fog is disabled, then disable.
|
|
|
|
// If fog is disabled, then disable.
|
|
|
|
new bool:sun = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE]);
|
|
|
|
new bool:sun = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE]);
|
|
|
|
|
|
|
|
|
|
|
|
// Apply fog.
|
|
|
|
// Apply fog.
|
|
|
|
VAmbienceApplySunDisable(!sun);
|
|
|
|
VAmbienceApplySunDisable(!sun);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Cvar hook callback (zr_veffects_fog_*)
|
|
|
|
* Cvar hook callback (zr_veffects_fog_*)
|
|
|
|
* Updated server to cvar values.
|
|
|
|
* Updated server to cvar values.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param convar The cvar handle.
|
|
|
|
* @param convar The cvar handle.
|
|
|
|
* @param oldvalue The value before change.
|
|
|
|
* @param oldvalue The value before change.
|
|
|
|
* @param newvalue The new value.
|
|
|
|
* @param newvalue The new value.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public VAmbienceCvarsHookFog(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
|
|
|
public VAmbienceCvarsHookFog(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If fog is disabled, then disable.
|
|
|
|
// If fog is disabled, then disable.
|
|
|
|
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
|
|
|
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
|
|
|
|
|
|
|
|
|
|
|
// Apply fog.
|
|
|
|
// Apply fog.
|
|
|
|
VAmbienceApplyFog(fogoverride);
|
|
|
|
VAmbienceApplyFog(fogoverride);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Apply all cvar values on server.
|
|
|
|
* Apply all cvar values on server.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAmbienceApplyAll()
|
|
|
|
VAmbienceApplyAll()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If lightstyle is disabled, then disable.
|
|
|
|
// If lightstyle is disabled, then disable.
|
|
|
|
new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]);
|
|
|
|
new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]);
|
|
|
|
|
|
|
|
|
|
|
|
// Apply light style.
|
|
|
|
// Apply light style.
|
|
|
|
VAmbienceApplyLightStyle(!lightstyle);
|
|
|
|
VAmbienceApplyLightStyle(!lightstyle);
|
|
|
|
|
|
|
|
|
|
|
|
// If sky is disabled, then disable.
|
|
|
|
// If sky is disabled, then disable.
|
|
|
|
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
|
|
|
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
|
|
|
|
|
|
|
|
|
|
|
// Apply new sky.
|
|
|
|
// Apply new sky.
|
|
|
|
VAmbienceApplySky(!sky);
|
|
|
|
VAmbienceApplySky(!sky);
|
|
|
|
|
|
|
|
|
|
|
|
// If fog is disabled, then disable.
|
|
|
|
// If fog is disabled, then disable.
|
|
|
|
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
|
|
|
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
|
|
|
|
|
|
|
|
|
|
|
// Apply fog.
|
|
|
|
// Apply fog.
|
|
|
|
VAmbienceApplyFog(fogoverride);
|
|
|
|
VAmbienceApplyFog(fogoverride);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VAmbienceApplyLightStyle(bool:disable = false)
|
|
|
|
VAmbienceApplyLightStyle(bool:disable = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If default, then set to normal light style.
|
|
|
|
// If default, then set to normal light style.
|
|
|
|
if (disable)
|
|
|
|
if (disable)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set light style.
|
|
|
|
// Set light style.
|
|
|
|
SetLightStyle(0, "n");
|
|
|
|
SetLightStyle(0, "n");
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get light value.
|
|
|
|
// Get light value.
|
|
|
|
decl String:lightstylevalue[4];
|
|
|
|
decl String:lightstylevalue[4];
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], lightstylevalue, sizeof(lightstylevalue));
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], lightstylevalue, sizeof(lightstylevalue));
|
|
|
|
|
|
|
|
|
|
|
|
// Set light style.
|
|
|
|
// Set light style.
|
|
|
|
SetLightStyle(0, lightstylevalue);
|
|
|
|
SetLightStyle(0, lightstylevalue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VAmbienceApplySky(bool:disable = false)
|
|
|
|
VAmbienceApplySky(bool:disable = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if we can't find the sv_skyname cvar, then stop.
|
|
|
|
// if we can't find the sv_skyname cvar, then stop.
|
|
|
|
new Handle:hSkyname = FindConVar("sv_skyname");
|
|
|
|
new Handle:hSkyname = FindConVar("sv_skyname");
|
|
|
|
if (hSkyname == INVALID_HANDLE)
|
|
|
|
if (hSkyname == INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If default, then set to default sky.
|
|
|
|
// If default, then set to default sky.
|
|
|
|
if (disable)
|
|
|
|
if (disable)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (g_VAmbienceDefaultSky[0])
|
|
|
|
if (g_VAmbienceDefaultSky[0])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SetConVarString(hSkyname, g_VAmbienceDefaultSky, true);
|
|
|
|
SetConVarString(hSkyname, g_VAmbienceDefaultSky, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get sky path.
|
|
|
|
// Get sky path.
|
|
|
|
decl String:skypath[PLATFORM_MAX_PATH];
|
|
|
|
decl String:skypath[PLATFORM_MAX_PATH];
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], skypath, sizeof(skypath));
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], skypath, sizeof(skypath));
|
|
|
|
|
|
|
|
|
|
|
|
// Set new sky on all clients.
|
|
|
|
// Set new sky on all clients.
|
|
|
|
SetConVarString(hSkyname, skypath, true);
|
|
|
|
SetConVarString(hSkyname, skypath, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VAmbienceApplySunDisable(bool:disable = false)
|
|
|
|
VAmbienceApplySunDisable(bool:disable = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Find sun entity.
|
|
|
|
// Find sun entity.
|
|
|
|
new sun = FindEntityByClassname(-1, "env_sun");
|
|
|
|
new sun = FindEntityByClassname(-1, "env_sun");
|
|
|
|
|
|
|
|
|
|
|
|
// If sun is invalid, then stop.
|
|
|
|
// If sun is invalid, then stop.
|
|
|
|
if (sun == -1)
|
|
|
|
if (sun == -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If default, then re-enable sun rendering.
|
|
|
|
// If default, then re-enable sun rendering.
|
|
|
|
if (disable)
|
|
|
|
if (disable)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Turn on sun rendering.
|
|
|
|
// Turn on sun rendering.
|
|
|
|
AcceptEntityInput(sun, "TurnOn");
|
|
|
|
AcceptEntityInput(sun, "TurnOn");
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Turn off sun rendering.
|
|
|
|
// Turn off sun rendering.
|
|
|
|
AcceptEntityInput(sun, "TurnOff");
|
|
|
|
AcceptEntityInput(sun, "TurnOff");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VAmbienceApplyFog(bool:override = false)
|
|
|
|
VAmbienceApplyFog(bool:override = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If fog is disabled, then stop.
|
|
|
|
// If fog is disabled, then stop.
|
|
|
|
new bool:fog = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG]);
|
|
|
|
new bool:fog = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG]);
|
|
|
|
|
|
|
|
|
|
|
|
// DUE TO SOURCEMOD NOT SUPPORT FOG, DISABLE.
|
|
|
|
// DUE TO SOURCEMOD NOT SUPPORT FOG, DISABLE.
|
|
|
|
fog = false;
|
|
|
|
fog = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (!fog)
|
|
|
|
if (!fog)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Find current fog index
|
|
|
|
// Find current fog index
|
|
|
|
new fogindex = FindEntityByClassname(-1, "env_fog_controller");
|
|
|
|
new fogindex = FindEntityByClassname(-1, "env_fog_controller");
|
|
|
|
|
|
|
|
|
|
|
|
// If override is enabled, then continue.
|
|
|
|
// If override is enabled, then continue.
|
|
|
|
if (override)
|
|
|
|
if (override)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If there is fog, then continue.
|
|
|
|
// If there is fog, then continue.
|
|
|
|
if (fogindex != -1)
|
|
|
|
if (fogindex != -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Delete fog.
|
|
|
|
// Delete fog.
|
|
|
|
RemoveEdict(fogindex);
|
|
|
|
RemoveEdict(fogindex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If there is no fog on the map, create new fog.
|
|
|
|
// If there is no fog on the map, create new fog.
|
|
|
|
if (fogindex == -1)
|
|
|
|
if (fogindex == -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Create and spawn fog.
|
|
|
|
// Create and spawn fog.
|
|
|
|
fogindex = CreateEntityByName("env_fog_controller");
|
|
|
|
fogindex = CreateEntityByName("env_fog_controller");
|
|
|
|
DispatchSpawn(fogindex);
|
|
|
|
DispatchSpawn(fogindex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
decl String:fogcolor[16];
|
|
|
|
decl String:fogcolor[16];
|
|
|
|
|
|
|
|
|
|
|
|
// Set primary fog color.
|
|
|
|
// Set primary fog color.
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], fogcolor, sizeof(fogcolor));
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], fogcolor, sizeof(fogcolor));
|
|
|
|
VAmbienceSetFogColor(fogindex, fogcolor, true);
|
|
|
|
VAmbienceSetFogColor(fogindex, fogcolor, true);
|
|
|
|
|
|
|
|
|
|
|
|
// Set secondary fog color.
|
|
|
|
// Set secondary fog color.
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], fogcolor, sizeof(fogcolor));
|
|
|
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], fogcolor, sizeof(fogcolor));
|
|
|
|
VAmbienceSetFogColor(fogindex, fogcolor, false);
|
|
|
|
VAmbienceSetFogColor(fogindex, fogcolor, false);
|
|
|
|
|
|
|
|
|
|
|
|
// Set fog's density.
|
|
|
|
// Set fog's density.
|
|
|
|
new Float:fogdensity = GetConVarFloat(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY]);
|
|
|
|
new Float:fogdensity = GetConVarFloat(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY]);
|
|
|
|
VAmbienceSetFogDensity(fogindex, fogdensity);
|
|
|
|
VAmbienceSetFogDensity(fogindex, fogdensity);
|
|
|
|
|
|
|
|
|
|
|
|
// Set fog's start distance.
|
|
|
|
// Set fog's start distance.
|
|
|
|
new fogstart = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST]);
|
|
|
|
new fogstart = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST]);
|
|
|
|
VAmbienceSetFogStartDist(fogindex, fogstart);
|
|
|
|
VAmbienceSetFogStartDist(fogindex, fogstart);
|
|
|
|
|
|
|
|
|
|
|
|
// Set fog's end distance.
|
|
|
|
// Set fog's end distance.
|
|
|
|
new fogend = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST]);
|
|
|
|
new fogend = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST]);
|
|
|
|
VAmbienceSetFogEndDist(fogindex, fogend);
|
|
|
|
VAmbienceSetFogEndDist(fogindex, fogend);
|
|
|
|
|
|
|
|
|
|
|
|
// Set fog's far z distance.
|
|
|
|
// Set fog's far z distance.
|
|
|
|
new fogfarz = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ]);
|
|
|
|
new fogfarz = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ]);
|
|
|
|
VAmbienceSetFogFarZ(fogindex, fogfarz);
|
|
|
|
VAmbienceSetFogFarZ(fogindex, fogfarz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set fog's primary or secondary color.
|
|
|
|
* Set fog's primary or secondary color.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param color The rgb color of the fog.
|
|
|
|
* @param color The rgb color of the fog.
|
|
|
|
* @param primary (Optional) True to set primary, false otherwise.
|
|
|
|
* @param primary (Optional) True to set primary, false otherwise.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAmbienceSetFogColor(fogindex, const String:color[], bool:primary = true)
|
|
|
|
VAmbienceSetFogColor(fogindex, const String:color[], bool:primary = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set primary color.
|
|
|
|
// Set primary color.
|
|
|
|
if (primary)
|
|
|
|
if (primary)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set new color.
|
|
|
|
// Set new color.
|
|
|
|
SetVariantString(color);
|
|
|
|
SetVariantString(color);
|
|
|
|
AcceptEntityInput(fogindex, "SetColor");
|
|
|
|
AcceptEntityInput(fogindex, "SetColor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Set secondary color.
|
|
|
|
// Set secondary color.
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set new color.
|
|
|
|
// Set new color.
|
|
|
|
SetVariantString(color);
|
|
|
|
SetVariantString(color);
|
|
|
|
AcceptEntityInput(fogindex, "SetColorSecondary");
|
|
|
|
AcceptEntityInput(fogindex, "SetColorSecondary");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set fog's density.
|
|
|
|
* Set fog's density.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param density The density of the fog.
|
|
|
|
* @param density The density of the fog.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAmbienceSetFogDensity(fogindex, Float:density)
|
|
|
|
VAmbienceSetFogDensity(fogindex, Float:density)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set density.
|
|
|
|
// Set density.
|
|
|
|
DispatchKeyValueFloat(fogindex, "fogmaxdensity", density);
|
|
|
|
DispatchKeyValueFloat(fogindex, "fogmaxdensity", density);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set fog's start distance.
|
|
|
|
* Set fog's start distance.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param startdist The start distance of the fog.
|
|
|
|
* @param startdist The start distance of the fog.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAmbienceSetFogStartDist(fogindex, startdist)
|
|
|
|
VAmbienceSetFogStartDist(fogindex, startdist)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set start distance.
|
|
|
|
// Set start distance.
|
|
|
|
SetVariantInt(startdist);
|
|
|
|
SetVariantInt(startdist);
|
|
|
|
AcceptEntityInput(fogindex, "SetStartDist");
|
|
|
|
AcceptEntityInput(fogindex, "SetStartDist");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set fog's end distance.
|
|
|
|
* Set fog's end distance.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param enddist The end distance of the fog.
|
|
|
|
* @param enddist The end distance of the fog.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAmbienceSetFogEndDist(fogindex, enddist)
|
|
|
|
VAmbienceSetFogEndDist(fogindex, enddist)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set end distance.
|
|
|
|
// Set end distance.
|
|
|
|
SetVariantInt(enddist);
|
|
|
|
SetVariantInt(enddist);
|
|
|
|
AcceptEntityInput(fogindex, "SetEndDist");
|
|
|
|
AcceptEntityInput(fogindex, "SetEndDist");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set fog's far z distance.
|
|
|
|
* Set fog's far z distance.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param fogindex Edict index of the fog to modify.
|
|
|
|
* @param farz The far z distance of the fog.
|
|
|
|
* @param farz The far z distance of the fog.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
VAmbienceSetFogFarZ(fogindex, farz)
|
|
|
|
VAmbienceSetFogFarZ(fogindex, farz)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set far z distance.
|
|
|
|
// Set far z distance.
|
|
|
|
SetVariantInt(farz);
|
|
|
|
SetVariantInt(farz);
|
|
|
|
AcceptEntityInput(fogindex, "SetFarZ");
|
|
|
|
AcceptEntityInput(fogindex, "SetFarZ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|