#include <amxmodx>
#include <fakemeta>
#include <engine>
#define MODEL "models/flag_ctf_new.mdl"
#define MAX 82
public plugin_init()
{
register_clcmd("blood", "test_blood");
register_think("BloodMdl", "ThinkBloodEnt");
}
public plugin_precache() {
precache_model(MODEL);
}
public test_blood(id) {
if (!is_user_alive(id))
return;
new Float:fVecOrigin[3];
UTIL_GetAimOrigin(id, fVecOrigin);
SetBlood(fVecOrigin);
}
SetBlood(Float:fOrigin[3]) {
new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"));
engfunc(EngFunc_SetOrigin, iEnt, fOrigin);
engfunc(EngFunc_SetModel, iEnt, MODEL);
set_pev(iEnt, pev_classname, "BloodMdl");
set_pev(iEnt, pev_solid, SOLID_NOT);
set_pev(iEnt, pev_skin, 0);
/*
set_pev( iEnt, var_renderamt, 255.0 );
set_pev( iEnt, var_rendermode, kRenderTransAdd );
set_pev( iEnt, var_rendercolor, Float: { 0.0, 96.0, 0.0 } );
*/
set_pev(iEnt, pev_nextthink, get_gametime() + 0.1);
drop_to_floor(iEnt);
}
public ThinkBloodEnt(iEnt) {
if (!pev_valid(iEnt))
return;
new iSkin = pev(iEnt, pev_skin);
if (++iSkin > MAX) {
iSkin = MAX;
}
set_pev(iEnt, pev_skin, iSkin);
set_pev(iEnt, pev_nextthink, get_gametime() + 0.1);
}
#include <xs>
stock UTIL_GetAimOrigin(const iPlayer, Float:fVecOriginOut[3], Float:iDist = 8192.0)
{
if (!is_user_alive(iPlayer))
return -1;
enum _:eCoord { Player, View, Angle };
static Float:fVecOrigin[eCoord][3];
pev(iPlayer, pev_origin, fVecOrigin[Player]);
pev(iPlayer, pev_view_ofs, fVecOrigin[View]);
pev(iPlayer, pev_v_angle, fVecOrigin[Angle]);
xs_vec_add(fVecOrigin[Player], fVecOrigin[View], fVecOrigin[Player]);
engfunc(EngFunc_MakeVectors, fVecOrigin[Angle]);
global_get(glb_v_forward, fVecOrigin[Angle]);
xs_vec_mul_scalar(fVecOrigin[Angle], iDist, fVecOrigin[Angle]);
xs_vec_add(fVecOrigin[Player], fVecOrigin[Angle], fVecOrigin[Angle]);
engfunc(EngFunc_TraceLine, fVecOrigin[Player], fVecOrigin[Angle], 0, iPlayer, 0);
get_tr2(0, TR_vecEndPos, fVecOriginOut);
return get_tr2(0, TR_pHit);
}