#include <amxmodx>
#include <fakemeta>
#include <reapi>
#define ROTATE
new const PLUGIN_NAME[] = "[ReAPI] Ghost after death";
new const PLUGIN_VERSION[] = "0.0.1";
new const ENTITY_CLASSNAME[] = "ghost";
new const ENTITY_MODEL[] = "models/ghost.mdl";
const Float: ENTITY_LIFETIME = 2.5;
const Float: ENTITY_SPEED = 135.0;
#if defined ROTATE
const Float: ENTITY_SPEED_ROTATE = 165.0;
#endif
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, "steelzzz");
RegisterHookChain(RG_CBasePlayer_Killed, "@CPlayer_Killed_Post", .post = true);
}
public plugin_precache()
{
engfunc(EngFunc_PrecacheModel, ENTITY_MODEL);
}
@CPlayer_Killed_Post(iVictim, iAttacker, iGib)
{
if(!is_user_connected(iAttacker))
{
return;
}
new Float: vecOrigin[3];
#if defined ROTATE
new Float: vecAVelocity[3];
vecAVelocity[1] = ENTITY_SPEED_ROTATE;
#endif
get_entvar(iVictim, var_origin, vecOrigin);
new iEntity = rg_create_entity("info_target", true);
if(is_nullent(iEntity))
{
return;
}
engfunc(EngFunc_SetModel, iEntity, ENTITY_MODEL);
engfunc(EngFunc_SetSize, iEntity, {-10.0, -10.0, -10.0}, {10.0, 10.0, 10.0});
engfunc(EngFunc_SetOrigin, iEntity, vecOrigin);
set_entvar(iEntity, var_classname, ENTITY_CLASSNAME);
set_entvar(iEntity, var_movetype, MOVETYPE_NOCLIP);
set_entvar(iEntity, var_solid, SOLID_NOT);
set_entvar(iEntity, var_velocity, Float: {0.0, 0.0, ENTITY_SPEED});
#if defined ROTATE
set_entvar(iEntity, var_avelocity, vecAVelocity);
#endif
set_entvar(iEntity, var_nextthink, get_gametime() + ENTITY_LIFETIME);
SetThink(iEntity, "@EGhost_Think");
}
@EGhost_Think(iEntity)
{
set_entvar(iEntity, var_flags, get_entvar(iEntity, var_flags) | FL_KILLME);
}