Separated visualeffects into module/submodule format.
This commit is contained in:
parent
f30e8f5862
commit
18986a0d0a
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
#include "zr/account"
|
#include "zr/account"
|
||||||
#include "zr/visualeffects"
|
#include "zr/visualeffects/visualeffects"
|
||||||
#include "zr/soundeffects/soundeffects"
|
#include "zr/soundeffects/soundeffects"
|
||||||
#include "zr/antistick"
|
#include "zr/antistick"
|
||||||
#include "zr/knockback"
|
#include "zr/knockback"
|
||||||
|
@ -1,500 +1,410 @@
|
|||||||
/*
|
/*
|
||||||
* ============================================================================
|
* ============================================================================
|
||||||
*
|
*
|
||||||
* Zombie:Reloaded
|
* Zombie:Reloaded
|
||||||
*
|
*
|
||||||
* File: visualeffects.inc
|
* File: visualambience.inc
|
||||||
* Type: Module
|
* Type: Module
|
||||||
* Description: Visual effects such as map darkening, fog, etc..
|
* Description: Fog, light style, sky, sun rendering, etc
|
||||||
*
|
*
|
||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default sky of current map.
|
* Default sky of current map.
|
||||||
*/
|
*/
|
||||||
new String:g_VEffectsDefaultSky[PLATFORM_MAX_PATH];
|
new String:g_VAmbienceDefaultSky[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cvar data and downloadable content to add to download table.
|
* Validate cvar data.
|
||||||
*/
|
*/
|
||||||
VEffectsLoad()
|
VAmbienceLoad()
|
||||||
{
|
{
|
||||||
// Apply all visual effects now
|
// Apply all visual effects now
|
||||||
VEffectsApplyAll();
|
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_VEffectsDefaultSky, sizeof(g_VEffectsDefaultSky));
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin has just finished creating/hooking cvars.
|
* Hook zr_veffects_* cvar changes.
|
||||||
*/
|
*
|
||||||
VEffectsOnCvarInit()
|
* @param unhook If true, cvars will be unhooked, false to hook cvars.
|
||||||
{
|
*/
|
||||||
// Hook zr_veffects_* cvars.
|
VAmbienceCvarsHook(bool:unhook = false)
|
||||||
VEffectsCvarsHook();
|
{
|
||||||
}
|
// If unhook is true, then continue.
|
||||||
|
if (unhook)
|
||||||
/**
|
{
|
||||||
* Hook zr_veffects_* cvar changes.
|
// Unhook lightstyle cvars.
|
||||||
*
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VAmbienceCvarsHookLightStyle);
|
||||||
* @param unhook If true, cvars will be unhooked, false to hook cvars.
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VAmbienceCvarsHookLightStyle);
|
||||||
*/
|
|
||||||
VEffectsCvarsHook(bool:unhook = false)
|
// Unhook sky cvars.
|
||||||
{
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VAmbienceCvarsHookSky);
|
||||||
// If unhook is true, then continue.
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VAmbienceCvarsHookSky);
|
||||||
if (unhook)
|
|
||||||
{
|
// Unhook sun cvars.
|
||||||
// Unhook lightstyle cvars.
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VAmbienceCvarsHookSunDisable);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VEffectsCvarsHookLightStyle);
|
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VEffectsCvarsHookLightStyle);
|
// Unhook fog cvars.
|
||||||
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VAmbienceCvarsHookFog);
|
||||||
// Unhook sky cvars.
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VEffectsCvarsHookSky);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VEffectsCvarsHookSky);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VAmbienceCvarsHookFog);
|
||||||
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VAmbienceCvarsHookFog);
|
||||||
// Unhook sun cvars.
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VEffectsCvarsHookSunDisable);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VAmbienceCvarsHookFog);
|
||||||
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VAmbienceCvarsHookFog);
|
||||||
// Unhook fog cvars.
|
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VEffectsCvarsHookFog);
|
// Stop after unhooking cvars.
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VEffectsCvarsHookFog);
|
return;
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VEffectsCvarsHookFog);
|
}
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VEffectsCvarsHookFog);
|
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VEffectsCvarsHookFog);
|
// Hook lightstyle cvars.
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VAmbienceCvarsHookLightStyle);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VAmbienceCvarsHookLightStyle);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VEffectsCvarsHookFog);
|
|
||||||
|
// Hook sky cvars.
|
||||||
// Stop after unhooking cvars.
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VAmbienceCvarsHookSky);
|
||||||
return;
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VAmbienceCvarsHookSky);
|
||||||
}
|
|
||||||
|
// Hook sun cvars.
|
||||||
// Hook lightstyle cvars.
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VAmbienceCvarsHookSunDisable);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VEffectsCvarsHookLightStyle);
|
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VEffectsCvarsHookLightStyle);
|
// Hook fog cvars.
|
||||||
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VAmbienceCvarsHookFog);
|
||||||
// Hook sky cvars.
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VEffectsCvarsHookSky);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VEffectsCvarsHookSky);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VAmbienceCvarsHookFog);
|
||||||
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VAmbienceCvarsHookFog);
|
||||||
// Hook sun cvars.
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VEffectsCvarsHookSunDisable);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VAmbienceCvarsHookFog);
|
||||||
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VAmbienceCvarsHookFog);
|
||||||
// Hook fog cvars.
|
}
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VEffectsCvarsHookFog);
|
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VEffectsCvarsHookFog);
|
/**
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VEffectsCvarsHookFog);
|
* Cvar hook callback (zr_veffects_lightstyle, zr_veffects_lightstyle_value)
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VEffectsCvarsHookFog);
|
* Updated server to cvar values.
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VEffectsCvarsHookFog);
|
*
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VEffectsCvarsHookFog);
|
* @param convar The cvar handle.
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VEffectsCvarsHookFog);
|
* @param oldvalue The value before change.
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VEffectsCvarsHookFog);
|
* @param newvalue The new value.
|
||||||
}
|
*/
|
||||||
|
public VAmbienceCvarsHookLightStyle(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
||||||
/**
|
{
|
||||||
* Cvar hook callback (zr_veffects_lightstyle, zr_veffects_lightstyle_value)
|
// If lightstyle is disabled, then disable.
|
||||||
* Updated server to cvar values.
|
new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]);
|
||||||
*
|
|
||||||
* @param convar The cvar handle.
|
// Apply light style.
|
||||||
* @param oldvalue The value before change.
|
VAmbienceApplyLightStyle(!lightstyle);
|
||||||
* @param newvalue The new value.
|
}
|
||||||
*/
|
|
||||||
public VEffectsCvarsHookLightStyle(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
/**
|
||||||
{
|
* Cvar hook callback (zr_veffects_sky, zr_veffects_sky_path)
|
||||||
// If lightstyle is disabled, then disable.
|
* Updated server to cvar values.
|
||||||
new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]);
|
*
|
||||||
|
* @param convar The cvar handle.
|
||||||
// Apply light style.
|
* @param oldvalue The value before change.
|
||||||
VEffectsApplyLightStyle(!lightstyle);
|
* @param newvalue The new value.
|
||||||
}
|
*/
|
||||||
|
public VAmbienceCvarsHookSky(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
||||||
/**
|
{
|
||||||
* Cvar hook callback (zr_veffects_sky, zr_veffects_sky_path)
|
// If sky is disabled, then disable.
|
||||||
* Updated server to cvar values.
|
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
||||||
*
|
|
||||||
* @param convar The cvar handle.
|
// Apply new sky.
|
||||||
* @param oldvalue The value before change.
|
VAmbienceApplySky(!sky);
|
||||||
* @param newvalue The new value.
|
}
|
||||||
*/
|
|
||||||
public VEffectsCvarsHookSky(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
/**
|
||||||
{
|
* Cvar hook callback (zr_veffects_sun_disable)
|
||||||
// If sky is disabled, then disable.
|
* Updated server to cvar values.
|
||||||
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
*
|
||||||
|
* @param convar The cvar handle.
|
||||||
// Apply new sky.
|
* @param oldvalue The value before change.
|
||||||
VEffectsApplySky(!sky);
|
* @param newvalue The new value.
|
||||||
}
|
*/
|
||||||
|
public VAmbienceCvarsHookSunDisable(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
||||||
/**
|
{
|
||||||
* Cvar hook callback (zr_veffects_sun_disable)
|
// If fog is disabled, then disable.
|
||||||
* Updated server to cvar values.
|
new bool:sun = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE]);
|
||||||
*
|
|
||||||
* @param convar The cvar handle.
|
// Apply fog.
|
||||||
* @param oldvalue The value before change.
|
VAmbienceApplySunDisable(!sun);
|
||||||
* @param newvalue The new value.
|
}
|
||||||
*/
|
|
||||||
public VEffectsCvarsHookSunDisable(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
/**
|
||||||
{
|
* Cvar hook callback (zr_veffects_fog_*)
|
||||||
// If fog is disabled, then disable.
|
* Updated server to cvar values.
|
||||||
new bool:sun = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE]);
|
*
|
||||||
|
* @param convar The cvar handle.
|
||||||
// Apply fog.
|
* @param oldvalue The value before change.
|
||||||
VEffectsApplySunDisable(!sun);
|
* @param newvalue The new value.
|
||||||
}
|
*/
|
||||||
|
public VAmbienceCvarsHookFog(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
||||||
/**
|
{
|
||||||
* Cvar hook callback (zr_veffects_fog_*)
|
// If fog is disabled, then disable.
|
||||||
* Updated server to cvar values.
|
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
||||||
*
|
|
||||||
* @param convar The cvar handle.
|
// Apply fog.
|
||||||
* @param oldvalue The value before change.
|
VAmbienceApplyFog(fogoverride);
|
||||||
* @param newvalue The new value.
|
}
|
||||||
*/
|
|
||||||
public VEffectsCvarsHookFog(Handle:cvar, const String:oldvalue[], const String:newvalue[])
|
/**
|
||||||
{
|
* Apply all cvar values on server.
|
||||||
// If fog is disabled, then disable.
|
*/
|
||||||
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
VAmbienceApplyAll()
|
||||||
|
{
|
||||||
// Apply fog.
|
// If lightstyle is disabled, then disable.
|
||||||
VEffectsApplyFog(fogoverride);
|
new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]);
|
||||||
}
|
|
||||||
|
// Apply light style.
|
||||||
/**
|
VAmbienceApplyLightStyle(!lightstyle);
|
||||||
* Apply all cvar values on server.
|
|
||||||
*/
|
// If sky is disabled, then disable.
|
||||||
VEffectsApplyAll()
|
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
||||||
{
|
|
||||||
// If lightstyle is disabled, then disable.
|
// Apply new sky.
|
||||||
new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]);
|
VAmbienceApplySky(!sky);
|
||||||
|
|
||||||
// Apply light style.
|
// If fog is disabled, then disable.
|
||||||
VEffectsApplyLightStyle(!lightstyle);
|
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
||||||
|
|
||||||
// If sky is disabled, then disable.
|
// Apply fog.
|
||||||
new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]);
|
VAmbienceApplyFog(fogoverride);
|
||||||
|
}
|
||||||
// Apply new sky.
|
|
||||||
VEffectsApplySky(!sky);
|
VAmbienceApplyLightStyle(bool:disable = false)
|
||||||
|
{
|
||||||
// If fog is disabled, then disable.
|
// If default, then set to normal light style.
|
||||||
new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]);
|
if (disable)
|
||||||
|
{
|
||||||
// Apply fog.
|
// Set light style.
|
||||||
VEffectsApplyFog(fogoverride);
|
SetLightStyle(0, "n");
|
||||||
}
|
|
||||||
|
return;
|
||||||
VEffectsApplyLightStyle(bool:disable = false)
|
}
|
||||||
{
|
|
||||||
// If default, then set to normal light style.
|
// Get light value.
|
||||||
if (disable)
|
decl String:lightstylevalue[4];
|
||||||
{
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], lightstylevalue, sizeof(lightstylevalue));
|
||||||
// Set light style.
|
|
||||||
SetLightStyle(0, "n");
|
// Set light style.
|
||||||
|
SetLightStyle(0, lightstylevalue);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
VAmbienceApplySky(bool:disable = false)
|
||||||
// Get light value.
|
{
|
||||||
decl String:lightstylevalue[4];
|
// if we can't find the sv_skyname cvar, then stop.
|
||||||
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], lightstylevalue, sizeof(lightstylevalue));
|
new Handle:hSkyname = FindConVar("sv_skyname");
|
||||||
|
if (hSkyname == INVALID_HANDLE)
|
||||||
// Set light style.
|
{
|
||||||
SetLightStyle(0, lightstylevalue);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VEffectsApplySky(bool:disable = false)
|
// If default, then set to default sky.
|
||||||
{
|
if (disable)
|
||||||
// if we can't find the sv_skyname cvar, then stop.
|
{
|
||||||
new Handle:hSkyname = FindConVar("sv_skyname");
|
if (g_VAmbienceDefaultSky[0])
|
||||||
if (hSkyname == INVALID_HANDLE)
|
{
|
||||||
{
|
SetConVarString(hSkyname, g_VAmbienceDefaultSky, true);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
return;
|
||||||
// If default, then set to default sky.
|
}
|
||||||
if (disable)
|
|
||||||
{
|
// Get sky path.
|
||||||
if (g_VEffectsDefaultSky[0])
|
decl String:skypath[PLATFORM_MAX_PATH];
|
||||||
{
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], skypath, sizeof(skypath));
|
||||||
SetConVarString(hSkyname, g_VEffectsDefaultSky, true);
|
|
||||||
}
|
// Set new sky on all clients.
|
||||||
|
SetConVarString(hSkyname, skypath, true);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
VAmbienceApplySunDisable(bool:disable = false)
|
||||||
// Get sky path.
|
{
|
||||||
decl String:skypath[PLATFORM_MAX_PATH];
|
// Find sun entity.
|
||||||
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], skypath, sizeof(skypath));
|
new sun = FindEntityByClassname(-1, "env_sun");
|
||||||
|
|
||||||
// Set new sky on all clients.
|
// If sun is invalid, then stop.
|
||||||
SetConVarString(hSkyname, skypath, true);
|
if (sun == -1)
|
||||||
}
|
{
|
||||||
|
return;
|
||||||
VEffectsApplySunDisable(bool:disable = false)
|
}
|
||||||
{
|
|
||||||
// Find sun entity.
|
// If default, then re-enable sun rendering.
|
||||||
new sun = FindEntityByClassname(-1, "env_sun");
|
if (disable)
|
||||||
|
{
|
||||||
// If sun is invalid, then stop.
|
// Turn on sun rendering.
|
||||||
if (sun == -1)
|
AcceptEntityInput(sun, "TurnOn");
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If default, then re-enable sun rendering.
|
// Turn off sun rendering.
|
||||||
if (disable)
|
AcceptEntityInput(sun, "TurnOff");
|
||||||
{
|
}
|
||||||
// Turn on sun rendering.
|
|
||||||
AcceptEntityInput(sun, "TurnOn");
|
VAmbienceApplyFog(bool:override = false)
|
||||||
|
{
|
||||||
return;
|
// If fog is disabled, then stop.
|
||||||
}
|
new bool:fog = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG]);
|
||||||
|
|
||||||
// Turn off sun rendering.
|
// DUE TO SOURCEMOD NOT SUPPORT FOG, DISABLE.
|
||||||
AcceptEntityInput(sun, "TurnOff");
|
fog = false;
|
||||||
}
|
|
||||||
|
if (!fog)
|
||||||
VEffectsApplyFog(bool:override = false)
|
{
|
||||||
{
|
return;
|
||||||
// If fog is disabled, then stop.
|
}
|
||||||
new bool:fog = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG]);
|
|
||||||
|
// Find current fog index
|
||||||
// DUE TO SOURCEMOD NOT SUPPORT FOG, DISABLE.
|
new fogindex = FindEntityByClassname(-1, "env_fog_controller");
|
||||||
fog = false;
|
|
||||||
|
// If override is enabled, then continue.
|
||||||
if (!fog)
|
if (override)
|
||||||
{
|
{
|
||||||
return;
|
// If there is fog, then continue.
|
||||||
}
|
if (fogindex != -1)
|
||||||
|
{
|
||||||
// Find current fog index
|
// Delete fog.
|
||||||
new fogindex = FindEntityByClassname(-1, "env_fog_controller");
|
RemoveEdict(fogindex);
|
||||||
|
}
|
||||||
// If override is enabled, then continue.
|
}
|
||||||
if (override)
|
|
||||||
{
|
// If there is no fog on the map, create new fog.
|
||||||
// If there is fog, then continue.
|
if (fogindex == -1)
|
||||||
if (fogindex != -1)
|
{
|
||||||
{
|
// Create and spawn fog.
|
||||||
// Delete fog.
|
fogindex = CreateEntityByName("env_fog_controller");
|
||||||
RemoveEdict(fogindex);
|
DispatchSpawn(fogindex);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
decl String:fogcolor[16];
|
||||||
// If there is no fog on the map, create new fog.
|
|
||||||
if (fogindex == -1)
|
// Set primary fog color.
|
||||||
{
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], fogcolor, sizeof(fogcolor));
|
||||||
// Create and spawn fog.
|
VAmbienceSetFogColor(fogindex, fogcolor, true);
|
||||||
fogindex = CreateEntityByName("env_fog_controller");
|
|
||||||
DispatchSpawn(fogindex);
|
// Set secondary fog color.
|
||||||
}
|
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], fogcolor, sizeof(fogcolor));
|
||||||
|
VAmbienceSetFogColor(fogindex, fogcolor, false);
|
||||||
decl String:fogcolor[16];
|
|
||||||
|
// Set fog's density.
|
||||||
// Set primary fog color.
|
new Float:fogdensity = GetConVarFloat(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY]);
|
||||||
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], fogcolor, sizeof(fogcolor));
|
VAmbienceSetFogDensity(fogindex, fogdensity);
|
||||||
VEffectsSetFogColor(fogindex, fogcolor, true);
|
|
||||||
|
// Set fog's start distance.
|
||||||
// Set secondary fog color.
|
new fogstart = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST]);
|
||||||
GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], fogcolor, sizeof(fogcolor));
|
VAmbienceSetFogStartDist(fogindex, fogstart);
|
||||||
VEffectsSetFogColor(fogindex, fogcolor, false);
|
|
||||||
|
// Set fog's end distance.
|
||||||
// Set fog's density.
|
new fogend = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST]);
|
||||||
new Float:fogdensity = GetConVarFloat(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY]);
|
VAmbienceSetFogEndDist(fogindex, fogend);
|
||||||
VEffectsSetFogDensity(fogindex, fogdensity);
|
|
||||||
|
// Set fog's far z distance.
|
||||||
// Set fog's start distance.
|
new fogfarz = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ]);
|
||||||
new fogstart = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST]);
|
VAmbienceSetFogFarZ(fogindex, fogfarz);
|
||||||
VEffectsSetFogStartDist(fogindex, fogstart);
|
}
|
||||||
|
|
||||||
// Set fog's end distance.
|
/**
|
||||||
new fogend = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST]);
|
* Set fog's primary or secondary color.
|
||||||
VEffectsSetFogEndDist(fogindex, fogend);
|
*
|
||||||
|
* @param fogindex Edict index of the fog to modify.
|
||||||
// Set fog's far z distance.
|
* @param color The rgb color of the fog.
|
||||||
new fogfarz = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ]);
|
* @param primary (Optional) True to set primary, false otherwise.
|
||||||
VEffectsSetFogFarZ(fogindex, fogfarz);
|
*/
|
||||||
}
|
VAmbienceSetFogColor(fogindex, const String:color[], bool:primary = true)
|
||||||
|
{
|
||||||
/**
|
// Set primary color.
|
||||||
* Set fog's primary or secondary color.
|
if (primary)
|
||||||
*
|
{
|
||||||
* @param fogindex Edict index of the fog to modify.
|
// Set new color.
|
||||||
* @param color The rgb color of the fog.
|
SetVariantString(color);
|
||||||
* @param primary (Optional) True to set primary, false otherwise.
|
AcceptEntityInput(fogindex, "SetColor");
|
||||||
*/
|
}
|
||||||
VEffectsSetFogColor(fogindex, const String:color[], bool:primary = true)
|
// Set secondary color.
|
||||||
{
|
else
|
||||||
// Set primary color.
|
{
|
||||||
if (primary)
|
// Set new color.
|
||||||
{
|
SetVariantString(color);
|
||||||
// Set new color.
|
AcceptEntityInput(fogindex, "SetColorSecondary");
|
||||||
SetVariantString(color);
|
}
|
||||||
AcceptEntityInput(fogindex, "SetColor");
|
}
|
||||||
}
|
|
||||||
// Set secondary color.
|
/**
|
||||||
else
|
* Set fog's density.
|
||||||
{
|
*
|
||||||
// Set new color.
|
* @param fogindex Edict index of the fog to modify.
|
||||||
SetVariantString(color);
|
* @param density The density of the fog.
|
||||||
AcceptEntityInput(fogindex, "SetColorSecondary");
|
*/
|
||||||
}
|
VAmbienceSetFogDensity(fogindex, Float:density)
|
||||||
}
|
{
|
||||||
|
// Set density.
|
||||||
/**
|
DispatchKeyValueFloat(fogindex, "fogmaxdensity", density);
|
||||||
* Set fog's density.
|
}
|
||||||
*
|
|
||||||
* @param fogindex Edict index of the fog to modify.
|
/**
|
||||||
* @param density The density of the fog.
|
* Set fog's start distance.
|
||||||
*/
|
*
|
||||||
VEffectsSetFogDensity(fogindex, Float:density)
|
* @param fogindex Edict index of the fog to modify.
|
||||||
{
|
* @param startdist The start distance of the fog.
|
||||||
// Set density.
|
*/
|
||||||
DispatchKeyValueFloat(fogindex, "fogmaxdensity", density);
|
VAmbienceSetFogStartDist(fogindex, startdist)
|
||||||
}
|
{
|
||||||
|
// Set start distance.
|
||||||
/**
|
SetVariantInt(startdist);
|
||||||
* Set fog's start distance.
|
AcceptEntityInput(fogindex, "SetStartDist");
|
||||||
*
|
}
|
||||||
* @param fogindex Edict index of the fog to modify.
|
|
||||||
* @param startdist The start distance of the fog.
|
/**
|
||||||
*/
|
* Set fog's end distance.
|
||||||
VEffectsSetFogStartDist(fogindex, startdist)
|
*
|
||||||
{
|
* @param fogindex Edict index of the fog to modify.
|
||||||
// Set start distance.
|
* @param enddist The end distance of the fog.
|
||||||
SetVariantInt(startdist);
|
*/
|
||||||
AcceptEntityInput(fogindex, "SetStartDist");
|
VAmbienceSetFogEndDist(fogindex, enddist)
|
||||||
}
|
{
|
||||||
|
// Set end distance.
|
||||||
/**
|
SetVariantInt(enddist);
|
||||||
* Set fog's end distance.
|
AcceptEntityInput(fogindex, "SetEndDist");
|
||||||
*
|
}
|
||||||
* @param fogindex Edict index of the fog to modify.
|
|
||||||
* @param enddist The end distance of the fog.
|
/**
|
||||||
*/
|
* Set fog's far z distance.
|
||||||
VEffectsSetFogEndDist(fogindex, enddist)
|
*
|
||||||
{
|
* @param fogindex Edict index of the fog to modify.
|
||||||
// Set end distance.
|
* @param farz The far z distance of the fog.
|
||||||
SetVariantInt(enddist);
|
*/
|
||||||
AcceptEntityInput(fogindex, "SetEndDist");
|
VAmbienceSetFogFarZ(fogindex, farz)
|
||||||
}
|
{
|
||||||
|
// Set far z distance.
|
||||||
/**
|
SetVariantInt(farz);
|
||||||
* Set fog's far z distance.
|
AcceptEntityInput(fogindex, "SetFarZ");
|
||||||
*
|
}
|
||||||
* @param fogindex Edict index of the fog to modify.
|
|
||||||
* @param farz The far z distance of the fog.
|
|
||||||
*/
|
|
||||||
VEffectsSetFogFarZ(fogindex, farz)
|
|
||||||
{
|
|
||||||
// Set far z distance.
|
|
||||||
SetVariantInt(farz);
|
|
||||||
AcceptEntityInput(fogindex, "SetFarZ");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an energy splash effect.
|
|
||||||
*
|
|
||||||
* @param client The client index.
|
|
||||||
* @param origin The origin of the effect.
|
|
||||||
* @param direction The direction of the effect.
|
|
||||||
*/
|
|
||||||
VEffectsCreateEnergySplash(const Float:origin[3], const Float:direction[3], bool:explosive)
|
|
||||||
{
|
|
||||||
TE_SetupEnergySplash(origin, direction, explosive);
|
|
||||||
TE_SendToAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an explosion effect with strict flags.
|
|
||||||
*
|
|
||||||
* @param origin The (x, y, z) coordinate of the explosion.
|
|
||||||
* @param flags The flags to set on the explosion.
|
|
||||||
*/
|
|
||||||
VEffectsCreateExplosion(const Float:origin[3], flags)
|
|
||||||
{
|
|
||||||
// Create an explosion entity.
|
|
||||||
new explosion = CreateEntityByName("env_explosion");
|
|
||||||
|
|
||||||
// If explosion entity isn't valid, then stop.
|
|
||||||
if (explosion == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get and modify flags on explosion.
|
|
||||||
new spawnflags = GetEntProp(explosion, Prop_Data, "m_spawnflags");
|
|
||||||
spawnflags = spawnflags | EXP_NODAMAGE | EXP_NODECAL | flags;
|
|
||||||
|
|
||||||
// Set modified flags on entity.
|
|
||||||
SetEntProp(explosion, Prop_Data, "m_spawnflags", spawnflags);
|
|
||||||
|
|
||||||
// Spawn the entity into the world.
|
|
||||||
DispatchSpawn(explosion);
|
|
||||||
|
|
||||||
// Set the origin of the explosion.
|
|
||||||
DispatchKeyValueVector(explosion, "origin", origin);
|
|
||||||
|
|
||||||
// Set fireball material.
|
|
||||||
PrecacheModel("materials/sprites/xfireball3.vmt");
|
|
||||||
DispatchKeyValue(explosion, "fireballsprite", "materials/sprites/xfireball3.vmt");
|
|
||||||
|
|
||||||
// Tell the entity to explode.
|
|
||||||
AcceptEntityInput(explosion, "Explode");
|
|
||||||
|
|
||||||
// Remove entity from world.
|
|
||||||
RemoveEdict(explosion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shake a client's screen with specific parameters.
|
|
||||||
*
|
|
||||||
* @param client The client index.
|
|
||||||
* @param amplitude The amplitude (intensity) of the shaking.
|
|
||||||
* @param frequency The frequency (speed) of the shaking.
|
|
||||||
* @param duration The duration (time) of the shaking.
|
|
||||||
*/
|
|
||||||
VEffectsShakeClientScreen(client, Float:amplitude, Float:frequency, Float:duration)
|
|
||||||
{
|
|
||||||
// If shake usermsg isn't invalid, then stop.
|
|
||||||
new Handle:hShake = StartMessageOne("Shake", client);
|
|
||||||
if (hShake == INVALID_HANDLE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write shake information to usermsg handle.
|
|
||||||
BfWriteByte(hShake, 0);
|
|
||||||
BfWriteFloat(hShake, amplitude);
|
|
||||||
BfWriteFloat(hShake, frequency);
|
|
||||||
BfWriteFloat(hShake, duration);
|
|
||||||
|
|
||||||
// End usermsg and send to client.
|
|
||||||
EndMessage();
|
|
||||||
}
|
|
112
src/zr/visualeffects/visualeffects.inc
Normal file
112
src/zr/visualeffects/visualeffects.inc
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* ============================================================================
|
||||||
|
*
|
||||||
|
* Zombie:Reloaded
|
||||||
|
*
|
||||||
|
* File: visualeffects.inc
|
||||||
|
* Type: Module
|
||||||
|
* Description: Visual effects API.
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "zr/visualeffects/visualambience"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visual effect loading.
|
||||||
|
*/
|
||||||
|
VEffectsLoad()
|
||||||
|
{
|
||||||
|
// Forward event to sub-modules.
|
||||||
|
VAmbienceLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin has just finished creating/hooking cvars.
|
||||||
|
*/
|
||||||
|
VEffectsOnCvarInit()
|
||||||
|
{
|
||||||
|
// Hook zr_veffects_* cvars.
|
||||||
|
VAmbienceCvarsHook();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an energy splash effect.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param origin The origin of the effect.
|
||||||
|
* @param direction The direction of the effect.
|
||||||
|
*/
|
||||||
|
VEffectsCreateEnergySplash(const Float:origin[3], const Float:direction[3], bool:explosive)
|
||||||
|
{
|
||||||
|
TE_SetupEnergySplash(origin, direction, explosive);
|
||||||
|
TE_SendToAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an explosion effect with strict flags.
|
||||||
|
*
|
||||||
|
* @param origin The (x, y, z) coordinate of the explosion.
|
||||||
|
* @param flags The flags to set on the explosion.
|
||||||
|
*/
|
||||||
|
VEffectsCreateExplosion(const Float:origin[3], flags)
|
||||||
|
{
|
||||||
|
// Create an explosion entity.
|
||||||
|
new explosion = CreateEntityByName("env_explosion");
|
||||||
|
|
||||||
|
// If explosion entity isn't valid, then stop.
|
||||||
|
if (explosion == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get and modify flags on explosion.
|
||||||
|
new spawnflags = GetEntProp(explosion, Prop_Data, "m_spawnflags");
|
||||||
|
spawnflags = spawnflags | EXP_NODAMAGE | EXP_NODECAL | flags;
|
||||||
|
|
||||||
|
// Set modified flags on entity.
|
||||||
|
SetEntProp(explosion, Prop_Data, "m_spawnflags", spawnflags);
|
||||||
|
|
||||||
|
// Spawn the entity into the world.
|
||||||
|
DispatchSpawn(explosion);
|
||||||
|
|
||||||
|
// Set the origin of the explosion.
|
||||||
|
DispatchKeyValueVector(explosion, "origin", origin);
|
||||||
|
|
||||||
|
// Set fireball material.
|
||||||
|
PrecacheModel("materials/sprites/xfireball3.vmt");
|
||||||
|
DispatchKeyValue(explosion, "fireballsprite", "materials/sprites/xfireball3.vmt");
|
||||||
|
|
||||||
|
// Tell the entity to explode.
|
||||||
|
AcceptEntityInput(explosion, "Explode");
|
||||||
|
|
||||||
|
// Remove entity from world.
|
||||||
|
RemoveEdict(explosion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shake a client's screen with specific parameters.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param amplitude The amplitude (intensity) of the shaking.
|
||||||
|
* @param frequency The frequency (speed) of the shaking.
|
||||||
|
* @param duration The duration (time) of the shaking.
|
||||||
|
*/
|
||||||
|
VEffectsShakeClientScreen(client, Float:amplitude, Float:frequency, Float:duration)
|
||||||
|
{
|
||||||
|
// If shake usermsg isn't invalid, then stop.
|
||||||
|
new Handle:hShake = StartMessageOne("Shake", client);
|
||||||
|
if (hShake == INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write shake information to usermsg handle.
|
||||||
|
BfWriteByte(hShake, 0);
|
||||||
|
BfWriteFloat(hShake, amplitude);
|
||||||
|
BfWriteFloat(hShake, frequency);
|
||||||
|
BfWriteFloat(hShake, duration);
|
||||||
|
|
||||||
|
// End usermsg and send to client.
|
||||||
|
EndMessage();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user