| ConnorMcLeod |
05-09-2013 19:32 |
Re: AddToFullPack
If you set real origin, do that at another place, PostThink for example, then you don't even need to fake an origin in AddToFullPack because player gonna see it at the correct origin.
You may want to hide it from other players though, in that case, just supercede AddToFullPack for host == other players and ent == entity.
You could hook only AddToFullPack PRE (then no postThink at all), and do that :
PHP Code:
if( sprite[host] == ent ) { engfunc(EngFunc_SetOrigin, ent, ...) return FMRES_HANDLED } else { forward_return( 0 ) return FMRES_SUPERCEDE }
I don't know if a ZP server can support a well coded plugin, but if it does, you can try this :
PHP Code:
#include <amxmodx> #include <engine> #include <fakemeta> #include <hamsandwich> #include <zombieplague> #include <xs>
#pragma semicolon 1
#define PLUGIN "[ZP] Addon: Infect-Effect" #define VERSION "2.0.2"
new const INFECT_EFFECT_MODEL[] = "sprites/infect-effect.spr";
new const INFECT_EFFECT_CLASS[] = "env_infect_effect";
new const ENV_SPRITE_CLASS[] = "env_sprite"; // don't change
#define MaskEnt(%0) ( 1<<(%0 & 31) )
new g_bitSpriteEffectsEnts[64]; #define MarkSpriteEffect(%0) g_bitSpriteEffectsEnts[%0>>5] |= MaskEnt(%0) #define ClearSpriteEffect(%0) g_bitSpriteEffectsEnts[%0>>5] &= ~MaskEnt(%0) #define IsSpriteEffect(%0) ( g_bitSpriteEffectsEnts[%0>>5] & MaskEnt(%0) )
new cvar_scale, cvar_showtime, cvar_lightlevel;
new g_iPlayerEntEffectIndex[33]; new g_iszEnvSprite, g_iszCustomClass, g_iszModel;
public plugin_init() { register_plugin(PLUGIN, VERSION, "ConnorMcLeod");
cvar_scale = register_cvar("zp_in-ef_scale", "0.035"); cvar_showtime = register_cvar("zp_in-ef_showtime", "2.0"); cvar_lightlevel = register_cvar("zp_in-ef_lightlevel", "100");
g_iszEnvSprite = engfunc(EngFunc_AllocString, ENV_SPRITE_CLASS); g_iszCustomClass = engfunc(EngFunc_AllocString, INFECT_EFFECT_CLASS); g_iszModel = engfunc(EngFunc_AllocString, INFECT_EFFECT_MODEL); register_think(INFECT_EFFECT_CLASS, "Think_InfectEffect");
RegisterHam(Ham_Spawn, "player", "OnCBasePlayer_Spawn_P", true); register_forward(FM_AddToFullPack, "OnAddToFullPack", false); RegisterHam(Ham_CS_Restart, ENV_SPRITE_CLASS, "OnCSprite_Restart", false); }
public plugin_precache() { precache_model(INFECT_EFFECT_MODEL); }
public OnCBasePlayer_Spawn_P(id) { new ent = g_iPlayerEntEffectIndex[id]; if( ent ) { if( pev_valid(ent) ) { remove_entity(ent); ClearSpriteEffect(ent); } g_iPlayerEntEffectIndex[id] = 0; } }
public zp_user_infected_post(id, attacker) { if(is_user_alive(attacker)) { new ent = engfunc(EngFunc_CreateNamedEntity, g_iszEnvSprite); if( ent <= 0 ) { return; }
set_pev_string(ent, pev_model, g_iszModel); entity_set_int(ent, EV_INT_spawnflags, SF_SPRITE_STARTON);
if( DispatchSpawn(ent) == -1 ) { remove_entity(ent); } entity_set_int(ent, EV_INT_rendermode, kRenderTransAdd); entity_set_float(ent, EV_FL_renderamt, 200.0); entity_set_float(ent, EV_FL_scale, get_pcvar_float(cvar_scale)); entity_set_int(ent, EV_INT_light_level, get_pcvar_num(cvar_lightlevel));
set_pev_string(ent, pev_classname, g_iszCustomClass); entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(cvar_showtime));
MarkSpriteEffect(ent); g_iPlayerEntEffectIndex[id] = ent; entity_set_edict(ent, EV_ENT_euser1, id); } }
public OnAddToFullPack(es, e, ent, id, hostflags, player, pSet) { if( player || !IsSpriteEffect(ent) ) { return FMRES_IGNORED; }
if( g_iPlayerEntEffectIndex[id] != ent ) { forward_return(0); return FMRES_SUPERCEDE; }
static Float:origin[3], Float:v_forward[3], Float:angles[3];
velocity_by_aim(id, 10, v_forward);
entity_get_vector(id, EV_VEC_origin, origin); origin[2] += entity_get_int(id, EV_INT_flags) & FL_DUCKING ? 12.0 : 18.0;
xs_vec_add(origin, v_forward, origin); engfunc(EngFunc_SetOrigin, ent, origin);
entity_get_vector(id, EV_VEC_angles, angles); entity_set_vector(ent, EV_VEC_angles, angles);
return FMRES_HANDLED; }
public OnCSprite_Restart( ent ) { if( IsSpriteEffect(ent) ) { Think_InfectEffect( ent ); } }
public Think_InfectEffect( ent ) { new id = entity_get_edict(ent, EV_ENT_euser1); g_iPlayerEntEffectIndex[id] = 0; remove_entity(ent); ClearSpriteEffect(ent); return PLUGIN_HANDLED; }
|