Not thoroughly tested.
No friendly fire checking but that can be added
4 cvars
- rd_damageradius - radius from infected person that will cause damage
- rd_damageamount - amount of damage. this is not loss in hp, this is the amount of damage issued that may get offset by player armor
- rd_damageinterval - interval of issuance of damage in seconds. so if you are within radius, you get damage every X seconds
- rd_friendlyfire - enable/disable friendly fire damage
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
new const Version[] = "0.2";
const InfectionTask = 0b101110110101010101111;
new g_iMaxPlayers , g_pDamageRadius , g_pDamageAmount , g_pDamageInterval , g_pFriendlyFire;
public plugin_init()
{
register_plugin( "Radius Damage" , Version , "bugsy" );
register_clcmd( "say /infect" , "StartInfection" );
register_clcmd( "say /uninfect" , "EndInfection" );
g_pDamageRadius = register_cvar( "rd_damageradius" , "250" );
g_pDamageAmount = register_cvar( "rd_damageamount" , "15" );
g_pDamageInterval = register_cvar( "rd_damageinterval" , "1" );
g_pFriendlyFire = register_cvar( "rd_friendlyfire" , "0" );
g_iMaxPlayers = get_maxplayers();
}
public StartInfection( id )
{
if ( !task_exists( InfectionTask + id ) )
{
set_task( get_pcvar_float( g_pDamageInterval ) , "CheckForEnemies" , InfectionTask + id , .flags="b" );
client_print( id , print_chat , "* Infection enabled" );
}
else
{
client_print( id , print_chat , "* Infection is already enabled" );
}
return PLUGIN_HANDLED;
}
public EndInfection( id )
{
if ( task_exists( InfectionTask + id ) )
{
remove_task( InfectionTask + id );
client_print( id , print_chat , "* Infection disabled" );
}
else
{
client_print( id , print_chat , "* Infection not currently enabled" );
}
return PLUGIN_HANDLED;
}
public CheckForEnemies( TaskID )
{
new id = TaskID - InfectionTask;
new iEntity = -1 , DamageBits , Float:fOrigin[ 3 ] , Float:fRadius , Float:fDamage , bool:bFriendlyFire;
entity_get_vector( id , EV_VEC_origin , fOrigin );
fRadius = get_pcvar_float( g_pDamageRadius );
fDamage = get_pcvar_float( g_pDamageAmount );
bFriendlyFire = bool:!!get_pcvar_num( g_pFriendlyFire );
while ( (iEntity = find_ent_in_sphere( iEntity , fOrigin , fRadius ) ) )
{
if ( ( 1 <= iEntity <= g_iMaxPlayers ) && ( iEntity != id ) && ( bFriendlyFire || ( !bFriendlyFire & ( cs_get_user_team( id ) != cs_get_user_team( iEntity ) ) ) ) )
{
ExecuteHamB( Ham_TakeDamage , iEntity , 0 , id , fDamage , DamageBits );
}
}
}
__________________