- 听众
- 收听
- 积分
- 90
- 主题
- 回帖
- 0
- 精华
注册时间2008-11-24
最后登录1970-1-1
该用户从未签到
|
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
// ------------------------------------
new const PLUGIN[] = "No Fall Death"
#define VERSION "1.0"
// ------------------------------------
#define RANDOM_MIN_VALUE 1.0
#define REGENERATE_MIN_VALUE 1.0
new Float: Health[ 33 ];
new toggle_plugin, toggle_interval, toggle_amount;
new p_plugin, p_int, p_amount;
new g_msghealth;
public plugin_init()
{
register_plugin( PLUGIN, VERSION, "anakin_cstrike" );
register_logevent( "roundstart", 2, "1=Round_Start" );
RegisterHam( Ham_TakeDamage, "player", "ham_damage" );
toggle_plugin = register_cvar( "nfd_plugin", "1" );
toggle_interval = register_cvar( "nfd_interval", "5" );
toggle_amount = register_cvar( "ndf_amount", "3" );
g_msghealth = get_user_msgid( "Health" );
}
public roundstart()
{
p_plugin = get_pcvar_num( toggle_plugin );
p_int = get_pcvar_num( toggle_interval );
p_amount = get_pcvar_num( toggle_amount );
}
public ham_damage( this, inflictor, attacker, Float:damage, damagebits )
{
if( !p_plugin )
return FMRES_IGNORED;
if( !( damagebits & DMG_FALL ) )
return HAM_IGNORED;
if( task_exists( this+123 ) )
remove_task( this+123 );
pev( this, pev_health, Health[ this ] );
switch( p_plugin )
{
case 1: return HAM_SUPERCEDE;
case 2:
{
if( Check( damage, Health[ this ] ) )
{
SetHealth( this, random_float( RANDOM_MIN_VALUE, Health[ this ] ) );
return HAM_SUPERCEDE;
}
}
case 3:
{
if( Check( damage, Health[ this ] ) )
{
if( task_exists( this+123 ) )
remove_task( this+123 );
SetHealth( this, REGENERATE_MIN_VALUE );
set_task( float( p_int ), "give", this+123, _, _, "b" );
return HAM_SUPERCEDE;
}
}
}
return HAM_IGNORED;
}
public give( index )
{
index -= 123;
new Float: hp;
pev( index, pev_health, hp );
new Float: total = hp + float( p_amount );
SetHealth( index, total );
if( hp >= Health[ index ] )
{
SetHealth( index, Health[ index ] );
remove_task( index );
return 0;
}
return 0;
}
SetHealth( index, Float: hp )
{
message_begin( MSG_ONE, g_msghealth, {0,0,0}, index );
write_byte( floatround( hp ) );
message_end();
set_pev( index, pev_health, hp );
}
bool: Check( Float:value, Float:compare )
return ( value >= compare ) ? true : false; |
|