Thread: Ring Backpack
View Single Post
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-30-2022 , 19:33   Re: Ring Backpack
Reply With Quote #2

PHP Code:
set_pev(iEntpev_nextthinktime 0.1
It seems that when removing that part, the model is set and not removed.
Edit: I edited some parts of the code, I know it's not the right section but I had free time to do so. I've named the changes so it's easier for you to understand 'em.
By my perspective, your code was doing some weird things besides that issue. Let me know if that code I'm providing is what you wanted, it doesn't conflict with the Weapon Physics and also skips the wall.

PHP Code:
#pragma semicolon 1

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <xs>

new g_Backpack_SmokeSprite;

#define BOMB_PACK_ICON        "sprites/backpack_smoke/backpack_ring.spr"
#define RING_CLASSNAME        "Bomb_Ring"

#define RING_BOMB_ENTITY    pev_iuser1

new Float:fColor[][3] = 
{
    {
255.00.00.0},
    {
0.00.0255.0},
    {
0.0255.00.0},
    {
255.0255.06.0},
    {
255.00.0255.0}
};

public 
plugin_init()
{
    
register_plugin("C4 Smoke""1.0""fl0wer");
    
    
register_touch("worldspawn""weaponbox""weaponboxTouch");
    
register_think(RING_CLASSNAME"ringThink");
}

public 
plugin_precache()
{
    
g_Backpack_SmokeSprite precache_model("sprites/backpack_smoke/backpack_smoke.spr");
    
precache_model(BOMB_PACK_ICON);
}

public 
weaponboxTouch(iWorldSpawniBombEntity)
{
    if(!
pev_valid(iBombEntity))
        return 
PLUGIN_HANDLED;
        
    static 
szBombModel[32];
    
pev(iBombEntitypev_modelszBombModelcharsmax(szBombModel));
    if(
containi(szBombModel"w_backpack") == -1)
        return 
PLUGIN_HANDLED;
        
    if(
pev(iBombEntitypev_flags) & ~FL_ONGROUND
        return 
PLUGIN_HANDLED;
        
    static 
Float:vecOrigin[3];
    
pev(iBombEntitypev_originvecOrigin);
        
    
// lie flat code ^^
    
static Float:fTraceTo[3], Float:fFraction;
    
xs_vec_sub(vecOriginFloat:{0.00.010.0}, fTraceTo);
    
    
engfunc(EngFunc_TraceLinevecOriginfTraceToIGNORE_MONSTERSiBombEntity0);
    
get_tr2(0TR_flFractionfFraction);
    if(
fFraction == 1.0
        return 
PLUGIN_HANDLED;
        
    static 
bombEntity;bombEntity pev(iBombEntityRING_BOMB_ENTITY);
    if(
bombEntity)
    {
        if(
bombEntity get_maxplayers())
        {
            
remove_task(iBombEntity);
            
set_task(0.5"makeBombFloat"iBombEntity);
        }
        return 
PLUGIN_HANDLED;
    }
    switch(
random_num(01))    
    {
        case 
0:  
        {
            
remove_task(iBombEntity);
            
            
set_pev(iBombEntityRING_BOMB_ENTITYpev(iBombEntitypev_owner));
            
smokeEffect(iBombEntity);
        }
        case 
1:    
        {        
            new 
iEnt create_entity("env_sprite");
            if(
pev_valid(iEnt))
            {
                
set_pev(iBombEntityRING_BOMB_ENTITYiEnt);
                
                
remove_task(iBombEntity);
                
set_task(0.5"makeBombFloat"iBombEntity);
            }
        }
    }
    return 
PLUGIN_HANDLED;
}

public 
makeBombFloat(iBombEntity)
{
    if(!
pev_valid(iBombEntity))
        return;
        
    static 
Float:vecOrigin[3], iRingEntity;iRingEntity pev(iBombEntityRING_BOMB_ENTITY);
    
pev(iBombEntitypev_originvecOrigin);
    
vecOrigin[2] += 30.0;
    
engfunc(EngFunc_SetOriginiBombEntityvecOrigin);
    
    
// use this to change the ring origin, so you can make the bomb be right in the middle
    
vecOrigin[2] += 0.0;
    
engfunc(EngFunc_SetOriginiRingEntityvecOrigin);

    
set_pev(iRingEntitypev_classnameRING_CLASSNAME);
    
engfunc(EngFunc_SetOriginiRingEntityvecOrigin);
    
engfunc(EngFunc_SetModeliRingEntityBOMB_PACK_ICON);
    
set_pev(iRingEntitypev_solidSOLID_NOT);
    
set_pev(iRingEntitypev_movetypeMOVETYPE_FLY);
    
set_pev(iRingEntitypev_nextthinkget_gametime());
    
set_pev(iRingEntityRING_BOMB_ENTITYiBombEntity);
    
set_pev(iRingEntitypev_rendercolorfColor[random_num(0charsmax(fColor))]);
}

public 
smokeEffect(iBombEntity)
{
    if(!
pev_valid(iBombEntity))
        return;
    
    static 
Float:vecOrigin[3];
    
pev(iBombEntitypev_originvecOrigin);
    
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYvecOrigin0);
    
write_byte(TE_FIREFIELD);
    
engfunc(EngFunc_WriteCoordvecOrigin[0]);
    
engfunc(EngFunc_WriteCoordvecOrigin[1]);
    
engfunc(EngFunc_WriteCoordvecOrigin[2] += 15.0);
    
write_short(2);
    
write_short(g_Backpack_SmokeSprite);
    
write_byte(1);
    
write_byte(TEFIRE_FLAG_ALLFLOAT TEFIRE_FLAG_ALPHA);
    
write_byte(10);
    
message_end();
    
    
set_task(0.3"smokeEffect"iBombEntity);
}

public 
ringThink(ent)    
{
    if(!
pev_valid(ent))
        return;
    
    if(!
pev_valid(pev(entRING_BOMB_ENTITY)))    
    {
        
remove_entity(ent);
        return;
    }
    
    
set_pev(entpev_nextthinkget_gametime() + 0.5);

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 04-02-2022 at 16:35.
EFFx is offline