text
stringlengths
0
692
if (get_tr2(0, TR_AllSolid))
result += 2
if (!get_tr2(0, TR_InOpen))
result += 4
return result
}
stock fm_trace_normal(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
engfunc(EngFunc_TraceLine, start, end, 0, ignoreent, 0)
get_tr2(0, TR_vecPlaneNormal, ret)
new Float:fraction
get_tr2(0, TR_flFraction, fraction)
if (fraction >= 1.0)
return 0
return 1
}
// note that for CS planted C4 has a "grenade" classname as well
stock fm_get_grenade_id(id, model[], len, grenadeid = 0) {
new ent = fm_find_ent_by_owner(grenadeid, "grenade", id)
if (ent && len > 0)
pev(ent, pev_model, model, len)
return ent
}
#define fm_halflife_time() get_gametime()
/* stock Float:fm_halflife_time()
return get_gametime() */
#define fm_attach_view(%1,%2) engfunc(EngFunc_SetView, %1, %2)
/* stock fm_attach_view(index, entity)
return engfunc(EngFunc_SetView, index, entity) */
stock fm_playback_event(flags, invoker, eventindex, Float:delay, const Float:origin[3], const Float:angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2) {
return engfunc(EngFunc_PlaybackEvent, flags, invoker, eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2)
}
#define fm_eng_get_string(%1,%2,%3) engfunc(EngFunc_SzFromIndex, %1, %2, %3)
/* stock fm_eng_get_string(istring, string[], len)
return engfunc(EngFunc_SzFromIndex, istring, string, len) */
/* HLSDK functions */
// the dot product is performed in 2d, making the view cone infinitely tall
stock bool:fm_is_in_viewcone(index, const Float:point[3]) {
new Float:angles[3]
pev(index, pev_angles, angles)
engfunc(EngFunc_MakeVectors, angles)
global_get(glb_v_forward, angles)
angles[2] = 0.0
new Float:origin[3], Float:diff[3], Float:norm[3]
pev(index, pev_origin, origin)
xs_vec_sub(point, origin, diff)
diff[2] = 0.0
xs_vec_normalize(diff, norm)
new Float:dot, Float:fov
dot = xs_vec_dot(norm, angles)
pev(index, pev_fov, fov)
if (dot >= floatcos(fov * M_PI / 360))
return true
return false
}
stock bool:fm_is_visible(index, const Float:point[3], ignoremonsters = 0) {
new Float:start[3], Float:view_ofs[3]
pev(index, pev_origin, start)
pev(index, pev_view_ofs, view_ofs)
xs_vec_add(start, view_ofs, start)
engfunc(EngFunc_TraceLine, start, point, ignoremonsters, index, 0)
new Float:fraction
get_tr2(0, TR_flFraction, fraction)
if (fraction == 1.0)
return true
return false
}
/* Engine_stocks functions */
stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype) {
new class[] = "trigger_hurt"
new entity = fm_create_entity(class)
if (!entity)
return 0
new value[16]
float_to_str(takedmgdamage * 2, value, sizeof value - 1)
fm_set_kvd(entity, "dmg", value, class)