2009-04-17 10:22:02 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-07-05 08:49:23 +02:00
|
|
|
* Zombie:Reloaded
|
2009-04-17 10:22:02 +02:00
|
|
|
*
|
2009-06-12 05:51:26 +02:00
|
|
|
* File: napalm.inc
|
|
|
|
* Type: Module
|
|
|
|
* Description: Grenades burn zombies when damaged by them.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Greyscale, Richard Helgeby
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-04-17 10:22:02 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The fuse length of an hegrenade.
|
|
|
|
*/
|
|
|
|
#define GRENADE_FUSE_TIME 3.0
|
|
|
|
|
2009-07-17 03:34:56 +02:00
|
|
|
/**
|
|
|
|
* @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.
|
|
|
|
|
2009-12-29 01:38:21 +01:00
|
|
|
//ExtinguishEntity(client); <-- Don't use this. Takes off the FL_ONFIRE flag, but flame doesn't get extinguished.
|
|
|
|
|
|
|
|
// This works.
|
|
|
|
new ent = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity");
|
|
|
|
if (IsValidEdict(ent))
|
|
|
|
SetEntPropFloat(ent, Prop_Data, "m_flLifetime", 0.0);
|
|
|
|
|
2009-07-17 03:34:56 +02:00
|
|
|
// Stop the last bit of inflicted burn damage.
|
2009-11-04 21:37:26 +01:00
|
|
|
#if defined USE_SDKHOOKS
|
|
|
|
return _:Plugin_Handled;
|
|
|
|
#else
|
|
|
|
return _:ZRTools_Handled;
|
|
|
|
#endif
|
2009-07-17 03:34:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Let the damage module continue as usual.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-04-17 10:22:02 +02:00
|
|
|
/**
|
|
|
|
* Client has been hurt.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
2009-06-14 19:10:30 +02:00
|
|
|
* @param attacker The attacker index.
|
2009-04-17 10:22:02 +02:00
|
|
|
* @param weapon The weapon name.
|
|
|
|
*/
|
2009-06-14 19:10:30 +02:00
|
|
|
NapalmOnClientHurt(client, attacker, const String:weapon[])
|
2009-04-17 10:22:02 +02:00
|
|
|
{
|
2009-07-16 02:58:20 +02:00
|
|
|
// If there's no attacker, then stop.
|
|
|
|
if (!attacker)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-17 10:22:02 +02:00
|
|
|
// If player isn't a zombie, then stop.
|
2009-04-24 05:02:19 +02:00
|
|
|
if (!InfectIsClientInfected(client))
|
2009-04-17 10:22:02 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If napalm time is invalid or 0, then stop.
|
|
|
|
new Float:napalm_time = ClassGetNapalmTime(client);
|
|
|
|
if (napalm_time <= 0.0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-14 19:10:30 +02:00
|
|
|
// If the attacker can't throw napalm grenades, then stop.
|
2009-06-16 08:02:35 +02:00
|
|
|
if (!ClassGetHasNapalm(attacker))
|
2009-06-14 19:10:30 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-17 10:22:02 +02:00
|
|
|
// If weapon is a grenade, then ignite player.
|
|
|
|
if (StrEqual(weapon, "hegrenade", false))
|
|
|
|
{
|
2009-07-27 06:58:05 +02:00
|
|
|
new bool:reset = GetConVarBool(g_hCvarsList[CVAR_NAPALM_TIME_RESET]);
|
|
|
|
new flags = GetEntityFlags(client);
|
2009-04-17 10:22:02 +02:00
|
|
|
|
2009-07-27 06:58:05 +02:00
|
|
|
if (reset || !(flags & FL_ONFIRE))
|
|
|
|
{
|
|
|
|
// This stops the fire before re-ignition.
|
|
|
|
ExtinguishEntity(client);
|
|
|
|
|
|
|
|
// Ignite client.
|
|
|
|
IgniteEntity(client, napalm_time);
|
|
|
|
}
|
2009-04-17 10:22:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-21 07:39:24 +02:00
|
|
|
/**
|
|
|
|
* Client has been killed.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
NapalmOnClientDeath(client)
|
|
|
|
{
|
|
|
|
// Extinguish any flames to stop burning sounds.
|
|
|
|
ExtinguishEntity(client);
|
|
|
|
}
|
|
|
|
|
2009-04-17 10:22:02 +02:00
|
|
|
/**
|
|
|
|
* Weapon has been fired.
|
|
|
|
*
|
2009-06-14 19:10:30 +02:00
|
|
|
* @param client The client index.
|
|
|
|
* @param weapon The weapon name.
|
2009-04-17 10:22:02 +02:00
|
|
|
*/
|
2009-06-14 19:10:30 +02:00
|
|
|
NapalmOnWeaponFire(client, const String:weapon[])
|
2009-04-17 10:22:02 +02:00
|
|
|
{
|
2009-06-12 07:36:22 +02:00
|
|
|
// If grenade fire is disabled, then stop.
|
|
|
|
new bool:napalmignite = GetConVarBool(g_hCvarsList[CVAR_NAPALM_IGNITE]);
|
|
|
|
if (!napalmignite)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-14 19:10:30 +02:00
|
|
|
// If human class can't throw napalm grenades, then stop.
|
|
|
|
if (!ClassGetHasNapalm(client))
|
2009-04-17 10:22:02 +02:00
|
|
|
{
|
|
|
|
return;
|
2009-06-14 19:10:30 +02:00
|
|
|
}
|
2009-04-17 10:22:02 +02:00
|
|
|
|
|
|
|
// If weapon isn't a grenade, then stop.
|
|
|
|
if (!StrEqual(weapon, "hegrenade", false))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-17 03:34:56 +02:00
|
|
|
// Wait .1 seconds.
|
|
|
|
CreateTimer(0.1, NapalmIgniteGrenade);
|
2009-04-17 10:22:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Timer callback, ignite's all hegrenade projectiles.
|
|
|
|
*
|
|
|
|
* @param timer The timer handle.
|
|
|
|
*/
|
|
|
|
public Action:NapalmIgniteGrenade(Handle:timer)
|
|
|
|
{
|
|
|
|
decl String:classname[64];
|
|
|
|
|
|
|
|
// Get max entities.
|
|
|
|
new maxentities = GetMaxEntities();
|
|
|
|
|
|
|
|
// x = entity index.
|
|
|
|
for (new x = 0; x <= maxentities; x++)
|
|
|
|
{
|
|
|
|
// If entity is invalid, then stop.
|
2009-07-21 22:25:11 +02:00
|
|
|
if(!IsValidEntity(x))
|
2009-04-17 10:22:02 +02:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetEdictClassname(x, classname, sizeof(classname));
|
|
|
|
if(StrEqual(classname, "hegrenade_projectile"))
|
|
|
|
{
|
|
|
|
IgniteEntity(x, GRENADE_FUSE_TIME);
|
|
|
|
}
|
|
|
|
}
|
2009-05-01 11:22:45 +02:00
|
|
|
}
|
2009-07-17 03:34:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|