diff --git a/cstrike/addons/sourcemod/configs/zr/hitgroups.txt b/cstrike/addons/sourcemod/configs/zr/hitgroups.txt index 6b71d48..9edefc2 100644 --- a/cstrike/addons/sourcemod/configs/zr/hitgroups.txt +++ b/cstrike/addons/sourcemod/configs/zr/hitgroups.txt @@ -5,7 +5,8 @@ // "hitgroup index" // Index of the hitgroup (listed below) // { // "name" "name of hitgroup" // Redundant as of now, used for readability. -// "knockback" "1.0" (default) // The knockback multiplier for the hitgroup +// "knockback" "1.0" (default) // The knockback multiplier for the hitgroup. +// "damage" "yes" (default // Toggle damage on and off for this hitgroup. // } // // Notes: @@ -18,53 +19,62 @@ { "name" "Generic" "knockback" "1.0" + "damage" "yes" } "1" { "name" "Head" "knockback" "2.0" + "damage" "yes" } "2" { "name" "Chest" "knockback" "1.3" + "damage" "yes" } "3" { "name" "Stomach" "knockback" "1.2" + "damage" "yes" } "4" { "name" "Left Arm" "knockback" "1.0" + "damage" "yes" } "5" { "name" "Right Arm" "knockback" "1.0" + "damage" "yes" } "6" { "name" "Left Leg" "knockback" "0.9" + "damage" "yes" } "7" { "name" "Right Leg" "knockback" "0.9" + "damage" "yes" } "10" { "name" "Gear" "knockback" "1.0" + "damage" "yes" } } diff --git a/cstrike/addons/sourcemod/gamedata/plugin.zombiereloaded.txt b/cstrike/addons/sourcemod/gamedata/plugin.zombiereloaded.txt index e742e29..1289a0e 100644 --- a/cstrike/addons/sourcemod/gamedata/plugin.zombiereloaded.txt +++ b/cstrike/addons/sourcemod/gamedata/plugin.zombiereloaded.txt @@ -10,12 +10,6 @@ "Offsets" { - "EyePosition" - { - "windows" "117" - "linux" "118" - } - "EyeAngles" { "windows" "206" diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 96eff6c..f6d73f1 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -23,12 +23,12 @@ // External api (not done) //#include "zr/global" -// Cvars (core) -#include "zr/cvars" - // Log (core) #include "zr/log" +// Cvars (core) +#include "zr/cvars" + // Translations (core) #include "zr/translation" @@ -44,6 +44,9 @@ // Weapons (core) #include "zr/weapons/weapons" +// Hitgroups (core) +#include "zr/hitgroups" + // Round End (core) #include "zr/roundend" @@ -53,12 +56,12 @@ // Damage (core) #include "zr/damage" -// Hitgroups (core) -#include "zr/hitgroups" - // Account (module) #include "zr/account" +// Visual Effects (module) +#include "zr/visualeffects" + // Sound Effects (module) #include "zr/soundeffects/soundeffects" @@ -87,6 +90,8 @@ #include "zr/sayhooks" #include "zr/zadmin" #include "zr/commands" + +// Event #include "zr/event" public Plugin:myinfo = @@ -117,12 +122,13 @@ public OnPluginStart() // ====================================================================== + // Log + LogInit(); + // Cvars CvarsInit(); - CvarsHook(); // TODO: Be modulized/recoded. - HookEvents(); HookChatCmds(); CreateCommands(); HookCommands(); @@ -135,6 +141,9 @@ public OnPluginStart() // Damage DamageInit(); + // Event + EventInit(); + // ====================================================================== g_bMarket = LibraryExists("market"); @@ -172,10 +181,8 @@ public OnMapStart() LoadDownloadData(); // Forward event to modules. - WeaponsLoad(); RoundEndOnMapStart(); InfectOnMapStart(); - HitgroupsLoad(); SEffectsOnMapStart(); AntiStickOnMapStart(); Anticamp_Startup(); @@ -207,9 +214,11 @@ public OnConfigsExecuted() } } - FindMapSky(); - // Forward event to modules. + WeaponsLoad(); + HitgroupsLoad(); + InfectLoad(); + VEffectsLoad(); SEffectsLoad(); ClassLoad(); } diff --git a/src/zr/anticamp.inc b/src/zr/anticamp.inc index 70b6a52..0c02fa5 100644 --- a/src/zr/anticamp.inc +++ b/src/zr/anticamp.inc @@ -348,7 +348,7 @@ HurtPlayersInVolume(volume_index) { if (IsClientInGame(x) && IsPlayerAlive(x) && - IsPlayerHuman(x)) + InfectIsClientHuman(x)) { if (IsPlayerInVolume(x, volume_index)) { diff --git a/src/zr/antistick.inc b/src/zr/antistick.inc index 96254f2..724e5bb 100644 --- a/src/zr/antistick.inc +++ b/src/zr/antistick.inc @@ -84,7 +84,7 @@ AntiStickIsStuck(client) if (clientloc[2] <= stuckloc[2]) { new Float:eyeloc[3]; - GetPlayerEyePosition(client, eyeloc); + GetClientEyePosition(client, eyeloc); // Get the distance between the eyes and feet and subtract the stack "view crush." new Float:eyedistance = FloatAbs(eyeloc[2] - clientloc[2]) - PLAYER_HULL_STACK_OFFSET; diff --git a/src/zr/commands.inc b/src/zr/commands.inc index 7662c21..c326a90 100644 --- a/src/zr/commands.inc +++ b/src/zr/commands.inc @@ -71,7 +71,7 @@ public Action:Command_Infect(client, argc) for (new x = 0; x < tcount; x++) { - InfectPlayer(targets[x]); + InfectClient(targets[x]); if (LogCheckFlag(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS)) { GetClientName(targets[x], target_name, sizeof(target_name)); @@ -292,7 +292,7 @@ public Action:Command_GetClassKnockback(client, argc) public Action:Command_AdminMenu(client, argc) { - if (ZRIsValidClient(client)) + if (ZRIsClientValid(client)) { ZRAdminMenu(client); } @@ -306,7 +306,7 @@ public Action:Command_AdminMenu(client, argc) public Action:Command_KnockbackMMenu(client, argc) { - if (ZRIsValidClient(client)) + if (ZRIsClientValid(client)) { // Disabled, under construction. // ZRKnockbackMMenu(client); @@ -321,7 +321,7 @@ public Action:Command_KnockbackMMenu(client, argc) public Action:Command_TeleMenu(client, argc) { - if (ZRIsValidClient(client)) + if (ZRIsClientValid(client)) { ZRZTeleMenu(client); } diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 6bcebe4..dca2d8f 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -9,26 +9,40 @@ * ============================================================================ */ +/** + * @section Locked cvar value defines. + */ +#define CVARS_AUTOTEAMBALANCE_LOCKED 0 +#define CVARS_LIMITTEAMS_LOCKED 0 +/** + * @endsection + */ + /** * List of cvars used by the plugin. */ enum CvarsList { Handle:CVAR_ENABLE, - Handle:CVAR_LOG, - Handle:CVAR_LOGFLAGS, - Handle:CVAR_ROUNDEND_OVERLAY, - Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE, - Handle:CVAR_ROUNDEND_OVERLAY_HUMAN, Handle:CVAR_CLASSES_SPAWN, Handle:CVAR_CLASSES_RANDOM, Handle:CVAR_CLASSES_DEFAULT_ZOMBIE, Handle:CVAR_CLASSES_DEFAULT_HUMAN, Handle:CVAR_CLASSES_DEFAULT_ADMIN, Handle:CVAR_CLASSES_FILE, + Handle:CVAR_WEAPONS, + Handle:CVAR_WEAPONS_RESTRICT, + Handle:CVAR_WEAPONS_ZMARKET_BUYZONE, + Handle:CVAR_HITGROUPS, + Handle:CVAR_DAMAGE_HITGROUPS, + Handle:CVAR_DAMAGE_BLOCK_FF, + Handle:CVAR_DAMAGE_BLOCK_BLAST, Handle:CVAR_DAMAGE_SUICIDE_ZOMBIE, Handle:CVAR_DAMAGE_SUICIDE_HUMAN, Handle:CVAR_DAMAGE_SUICIDE_CMDS, + Handle:CVAR_ROUNDEND_OVERLAY, + Handle:CVAR_ROUNDEND_OVERLAY_ZOMBIE, + Handle:CVAR_ROUNDEND_OVERLAY_HUMAN, Handle:CVAR_INFECT_SPAWNTIME_MIN, Handle:CVAR_INFECT_SPAWNTIME_MAX, Handle:CVAR_INFECT_CONSECUTIVE_BLOCK, @@ -43,15 +57,23 @@ enum CvarsList Handle:CVAR_INFECT_SHAKE_AMP, Handle:CVAR_INFECT_SHAKE_FREQUENCY, Handle:CVAR_INFECT_SHAKE_DURATION, - Handle:CVAR_WEAPONS, - Handle:CVAR_WEAPONS_RESTRICT, - Handle:CVAR_WEAPONS_ZMARKET_BUYZONE, - Handle:CVAR_HITGROUPS, Handle:CVAR_ACCOUNT_CASHFILL, Handle:CVAR_ACCOUNT_CASHFILL_VALUE, - Handle:CVAR_SOUNDEFFECTS_MOAN, - Handle:CVAR_SOUNDEFFECTS_GROAN, - Handle:CVAR_SOUNDEFFECTS_DEATH, + Handle:CVAR_VEFFECTS_LIGHTSTYLE, + Handle:CVAR_VEFFECTS_LIGHTSTYLE_VALUE, + Handle:CVAR_VEFFECTS_SKY, + Handle:CVAR_VEFFECTS_SKY_PATH, + Handle:CVAR_VEFFECTS_FOG, + Handle:CVAR_VEFFECTS_FOG_OVERRIDE, + Handle:CVAR_VEFFECTS_FOG_PCOLOR, + Handle:CVAR_VEFFECTS_FOG_SCOLOR, + Handle:CVAR_VEFFECTS_FOG_DENSITY, + Handle:CVAR_VEFFECTS_FOG_STARTDIST, + Handle:CVAR_VEFFECTS_FOG_ENDDIST, + Handle:CVAR_VEFFECTS_FOG_FARZ, + Handle:CVAR_SEFFECTS_MOAN, + Handle:CVAR_SEFFECTS_GROAN, + Handle:CVAR_SEFFECTS_DEATH, Handle:CVAR_AMBIENTSOUNDS, Handle:CVAR_AMBIENTSOUNDS_FILE, Handle:CVAR_AMBIENTSOUNDS_LENGTH, @@ -71,9 +93,6 @@ enum CvarsList Handle:CVAR_OVERLAY_REDISPLAY, Handle:CVAR_ZVISION_ALLOW_DISABLE, Handle:CVAR_MENU_AUTOCLOSE, - Handle:CVAR_DARK, - Handle:CVAR_DARK_LEVEL, - Handle:CVAR_DARK_SKY, Handle:CVAR_ZSPAWN, Handle:CVAR_ZTELE, Handle:CVAR_ZTELE_STARTUP_DELAY, @@ -92,10 +111,37 @@ enum CvarsList */ new g_hCvarsList[CvarsList]; +/** + * @section Global cvar handles. + */ +new Handle:g_hAutoTeamBalance = INVALID_HANDLE; +new Handle:g_hLimitTeams = INVALID_HANDLE; +new Handle:g_hRestartGame = INVALID_HANDLE; +/** + * @endsection + */ + /** * Cvars module init function. - */ + */ CvarsInit() +{ + // Retrieve handles of CS:S cvars. + g_hAutoTeamBalance = FindConVar("mp_autoteambalance"); + g_hLimitTeams = FindConVar("mp_limitteams"); + g_hRestartGame = FindConVar("mp_restartgame"); + + // Create zombiereloaded cvars. + CvarsCreate(); + + // Hook cvars. + CvarsHook(); +} + +/** + * Create all cvars for plugin. + */ +CvarsCreate() { // Cvar naming guidelines: // 1. Prefix: "zr_" @@ -121,10 +167,8 @@ CvarsInit() // =========================== // Log (core) // =========================== - - g_hCvarsList[CVAR_LOG] = CreateConVar("zr_log", "1", ""); - g_hCvarsList[CVAR_LOGFLAGS] = CreateConVar("zr_logflags", "331", ""); - // Old Desc: Logging flags. Log messages to sourcemod logs, server console or client console. Use zr_log_flags to see a list of flags. (0: Disable) + + // Cvars created in log.inc, because of compilation problems when creating them here. // =========================== // Translations (core) @@ -132,17 +176,6 @@ CvarsInit() // (None) - // =========================== - // Round End (core) - // =========================== - - g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", ""); - // Old Desc: Shows an overlay to all clients when a team wins. (0: Disable) - g_hCvarsList[CVAR_ROUNDEND_OVERLAY_HUMAN] = CreateConVar("zr_roundend_overlays_human", ""); - // Old Desc: overlays/zr/humans_win", "Path to \"humans win\" overlay - g_hCvarsList[CVAR_ROUNDEND_OVERLAY_ZOMBIE] = CreateConVar("zr_roundend_overlays_zombie", "overlays/zr/zombies_win", ""); - // Old Desc: Path to \"zombies win\" overlay - // =========================== // Offsets (core) // =========================== @@ -172,39 +205,6 @@ CvarsInit() g_hCvarsList[CVAR_CLASSES_FILE] = CreateConVar("zr_classes_file", "configs/zr/playerclasses.txt", ""); // Old Desc: Class data file to read from, in Valves key/values format. The path is relative to the \"sourcemod\" folder. - // =========================== - // Damage (core) - // =========================== - - g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE] = CreateConVar("zr_damage_suicide_zombie", "1", ""); - // Old Desc: Intercept human suicide attempts. - g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "1", ""); - // Old Desc: Intercept zombie suicide attempts. - g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam", ""); - // Old Desc: List of suicide commands to intercept. (Delimited by \", \" - - // =========================== - // Infect (core) - // =========================== - - g_hCvarsList[CVAR_INFECT_MZOMBIE_RATIO] = CreateConVar("zr_infect_motherzombie_ratio", "5", ""); - g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN] = CreateConVar("zr_infect_motherzombie_respawn", "0", ""); - g_hCvarsList[CVAR_INFECT_SPAWNTIME_MIN] = CreateConVar("zr_infect_spawntime_min", "30.0", ""); - g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", ""); - g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", ""); - - // Effects - - g_hCvarsList[CVAR_INFECT_FIREBALL] = CreateConVar("zr_infect_fireball", "1", ""); - g_hCvarsList[CVAR_INFECT_SMOKE] = CreateConVar("zr_infect_smoke", "1", ""); - g_hCvarsList[CVAR_INFECT_SPARKS] = CreateConVar("zr_infect_sparks", "1", ""); - g_hCvarsList[CVAR_INFECT_SOUND] = CreateConVar("zr_infect_sound", "npc/fast_zombie/fz_scream1.wav", ""); - g_hCvarsList[CVAR_INFECT_ESPLASH] = CreateConVar("zr_infect_esplash", "1", ""); - g_hCvarsList[CVAR_INFECT_SHAKE] = CreateConVar("zr_infect_shake", "1", ""); - g_hCvarsList[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", ""); - g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", ""); - g_hCvarsList[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", ""); - // =========================== // Weapons (core) // =========================== @@ -232,6 +232,62 @@ CvarsInit() g_hCvarsList[CVAR_HITGROUPS] = CreateConVar("zr_hitgroups", "1", ""); // Note make config file cvar. + // =========================== + // Round End (core) + // =========================== + + g_hCvarsList[CVAR_ROUNDEND_OVERLAY] = CreateConVar("zr_roundend_overlay", "1", ""); + // Old Desc: Shows an overlay to all clients when a team wins. (0: Disable) + g_hCvarsList[CVAR_ROUNDEND_OVERLAY_HUMAN] = CreateConVar("zr_roundend_overlays_human", "overlays/zr/humans_win"); + // Old Desc: overlays/zr/humans_win", "Path to \"humans win\" overlay + g_hCvarsList[CVAR_ROUNDEND_OVERLAY_ZOMBIE] = CreateConVar("zr_roundend_overlays_zombie", "overlays/zr/zombies_win", ""); + // Old Desc: Path to \"zombies win\" overlay + + // =========================== + // Infect (core) + // =========================== + + g_hCvarsList[CVAR_INFECT_MZOMBIE_RATIO] = CreateConVar("zr_infect_mzombie_ratio", "5", ""); + g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN] = CreateConVar("zr_infect_mzombie_respawn", "0", ""); + g_hCvarsList[CVAR_INFECT_SPAWNTIME_MIN] = CreateConVar("zr_infect_spawntime_min", "30.0", ""); + g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", ""); + g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", ""); + + // Effects + + g_hCvarsList[CVAR_INFECT_FIREBALL] = CreateConVar("zr_infect_fireball", "1", ""); + g_hCvarsList[CVAR_INFECT_SMOKE] = CreateConVar("zr_infect_smoke", "1", ""); + g_hCvarsList[CVAR_INFECT_SPARKS] = CreateConVar("zr_infect_sparks", "1", ""); + g_hCvarsList[CVAR_INFECT_SOUND] = CreateConVar("zr_infect_sound", "npc/fast_zombie/fz_scream1.wav", ""); + g_hCvarsList[CVAR_INFECT_ESPLASH] = CreateConVar("zr_infect_esplash", "1", ""); + g_hCvarsList[CVAR_INFECT_SHAKE] = CreateConVar("zr_infect_shake", "1", ""); + g_hCvarsList[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", ""); + g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", ""); + g_hCvarsList[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", ""); + + // =========================== + // Damage (core) + // =========================== + + // Hitgroup Damage + + g_hCvarsList[CVAR_DAMAGE_HITGROUPS] = CreateConVar("zr_damage_hitgroups", "1", ""); + + // Block Damage Types + + g_hCvarsList[CVAR_DAMAGE_BLOCK_FF] = CreateConVar("zr_damage_block_ff", "1", ""); + // note overrides mp_friendlyfire + g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST] = CreateConVar("zr_damage_block_blast", "1", ""); + + // Suicide Intercept + + g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE] = CreateConVar("zr_damage_suicide_zombie", "1", ""); + // Old Desc: Intercept human suicide attempts. + g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "1", ""); + // Old Desc: Intercept zombie suicide attempts. + g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam", ""); + // Old Desc: List of suicide commands to intercept. (Delimited by \", \" + // =========================== // Account (module) // =========================== @@ -241,17 +297,44 @@ CvarsInit() g_hCvarsList[CVAR_ACCOUNT_CASHFILL_VALUE] = CreateConVar("zr_account_cashfill_value", "12000", ""); // Old Desc: How much money players will have when they spawn when zr_cashfill is 1 + // =========================== + // Visual Effects (module) + // =========================== + + // Lightstyle + + g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE] = CreateConVar("zr_veffects_lightstyle", "0", ""); + g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE] = CreateConVar("zr_veffects_lightstyle_value", "a", ""); + + // Sky + + g_hCvarsList[CVAR_VEFFECTS_SKY] = CreateConVar("zr_veffects_sky", "1", ""); + g_hCvarsList[CVAR_VEFFECTS_SKY_PATH] = CreateConVar("zr_veffects_sky_path", "sky_fake_white.vmt", ""); + + // Fog + + g_hCvarsList[CVAR_VEFFECTS_FOG] = CreateConVar("zr_veffects_fog", "0", ""); + // NOTE DISABLE. SOURCEMOD DOESNT SUPPORT THIS YET. + g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE] = CreateConVar("zr_veffects_fog_override", "0", ""); + // NOTE DISABLE. SOURCEMOD DOESNT SUPPORT THIS YET. + g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR] = CreateConVar("zr_veffects_fog_pcolor", "255 255 255", ""); + g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR] = CreateConVar("zr_veffects_fog_scolor", "255 255 255", ""); + g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY] = CreateConVar("zr_veffects_fog_density", "0.8", ""); + g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST] = CreateConVar("zr_veffects_fog_startdist", "0", ""); + g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST] = CreateConVar("zr_veffects_fog_enddist", "400", ""); + g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ] = CreateConVar("zr_veffects_fog_farz", "2000", ""); + // =========================== // Sound Effects (module) // =========================== // Zombie Sounds - g_hCvarsList[CVAR_SOUNDEFFECTS_MOAN] = CreateConVar("zr_soundeffects_moan", "30", ""); + g_hCvarsList[CVAR_SEFFECTS_MOAN] = CreateConVar("zr_seffects_moan", "30", ""); // Old Desc: How often, in seconds, a zombie moans (0: Disable) - g_hCvarsList[CVAR_SOUNDEFFECTS_GROAN] = CreateConVar("zr_soundeffects_groan", "5", ""); + g_hCvarsList[CVAR_SEFFECTS_GROAN] = CreateConVar("zr_seffects_groan", "5", ""); // Old Desc: Chance factor a zombie will groan when shot (Lower: More often, 0: Disable) - g_hCvarsList[CVAR_SOUNDEFFECTS_DEATH] = CreateConVar("zr_soundeffects_death", "1", ""); + g_hCvarsList[CVAR_SEFFECTS_DEATH] = CreateConVar("zr_seffects_death", "1", ""); // Old Desc: Zombie will emit a death sound when killed (0: Disable) // Ambient Sounds @@ -323,12 +406,6 @@ CvarsInit() // Old Desc: Allow users to disable ZVision with their nightvision key (0: Disable) g_hCvarsList[CVAR_MENU_AUTOCLOSE] = CreateConVar("zr_menu_autoclose", "0", ""); // Old Desc: Automatically close menus on selection. If disabled the menu will remain open. - g_hCvarsList[CVAR_DARK] = CreateConVar("zr_dark", "0", ""); - // Old Desc: Default value for darkening maps, most dislike this feature (0: Disable) - g_hCvarsList[CVAR_DARK_LEVEL] = CreateConVar("zr_dark_level", "a", ""); - // Old Desc: The darkness of the map, a being the darkest, z being extremely bright when zr_dark is 1 (n: Default) - g_hCvarsList[CVAR_DARK_SKY] = CreateConVar("zr_dark_sky", "sky_borealis01", ""); - // Old Desc: The sky the map will have when zr_dark is 1 g_hCvarsList[CVAR_ZSPAWN] = CreateConVar("zr_zspawn", "1", ""); // Old Desc: Allow players to spawn if they just joined the game (0: Disable) g_hCvarsList[CVAR_ZTELE] = CreateConVar("zr_tele", "1", ""); @@ -352,53 +429,105 @@ CvarsInit() g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL] = CreateConVar("zr_anticamp_update_interval", "1", ""); // Old Desc: How often to update player locations (in seconds). - // TODO: Recode. - //HookConVarChange(g_hCvarsList[CVAR_ENABLE], EnableHook); - + // Auto-generate config file if it doesn't exist, then execute. AutoExecConfig(true, "zombiereloaded", "sourcemod/zombiereloaded"); } -CvarsHook() -{ - SetConVarBool(FindConVar("mp_autoteambalance"), false); - SetConVarInt(FindConVar("mp_limitteams"), 0); +/** + * Hook cvar changes. + * + * @param unhook If true, cvars will be unhooked, false to hook cvars. + */ +CvarsHook(bool:unhook = false) +{ + // If unhook is true, then continue. + if (unhook) + { + // Unhook all cvars. + UnhookConVarChange(g_hAutoTeamBalance, CvarsHookLocked); + UnhookConVarChange(g_hLimitTeams, CvarsHookLocked); + UnhookConVarChange(g_hRestartGame, CvarsHookRestartGame); + + // Stop after unhooking cvars. + return; + } - HookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook); - HookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook); + // Set locked cvars to their locked value. + SetConVarInt(g_hAutoTeamBalance, CVARS_AUTOTEAMBALANCE_LOCKED); + SetConVarInt(g_hLimitTeams, CVARS_LIMITTEAMS_LOCKED); + // Hook cvar to prevent it from changing. + HookConVarChange(g_hAutoTeamBalance, CvarsHookLocked); + //HookConVarChange(hLimitTeams, CvarsHookLocked); + HookConVarChange(g_hRestartGame, CvarsHookRestartGame); + + // Anticamp shtuff. (needs to be moved to anticamp if these hooks are necessary) HookConVarChange(g_hCvarsList[CVAR_ANTICAMP], AnticampHook); HookConVarChange(g_hCvarsList[CVAR_ANTICAMP_UPDATE_INTERVAL], UpdateIntervalHook); } -CvarsUnhook() +/** + * Cvar hook callback (mp_autoteambalance, mp_limitteams) + * Prevents changes to cvar. + * + * @param convar The cvar handle. + * @param oldvalue The value before the attempted change. + * @param newvalue The new value. + */ +public CvarsHookLocked(Handle:cvar, const String:oldvalue[], const String:newvalue[]) { - UnhookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook); - UnhookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook); -} - -/*public EnableHook(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - new bool:enable = bool:StringToInt(newValue); - - if (enable) + // If cvar is mp_autoteambalance, then continue. + if (cvar == g_hAutoTeamBalance) { - HookEvents(); - HookCvars(); + // Revert to locked value. + SetConVarInt(g_hAutoTeamBalance, CVARS_AUTOTEAMBALANCE_LOCKED); - TerminateRound(3.0, Game_Commencing); + // If log flag check fails, then don't log. + if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CORE)) + { + LogMessageFormatted(-1, "Cvars", "Cvar Locked", "Cvar \"mp_autoteambalance\" was reverted back to \"CVARS_AUTOTEAMBALANCE_LOCKED\".", LOG_FORMAT_TYPE_FULL); + } } - else + // If cvar is mp_limitteams, then continue. + else if (cvar == g_hLimitTeams) { - ZREnd(); + // Revert to locked value. + SetConVarInt(g_hLimitTeams, CVARS_LIMITTEAMS_LOCKED); + + // If log flag check fails, then don't log. + if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CORE)) + { + LogMessageFormatted(-1, "Cvars", "Cvar Locked", "Cvar \"mp_limitteams\" was reverted back to \"CVARS_LIMITTEAMS_LOCKED\".", LOG_FORMAT_TYPE_FULL); + } } -}*/ - -public AutoTeamBalanceHook(Handle:convar, const String:oldValue[], const String:newValue[]) -{ - SetConVarBool(FindConVar("mp_autoteambalance"), false); } -public LimitTeamsHook(Handle:convar, const String:oldValue[], const String:newValue[]) +/** + * Cvar hook callback (mp_restartgame) + * Stops restart and just ends the round. + * + * @param convar The cvar handle. + * @param oldvalue The value before the attempted change. + * @param newvalue The new value. + */ +public CvarsHookRestartGame(Handle:cvar, const String:oldvalue[], const String:newvalue[]) { - SetConVarInt(FindConVar("mp_limitteams"), 0); + // Prevent round restart. + SetConVarInt(cvar, 0); + + // If value was invalid or 0, then stop. + new Float:delay = StringToFloat(newvalue); + if (delay <= 0) + { + return; + } + + // Terminate the round with restart time as delay. + RoundEndRestart(delay); + + // If log flag check fails, then don't log. + if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CORE)) + { + LogMessageFormatted(-1, "Cvars", "Restart Game", "\"mp_restartgame\" was caught and blocked, commencing round.", LOG_FORMAT_TYPE_FULL); + } } \ No newline at end of file diff --git a/src/zr/damage.inc b/src/zr/damage.inc index 5f693ee..ff3603f 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -108,22 +108,54 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup) // new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]); // If attacker isn't valid, then stop. - if (!ZRIsValidClient(attacker)) + if (!ZRIsClientValid(attacker)) + { + return Hacks_Continue; + } + + // If client is attacking himself, then stop. + if(attacker == client) { return Hacks_Continue; } // Get zombie flag for each client. - new bool:clientzombie = IsPlayerZombie(client); - new bool:attackerzombie = IsPlayerZombie(attacker); + new bool:clientzombie = InfectIsClientInfected(client); + new bool:attackerzombie = InfectIsClientInfected(attacker); // If the flags are the same on both clients, then stop. if (clientzombie == attackerzombie) { + // If friendly fire is blocked, then allow damage. + new bool:damageblockff = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_FF]); + if (!damageblockff) + { + return Hacks_Continue; + } + + // Stop bullet from hurting client. return 0; } - // Players are on differen't teams. + // Here we know that attacker and client are different teams. + + // If damage hitgroups cvar is disabled, then allow damage. + new bool:damagehitgroups = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_HITGROUPS]); + if (!damagehitgroups) + { + // Allow damage. + return Hacks_Continue; + } + + // If damage is disabled for this hitgroup, then stop. + new bool:candamage = HitgroupsCanDamageHitgroup(hitgroup); + if (!candamage) + { + // Stop bullet from hurting client. + return 0; + } + + // Allow damage. return Hacks_Continue; } @@ -160,55 +192,18 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot return Hacks_Continue; } - // Client was damaged by falling. - if (damagetype & DMG_FALL) - { - // If client isn't a zombie, then allow damage. - if (!IsPlayerZombie(client)) - { - return Hacks_Continue; - } - - // If class has "nofalldamage" disabled, then allow damage. - new bool:blockfalldamage = ClassGetNoFallDamage(client); - if (!blockfalldamage) - { - return Hacks_Continue; - } - - // Stop damage. - return 0; - } - // Client was damaged by explosion. - else if (damagetype & DMG_BLAST) - { - // If attacker isn't valid, then allow damage. - if (!ZRIsValidClient(attacker)) - { - return Hacks_Continue; - } - - // If client is a zombie, then allow damage. - if (IsPlayerZombie(client)) - { - return Hacks_Continue; - } - - // Stop damage. - return 0; - } // Client was shot or knifed. - else if (damagetype & DMG_BULLET) + if (damagetype & DMG_BULLET) { // If attacker isn't valid, then allow damage. - if (!ZRIsValidClient(attacker)) + if (!ZRIsClientValid(attacker)) { return Hacks_Continue; } // Get zombie flag for each client. - new bool:clientzombie = IsPlayerZombie(client); - new bool:attackerzombie = IsPlayerZombie(attacker); + new bool:clientzombie = InfectIsClientInfected(client); + new bool:attackerzombie = InfectIsClientInfected(attacker); // If client and attacker are on the same team, then let CS:S handle the rest. if (clientzombie == attackerzombie) @@ -231,6 +226,50 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot // Allow damage. return Hacks_Continue; } + // Client was damaged by explosion. + else if (damagetype & DMG_BLAST) + { + // If blast damage is blocked, then stop. + new bool:damageblockblast = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST]); + if (!damageblockblast) + { + return Hacks_Continue; + } + + // If attacker isn't valid, then allow damage. + if (!ZRIsClientValid(attacker)) + { + return Hacks_Continue; + } + + // If client is a zombie, then allow damage. + if (InfectIsClientInfected(client)) + { + return Hacks_Continue; + } + + // Stop damage. + return 0; + } + // Client was damaged by falling. + else if (damagetype & DMG_FALL) + { + // If client isn't a zombie, then allow damage. + if (!InfectIsClientInfected(client)) + { + return Hacks_Continue; + } + + // If class has "nofalldamage" disabled, then allow damage. + new bool:blockfalldamage = ClassGetNoFallDamage(client); + if (!blockfalldamage) + { + return Hacks_Continue; + } + + // Stop damage. + return 0; + } // Allow damage. return Hacks_Continue; @@ -260,7 +299,7 @@ public Action:DamageSuicideIntercept(client, argc) } // If client is invalid, then stop. (Stop console.) - if (!ZRIsValidClient(client)) + if (!ZRIsClientValid(client)) { return Plugin_Continue; } @@ -272,7 +311,7 @@ public Action:DamageSuicideIntercept(client, argc) } // Get zombie flag on client. - new bool:clientzombie = IsPlayerZombie(client); + new bool:clientzombie = InfectIsClientInfected(client); // Get cvar values for suicide interception. new bool:suicidezombie = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE]); diff --git a/src/zr/event.inc b/src/zr/event.inc index 77ed8af..092cc69 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -1,51 +1,89 @@ -/** - * ==================== +/* + * ============================================================================ + * * Zombie:Reloaded - * File: events.inc - * Author: Greyscale - * ==================== + * + * File: (Core) event.inc + * Description: Event hooking and forwarding. + * + * ============================================================================ */ -HookEvents() +/** + * Init function for event module. + */ +EventInit() { - HookEvent("round_start", RoundStart); - HookEvent("round_freeze_end", RoundFreezeEnd); - HookEvent("round_end", RoundEnd); - HookEvent("player_team", PlayerTeam, EventHookMode_Pre); - HookEvent("player_spawn", PlayerSpawn); - HookEvent("player_hurt", PlayerHurt); - HookEvent("player_death", PlayerDeath); - HookEvent("player_jump", PlayerJump); - HookEvent("weapon_fire", WeaponFire); + // Hook all events used by plugin. + EventHook(); } -UnhookEvents() +/** + * Hook events used by plugin. + * + * @param unhook If true, then unhook all events, if false, then hook. + */ +EventHook(bool:unhook = false) { - UnhookEvent("round_start", RoundStart); - UnhookEvent("round_freeze_end", RoundFreezeEnd); - UnhookEvent("round_end", RoundEnd); - UnhookEvent("player_team", PlayerTeam, EventHookMode_Pre); - UnhookEvent("player_spawn", PlayerSpawn); - UnhookEvent("player_hurt", PlayerHurt); - UnhookEvent("player_death", PlayerDeath); - UnhookEvent("player_jump", PlayerJump); - UnhookEvent("weapon_fire", WeaponFire); -} - -public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast) -{ - ChangeLightStyle(); + // If unhook is true, then continue. + if (unhook) + { + // Unhook all events. + UnhookEvent("round_start", EventRoundStart); + UnhookEvent("round_freeze_end", EventRoundFreezeEnd); + UnhookEvent("round_end", EventRoundEnd); + UnhookEvent("player_team", EventPlayerTeam, EventHookMode_Pre); + UnhookEvent("player_spawn", EventPlayerSpawn); + UnhookEvent("player_hurt", EventPlayerHurt); + UnhookEvent("player_death", EventPlayerDeath); + UnhookEvent("player_jump", EventPlayerJump); + UnhookEvent("weapon_fire", EventWeaponFire); + + // Stop after unhooking events. + return; + } + // Hook all events used by plugin. + HookEvent("round_start", EventRoundStart); + HookEvent("round_freeze_end", EventRoundFreezeEnd); + HookEvent("round_end", EventRoundEnd); + HookEvent("player_team", EventPlayerTeam, EventHookMode_Pre); + HookEvent("player_spawn", EventPlayerSpawn); + HookEvent("player_hurt", EventPlayerHurt); + HookEvent("player_death", EventPlayerDeath); + HookEvent("player_jump", EventPlayerJump); + HookEvent("weapon_fire", EventWeaponFire); +} + +/** + * Event callback (round_start) + * The round is starting. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) +{ ZR_PrintToChat(0, "Round objective"); // Forward event to sub-modules. RoundEndOnRoundStart(); InfectOnRoundStart(); + VEffectsOnRoundStart(); SEffectsOnRoundStart(); AntiStickOnRoundStart(); } -public Action:RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast) +/** + * Event callback (round_freeze_end) + * The freeze time is ending. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventRoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast) { RemoveObjectives(); @@ -56,7 +94,15 @@ public Action:RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadca } -public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) +/** + * Event callback (round_end) + * The round is ending. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) { // Get all required event info. new reason = GetEventInt(event, "reason"); @@ -64,10 +110,19 @@ public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) // Forward event to modules. RoundEndOnRoundEnd(reason); InfectOnRoundEnd(); + RespawnOnRoundEnd(); ZTeleReset(); } -public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) +/** + * Event callback (player_team) + * Client is joining a team. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) { // Get all required event info. new index = GetClientOfUserId(GetEventInt(event, "userid")); @@ -79,7 +134,15 @@ public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) return Plugin_Handled; } -public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) +/** + * Event callback (player_spawn) + * Client is spawning into the game. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) { // Get all required event info. new index = GetClientOfUserId(GetEventInt(event, "userid")); @@ -122,7 +185,15 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) ZR_PrintToChat(index, "!zmenu reminder"); } -public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) +/** + * Event callback (player_hurt) + * Client is being hurt. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) { // Get all required event info. new index = GetClientOfUserId(GetEventInt(event, "userid")); @@ -130,7 +201,7 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) new hitgroup = GetEventInt(event, "hitgroup"); new dmg_health = GetEventInt(event, "dmg_health"); - decl String:weapon[32]; + decl String:weapon[WEAPONS_MAX_LENGTH]; GetEventString(event, "weapon", weapon, sizeof(weapon)); // Forward event to modules. @@ -142,10 +213,18 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) ZHPOnClientHurt(index); } -public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) +/** + * Event callback (player_death) + * Client has been killed. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) { // Get the weapon name. - decl String:weapon[32]; + decl String:weapon[WEAPONS_MAX_LENGTH]; GetEventString(event, "weapon", weapon, sizeof(weapon)); // If client is being infected, then stop. @@ -162,10 +241,10 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) ExtinguishEntity(index); // If the attacker is valid, then continue. - if (ZRIsValidClient(attacker)) + if (ZRIsClientValid(attacker)) { // If the client is a zombie, then continue. - if (IsPlayerZombie(index)) + if (InfectIsClientInfected(index)) { // Add kill bonus to attacker's score. new bonus = ClassGetKillBonus(attacker); @@ -182,7 +261,15 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) ZHPOnClientDeath(index); } -public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast) +/** + * Event callback (player_jump) + * Client is jumping. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventPlayerJump(Handle:event, const String:name[], bool:dontBroadcast) { // Get all required event info. new client = GetClientOfUserId(GetEventInt(event, "userid")); @@ -193,7 +280,15 @@ public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast) JumpBoost(client, distance, height); } -public Action:WeaponFire(Handle:event, const String:name[], bool:dontBroadcast) +/** + * Event callback (weapon_fire) + * Weapon has been fired. + * + * @param event The event handle. + * @param name Name of the event. + * @dontBroadcast If true, event is broadcasted to all clients, false if not. + */ +public Action:EventWeaponFire(Handle:event, const String:name[], bool:dontBroadcast) { // Get all required event info. decl String:weapon[32]; diff --git a/src/zr/hitgroups.inc b/src/zr/hitgroups.inc index 267430c..0d2f724 100644 --- a/src/zr/hitgroups.inc +++ b/src/zr/hitgroups.inc @@ -82,7 +82,7 @@ HitgroupsLoad() */ HitgroupsValidateConfig() { - // If log flag check fails, don't log. + // If log flag check fails, then don't log. if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_HITGROUPS)) { return; @@ -99,7 +99,8 @@ HitgroupsValidateConfig() * Retrieve hitgroup knockback value. * * @param hitgroup The hitgroup index. - */ + * @return The knockback multiplier of the hitgroup. + */ Float:HitgroupsGetHitgroupKnockback(hitgroup) { // Reset keyvalue's traversal stack. @@ -121,4 +122,39 @@ Float:HitgroupsGetHitgroupKnockback(hitgroup) } return 1.0; +} + +/** + * Retrieve hitgroup damage value. + * + * @param hitgroup The hitgroup index. + * @return True if hitgroup can be damaged, false if not. + */ +bool:HitgroupsCanDamageHitgroup(hitgroup) +{ + // Reset keyvalue's traversal stack. + KvRewind(kvHitgroups); + if (KvGotoFirstSubKey(kvHitgroups)) + { + decl String:sHitgroup[4]; + decl String:damage[8]; + + do + { + KvGetSectionName(kvHitgroups, sHitgroup, sizeof(sHitgroup)); + + // If this is the right hitgroup, then return knockback for it. + if (hitgroup == StringToInt(sHitgroup)) + { + // Get config setting string. + KvGetString(kvHitgroups, "damage", damage, sizeof(damage), "yes"); + + // Return hitgroup's damage setting. + return ZRConfigSettingToBool(damage); + } + } while (KvGotoNextKey(kvHitgroups)); + } + + // If hitgroup is missing, then default to "yes." + return true; } \ No newline at end of file diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 8eb57e8..369d20b 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -60,7 +60,13 @@ InfectOnMapStart() { // Reset timer handle. tInfect = INVALID_HANDLE; - +} + +/** + * Loads downloadable content data for infect module. + */ +InfectLoad() +{ // Get infection sound. decl String:sound[PLATFORM_MAX_PATH]; GetConVarString(g_hCvarsList[CVAR_INFECT_SOUND], sound, sizeof(sound)); @@ -117,7 +123,7 @@ InfectOnClientDisconnect(client) ZRCountValidClients(zombiecount, humancount); // If client is a human. - if (IsPlayerHuman(client)) + if (InfectIsClientHuman(client)) { // If there are other humans (ignoring this human), then stop. if (humancount > 1) @@ -170,7 +176,7 @@ InfectOnClientDisconnect(client) new randclient = GetArrayCell(arrayEligibleClients, randindex); // Infect player. - InfectPlayer(randclient); + InfectClient(randclient); // Tell client they have been randomly been chosen to replace disconnecting zombie. ZR_PrintToChat(randclient, "Zombie replacement"); @@ -217,19 +223,19 @@ InfectOnClientSpawn(client) InfectOnClientHurt(client, attacker, const String:weapon[]) { // If attacker isn't valid, then stop. - if (!ZRIsValidClient(attacker)) + if (!ZRIsClientValid(attacker)) { return; } // If client isn't a human, then stop. - if (!IsPlayerHuman(client)) + if (!InfectIsClientHuman(client)) { return; } // Attacker isn't a zombie, then stop. - if (!IsPlayerZombie(attacker)) + if (!InfectIsClientInfected(attacker)) { return; } @@ -247,7 +253,7 @@ InfectOnClientHurt(client, attacker, const String:weapon[]) } // Infect client. - InfectPlayer(client, attacker); + InfectClient(client, attacker); } /** @@ -264,19 +270,6 @@ InfectOnRoundStart() // Reset timer handle. tInfect = INVALID_HANDLE; } - - // x = client index. - for (new x = 1; x <= MaxClients; x++) - { - // If client isn't in-game, then stop. - if (!IsClientInGame(x)) - { - continue; - } - - // Disable zombie flag on client. - bZombie[x] = false; - } } /** @@ -419,7 +412,7 @@ public Action:InfectMotherZombie(Handle:timer) client = GetArrayCell(arrayEligibleClients, randindex); // Infect player. - InfectPlayer(client, _, true); + InfectClient(client, _, true); } else { @@ -431,7 +424,7 @@ public Action:InfectMotherZombie(Handle:timer) ZRCountValidClients(zombiecount, humancount, _, true); // Calculate mother zombie count. - new mothercount = RoundToCeil(float(humancount) / ratio); + new mothercount = RoundToNearest(float(humancount) / ratio); // x = current mother zombie count. for (new x = 0; x < mothercount; x++) @@ -451,7 +444,7 @@ public Action:InfectMotherZombie(Handle:timer) client = GetArrayCell(arrayEligibleClients, randindex); // Infect player. - InfectPlayer(client, _, true); + InfectClient(client, _, true); // Remove player from eligible zombie list. RemoveFromArray(arrayEligibleClients, randindex); @@ -473,7 +466,7 @@ public Action:InfectMotherZombie(Handle:timer) * @param attacker (Optional) The attacker who did the infect. * @param motherinfect (Optional) Indicates a mother zombie infect. */ -InfectPlayer(client, attacker = -1, bool:motherinfect = false) +InfectClient(client, attacker = -1, bool:motherinfect = false) { // Mark player as zombie. bZombie[client] = true; @@ -515,13 +508,10 @@ InfectPlayer(client, attacker = -1, bool:motherinfect = false) bInfectImmune[client][INFECT_TYPE_MOTHER] = infectconsecutiveblock ? motherinfect : false; // Apply effects. - InfectEffects(client); + InfectFireEffects(client); - // Add a death to the zombie's score. - AddPlayerDeath(client, 1); - - // Fire death event and set weapon info if the attacker is specified. - if (ZRIsValidClient(attacker)) + // If attacker is valid, then continue. + if (ZRIsClientValid(attacker)) { // Create and send custom player_death event. new Handle:event = CreateEvent("player_death"); @@ -536,6 +526,9 @@ InfectPlayer(client, attacker = -1, bool:motherinfect = false) // Give client's infector a point. AddPlayerScore(attacker, 1); + // Add a death to the zombie's score. + AddPlayerDeath(client, 1); + // Apply infect HP gain. new healthgain = ClassGetHealthInfectGain(attacker); new health = GetClientHealth(attacker); @@ -553,16 +546,10 @@ InfectPlayer(client, attacker = -1, bool:motherinfect = false) // Forward event to modules. ClassOnClientInfected(client, motherinfect); + RoundEndOnClientInfected(); SEffectsOnClientInfected(client); ZHPOnClientInfected(client); TeleportOnClientInfected(client); - - // Terminate the round if the last player was infected. - new RoundEndOutcome:outcome; - if (RoundEndGetRoundStatus(outcome)) - { - RoundEndTerminateRound(outcome); - } } /** @@ -570,9 +557,9 @@ InfectPlayer(client, attacker = -1, bool:motherinfect = false) * * @param client The client index. */ -InfectEffects(client) +InfectFireEffects(client) { - // Create location and direction arrays. + // Initialize vector variables. new Float:clientloc[3]; new Float:direction[3] = {0.0, 0.0, 0.0}; @@ -580,86 +567,96 @@ InfectEffects(client) GetClientAbsOrigin(client, clientloc); clientloc[2] += 30; - // Get infection sound. + // If cvar contains path, then continue. decl String:sound[PLATFORM_MAX_PATH]; GetConVarString(g_hCvarsList[CVAR_INFECT_SOUND], sound, sizeof(sound)); if (sound[0]) { + // Emit infect sound from infected client. SEffectsEmitSoundFromClient(client, sound, SNDLEVEL_SCREAMING); } - // Create an energy splash effect. + // If energy splash effect is enabled, then continue. new bool:esplash = GetConVarBool(g_hCvarsList[CVAR_INFECT_ESPLASH]); if (esplash) { - TE_SetupEnergySplash(clientloc, direction, true); - TE_SendToAll(); + // Create energy splash effect. + VEffectsCreateEnergySplash(clientloc, direction, true); } - // Create an explosion entity. - new explosion = CreateEntityByName("env_explosion"); + // Initialize explosion flags variable. + new flags; - // If explosion entity is valid, then continue. - if (explosion != -1) + // Set "nofireball" flag if fireball is disabled. + new bool:fireball = GetConVarBool(g_hCvarsList[CVAR_INFECT_FIREBALL]); + if (!fireball) { - // Get and set flags on explosion. - new flags = GetEntProp(explosion, Prop_Data, "m_spawnflags"); - flags = flags | EXP_NODAMAGE | EXP_NODECAL; - - // Set "nofireball" flag if fireball is disabled. - new bool:fireball = GetConVarBool(g_hCvarsList[CVAR_INFECT_FIREBALL]); - if (!fireball) - { - flags = flags | EXP_NOFIREBALL; - } - - // Set "nosmoke" flag if smoke is disabled. - new bool:smoke = GetConVarBool(g_hCvarsList[CVAR_INFECT_SMOKE]); - if (!smoke) - { - flags = flags | EXP_NOSMOKE; - } - - // Set "nosparks" flag if sparks are disabled. - new bool:sparks = GetConVarBool(g_hCvarsList[CVAR_INFECT_SPARKS]); - if (!sparks) - { - flags = flags | EXP_NOSPARKS; - } - - // Set new flags on entity. - SetEntProp(explosion, Prop_Data, "m_spawnflags", flags); - - // Spawn the entity into the world. - DispatchSpawn(explosion); - - // Precache fireball model. - PrecacheModel("materials/sprites/xfireball3.vmt"); - - // Set origin and explosion key values on entity. - DispatchKeyValueVector(explosion, "origin", clientloc); - DispatchKeyValue(explosion, "fireballsprite", "materials/sprites/xfireball3.vmt"); - - // Tell the entity to explode. - AcceptEntityInput(explosion, "Explode"); + flags = flags | EXP_NOFIREBALL; } + // Set "nosmoke" flag if smoke is disabled. + new bool:smoke = GetConVarBool(g_hCvarsList[CVAR_INFECT_SMOKE]); + if (!smoke) + { + flags = flags | EXP_NOSMOKE; + } + + // Set "nosparks" flag if sparks are disabled. + new bool:sparks = GetConVarBool(g_hCvarsList[CVAR_INFECT_SPARKS]); + if (!sparks) + { + flags = flags | EXP_NOSPARKS; + } + + // Create explosion at client's origin. + VEffectsCreateExplosion(clientloc, flags); + // If shake effect is enabled, then continue. new bool:shake = GetConVarBool(g_hCvarsList[CVAR_INFECT_SHAKE]); if (shake) { - // If shake usermsg isn't invalid, then continue. - new Handle:hShake = StartMessageOne("Shake", client); - if (hShake != INVALID_HANDLE) - { - // Write shake information to usermsg handle. - BfWriteByte(hShake, 0); - BfWriteFloat(hShake, GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_AMP])); - BfWriteFloat(hShake, GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY])); - BfWriteFloat(hShake, GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_DURATION])); - - // End usermsg and sent to client. - EndMessage(); - } + // Get shake info. + new Float:shakeamp = GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_AMP]); + new Float:shakefrequency = GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_FREQUENCY]); + new Float:shakeduration = GetConVarFloat(g_hCvarsList[CVAR_INFECT_SHAKE_DURATION]); + + // Shake client's screen. + VEffectsShakeClientScreen(client, shakeamp, shakefrequency, shakeduration); } +} + +/** + * Returns if a client is infected. + * + * @param client The client index. + * @return True if the client has been infected, false otherwise. + */ +bool:InfectIsClientInfected(client) +{ + // If client is invalid, then stop. + if (!ZRIsClientValid(client)) + { + return false; + } + + // Return client's zombie flag. + return bZombie[client]; +} + +/** + * Returns if a client is a human. + * + * @param client The client index. + * @return True if the client is a human, false otherwise. + */ +bool:InfectIsClientHuman(client) +{ + // If client is invalid, then stop. + if (!ZRIsClientValid(client)) + { + return true; + } + + // Return opposite of client's zombie flag. + return !bZombie[client]; } \ No newline at end of file diff --git a/src/zr/knockback.inc b/src/zr/knockback.inc index 9a1004d..3d9a703 100644 --- a/src/zr/knockback.inc +++ b/src/zr/knockback.inc @@ -17,19 +17,19 @@ KnockbackOnClientHurt(client, attacker, const String:weapon[], hitgroup, dmg_health) { // If attacker is invalid, then stop. - if (!ZRIsValidClient(attacker)) + if (!ZRIsClientValid(attacker)) { return; } // Client is a human, then stop. - if (IsPlayerHuman(client)) + if (InfectIsClientHuman(client)) { return; } // If attacker is a zombie, then stop. - if (IsPlayerZombie(attacker)) + if (InfectIsClientInfected(attacker)) { return; } @@ -55,7 +55,7 @@ KnockbackOnClientHurt(client, attacker, const String:weapon[], hitgroup, dmg_hea else { // Get attackers eye position. - GetPlayerEyePosition(attacker, attackerloc); + GetClientEyePosition(attacker, attackerloc); // Get attackers eye angles. new Float:attackerang[3]; diff --git a/src/zr/log.inc b/src/zr/log.inc index 8aeb64c..bcd8e80 100644 --- a/src/zr/log.inc +++ b/src/zr/log.inc @@ -57,7 +57,24 @@ /* * @endsection */ - + +/** + * @section Global handles for modules cvars. + */ +new Handle:g_hLog = INVALID_HANDLE; +new Handle:g_hLogFlags = INVALID_HANDLE; +/** + * @endsection + */ + +LogInit() +{ + // Create modules cvars. + g_hLog = CreateConVar("zr_log", "1", ""); + g_hLogFlags = CreateConVar("zr_logflags", "331", ""); + // Old Desc: Logging flags. Log messages to sourcemod logs, server console or client console. Use zr_log_flags to see a list of flags. (0: Disable) +} + /** * Logs a formatted message with module and block info depending, on the type. * @@ -75,39 +92,45 @@ LogMessageFormatted(client, const String:module[], const String:block[], const String:message[], type = LOG_FORMAT_TYPE_FULL, any:...) { // If logging is disabled, then stop. - new bool:log = GetConVarBool(g_hCvarsList[CVAR_LOG]); + new bool:log = GetConVarBool(g_hLog); if (!log) { return; } - decl String:buffer[LOG_MAX_LENGTH_FILE]; - decl String:text[LOG_MAX_LENGTH_FILE]; - - if (client == 0 && LogCheckFlag(LOG_IGNORE_CONSOLE)) + decl String:logtext[LOG_MAX_LENGTH_FILE]; + + // Set to true if log to console, false if client. + new bool:console = !ZRIsClientValid(client); + + // If client is invalid (console), and console is ignored, then stop. + if (console && LogCheckFlag(LOG_IGNORE_CONSOLE)) { return; } + // Format log text. + VFormat(logtext, sizeof(logtext), message, 6); + + // Format other parameters onto the log text. switch (type) { + // Log type is simple. case LOG_FORMAT_TYPE_SIMPLE: { - VFormat(buffer, sizeof(buffer), message, 6); - Format(text, sizeof(text), "%s", message); - LogMessage(text); + LogMessage(logtext); } + // Log type is full. case LOG_FORMAT_TYPE_FULL: { - VFormat(buffer, sizeof(buffer), message, 6); - Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer); - LogMessage(text); + Format(logtext, sizeof(logtext), "\"%s\" : \"%s\" -- %s", module, block, logtext); + LogMessage(logtext); } + // Log type is error. case LOG_FORMAT_TYPE_ERROR: { - VFormat(buffer, sizeof(buffer), message, 6); - Format(text, sizeof(text), "\"%s\" : \"%s\" -- %s", module, block, buffer); - LogError(text); + Format(logtext, sizeof(logtext), "\"%s\" : \"%s\" -- %s", module, block, logtext); + LogError(logtext); } } @@ -115,16 +138,17 @@ LogMessageFormatted(client, const String:module[], const String:block[], const S if (LogCheckFlag(LOG_TO_ADMINS)) { // Print text to admins. - LogToAdmins(text); + LogToAdmins(logtext); } - if (ZRIsValidClient(client) && LogCheckFlag(LOG_TO_CLIENT)) + // If client isn't console, and we log to client's then continue. + if (!console && LogCheckFlag(LOG_TO_CLIENT)) { // Set client as translation target. SetGlobalTransTarget(client); // Print to client. - PrintToConsole(client, "%t %s", "ZR", text); + PrintToConsole(client, "%t %s", "ZR", logtext); } } @@ -164,7 +188,7 @@ LogToAdmins(String:message[]) bool:LogHasFlag(flag) { // Get log flags. - new logflags = GetConVarInt(g_hCvarsList[CVAR_LOGFLAGS]); + new logflags = GetConVarInt(g_hLogFlags); // Return true if flag is found, false if not. return bool:(logflags & flag); @@ -174,9 +198,9 @@ bool:LogHasFlag(flag) * Check if a log message should be written depending on log flags. If module * overrides are enabled only logs with it's module flag set will be logged. * - * @param logtype Log type flag. - * @param module Specifies what module the log event belongs to. - * @return True if the event should be logged, false otherwise. + * @param logtype Log type flag. + * @param modulefilter Specifies what module the log event belongs to. + * @return True if the event should be logged, false otherwise. */ bool:LogCheckFlag(logtype, modulefilter = 0) { @@ -186,4 +210,29 @@ bool:LogCheckFlag(logtype, modulefilter = 0) } return LogHasFlag(logtype); +} + +/** + * Toggles a log flag. + * + * @param flag The flag to toggle. + */ +LogToggleFlag(flag) +{ + // Get current flags + new logflags = GetConVarInt(g_hLogFlags); + + // If cvar contains flag, then remove it. + if (logflags & flag) + { + logflags = logflags - flag; + } + // If cvar doesn't have the flag, then add it. + else + { + logflags = logflags + flag; + } + + // Set new value to logflags cvar. + SetConVarInt(g_hLogFlags, logflags); } \ No newline at end of file diff --git a/src/zr/napalm.inc b/src/zr/napalm.inc index 76187d3..fa0c851 100644 --- a/src/zr/napalm.inc +++ b/src/zr/napalm.inc @@ -23,7 +23,7 @@ NapalmOnClientHurt(client, const String:weapon[]) { // If player isn't a zombie, then stop. - if (!IsPlayerZombie(client)) + if (!InfectIsClientInfected(client)) { return; } diff --git a/src/zr/offsets.inc b/src/zr/offsets.inc index e3088d9..4544149 100644 --- a/src/zr/offsets.inc +++ b/src/zr/offsets.inc @@ -21,7 +21,6 @@ new offsRender; new offsActiveWeapon; new Handle:g_hGameConf = INVALID_HANDLE; -new Handle:g_hEyePosition = INVALID_HANDLE; new Handle:g_hEyeAngles = INVALID_HANDLE; new Handle:g_hTerminateRound = INVALID_HANDLE; new Handle:g_hCSWeaponDrop = INVALID_HANDLE; @@ -111,16 +110,6 @@ SetupGameData() { // Load game config file. g_hGameConf = LoadGameConfigFile("plugin.zombiereloaded"); - - StartPrepSDKCall(SDKCall_Player); - PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "EyePosition"); - PrepSDKCall_SetReturnInfo(SDKType_QAngle, SDKPass_ByValue); - g_hEyePosition = EndPrepSDKCall(); - - if(g_hEyePosition == INVALID_HANDLE) - { - SetFailState("Couldn't find offset \"EyePosition\"!"); - } StartPrepSDKCall(SDKCall_Player); PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "EyeAngles"); @@ -242,11 +231,6 @@ AddPlayerDeath(client, amount) SetEntProp(client, Prop_Data, "m_iDeaths", deaths + amount); } -GetPlayerEyePosition(client, Float:vec[3]) -{ - SDKCall(g_hEyePosition, client, vec); -} - GetPlayerEyeAngles(client, Float:ang[3]) { SDKCall(g_hEyeAngles, client, ang); diff --git a/src/zr/playerclasses/classevents.inc b/src/zr/playerclasses/classevents.inc index bde28a5..a98b970 100644 --- a/src/zr/playerclasses/classevents.inc +++ b/src/zr/playerclasses/classevents.inc @@ -22,7 +22,7 @@ */ ClassClientInit(client) { - if (ZRIsValidClient(client)) + if (ZRIsClientValid(client)) { // Set default class indexes on the player. ClassClientSetDefaultIndexes(client); diff --git a/src/zr/playerclasses/clientoverlays.inc b/src/zr/playerclasses/clientoverlays.inc index 07fdae6..e2687be 100644 --- a/src/zr/playerclasses/clientoverlays.inc +++ b/src/zr/playerclasses/clientoverlays.inc @@ -20,7 +20,7 @@ new Handle:tOverlay[MAXPLAYERS + 1]; new bool:bClientHasOverlay[MAXPLAYERS + 1]; /** - * Tells wether the overlay is on or not. + * Tells whether the overlay is on or not. */ new bool:bClientOverlayOn[MAXPLAYERS + 1]; @@ -104,7 +104,7 @@ ClassOverlayStop(client) public Action:ClassOverlayTimer(Handle:timer, any:client) { - if (!IsClientInGame(client) || !IsPlayerZombie(client)) + if (!IsClientInGame(client) || !InfectIsClientInfected(client)) { tOverlay[client] = INVALID_HANDLE; return Plugin_Stop; diff --git a/src/zr/playerclasses/filtertools.inc b/src/zr/playerclasses/filtertools.inc index bab3dbc..43a9123 100644 --- a/src/zr/playerclasses/filtertools.inc +++ b/src/zr/playerclasses/filtertools.inc @@ -359,7 +359,7 @@ ClassGetActiveIndex(client) else { // Not in admin mode, check if player is human or zombie. - if (IsPlayerHuman(client)) + if (InfectIsClientHuman(client)) { teamid = ZR_CLASS_TEAM_HUMANS; } diff --git a/src/zr/playerclasses/playerclasses.inc b/src/zr/playerclasses/playerclasses.inc index e158af7..d7d3565 100644 --- a/src/zr/playerclasses/playerclasses.inc +++ b/src/zr/playerclasses/playerclasses.inc @@ -495,7 +495,7 @@ bool:ClassReloadDataCache() bool:ClassReloadPlayerCache(client, classindex, cachetype = ZR_CLASS_CACHE_MODIFIED) { // Validate indexes. - if (!ClassValidateIndex(classindex) || !ZRIsValidClient(client)) + if (!ClassValidateIndex(classindex) || !ZRIsClientValid(client)) { return false; } diff --git a/src/zr/respawn.inc b/src/zr/respawn.inc index 030ce1e..e5fcf76 100644 --- a/src/zr/respawn.inc +++ b/src/zr/respawn.inc @@ -17,7 +17,7 @@ new Handle:tRespawn[MAXPLAYERS + 1]; /** * Array for flagging zombies who were killed by world. */ -new bool:pKilledByWorld[MAXPLAYERS + 1]; +new bool:bKilledByWorld[MAXPLAYERS + 1]; /** * Client is joining the server. @@ -27,8 +27,8 @@ RespawnClientInit(client) // Reset timer handle. tRespawn[client] = INVALID_HANDLE; - // Init pKilledByWorld for client. - pKilledByWorld[client] = false; + // Init bKilledByWorld for client. + bKilledByWorld[client] = false; } /** @@ -56,10 +56,10 @@ RespawnOnClientSpawn(client) RespawnOnClientDeath(client, attacker, const String:weapon[]) { // If client is a zombie, check if they were killed by world. - if (IsPlayerZombie(client)) + if (InfectIsClientInfected(client)) { - // Set pKilledByWorld to true if attacker is not a valid client. - pKilledByWorld[client] = !ZRIsValidClient(attacker); + // Set bKilledByWorld to true if attacker is not a valid client. + bKilledByWorld[client] = !ZRIsClientValid(attacker); } // If timer is running, kill it. @@ -86,6 +86,34 @@ RespawnOnClientDeath(client, attacker, const String:weapon[]) tRespawn[client] = CreateTimer(delay, RespawnTimer, client, TIMER_FLAG_NO_MAPCHANGE); } +/** + * The round is ending. + */ +RespawnOnRoundEnd() +{ + // x = client index. + for (new x = 1; x <= MaxClients; x++) + { + // If client isn't in-game, then stop. + if (!IsClientInGame(x)) + { + continue; + } + + // If timer isn't currently running, then stop. + if (tRespawn[x] == INVALID_HANDLE) + { + continue; + } + + // Stop timer. + KillTimer(tRespawn[x]); + + // Reset timer handle. + tRespawn[x] = INVALID_HANDLE; + } +} + /** * Returns if a player is to be respawned as a zombie, because they were killed by world. * @@ -95,7 +123,7 @@ RespawnOnClientDeath(client, attacker, const String:weapon[]) RespawnKilledByWorld(client) { // Return true if both the cvar is enabled and the player was killed by world. - return (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && pKilledByWorld[client]); + return (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && bKilledByWorld[client]); } /** @@ -126,14 +154,14 @@ RespawnSpawnClient(client) // Get suicide respawn cvar if (respawn_zombie) { - InfectPlayer(client); + InfectClient(client); return; } - if (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && pKilledByWorld[client]) + if (GetConVarBool(g_hCvarsList[CVAR_RESPAWN_ZOMBIE_WORLD]) && bKilledByWorld[client]) { - InfectPlayer(client); - pKilledByWorld[client] = false; + InfectClient(client); + bKilledByWorld[client] = false; } } diff --git a/src/zr/roundend.inc b/src/zr/roundend.inc index a1f9eea..4998670 100644 --- a/src/zr/roundend.inc +++ b/src/zr/roundend.inc @@ -47,9 +47,9 @@ */ enum RoundEndOutcome { - HumansWin, /** Humans have killed all zombies. */ - ZombiesWin, /** Zombies have infected all humans. */ - Draw, /** Round has ended in unexpected way. */ + HumansWin, /** Humans have killed all zombies. */ + ZombiesWin, /** Zombies have infected all humans. */ + Draw, /** Round has ended in unexpected way. */ } /** @@ -84,10 +84,21 @@ RoundEndClientInit(client) /** * Client has been killed. - * - * @param client The client index. */ RoundEndOnClientDeath() +{ + // Terminate the round if the last player was killed. + new RoundEndOutcome:outcome; + if (RoundEndGetRoundStatus(outcome)) + { + RoundEndTerminateRound(outcome); + } +} + +/** + * Client has been infected. + */ +RoundEndOnClientInfected() { // Terminate the round if the last player was infected. new RoundEndOutcome:outcome; @@ -111,12 +122,6 @@ RoundEndOnRoundStart() // Reset timer handle. tRoundEnd = INVALID_HANDLE; } - - // Tell plugin no zombies have been spawned. - g_bZombieSpawned = false; - - // Balance teams, and respawn all players. - RoundEndBalanceTeams(true); } /** @@ -331,12 +336,23 @@ RoundEndTerminateRound(RoundEndOutcome:outcome) } } +/** + * Restarts the game. + * + * @param delay How long to wait between round end and new round. + */ +RoundEndRestart(Float:delay) +{ + // Terminate the round. + TerminateRound(delay, ROUNDEND_GAME_COMMENCING); +} + /** * Balances teams * * @param spawn If true, it will respawn player after switching their team. */ -RoundEndBalanceTeams(bool:spawn = false) +RoundEndBalanceTeams() { // Create eligible player list. new Handle:arrayEligibleClients = INVALID_HANDLE; @@ -376,29 +392,6 @@ RoundEndBalanceTeams(bool:spawn = false) CS_SwitchTeam(client, CS_TEAM_CT); } - // If spawn is false, then stop. - if (!spawn) - { - return; - } - - // x = array index. - // client = client index. - for (new x = 0; x < eligibleclients; x++) - { - // Get client stored in array index. - client = GetArrayCell(arrayEligibleClients, x); - - // If client is dead, then stop. - if (!IsPlayerAlive(client)) - { - continue; - } - - // Respawn client. - CS_RespawnPlayer(client); - } - // Destroy handle. CloseHandle(arrayEligibleClients); } diff --git a/src/zr/soundeffects/ambientsounds.inc b/src/zr/soundeffects/ambientsounds.inc index 3a46d04..664271b 100644 --- a/src/zr/soundeffects/ambientsounds.inc +++ b/src/zr/soundeffects/ambientsounds.inc @@ -101,7 +101,7 @@ bool:AmbientSoundsValidateConfig() /** * Map is starting. - */ + */ AmbientSoundsOnMapStart() { // Reset timer handle. diff --git a/src/zr/soundeffects/soundeffects.inc b/src/zr/soundeffects/soundeffects.inc index 8982d77..e94af52 100644 --- a/src/zr/soundeffects/soundeffects.inc +++ b/src/zr/soundeffects/soundeffects.inc @@ -121,7 +121,7 @@ SEffectsEmitAmbientSound(const String:sound[], Float:ambientvolume = 1.0, client // Stop sound before playing again. SEffectsStopAmbientSound(sound); - if (ZRIsValidClient(client)) + if (ZRIsClientValid(client)) { // Emit ambient sound. EmitSoundToClient(client, sound, SOUND_FROM_PLAYER, SOUND_AMBIENT_CHANNEL, _, _, ambientvolume); diff --git a/src/zr/soundeffects/zombiesounds.inc b/src/zr/soundeffects/zombiesounds.inc index c14b1c0..85bf4f3 100644 --- a/src/zr/soundeffects/zombiesounds.inc +++ b/src/zr/soundeffects/zombiesounds.inc @@ -99,13 +99,13 @@ ZombieSoundsOnClientDeath(client) tSEffectsMoan[client] = INVALID_HANDLE; // If player isn't a zombie, then stop. - if (!IsPlayerZombie(client)) + if (!InfectIsClientInfected(client)) { return; } // If death sound cvar is disabled, then stop. - new bool:death = GetConVarBool(g_hCvarsList[CVAR_SOUNDEFFECTS_DEATH]); + new bool:death = GetConVarBool(g_hCvarsList[CVAR_SEFFECTS_DEATH]); if (!death) { return; @@ -126,13 +126,13 @@ ZombieSoundsOnClientDeath(client) ZombieSoundsOnClientHurt(client) { // If player isn't a zombie, then stop. - if (!IsPlayerZombie(client)) + if (!InfectIsClientInfected(client)) { return; } // Get groan factor, if 0, then stop. - new groan = GetConVarInt(g_hCvarsList[CVAR_SOUNDEFFECTS_GROAN]); + new groan = GetConVarInt(g_hCvarsList[CVAR_SEFFECTS_GROAN]); if (!groan) { return; @@ -157,7 +157,7 @@ ZombieSoundsOnClientHurt(client) ZombieSoundsOnClientInfected(client) { // If interval is set to 0, then stop. - new Float:interval = GetConVarFloat(g_hCvarsList[CVAR_SOUNDEFFECTS_MOAN]); + new Float:interval = GetConVarFloat(g_hCvarsList[CVAR_SEFFECTS_MOAN]); if (!interval) { return; @@ -245,7 +245,7 @@ bool:ZombieSoundsGetRandomSound(String:sound[], ZombieSounds:soundtype) public Action:ZombieSoundsMoanTimer(Handle:timer, any:client) { // If client isn't in-game or client is no longer a zombie, then stop. - if (!IsClientInGame(client) || !IsPlayerZombie(client)) + if (!IsClientInGame(client) || !InfectIsClientInfected(client)) { // Reset timer handle. tSEffectsMoan[client] = INVALID_HANDLE; diff --git a/src/zr/spawnprotect.inc b/src/zr/spawnprotect.inc index 042a67e..89e4929 100644 --- a/src/zr/spawnprotect.inc +++ b/src/zr/spawnprotect.inc @@ -129,7 +129,7 @@ public Action:SpawnProtectTimer(Handle:timer, any:client) } // If client has become a zombie, then stop timer. - if (!IsPlayerHuman(client)) + if (!InfectIsClientHuman(client)) { return Plugin_Stop; } diff --git a/src/zr/teleport.inc b/src/zr/teleport.inc index ad1c2b9..158d0a1 100644 --- a/src/zr/teleport.inc +++ b/src/zr/teleport.inc @@ -390,7 +390,7 @@ bool:ZTele(client) } // Check limits. - if (IsPlayerHuman(client)) + if (InfectIsClientHuman(client)) { new human_limit = GetConVarInt(g_hCvarsList[CVAR_ZTELE_HUMAN_LIMIT]); new bool:tele_humans; @@ -454,7 +454,7 @@ TeleportClient(client, bool:no_delay = false, bool:free_tele = false, bool:no_co new bool:teleports_unlimited = false; new Float:empty_vector[3] = {0.0, 0.0, 0.0}; - if (IsPlayerHuman(client)) + if (InfectIsClientHuman(client)) { new human_delay = GetConVarInt(g_hCvarsList[CVAR_ZTELE_HUMAN_DELAY]); new human_limit = GetConVarInt(g_hCvarsList[CVAR_ZTELE_HUMAN_LIMIT]); diff --git a/src/zr/translation.inc b/src/zr/translation.inc index 3717b01..5428305 100644 --- a/src/zr/translation.inc +++ b/src/zr/translation.inc @@ -19,7 +19,7 @@ stock ZR_PrintToChat(client, any:...) { decl String:phrase[192]; - if (ZRIsValidClient(client)) + if (ZRIsClientValid(client)) { SetGlobalTransTarget(client); diff --git a/src/zr/visualeffects.inc b/src/zr/visualeffects.inc new file mode 100644 index 0000000..636a431 --- /dev/null +++ b/src/zr/visualeffects.inc @@ -0,0 +1,329 @@ +/* + * ============================================================================ + * + * Zombie:Reloaded + * + * File: visualeffects.inc + * Description: Visual effects such as map darkening, fog, etc.. + * + * ============================================================================ + */ + +/** + * Handle of cvar "sv_skyname." + */ +new Handle:g_hSkyname = INVALID_HANDLE; + +/** + * Default sky of current map. + */ +new String:g_VEffectsDefaultSky[PLATFORM_MAX_PATH]; + +/** + * Get cvar data and downloadable content to add to download table. + */ +VEffectsLoad() +{ + // Get sv_skyname's convar handle, if invalid, log error, then stop. + g_hSkyname = FindConVar("sv_skyname"); + if (g_hSkyname == INVALID_HANDLE) + { + // TODO LOG. + + return; + } + + // Store map's default sky before applying new one. + GetConVarString(g_hSkyname, g_VEffectsDefaultSky, sizeof(g_VEffectsDefaultSky)); + + // If sky path is empty, then stop. + if (!g_VEffectsDefaultSky[0]) + { + return; + } + + decl String:downloadpath[PLATFORM_MAX_PATH]; + + // Prepend materials/skybox to the path. + Format(downloadpath, sizeof(downloadpath), "materials/skybox/%s", g_VEffectsDefaultSky); + + // Add skybox file to downloads table. + AddFileToDownloadsTable(downloadpath); +} + +/** + * The round is starting. + */ +VEffectsOnRoundStart() +{ + // If lightstyle is disabled, then disable. + new bool:lightstyle = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE]); + + // Apply light style. + VEffectsApplyLightStyle(!lightstyle); + + // If sky is disabled, then disable. + new bool:sky = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_SKY]); + + // Apply new sky. + VEffectsApplySky(!sky); + + // If fog is disabled, then disable. + new bool:fogoverride = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG_OVERRIDE]); + + // Apply fog. + VEffectsApplyFog(fogoverride); +} + +VEffectsApplyLightStyle(bool:disable = false) +{ + // If default, then set to normal light style. + if (disable) + { + // Set light style. + SetLightStyle(0, "n"); + + return; + } + + // Get light value. + decl String:lightstylevalue[4]; + GetConVarString(g_hCvarsList[CVAR_VEFFECTS_LIGHTSTYLE_VALUE], lightstylevalue, sizeof(lightstylevalue)); + + // Set light style. + SetLightStyle(0, lightstylevalue); +} + +VEffectsApplySky(bool:disable = false) +{ + // If default, then set to default sky. + if (disable) + { + // Set new sky on all clients. + SetConVarString(g_hSkyname, g_VEffectsDefaultSky, true); + + return; + } + + // Get sky path. + decl String:skypath[PLATFORM_MAX_PATH]; + GetConVarString(g_hCvarsList[CVAR_VEFFECTS_SKY_PATH], skypath, sizeof(skypath)); + + // Set new sky on all clients. + SetConVarString(g_hSkyname, skypath, true); +} + +VEffectsApplyFog(bool:override = false) +{ + // Find current fog index + new fogindex = FindEntityByClassname(-1, "env_fog_controller"); + + // If override is enabled, then continue. + if (override) + { + // If there is fog, then continue. + if (fogindex != -1) + { + // Delete fog. + RemoveEdict(fogindex); + } + } + + // If fog is disabled, then stop. + new bool:fog = GetConVarBool(g_hCvarsList[CVAR_VEFFECTS_FOG]); + if (!fog) + { + return; + } + + // If there is no fog on the map, create new fog. + if (fogindex == -1) + { + // Create and spawn fog. + fogindex = CreateEntityByName("env_fog_controller"); + DispatchSpawn(fogindex); + } + + decl String:fogcolor[16]; + + // Set primary fog color. + GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_PCOLOR], fogcolor, sizeof(fogcolor)); + VEffectsSetFogColor(fogindex, fogcolor, true); + + // Set secondary fog color. + GetConVarString(g_hCvarsList[CVAR_VEFFECTS_FOG_SCOLOR], fogcolor, sizeof(fogcolor)); + VEffectsSetFogColor(fogindex, fogcolor, false); + + // Set fog's density. + new Float:fogdensity = GetConVarFloat(g_hCvarsList[CVAR_VEFFECTS_FOG_DENSITY]); + VEffectsSetFogDensity(fogindex, fogdensity); + + // Set fog's start distance. + new fogstart = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_STARTDIST]); + VEffectsSetFogStartDist(fogindex, fogstart); + + // Set fog's end distance. + new fogend = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_ENDDIST]); + VEffectsSetFogEndDist(fogindex, fogend); + + // Set fog's far z distance. + new fogfarz = GetConVarInt(g_hCvarsList[CVAR_VEFFECTS_FOG_FARZ]); + VEffectsSetFogFarZ(fogindex, fogfarz); +} + +/** + * Set fog's primary or secondary color. + * + * @param fogindex Edict index of the fog to modify. + * @param color The rgb color of the fog. + * @param primary (Optional) True to set primary, false otherwise. + */ +VEffectsSetFogColor(fogindex, const String:color[], bool:primary = true) +{ + // Set primary color. + if (primary) + { + // Set new color. + SetVariantString(color); + AcceptEntityInput(fogindex, "SetColor"); + } + // Set secondary color. + else + { + // Set new color. + SetVariantString(color); + AcceptEntityInput(fogindex, "SetColorSecondary"); + } +} + +/** + * Set fog's density. + * + * @param fogindex Edict index of the fog to modify. + * @param density The density of the fog. + */ +VEffectsSetFogDensity(fogindex, Float:density) +{ + // Set density. + DispatchKeyValueFloat(fogindex, "fogmaxdensity", density); +} + +/** + * Set fog's start distance. + * + * @param fogindex Edict index of the fog to modify. + * @param startdist The start distance of the fog. + */ +VEffectsSetFogStartDist(fogindex, startdist) +{ + // Set start distance. + SetVariantInt(startdist); + AcceptEntityInput(fogindex, "SetStartDist"); +} + +/** + * Set fog's end distance. + * + * @param fogindex Edict index of the fog to modify. + * @param enddist The end distance of the fog. + */ +VEffectsSetFogEndDist(fogindex, enddist) +{ + // Set end distance. + SetVariantInt(enddist); + AcceptEntityInput(fogindex, "SetEndDist"); +} + +/** + * Set fog's far z distance. + * + * @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(); +} \ No newline at end of file diff --git a/src/zr/weapons/markethandler.inc b/src/zr/weapons/markethandler.inc index c6a83c7..83c119d 100644 --- a/src/zr/weapons/markethandler.inc +++ b/src/zr/weapons/markethandler.inc @@ -79,7 +79,7 @@ public bool:Market_OnWeaponSelected(client, String:weaponid[]) } // If player is a zombie, then stop. - if (IsPlayerZombie(client)) + if (InfectIsClientInfected(client)) { ZR_PrintToChat(client, "Zombie cant use weapon"); diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index e8d7bf2..274b1b8 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -42,7 +42,9 @@ RestrictInit() gRestrictedWeapons = CreateArray(32, 0); // Hook buy command. - RegConsoleCmd("buy", RestrictBuyHook); + RegConsoleCmd("buy", RestrictBuyCommand); + RegConsoleCmd("autobuy", RestrictBuyCommand); + RegConsoleCmd("rebuy", RestrictBuyCommand); } /** @@ -136,7 +138,7 @@ RestrictDefaultRestrictions() */ RestrictValidateWeaponGroups() { - // If log flag check fails, don't log. + // If log flag check fails, then don't log. if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS)) { return; @@ -215,18 +217,19 @@ RestrictOnClientDisconnect(client) * @param client The client index. * @param argc Argument count. */ -public Action:RestrictBuyHook(client, argc) +public Action:RestrictBuyCommand(client, argc) { // If plugin is disabled then stop. - new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]); + /*new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]); if (!enabled) { // Allow command. return Plugin_Continue; - } + }*/ + // Disabled - // If player is a zombie then block command. - if (IsPlayerZombie(client)) + // If player is a zombie, then block command. + if (InfectIsClientInfected(client)) { ZR_PrintToChat(client, "Zombie cant use weapon"); @@ -864,7 +867,7 @@ public RestrictCanUse(client, weapon, dummy1, dummy2, dummy3, dummy4) } // If the player is a zombie and the weapon isn't a knife then prevent pickup. - if (IsPlayerZombie(client) && !StrEqual(weaponname, "knife")) + if (InfectIsClientInfected(client) && !StrEqual(weaponname, "knife")) { return 0; } diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index 70dcd7e..3f1c217 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -108,7 +108,7 @@ WeaponsLoad() */ WeaponsValidateConfig() { - // If log flag check fails, don't log. + // If log flag check fails, then don't log. if (!LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS)) { return; diff --git a/src/zr/zadmin.inc b/src/zr/zadmin.inc index 01bd30b..93d86fb 100644 --- a/src/zr/zadmin.inc +++ b/src/zr/zadmin.inc @@ -397,7 +397,7 @@ public ZRInfectHandle(Handle:menu_infect, MenuAction:action, client, slot) { decl String:name[64]; GetClientName(target, name, sizeof(name)); - InfectPlayer(target); + InfectClient(target); ShowActivity2(client, "[ZR] ", "Infected %s", name); ZRInfectMenu(client); } @@ -583,112 +583,112 @@ public ZRLogFlagsMenuHandle(Handle:menu_log_flags, MenuAction:action, client, sl { case 0: { - ToggleLogFlag(LOG_CORE_EVENTS); + LogToggleFlag(LOG_CORE_EVENTS); ZRLogFlagsMenu(client); } case 1: { - ToggleLogFlag(LOG_GAME_EVENTS); + LogToggleFlag(LOG_GAME_EVENTS); ZRLogFlagsMenu(client); } case 2: { - ToggleLogFlag(LOG_PLAYER_COMMANDS); + LogToggleFlag(LOG_PLAYER_COMMANDS); ZRLogFlagsMenu(client); } case 3: { - ToggleLogFlag(LOG_DEBUG); + LogToggleFlag(LOG_DEBUG); ZRLogFlagsMenu(client); } case 4: { - ToggleLogFlag(LOG_DEBUG_DETAIL); + LogToggleFlag(LOG_DEBUG_DETAIL); ZRLogFlagsMenu(client); } case 5: { - ToggleLogFlag(LOG_DEBUG_MAX_DETAIL); + LogToggleFlag(LOG_DEBUG_MAX_DETAIL); ZRLogFlagsMenu(client); } case 6: { - ToggleLogFlag(LOG_TO_ADMINS); + LogToggleFlag(LOG_TO_ADMINS); ZRLogFlagsMenu(client); } case 7: { - ToggleLogFlag(LOG_TO_CLIENT); + LogToggleFlag(LOG_TO_CLIENT); ZRLogFlagsMenu(client); } case 8: { - ToggleLogFlag(LOG_IGNORE_CONSOLE); + LogToggleFlag(LOG_IGNORE_CONSOLE); ZRLogFlagsMenu(client); } case 9: { - ToggleLogFlag(LOG_MODULES_ENABLED); + LogToggleFlag(LOG_MODULES_ENABLED); ZRLogFlagsMenu(client); } case 10: { - ToggleLogFlag(LOG_MODULE_ZOMBIE); + LogToggleFlag(LOG_MODULE_ZOMBIE); ZRLogFlagsMenu(client); } case 11: { - ToggleLogFlag(LOG_MODULE_AMBIENTSOUNDS); + LogToggleFlag(LOG_MODULE_AMBIENTSOUNDS); ZRLogFlagsMenu(client); } case 12: { - ToggleLogFlag(LOG_MODULE_OVERLAYS); + LogToggleFlag(LOG_MODULE_OVERLAYS); ZRLogFlagsMenu(client); } case 13: { - ToggleLogFlag(LOG_MODULE_SAYTRIGGERS); + LogToggleFlag(LOG_MODULE_SAYTRIGGERS); ZRLogFlagsMenu(client); } case 14: { - ToggleLogFlag(LOG_MODULE_TELEPORT); + LogToggleFlag(LOG_MODULE_TELEPORT); ZRLogFlagsMenu(client); } case 15: { - ToggleLogFlag(LOG_MODULE_CLASSES); + LogToggleFlag(LOG_MODULE_CLASSES); ZRLogFlagsMenu(client); } case 16: { - ToggleLogFlag(LOG_MODULE_WEAPONS); + LogToggleFlag(LOG_MODULE_WEAPONS); ZRLogFlagsMenu(client); } case 17: { - ToggleLogFlag(LOG_MODULE_HITGROUPS); + LogToggleFlag(LOG_MODULE_HITGROUPS); ZRLogFlagsMenu(client); } case 18: { - ToggleLogFlag(LOG_MODULE_COMMANDS); + LogToggleFlag(LOG_MODULE_COMMANDS); ZRLogFlagsMenu(client); } case 19: { - ToggleLogFlag(LOG_MODULE_ANTICAMP); + LogToggleFlag(LOG_MODULE_ANTICAMP); ZRLogFlagsMenu(client); } case 20: { - ToggleLogFlag(LOG_MODULE_DAMAGE); + LogToggleFlag(LOG_MODULE_DAMAGE); ZRLogFlagsMenu(client); } case 21: { - ToggleLogFlag(LOG_MODULE_OFFSETS); + LogToggleFlag(LOG_MODULE_OFFSETS); ZRLogFlagsMenu(client); } } @@ -715,21 +715,4 @@ AddToKnockbackMultiplier(Float:value) AddToClassKnockback(classindex, Float:value) { arrayClasses[classindex][data_knockback] = arrayClasses[classindex][data_knockback] + value; -} - -ToggleLogFlag(flag) -{ - new log_flags; - log_flags = GetConVarInt(g_hCvarsList[CVAR_LOG]); - - if (log_flags & flag) - { - log_flags = log_flags - flag; - } - else - { - log_flags = log_flags + flag; - } - - SetConVarInt(g_hCvarsList[CVAR_LOG], log_flags); } \ No newline at end of file diff --git a/src/zr/zhp.inc b/src/zr/zhp.inc index 12fbfb8..9bf4d43 100644 --- a/src/zr/zhp.inc +++ b/src/zr/zhp.inc @@ -171,7 +171,7 @@ ZHPUpdateHUD(client) } // If player is a zombie, or has ZHP disabled, then stop. - if (!IsPlayerZombie(client) || !pZHP[client]) + if (!InfectIsClientInfected(client) || !pZHP[client]) { return; } diff --git a/src/zr/zombie.inc b/src/zr/zombie.inc index e40870c..070b80c 100644 --- a/src/zr/zombie.inc +++ b/src/zr/zombie.inc @@ -6,8 +6,6 @@ * ==================== */ -new String:skyname[32]; - HookCommands() { RegConsoleCmd("nightvision", Command_NightVision); @@ -45,32 +43,6 @@ public Action:Command_NightVision(client, argc) } } -FindMapSky() -{ - GetConVarString(FindConVar("sv_skyname"), skyname, sizeof(skyname)); -} - -ChangeLightStyle() -{ - new bool:dark = GetConVarBool(g_hCvarsList[CVAR_DARK]); - if (dark) - { - decl String:darkness[2]; - decl String:sky[32]; - - GetConVarString(g_hCvarsList[CVAR_DARK_LEVEL], darkness, sizeof(darkness)); - GetConVarString(g_hCvarsList[CVAR_DARK_SKY], sky, sizeof(sky)); - - SetLightStyle(0, darkness); - SetConVarString(FindConVar("sv_skyname"), sky, true, false); - } - else - { - SetLightStyle(0, "n"); - SetConVarString(FindConVar("sv_skyname"), skyname, true, false); - } -} - JumpBoost(client, Float:distance, Float:height) { new Float:vel[3]; @@ -105,14 +77,4 @@ RemoveObjectives() RemoveEdict(x); } } -} - -bool:IsPlayerZombie(client) -{ - return bZombie[client]; -} - -bool:IsPlayerHuman(client) -{ - return !bZombie[client]; } \ No newline at end of file diff --git a/src/zr/zombiereloaded.inc b/src/zr/zombiereloaded.inc index bf04dc1..a6aa2ee 100644 --- a/src/zr/zombiereloaded.inc +++ b/src/zr/zombiereloaded.inc @@ -98,7 +98,7 @@ ZRCreateEligibleClientList(&Handle:arrayEligibleClients, bool:team = false, bool } // If client is already zombie (via admin), then stop. - if (human && !IsPlayerHuman(x)) + if (human && !InfectIsClientHuman(x)) { continue; } @@ -117,7 +117,7 @@ ZRCreateEligibleClientList(&Handle:arrayEligibleClients, bool:team = false, bool * @param console True to include console (index 0), false if not. * @return True if client is valid, false otherwise. */ -bool:ZRIsValidClient(client, bool:console = false) +bool:ZRIsClientValid(client, bool:console = false) { // If index is greater than max number of clients, then return false. if (client > MaxClients) @@ -167,12 +167,12 @@ bool:ZRCountValidClients(&zombiecount = 0, &humancount = 0, bool:alive = true, b } // If player is a zombie, then increment zombie variable. - if (IsPlayerZombie(x)) + if (InfectIsClientInfected(x)) { zombiecount++; } // If player is a human, then increment human variable. - else if (IsPlayerHuman(x)) + else if (InfectIsClientHuman(x)) { humancount++; } @@ -191,7 +191,7 @@ bool:ZRCountValidClients(&zombiecount = 0, &humancount = 0, bool:alive = true, b bool:ZRIsClientOnTeam(client, team = -1) { // If index is invalid, then stop. - if (!ZRIsValidClient(client)) + if (!ZRIsClientValid(client)) { return false; } @@ -234,7 +234,7 @@ bool:ZRTeamHasClients(team = -1) bool:ZRIsClientAdmin(client) { // If index is invalid, then stop. - if (!ZRIsValidClient(client)) + if (!ZRIsClientValid(client)) { return false; }