Nade Health?Привет всем.
Не знаю, как правильно объяснить, но кто видел, тот поймёт.
Плагин заменяет дым на гранату с лечением в радиусе своих.
Кто знает?
/*
For fun >_<
bulka1337
04/august/17
===================================
Require:
- Reapi
- AMX 1.8.3 or above
===================================
*/
#define MAX_HEALTH 100
#define V_MODEL "models/x/v_heal.mdl"
#define P_MODEL "models/x/p_heal.mdl"
#define W_HEAL_MODEL "models/x/w_heal.mdl"
#define HEAL_SOUND "sound/x/heal.wav"
/*========================================
// Don't touch it LOL
========================================*/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <reapi>
#define NADE_HEAL 1337
enum _:ANIM_SMOKE
{
ANIM_IDLE = 0,
ANIM_PULLIN,
ANIM_THROW,
ANIM_DEPLOY
}
public plugin_precache()
{
precache_model(V_MODEL);
precache_model(P_MODEL);
precache_model(W_HEAL_MODEL);
precache_sound(HEAL_SOUND);
}
public plugin_init()
{
register_plugin("Heal Grenade", )
register_forward(FM_SetModel, "FM_SetModel_Grenade")
RegisterHam( Ham_Think, "grenade", "HamHook_ThinkGrenade" )
RegisterHam( Ham_CS_Weapon_SendWeaponAnim, "weapon_smokegrenade", "HamHook_Weapon_Anim_Post", true) // Better than use CurWeapon for that
}
public FM_SetModel_Grenade(ent, model[])
{
if (strlen(model) < 8)
{
return;
}
if (model[7] != 'w' || model[8] != '_')
{
return;
}
new Float:dmgtime
get_entvar(ent, var_dmgtime, dmgtime)
// Grenade not yet thrown
if (dmgtime == 0.0)
{
return;
}
if (model[9] == 's' && model[10] == 'm')
{
engfunc( EngFunc_SetModel, ent, W_HEAL_MODEL )
set_entvar(ent, var_flTimeStepSound, NADE_HEAL)
}
}
public HamHook_ThinkGrenade(ent)
{
if(!is_entity(ent))
{
return HAM_IGNORED;
}
new Float:dmgtime; dmgtime = get_entvar(ent, var_dmgtime);
if(dmgtime > get_gametime())
{
return HAM_IGNORED;
}
if(get_entvar(ent, var_flTimeStepSound) != NADE_HEAL)
{
return HAM_IGNORED;
}
boom(ent);
return HAM_IGNORED;
}
public HamHook_Weapon_Anim_Post(ent, anim, skiplocal)
{
new iPlayer; iPlayer = get_member(ent, m_pPlayer)
switch(anim)
{
case ANIM_IDLE:
{
// No code
}
case ANIM_PULLIN:
{
// No code
}
case ANIM_THROW:
{
/*
Delete the player weapon model,
cause grenade already throw
so we don't need model on the player
*/
set_entvar(iPlayer, var_weaponmodel, 0);
}
case ANIM_DEPLOY:
{
set_entvar(iPlayer, var_viewmodel, V_MODEL)
set_entvar(iPlayer, var_weaponmodel, P_MODEL)
}
}
}
public boom(ent)
{
new Float:origin[3], victim
get_entvar(ent, var_origin, origin)
some_effect(origin)
emit_sound(ent, CHAN_WEAPON, HEAL_SOUND, 1.0, ATTN_NORM, 0, PITCH_NORM)
victim = -1;
while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, 300.0)) != 0)
{
heal(victim);
}
}
public heal(iPlayer)
{
new health; health = get_entvar(iPlayer, var_health);
if(health > MAX_HEALTH)
{
return;
}
health = MAX_HEALTH - health;
set_member(iPlayer, m_idrowndmg, health)
set_member(iPlayer, m_idrownrestored, 0)
}
stock some_effect(Float:Origin[3])
{
// No code for now
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(TE_DLIGHT);//27
write_coord(floatround(Origin[0])); // x
write_coord(floatround(Origin[1])); // y
write_coord(floatround(Origin[2])); // z
write_byte(15); // radius
write_byte(150); // r
write_byte(255); // g
write_byte(150); // b
write_byte(20); // life <<<<<<<<
write_byte(60); // decay rate
message_end();
}
Не компилирует :-(Написал по фану
не тестил
Код:/* For fun >_< bulka1337 04/august/17 =================================== Require: - Reapi - AMX 1.8.3 or above =================================== */ #define MAX_HEALTH 100 #define V_MODEL "models/x/v_heal.mdl" #define P_MODEL "models/x/p_heal.mdl" #define W_HEAL_MODEL "models/x/w_heal.mdl" #define HEAL_SOUND "sound/x/heal.wav" /*======================================== // Don't touch it LOL ========================================*/ #include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <reapi> #define NADE_HEAL 1337 enum _:ANIM_SMOKE { ANIM_IDLE = 0, ANIM_PULLIN, ANIM_THROW, ANIM_DEPLOY } public plugin_precache() { precache_model(V_MODEL); precache_model(P_MODEL); precache_model(W_HEAL_MODEL); precache_sound(HEAL_SOUND); } public plugin_init() { register_plugin("Heal Grenade", ) register_forward(FM_SetModel, "FM_SetModel_Grenade") RegisterHam( Ham_Think, "grenade", "HamHook_ThinkGrenade" ) RegisterHam( Ham_CS_Weapon_SendWeaponAnim, "weapon_smokegrenade", "HamHook_Weapon_Anim_Post", true) // Better than use CurWeapon for that } public FM_SetModel_Grenade(ent, model[]) { if (strlen(model) < 8) { return; } if (model[7] != 'w' || model[8] != '_') { return; } new Float:dmgtime get_entvar(ent, var_dmgtime, dmgtime) // Grenade not yet thrown if (dmgtime == 0.0) { return; } if (model[9] == 's' && model[10] == 'm') { engfunc( EngFunc_SetModel, ent, W_HEAL_MODEL ) set_entvar(ent, var_flTimeStepSound, NADE_HEAL) } } public HamHook_ThinkGrenade(ent) { if(!is_entity(ent)) { return HAM_IGNORED; } new Float:dmgtime; dmgtime = get_entvar(ent, var_dmgtime); if(dmgtime > get_gametime()) { return HAM_IGNORED; } if(get_entvar(ent, var_flTimeStepSound) != NADE_HEAL) { return HAM_IGNORED; } boom(ent); return HAM_IGNORED; } public HamHook_Weapon_Anim_Post(ent, anim, skiplocal) { new iPlayer; iPlayer = get_member(ent, m_pPlayer) switch(anim) { case ANIM_IDLE: { // No code } case ANIM_PULLIN: { // No code } case ANIM_THROW: { /* Delete the player weapon model, cause grenade already throw so we don't need model on the player */ set_entvar(iPlayer, var_weaponmodel, 0); } case ANIM_DEPLOY: { set_entvar(iPlayer, var_viewmodel, V_MODEL) set_entvar(iPlayer, var_weaponmodel, P_MODEL) } } } public boom(ent) { new Float:origin[3], victim get_entvar(ent, var_origin, origin) some_effect(origin) emit_sound(ent, CHAN_WEAPON, HEAL_SOUND, 1.0, ATTN_NORM, 0, PITCH_NORM) victim = -1; while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, 300.0)) != 0) { heal(victim); } } public heal(iPlayer) { new health; health = get_entvar(iPlayer, var_health); if(health > MAX_HEALTH) { return; } health = MAX_HEALTH - health; set_member(iPlayer, m_idrowndmg, health) set_member(iPlayer, m_idrownrestored, 0) } stock some_effect(Float:Origin[3]) { // No code for now message_begin(MSG_BROADCAST,SVC_TEMPENTITY); write_byte(TE_DLIGHT);//27 write_coord(floatround(Origin[0])); // x write_coord(floatround(Origin[1])); // y write_coord(floatround(Origin[2])); // z write_byte(15); // radius write_byte(150); // r write_byte(255); // g write_byte(150); // b write_byte(20); // life <<<<<<<< write_byte(60); // decay rate message_end(); }
Ванин у меня не работает , хотя очень функциональный . А второй с багом . Игроки бегают с зеленым свечением )