diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index fd17a27..62f62c3 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -566,6 +566,10 @@ zr_respawn_team_zombie_world "1" // Default: "1" zr_napalm_ignite "1" +// Minimum water-saturation before flame is extinguished. ['0' = Disabled | '1' = Feet | '2' = Waist | '3' = Full submersion] +// Default: "0" +zr_napalm_douse "0" + // ---------------------------------------------------------------------------- // Jump Boost (module) diff --git a/src/include/zrtools.inc b/src/include/zrtools.inc index ed20afe..c2a6e03 100644 --- a/src/include/zrtools.inc +++ b/src/include/zrtools.inc @@ -91,6 +91,7 @@ native ZRTools_UnhookTraceAttack(hookid); // CS:S Specific damage flags. (should probably use these) #define DMG_CSS_FALL (DMG_FALL) // Client was damaged by falling. #define DMG_CSS_BLAST (DMG_BLAST) // Client was damaged by explosion. +#define DMG_CSS_BURN (DMG_DIRECT) // Client was damaged by fire. #define DMG_CSS_BULLET (DMG_NEVERGIB) // Client was shot or knifed. #define DMG_CSS_HEADSHOT (1 << 30) // Client was shot in the head. diff --git a/src/zr/antistick.inc b/src/zr/antistick.inc index e215445..4f8d3de 100644 --- a/src/zr/antistick.inc +++ b/src/zr/antistick.inc @@ -87,13 +87,6 @@ AntiStickOnCommandsCreate() */ AntiStickLoad() { - // If antistick is disabled, then stop. - new bool:antistick = GetConVarBool(g_hCvarsList[CVAR_ANTISTICK]); - if (!antistick) - { - return; - } - // Create antistick keyvalues if it hasn't been created yet. if (g_kvAntiStick == INVALID_HANDLE) { @@ -255,6 +248,13 @@ stock AntiStickSetModelHullWidth(client, const String:model[] = "", Float:hull_w */ public ZRTools_Action:AntiStickStartTouch(client, entity) { + // If antistick is disabled, then stop. + new bool:antistick = GetConVarBool(g_hCvarsList[CVAR_ANTISTICK]); + if (!antistick) + { + return; + } + // If client isn't in-game, then stop. if (!IsClientInGame(client)) { diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 9426865..6a30bbc 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -137,6 +137,7 @@ enum CvarsList Handle:CVAR_RESPAWN_TEAM_ZOMBIE, Handle:CVAR_RESPAWN_TEAM_ZOMBIE_WORLD, Handle:CVAR_NAPALM_IGNITE, + Handle:CVAR_NAPALM_DOUSE, Handle:CVAR_JUMPBOOST_BHOP_PROTECT, Handle:CVAR_JUMPBOOST_BHOP_MAX, Handle:CVAR_VOL, @@ -414,6 +415,7 @@ CvarsCreate() // Napalm (module) // =========================== g_hCvarsList[CVAR_NAPALM_IGNITE] = CreateConVar("zr_napalm_ignite", "1", "Ignite grenade in mid-air after player throws it. [Dependency: Human Attribute 'has_napalm']"); + g_hCvarsList[CVAR_NAPALM_DOUSE] = CreateConVar("zr_napalm_douse", "0", "Minimum water-saturation before flame is extinguished. ['0' = Disabled | '1' = Feet | '2' = Waist | '3' = Full submersion]"); // =========================== diff --git a/src/zr/damage.inc b/src/zr/damage.inc index b261986..e69a5df 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -231,6 +231,17 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama return ZRTools_Continue; } + new action; + + // Forward this hook to another module an return (or not) what it wants. + action = NapalmOnTakeDamage(client, damagetype); + + // If the napalm module wants to return here, then return the int casted into the ZRTools_Action type. + if (action > -1) + { + return ZRTools_Action:action; + } + // Client was shot or knifed. if (damagetype & DMG_CSS_BULLET) { diff --git a/src/zr/log.h.inc b/src/zr/log.h.inc index 5588165..8dd7145 100644 --- a/src/zr/log.h.inc +++ b/src/zr/log.h.inc @@ -78,6 +78,7 @@ enum LogModules bool:LogModule_Hitgroups, bool:LogModule_Infect, bool:LogModule_Models, + bool:LogModule_Napalm, bool:LogModule_Playerclasses, bool:LogModule_VEffects, bool:LogModule_SEffects, diff --git a/src/zr/log.inc b/src/zr/log.inc index db4d748..0682a3c 100644 --- a/src/zr/log.inc +++ b/src/zr/log.inc @@ -91,6 +91,10 @@ LogGetModuleNameString(String:buffer[], maxlen, LogModules:module, bool:shortNam { return shortName ? strcopy(buffer, maxlen, "models") : strcopy(buffer, maxlen, "Models"); } + case LogModule_Napalm: + { + return shortName ? strcopy(buffer, maxlen, "napalm") : strcopy(buffer, maxlen, "Napalm"); + } case LogModule_Playerclasses: { return shortName ? strcopy(buffer, maxlen, "playerclasses") : strcopy(buffer, maxlen, "Player Classes"); @@ -178,6 +182,10 @@ LogModules:LogGetModule(const String:moduleName[]) { return LogModule_Models; } + else if (StrEqual(moduleName, "napalm", false)) + { + return LogModule_Napalm; + } else if (StrEqual(moduleName, "playerclasses", false)) { return LogModule_Playerclasses; diff --git a/src/zr/models.inc b/src/zr/models.inc index d0f2e46..44389f4 100644 --- a/src/zr/models.inc +++ b/src/zr/models.inc @@ -94,7 +94,7 @@ ModelsLoad() { // Get base model path, excluding the public/non-public setting. ModelReturnPath(x, modelbase, sizeof(modelbase)); - PrintToServer("PATH BASE [%s]", modelbase); + // Explode path into pieces. (separated by "/") new strings = ExplodeString(modelbase, "/", baseexploded, MODELS_PATH_MAX_DEPTH, MODELS_PATH_DIR_MAX_LENGTH); diff --git a/src/zr/napalm.inc b/src/zr/napalm.inc index 1cca75e..c36d6d1 100644 --- a/src/zr/napalm.inc +++ b/src/zr/napalm.inc @@ -30,6 +30,71 @@ */ #define GRENADE_FUSE_TIME 3.0 +/** + * @section m_nWaterLevel defines. + */ +#define NAPALM_WLEVEL_DRY 0 +#define NAPALM_WLEVEL_FEET 1 +#define NAPALM_WLEVEL_HALF 2 +#define NAPALM_WLEVEL_FULL 3 +/** + * @endsection + */ + +/** + * Variable to store water-level offset value. + */ +new g_iToolsWaterLevel; + +/** + * Find napalm-specific offsets here. + */ +NapalmOnOffsetsFound() +{ + // If offset "m_bInBuyZone" can't be found, then stop the plugin. + g_iToolsWaterLevel = FindSendPropInfo("CBasePlayer", "m_nWaterLevel"); + if (g_iToolsWaterLevel == -1) + { + LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Napalm, "Offsets", "Offset \"CBaseEntity::m_nWaterLevel\" was not found."); + } +} + +/** + * Hook: OnTakeDamage + * Forwarded from the damage module to check if we should extinguish any flames. + * + * @param client The client index. + * @param damagetype The type of damage inflicted. + * @return Return ZRTools_Handled to stop the damage to client. + * ZRTools_Continue to allow damage to client. + * Return -1 to not return anything and let the damage module continue as usual. + */ +NapalmOnTakeDamage(client, damagetype) +{ + // Client was damaged by fire. + if (damagetype & DMG_CSS_BURN) + { + // Only take action if it isn't disabled, or the option is valid. + new douse = GetConVarInt(g_hCvarsList[CVAR_NAPALM_DOUSE]); + + if (douse > 0 && douse <= 3) + { + // If the client water-level is equal or higher than the given, then we want to extinguish the flame. + if (NapalmGetClientWaterLevel(client) >= douse) + { + // Put the fire out. + ExtinguishEntity(client); + + // Stop the last bit of inflicted burn damage. + return _:ZRTools_Handled; + } + } + } + + // Let the damage module continue as usual. + return -1; +} + /** * Client has been hurt. * @@ -113,8 +178,8 @@ NapalmOnWeaponFire(client, const String:weapon[]) return; } - // Wait .15 seconds. - CreateTimer(0.15, NapalmIgniteGrenade); + // Wait .1 seconds. + CreateTimer(0.1, NapalmIgniteGrenade); } /** @@ -145,3 +210,15 @@ public Action:NapalmIgniteGrenade(Handle:timer) } } } + +/** + * Checks the current water-level on a client. + * + * @param client The client index. + * @return A NAPALM_WLEVEL_ define. + */ +stock NapalmGetClientWaterLevel(client) +{ + // Return client's water-level. + return GetEntData(client, g_iToolsWaterLevel); +} \ No newline at end of file diff --git a/src/zr/tools.inc b/src/zr/tools.inc index a8a8d8f..574cf42 100644 --- a/src/zr/tools.inc +++ b/src/zr/tools.inc @@ -107,7 +107,7 @@ ToolsFindOffsets() WeaponsOnOffsetsFound(); AccountOnOffsetsFound(); VEffectsOnOffsetsFound(); - ZMarketOnOffsetsFound(); + NapalmOnOffsetsFound(); } /** diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index 8beea92..b6ff945 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -119,6 +119,7 @@ WeaponsOnOffsetsFound() // Forward event to sub-modules WeaponAmmoOnOffsetsFound(); + ZMarketOnOffsetsFound(); } /**