关于zombie icon的问题
本帖最后由 Osker Lee 于 2011-7-31 23:25 编辑最近研究了一下僵尸插件,我想让人类变成僵尸的时候,屏幕会出现一个zombie icon图标(如图示),我拿某个单体僵尸插件改了一下,结果可以显示icon图标。但有一个问题就是:当我由僵尸变回人类时,那个icon依然还存在,一直不消失。请问有高人知道怎么解决这个问题吗?
#include <amxmodx>
#include <xs>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#define SUPPORT_BOT_TO_USE
new const zclass_name[] = { "Zombie Class: Healer" }
new const zclass_info[] = { "=Press 'R' to heal=" }
new const zclass_model[] = { "zombie_healer" }
new const zclass_clawmodel[] = { "v_knife_healer.mdl" }
const zclass_health = 5000
const zclass_speed = 240
const Float:zclass_gravity = 1.0
const Float:zclass_knockback = 1.0
new const HealSound[] = { "zombie_plague/td_debuff.wav" }
new g_zclass_kuca
new kuca_skill_cooldown, kuca_skill_range, kuca_skill_heal_point
new Float:eyes_skill
new heal_spr
public plugin_init()
{
register_plugin(" Class: Healer", "1.0", "I don't know")
kuca_skill_cooldown = register_cvar("zp_kuca_cooldown", "20.0")
kuca_skill_range = register_cvar("zp_kuca_heal_range", "300")
kuca_skill_heal_point = register_cvar("zp_kuca_heal_hp_percentage", "10")
register_forward(FM_CmdStart, "fw_CmdStart")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_event("ResetHUD","NewRound","be")
register_event("DeathMsg", "Death", "a")
}
public plugin_precache()
{
precache_sound(HealSound)
heal_spr = precache_model("sprites/zombie_plague/zombie_healer.spr")
g_zclass_kuca = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players
static msg
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color
replace_all(msg, 190, "!team2", "^0") // Team2 Color
if (id) players = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players)
write_byte(players);
write_string(msg);
message_end();
}
}
}
}
public zp_user_infected_post(id, infector)
{
if (zp_get_user_zombie_class(id) == g_zclass_kuca)
{
set_hud_spr(id,1)
ChatColor(id, "!g!yPress 'R' to heal yourself and teamates!Healing Range: %.1f,Restore HP: %d%,Cooldowng Time: %.1f.", get_pcvar_float(kuca_skill_range), get_pcvar_num(kuca_skill_heal_point), get_pcvar_float(kuca_skill_cooldown))
}
}
set_hud_spr(id,status)
{
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("StatusIcon"),{0,0,0},id);
write_byte(status); // status (0=hide, 1=show, 2=flash)
write_string("dmg_bio"); // sprite name
write_byte(0); // red
write_byte(255); // green
write_byte(0); // blue
message_end();
}
public zp_user_humanized_post(id)
{
clear(id)
}
public Death()
{
new id = read_data(2)
clear(id)
}
public NewRound(id)
{
clear(id)
}
public client_connect(id)
{
clear(id)
}
public client_disconnect(id)
{
clear(id)
}
public clear(id)
{
eyes_skill = 0.0
}
public fw_CmdStart(id, uc_handle, seed)
{
if (!is_user_alive(id))
return FMRES_IGNORED;
if (!zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_kuca)
return FMRES_IGNORED;
if (zp_get_user_nemesis(id))
return FMRES_IGNORED;
static button, oldbutton, i
button = get_uc(uc_handle, UC_Buttons)
oldbutton = pev(id, pev_oldbuttons)
if ((button & IN_RELOAD) && !(oldbutton & IN_RELOAD))
{
if (get_gametime() - eyes_skill < get_pcvar_float(kuca_skill_cooldown))
{
ChatColor(id, "!g!yDuring the cooldown...")
return FMRES_IGNORED;
}
for(i = 1; i <= get_playersnum(); i++)
if(id != i && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
if (is_in_view(id, i) && get_range(id, i) <= get_pcvar_float(kuca_skill_range))
heal_zombie(i)
heal_zombie(id)
eyes_skill = get_gametime()
}
#if defined SUPPORT_BOT_TO_USE
if (is_user_bot(id))
{
if (get_gametime() - eyes_skill < get_pcvar_float(kuca_skill_cooldown))
return FMRES_IGNORED;
static bool:need_heal_in_view
for(i = 1; i <= get_playersnum(); i++)
if(id != i && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
if (pev(i, pev_health) <= float(zp_get_zombie_maxhealth(i))*(100-get_pcvar_float(kuca_skill_heal_point))/100)
if (is_in_view(id, i) && get_range(id, i) <= get_pcvar_float(kuca_skill_range))
need_heal_in_view = true
if (need_heal_in_view || pev(id, pev_health) <= float(zp_get_zombie_maxhealth(id))*(100-get_pcvar_float(kuca_skill_heal_point))/100)
{
for(i = 1; i <= get_playersnum(); i++)
if(id != i && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
if (is_in_view(id, i) && get_range(id, i) <= get_pcvar_float(kuca_skill_range))
heal_zombie(i)
heal_zombie(id)
need_heal_in_view = false
eyes_skill = get_gametime()
}
}
#endif
return FMRES_HANDLED;
}
public heal_zombie(id)
{
show_spr(id)
engfunc(EngFunc_EmitSound, id, CHAN_AUTO, HealSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
if (pev(id, pev_health) < float(zp_get_zombie_maxhealth(id)))
set_pev(id, pev_health, floatmin(pev(id, pev_health) + float(zp_get_zombie_maxhealth(id))*get_pcvar_float(kuca_skill_heal_point)/100, float(zp_get_zombie_maxhealth(id))))
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id)) return FMRES_IGNORED;
if (zp_get_user_nemesis(id)) return FMRES_IGNORED;
if (!zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_kuca) return FMRES_IGNORED;
if (get_gametime() - eyes_skill >= get_pcvar_float(kuca_skill_cooldown) && get_gametime() - eyes_skill < get_pcvar_float(kuca_skill_cooldown)+0.1)
ChatColor(id, "!g!yNow you can use your skill again!")
return FMRES_IGNORED;
}
stock Float:get_range(index, target)
{
static Float:origin1, Float:origin2
pev(index, pev_origin, origin1)
pev(target, pev_origin, origin2)
return get_distance_f(origin1,origin2)
}
stock show_spr(id)
{
static Float:origin
pev(id, pev_origin, origin)
engfunc(EngFunc_MessageBegin,MSG_BROADCAST,SVC_TEMPENTITY,origin,0)
write_byte(TE_SPRITE)
engfunc(EngFunc_WriteCoord,origin)
engfunc(EngFunc_WriteCoord,origin)
engfunc(EngFunc_WriteCoord,origin+16)
write_short(heal_spr)
write_byte(10)
write_byte(255)
message_end()
}
stock bool:is_in_view(index, target, ignoremonsters = 1)
{
if (index == target) return false;
new Float:angles;
pev(index, pev_angles, angles);
engfunc(EngFunc_MakeVectors, angles);
global_get(glb_v_forward, angles);
angles = 0.0;
new Float:origin, Float:point, Float:diff, Float:norm, Float:view_ofs;
pev(index, pev_origin, origin);
pev(target, pev_origin, point);
xs_vec_sub(point, origin, diff);
diff = 0.0;
xs_vec_normalize(diff, norm);
pev(index, pev_view_ofs, view_ofs);
xs_vec_add(origin, view_ofs, origin);
engfunc(EngFunc_TraceLine, origin, point, ignoremonsters, index, 0);
new Float:dot, Float:fov;
dot = xs_vec_dot(norm, angles);
pev(index, pev_fov, fov);
new Float:fraction;
get_tr2(0, TR_flFraction, fraction);
if (dot >= floatcos(fov * M_PI / 360) && fraction == 1.0)
return true;
return false;
} 变回人类时,用一下
set_hud_spr(id, 0)
页:
[1]