#include <amxmodx>
#include <engine>
#include <fakemeta_util>
#define GIVE_HEALTH 2
#define GIVE_ARMOR 1
#define INTERVAL_REGENERATION 1.0
new const g_szModel[] = "models/crux_ansata.mdl";
new g_iPlayerId, szName[32];
public plugin_init()
{
register_plugin("Crux Ansata", "1.0", "DUKKHAZ0R");
register_touch("crux_ansata", "player", "fw_TouchEntity");
register_event("DeathMsg", "eDeathMsg", "a", "1>0");
register_concmd("talisman", "GiveTalisman");
set_task(INTERVAL_REGENERATION, "RegenerationHealth", .flags="b");
}
public plugin_precache()
{
precache_model(g_szModel);
}
public client_disconnect(id)
{
if(g_iPlayerId == id)
{
static Float:flOrigin[3];
new iEnt = create_entity("info_target");
if(!is_valid_ent(iEnt))
return;
entity_get_vector(id, EV_VEC_origin, flOrigin);
entity_set_vector(iEnt, EV_VEC_origin, flOrigin);
entity_set_string(iEnt, EV_SZ_classname, "crux_ansata");
entity_set_int(iEnt, EV_INT_solid, SOLID_TRIGGER);
// entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_NONE);
entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_TOSS);
// entity_set_int(iEnt, EV_INT_effects, 8);
fm_set_rendering(iEnt,kRenderFxGlowShell,0,250,0,kRenderNormal,32);
entity_set_model(iEnt, g_szModel);
entity_set_size(iEnt, Float:{-16.0,-16.0,-16.0}, Float:{16.0,16.0,16.0});
client_print(0,print_chat,"%s lost the talisman!", szName);
g_iPlayerId = 0;
}
}
public GiveTalisman(id)
{
static iEnt;
while((iEnt = find_ent_by_class(iEnt, "crux_ansata")))
remove_entity(iEnt);
g_iPlayerId = id
get_user_name(g_iPlayerId, szName, charsmax(szName));
client_print(0,print_chat,"%s have the talisman!", szName);
fm_set_rendering(id,kRenderFxGlowShell,0,250,0,kRenderNormal,32);
}
public eDeathMsg()
{
static pVictim, Float:flOrigin[3]; pVictim = read_data(2);
if(pVictim == g_iPlayerId)
{
new iEnt = create_entity("info_target");
if(!is_valid_ent(iEnt))
return;
entity_get_vector(pVictim, EV_VEC_origin, flOrigin);
entity_set_vector(iEnt, EV_VEC_origin, flOrigin);
entity_set_string(iEnt, EV_SZ_classname, "crux_ansata");
entity_set_int(iEnt, EV_INT_solid, SOLID_TRIGGER);
// entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_NONE);
entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_TOSS);
// entity_set_int(iEnt, EV_INT_effects, 8);
fm_set_rendering(iEnt,kRenderFxGlowShell,0,250,0,kRenderNormal,32);
entity_set_model(iEnt, g_szModel);
entity_set_size(iEnt, Float:{-16.0,-16.0,-16.0}, Float:{16.0,16.0,16.0});
client_print(0,print_chat,"%s lost the talisman!", szName);
g_iPlayerId = 0;
}
}
public fw_TouchEntity(iEnt, id)
{
if(!is_valid_ent(iEnt) || !is_user_alive(id))
return;
entity_set_int(iEnt, EV_INT_flags, FL_KILLME);
fm_set_rendering(id,kRenderFxGlowShell,0,250,0,kRenderNormal,32);
get_user_name(g_iPlayerId = id, szName, charsmax(szName));
client_print(0,print_chat,"%s took the talisman!", szName);
}
public RegenerationHealth()
{
if(!g_iPlayerId)
return;
static Float:fHealth, MsgId_Health; fHealth = entity_get_float(g_iPlayerId, EV_FL_health);
static Float:fArmor, MsgId_Armor; fArmor = entity_get_float(g_iPlayerId, EV_FL_armorvalue);
if(!MsgId_Health) MsgId_Health = get_user_msgid("Health");
if(fHealth < 100 && is_user_alive(g_iPlayerId))
{
static Float:giveHealth; giveHealth = (fHealth + GIVE_HEALTH) < 100 ? float(GIVE_HEALTH) : (100 - fHealth);
entity_set_float(g_iPlayerId, EV_FL_health, fHealth + giveHealth);
}
else if(fArmor < 100 && is_user_alive(g_iPlayerId))
{
static Float:giveArmor; giveArmor = (fArmor + GIVE_ARMOR) < 100 ? float(GIVE_ARMOR) : (100 - fArmor);
entity_set_float(g_iPlayerId, EV_FL_armorvalue, fArmor + giveArmor);
}
// static Float:origin[3];
// pev(g_iPlayerId,pev_origin,origin);
// message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
// write_byte(27); // TE_DLIGHT
// write_coord(floatround(origin[0])); // x
// write_coord(floatround(origin[1])); // y
// write_coord(floatround(origin[2])); // z
// write_byte(15); // radius
// write_byte(0); // r
// write_byte(100); // g
// write_byte(0); // b
// write_byte(100); // life <<<<<<<<
// write_byte(10); // decay rate
// message_end();