Raised This Month: $ Target: $400
 0% 

AddToFullPack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 05-09-2013 , 05:35   AddToFullPack
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <xs>

#define PLUGIN "[ZP] Addon: Infect-Effect"
#define VERSION "1.0"
#define AUTHOR "Dias"

new g_effect_id[33], g_had_effect[33]
new const 
effect_model[] = "sprites/infect-effect.spr"

new cvar_scalecvar_showtimecvar_lightlevel

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn"player""fw_spawn_post"1)
    
register_forward(FM_AddToFullPack"fw_WhatTheFuck_Post"1)
    
    
cvar_scale ryegister_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.0")
}

public 
plugin_precache()
{
    
precache_model(effect_model)
}

public 
fw_spawn_post(id)
{
    if(
g_had_effect[id])
        
remove_effect(id)
}

public 
zp_user_infected_post(idattacker)
{
    if(
is_user_alive(attacker))
    {
        
show_effect(id)
    }
}

public 
show_effect(id)
{
    
g_effect_id[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"env_sprite"))
    
    if (!
pev_valid(g_effect_id[id]))
        return
    
    
g_had_effect[id] = 1
    
    set_pev
(g_effect_id[id], pev_solidSOLID_NOT)
    
set_pev(g_effect_id[id], pev_movetypeMOVETYPE_NONE)

    
engfunc(EngFunc_SetModelg_effect_id[id], effect_model)
    
    
set_pev(g_effect_id[id], pev_rendermodekRenderTransAlpha)
    
set_pev(g_effect_id[id], pev_renderamt0.0)
    
set_pev(g_effect_id[id], pev_ownerid)
    
set_pev(g_effect_id[id], pev_scaleget_pcvar_float(cvar_scale))
    
set_pev(g_effect_id[id], pev_light_levelget_pcvar_float(cvar_lightlevel))
    
    
set_task(get_pcvar_float(cvar_showtime), "remove_effect"g_effect_id[id])
}

public 
fw_WhatTheFuck_Post(eseenthosthost_flagsplayerp_set)
{
    if(!(
host 33))
        return 
FMRES_IGNORED
        
    
if(ent != g_effect_id[host] || !pev_valid(ent))
        return 
FMRES_IGNORED
        
    
if(pev(entpev_owner) != host)
        return 
FMRES_IGNORED
        
    
if(!is_user_alive(host))
        return 
FMRES_IGNORED
        
    
static Float:origin[3], Float:forvec[3], Float:voffsets[3], Float:Angles[3]
    
    
pev(hostpev_originorigin)
    
pev(hostpev_view_ofsvoffsets)
    
pev(hostpev_anglesAngles)
    
    
xs_vec_add(originvoffsetsorigin)
    
    
// Get a forward vector in the direction of player's aim
    
velocity_by_aim(host10forvec)
    
    
// Set the sprite on the new origin
    
xs_vec_add(originforvecorigin)
    
    
engfunc(EngFunc_SetOriginentorigin)
    
set_es(esES_Originorigin)
    
set_es(esES_AnglesAngles)
    
    
// Make the sprite visible
    
set_es(esES_RenderModekRenderTransAdd)
    
set_es(esES_RenderAmt200)
        
    return 
FMRES_HANDLED
}

public 
remove_effect(ent)
{
    
g_had_effect[pev(entpev_owner)] = 0
    
    
if(pev_valid(ent))
        
engfunc(EngFunc_RemoveEntityent)

This code works, but it sometimes bugs weapons or grenades. E.g. you want to throw a weapon, but it stays in front of you and follows you, the same thing with grenade. Why is that bug appearing? I looked through the code many times and still cant get whats wrong..
Podarok is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-09-2013 , 06:11   Re: AddToFullPack
Reply With Quote #2

You shouldn't use :

engfunc(EngFunc_SetOrigin, ent, origin)

in AddToFullPack.

Only alter es struct values (set_es)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 05-09-2013 , 17:59   Re: AddToFullPack
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
You shouldn't use :

engfunc(EngFunc_SetOrigin, ent, origin)

in AddToFullPack.

Only alter es struct values (set_es)
._. I always thougth that you need to use SetOrigin on AddToFullPack + ES_Origin for showing correctly an sprite constantly on your screen, so it isn't needed?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-09-2013 , 19:32   Re: AddToFullPack
Reply With Quote #4

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_SetOriginent, ...)
    return 
FMRES_HANDLED
}
else
{
    
forward_return)
    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_scalecvar_showtimecvar_lightlevel;

new 
g_iPlayerEntEffectIndex[33];
new 
g_iszEnvSpriteg_iszCustomClassg_iszModel;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSION"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_AllocStringENV_SPRITE_CLASS);
    
g_iszCustomClass engfunc(EngFunc_AllocStringINFECT_EFFECT_CLASS);
    
g_iszModel engfunc(EngFunc_AllocStringINFECT_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_RestartENV_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(idattacker)
{
    if(
is_user_alive(attacker))
    {
        new 
ent engfunc(EngFunc_CreateNamedEntityg_iszEnvSprite);
        if( 
ent <= )
        {
            return;
        }

        
set_pev_string(entpev_modelg_iszModel);
        
entity_set_int(entEV_INT_spawnflagsSF_SPRITE_STARTON);

        if( 
DispatchSpawn(ent) == -)
        {
            
remove_entity(ent);
        }
        
        
entity_set_int(entEV_INT_rendermodekRenderTransAdd);
        
entity_set_float(entEV_FL_renderamt200.0);
        
entity_set_float(entEV_FL_scaleget_pcvar_float(cvar_scale));
        
entity_set_int(entEV_INT_light_levelget_pcvar_num(cvar_lightlevel));

        
set_pev_string(entpev_classnameg_iszCustomClass);
        
entity_set_float(entEV_FL_nextthinkget_gametime() + get_pcvar_float(cvar_showtime));

        
MarkSpriteEffect(ent);
        
g_iPlayerEntEffectIndex[id] = ent;
        
entity_set_edict(entEV_ENT_euser1id);
    }
}

public 
OnAddToFullPack(eseentidhostflagsplayerpSet)
{
    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(id10v_forward);

    
entity_get_vector(idEV_VEC_originorigin);
    
origin[2] += entity_get_int(idEV_INT_flags) & FL_DUCKING 12.0 18.0;

    
xs_vec_add(originv_forwardorigin);
    
engfunc(EngFunc_SetOriginentorigin);

    
entity_get_vector(idEV_VEC_anglesangles);
    
entity_set_vector(entEV_VEC_anglesangles);

    return 
FMRES_HANDLED;
}

public 
OnCSprite_Restartent )
{
    if( 
IsSpriteEffect(ent) )
    {
        
Think_InfectEffectent );
    }
}

public 
Think_InfectEffectent )
{
    new 
id entity_get_edict(entEV_ENT_euser1);
    
g_iPlayerEntEffectIndex[id] = 0;
    
remove_entity(ent);
    
ClearSpriteEffect(ent);
    return 
PLUGIN_HANDLED;

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 05-09-2013 at 20:39.
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 05-09-2013 , 10:04   Re: AddToFullPack
Reply With Quote #5

PHP Code:
"fw_WhatTheFuck_Post" 
Seriously?
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 05-09-2013 , 10:31   Re: AddToFullPack
Reply With Quote #6

I just removed
engfunc(EngFunc_SetOrigin, ent, origin)
but stuff is still stucking into player :/ what to do ?
Podarok is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 05-09-2013 , 12:08   Re: AddToFullPack
Reply With Quote #7

set_es( es, ES_Origin, origin )
.Dare Devil. is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 05-09-2013 , 12:12   Re: AddToFullPack
Reply With Quote #8

What do I have to do with this , Dare? Its there, right... i just removed engfunc line and its still lagging (stucking grenades and weapons when throw)
Podarok is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 05-10-2013 , 09:37   Re: AddToFullPack
Reply With Quote #9

It works thanks Connor, no items getting stuck, awesome, but one problem that this sprite is flashing much on enemies screen..
Podarok is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode