图 1.
new cumulative[33];
new g_Time;
new g_Amount;
new Float:get_attack_time[33];
new g_hamczbots;
new cvar_botquota;
public plugin_init()
{
register_plugin(320, "1.0", 412);
register_event("Damage", "NeedRecovery", "be", "2>0");
register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
g_Time = register_cvar("mychat_recovery_time", "3", 0, 0.00);
g_Amount = register_cvar("mychat_recovery_health", "20", 0, 0.00);
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage", 0);
return 0;
}
public plugin_precache()
{
precache_sound("mychat/memberid_604597/post_in_mychat.wav");
return 0;
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
if (attacker != victim && !is_user_connected(attacker))
{
return 1;
}
if (zp_get_user_zombie(victim) == zp_get_user_zombie(attacker))
{
return 1;
}
if (!zp_get_user_zombie(victim))
{
return 1;
}
if (!damage_type & 2 || !damage_type & 4)
{
return 1;
}
static id;
id = victim;
if (task_exists(id, 0))
{
remove_task(id, 0);
}
if (task_exists(id + 9988, 0))
{
remove_task(id + 9988, 0);
}
cumulative[id] = 0;
return 1;
}
public NeedRecovery(id)
{
if (!is_user_alive(id) || !zp_get_user_zombie(id))
{
return 0;
}
if (1 <= cumulative[id][0][0])
{
return 0;
}
new max_health = 0;
max_health = zp_get_zombie_maxhealth(id);
if (max_health > get_user_health(id))
{
new var2 = cumulative[id];
var2 = var2[0][0] + 1;
new param[2];
param[0] = id;
if (cumulative[id][0][0] == 1)
{
param[1] = 0;
set_task(get_pcvar_float(g_Time), "RecoveryRate", id, param, 2, "b", 0);
}
else
{
param[1] = 1;
set_task(get_pcvar_float(g_Time), "RecoveryRate", id + 9988, param, 2, "", 0);
}
}
return 0;
}
public RecoveryRate(param[2])
{
if (!is_user_alive(id) || !zp_get_user_zombie(id))
{
return 0;
}
new health = get_user_health(id);
new max_health = 0;
max_health = zp_get_zombie_maxhealth(id);
new need_health = max_health - health;
if (get_pcvar_num(g_Amount) >= need_health)
{
engfunc(EngFunc_EmitSound, id, 2, "mychat/memberid_604597/post_in_mychat.wav", 1.00/*1065353216*/, 0.80/*1061997773*/, 0, 100);
set_user_health(id, max_health);
remove_task(id, 0);
remove_task(id + 9988, 0);
cumulative[id] = 0;
}
else
{
set_user_health(id, get_pcvar_num(g_Amount) + health);
if (deduct_times == 1)
{
cumulative[id] = max(cumulative[id][0][0] - 1, 0);
}
}
return 0;
}
public client_PreThink(id)
{
if (!is_user_alive(id) || !zp_get_user_zombie(id))
{
return 0;
}
if (get_gametime() - get_attack_time[id][0][0] < 0.50/*1056964608*/)
{
if (task_exists(id, 0))
{
remove_task(id, 0);
}
if (task_exists(id + 9988, 0))
{
remove_task(id + 9988, 0);
}
cumulative[id] = 0;
return 0;
}
new speed = fm_get_speed(id);
if (floatround(0.10/*1036831949*/ * 240, floatround_round) < speed)
{
if (task_exists(id, 0))
{
remove_task(id, 0);
}
if (task_exists(id + 9988, 0))
{
remove_task(id + 9988, 0);
}
cumulative[id] = 0;
return 0;
}
if (!task_exists(id, 0))
{
cumulative[id] = 0;
}
new health = get_user_health(id);
if (health >= 1)
{
if (health < max_health && cumulative[id][0][0])
{
NeedRecovery(id);
}
}
return 0;
}
public event_round_start()
{
new i = 1;
while (i <= 32)
{
cumulative[i] = 0;
i++;
}
client_print(0, print_chat, "仿CSO丧尸自愈插件 By MyChat - 文♂[会员ID:604597],此插件仅发布于MyChat数位男女论坛,若出现于其他论坛均为盗文!");
return 0;
}
public client_putinserver(id)
{
if (is_user_bot(id))
{
if (!g_hamczbots && cvar_botquota)
{
set_task(0.10, "register_ham_czbots", id, "", 0, "", 0);
}
}
return 0;
}
public register_ham_czbots(id)
{
if (g_hamczbots || !is_user_connected(id) || !get_pcvar_num(cvar_botquota))
{
return 0;
}
RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage", 0);
g_hamczbots = 1;
return 0;
}
fm_get_speed(entity)
{
static Float:velocity[3];
pev(entity, pev_velocity, velocity);
return floatround(vector_length(velocity), floatround_round);
}