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"
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* 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
|
||||||
*
|
*
|
||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
@ -13,22 +13,22 @@
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
@ -51,70 +51,61 @@ VEffectsLoad()
|
||||||
AddFileToDownloadsTable(downloadpath);
|
AddFileToDownloadsTable(downloadpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Plugin has just finished creating/hooking cvars.
|
|
||||||
*/
|
|
||||||
VEffectsOnCvarInit()
|
|
||||||
{
|
|
||||||
// Hook zr_veffects_* cvars.
|
|
||||||
VEffectsCvarsHook();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
VEffectsCvarsHook(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], VEffectsCvarsHookLightStyle);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VAmbienceCvarsHookLightStyle);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VEffectsCvarsHookLightStyle);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VAmbienceCvarsHookLightStyle);
|
||||||
|
|
||||||
// Unhook sky cvars.
|
// Unhook sky cvars.
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VEffectsCvarsHookSky);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VAmbienceCvarsHookSky);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VEffectsCvarsHookSky);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VAmbienceCvarsHookSky);
|
||||||
|
|
||||||
// Unhook sun cvars.
|
// Unhook sun cvars.
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VEffectsCvarsHookSunDisable);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VAmbienceCvarsHookSunDisable);
|
||||||
|
|
||||||
// Unhook fog cvars.
|
// Unhook fog cvars.
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VEffectsCvarsHookFog);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VEffectsCvarsHookFog);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VEffectsCvarsHookFog);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VEffectsCvarsHookFog);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VEffectsCvarsHookFog);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VEffectsCvarsHookFog);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VEffectsCvarsHookFog);
|
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VAmbienceCvarsHookFog);
|
||||||
UnhookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VEffectsCvarsHookFog);
|
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], VEffectsCvarsHookLightStyle);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE], VAmbienceCvarsHookLightStyle);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VEffectsCvarsHookLightStyle);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], VAmbienceCvarsHookLightStyle);
|
||||||
|
|
||||||
// Hook sky cvars.
|
// Hook sky cvars.
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VEffectsCvarsHookSky);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY], VAmbienceCvarsHookSky);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VEffectsCvarsHookSky);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], VAmbienceCvarsHookSky);
|
||||||
|
|
||||||
// Hook sun cvars.
|
// Hook sun cvars.
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VEffectsCvarsHookSunDisable);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_SUN_DISABLE], VAmbienceCvarsHookSunDisable);
|
||||||
|
|
||||||
// Hook fog cvars.
|
// Hook fog cvars.
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST], VAmbienceCvarsHookFog);
|
||||||
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VEffectsCvarsHookFog);
|
HookConVarChange(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ], VAmbienceCvarsHookFog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,13 +116,13 @@ VEffectsCvarsHook(bool:unhook = false)
|
||||||
* @param oldvalue The value before change.
|
* @param oldvalue The value before change.
|
||||||
* @param newvalue The new value.
|
* @param newvalue The new value.
|
||||||
*/
|
*/
|
||||||
public VEffectsCvarsHookLightStyle(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.
|
||||||
VEffectsApplyLightStyle(!lightstyle);
|
VAmbienceApplyLightStyle(!lightstyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,13 +133,13 @@ public VEffectsCvarsHookLightStyle(Handle:cvar, const String:oldvalue[], const S
|
||||||
* @param oldvalue The value before change.
|
* @param oldvalue The value before change.
|
||||||
* @param newvalue The new value.
|
* @param newvalue The new value.
|
||||||
*/
|
*/
|
||||||
public VEffectsCvarsHookSky(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.
|
||||||
VEffectsApplySky(!sky);
|
VAmbienceApplySky(!sky);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,13 +150,13 @@ public VEffectsCvarsHookSky(Handle:cvar, const String:oldvalue[], const String:n
|
||||||
* @param oldvalue The value before change.
|
* @param oldvalue The value before change.
|
||||||
* @param newvalue The new value.
|
* @param newvalue The new value.
|
||||||
*/
|
*/
|
||||||
public VEffectsCvarsHookSunDisable(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.
|
||||||
VEffectsApplySunDisable(!sun);
|
VAmbienceApplySunDisable(!sun);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,40 +167,40 @@ public VEffectsCvarsHookSunDisable(Handle:cvar, const String:oldvalue[], const S
|
||||||
* @param oldvalue The value before change.
|
* @param oldvalue The value before change.
|
||||||
* @param newvalue The new value.
|
* @param newvalue The new value.
|
||||||
*/
|
*/
|
||||||
public VEffectsCvarsHookFog(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.
|
||||||
VEffectsApplyFog(fogoverride);
|
VAmbienceApplyFog(fogoverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply all cvar values on server.
|
* Apply all cvar values on server.
|
||||||
*/
|
*/
|
||||||
VEffectsApplyAll()
|
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.
|
||||||
VEffectsApplyLightStyle(!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.
|
||||||
VEffectsApplySky(!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.
|
||||||
VEffectsApplyFog(fogoverride);
|
VAmbienceApplyFog(fogoverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEffectsApplyLightStyle(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)
|
||||||
|
@ -228,7 +219,7 @@ VEffectsApplyLightStyle(bool:disable = false)
|
||||||
SetLightStyle(0, lightstylevalue);
|
SetLightStyle(0, lightstylevalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEffectsApplySky(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");
|
||||||
|
@ -240,9 +231,9 @@ VEffectsApplySky(bool:disable = false)
|
||||||
// If default, then set to default sky.
|
// If default, then set to default sky.
|
||||||
if (disable)
|
if (disable)
|
||||||
{
|
{
|
||||||
if (g_VEffectsDefaultSky[0])
|
if (g_VAmbienceDefaultSky[0])
|
||||||
{
|
{
|
||||||
SetConVarString(hSkyname, g_VEffectsDefaultSky, true);
|
SetConVarString(hSkyname, g_VAmbienceDefaultSky, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -256,7 +247,7 @@ VEffectsApplySky(bool:disable = false)
|
||||||
SetConVarString(hSkyname, skypath, true);
|
SetConVarString(hSkyname, skypath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
VEffectsApplySunDisable(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");
|
||||||
|
@ -280,7 +271,7 @@ VEffectsApplySunDisable(bool:disable = false)
|
||||||
AcceptEntityInput(sun, "TurnOff");
|
AcceptEntityInput(sun, "TurnOff");
|
||||||
}
|
}
|
||||||
|
|
||||||
VEffectsApplyFog(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]);
|
||||||
|
@ -319,27 +310,27 @@ VEffectsApplyFog(bool:override = false)
|
||||||
|
|
||||||
// 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));
|
||||||
VEffectsSetFogColor(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));
|
||||||
VEffectsSetFogColor(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]);
|
||||||
VEffectsSetFogDensity(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]);
|
||||||
VEffectsSetFogStartDist(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]);
|
||||||
VEffectsSetFogEndDist(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]);
|
||||||
VEffectsSetFogFarZ(fogindex, fogfarz);
|
VAmbienceSetFogFarZ(fogindex, fogfarz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +340,7 @@ VEffectsApplyFog(bool:override = false)
|
||||||
* @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.
|
||||||
*/
|
*/
|
||||||
VEffectsSetFogColor(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)
|
||||||
|
@ -373,7 +364,7 @@ VEffectsSetFogColor(fogindex, const String:color[], bool:primary = true)
|
||||||
* @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.
|
||||||
*/
|
*/
|
||||||
VEffectsSetFogDensity(fogindex, Float:density)
|
VAmbienceSetFogDensity(fogindex, Float:density)
|
||||||
{
|
{
|
||||||
// Set density.
|
// Set density.
|
||||||
DispatchKeyValueFloat(fogindex, "fogmaxdensity", density);
|
DispatchKeyValueFloat(fogindex, "fogmaxdensity", density);
|
||||||
|
@ -385,7 +376,7 @@ VEffectsSetFogDensity(fogindex, Float:density)
|
||||||
* @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.
|
||||||
*/
|
*/
|
||||||
VEffectsSetFogStartDist(fogindex, startdist)
|
VAmbienceSetFogStartDist(fogindex, startdist)
|
||||||
{
|
{
|
||||||
// Set start distance.
|
// Set start distance.
|
||||||
SetVariantInt(startdist);
|
SetVariantInt(startdist);
|
||||||
|
@ -398,7 +389,7 @@ VEffectsSetFogStartDist(fogindex, startdist)
|
||||||
* @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.
|
||||||
*/
|
*/
|
||||||
VEffectsSetFogEndDist(fogindex, enddist)
|
VAmbienceSetFogEndDist(fogindex, enddist)
|
||||||
{
|
{
|
||||||
// Set end distance.
|
// Set end distance.
|
||||||
SetVariantInt(enddist);
|
SetVariantInt(enddist);
|
||||||
|
@ -411,90 +402,9 @@ VEffectsSetFogEndDist(fogindex, enddist)
|
||||||
* @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.
|
||||||
*/
|
*/
|
||||||
VEffectsSetFogFarZ(fogindex, farz)
|
VAmbienceSetFogFarZ(fogindex, farz)
|
||||||
{
|
{
|
||||||
// Set far z distance.
|
// Set far z distance.
|
||||||
SetVariantInt(farz);
|
SetVariantInt(farz);
|
||||||
AcceptEntityInput(fogindex, "SetFarZ");
|
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