#include <amxmodx>
#include <reapi>
enum {
TASK_Think = 13378
}
const Float: TASK_FREQ = 0.1;
const TRANS_SPEED = 60;
const Float: GRAVITY = -0.3;
const FULLVIS = 255;
new g_iCurrentThink[MAX_CLIENTS + 1] = { 255, ... };
public plugin_init() {
register_plugin("Angelic death", "0.0.1b", "wopox1337");
RegisterHookChain(RG_CSGameRules_PlayerKilled, "CSGameRules_PlayerKilled", .post = true);
RegisterHookChain(RG_CSGameRules_PlayerSpawn, "CSGameRules_PlayerSpawn", .post = true);
// TODO
//RegisterHookChain(RG_CBasePlayer_PreThink, "CBasePlayer_PreThink", .post = true);
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET);
}
public CBasePlayer_PreThink(pPlayer) {
set_entvar(pPlayer, var_sequence, 104);
set_entvar(pPlayer, var_gaitsequence, 1);
}
public CSGameRules_PlayerKilled(const pPlayer, const killer, const inflictor) {
set_entvar(pPlayer, var_gravity, GRAVITY);
set_task(TASK_FREQ, "OnPlayer_Think_Dead", .id = TASK_Think + pPlayer);
g_iCurrentThink[pPlayer] = FULLVIS;
}
public CSGameRules_PlayerSpawn(pPlayer) {
// set_entvar(pPlayer, var_flags, ~FL_FROZEN);
if(!is_user_connected(pPlayer)) return;
rg_set_rendering(pPlayer,
.fx = kRenderFxNone,
.render = kRenderNormal,
.amount = FULLVIS
);
}
public OnPlayer_Think_Dead(pPlayer) {
pPlayer -= TASK_Think;
if((g_iCurrentThink[pPlayer] -= TRANS_SPEED) > 0)
set_task(TASK_FREQ, "OnPlayer_Think_Dead", .id = TASK_Think + pPlayer);
else
g_iCurrentThink[pPlayer] = 0;
rg_set_rendering(pPlayer,
.fx = kRenderFxSolidFast,
.render = kRenderTransAdd,
.amount = g_iCurrentThink[pPlayer]
);
}
// Thanks to BAILOPAN for useful stock
stock rg_set_rendering(index, fx = kRenderFxNone, render = kRenderNormal, const amount = 16)
{
set_entvar(index, var_renderfx, fx);
set_entvar(index, var_rendermode, render);
set_entvar(index, var_renderamt, float(amount));
}