HsK
CCN@HsK
級別: 版主
版區: CS插件區
x1701
x1108
|
分享:
▲
▼
new ent, Float:botOrigin[3], Float:view_ofs[3]; pev(id, pev_origin, botOrigin); pev(id, pev_view_ofs, view_ofs); xs_vec_add(botOrigin, view_ofs, botOrigin);
while ((pev_valid(ent = fm_find_ent_by_class(ent, "npc_classname")))) { new Float:origin[3]; pev(ent, pev_origin, origin);
engfunc(EngFunc_TraceLine, botOrigin, origin, 1, id, 0); new Float:fraction; get_tr2(0, TR_flFraction, fraction); if (fraction == 1.0 || get_tr2(0, TR_pHit) == ent) { get_tr2(0, TR_vecEndPos, origin); //執行攻擊指令 } else { for (new i = 0; i < 5; i++) { new Float:mins[3], Float:maxs[3]; pev(ent, pev_mins, mins); pev(ent, pev_maxs, maxs); pev(ent, pev_origin, origin);
origin[0] += random_float (mins[0], maxs[0]); origin[1] += random_float (mins[1], maxs[1]); origin[2] += random_float (mins[2], maxs[2]);
engfunc(EngFunc_TraceLine, botOrigin, origin, 1, id, 0); get_tr2(0, TR_flFraction, fraction); if (fraction >= 1.0 && get_tr2(0, TR_pHit) == ent) { get_tr2(0, TR_vecEndPos, origin); //執行攻擊指令 break; } } } }
[ 此文章被HsK在2012-08-23 17:48重新編輯 ]
|