This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Custom smoke


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
uselessguy28
New Member
Join Date: Feb 2019
Old 02-28-2019 , 14:30   Custom smoke
Reply With Quote #1

Hello there,
I need some help with making a custom smoke grenade. I mean, when it explodes, the smoke is a custom sprite. I've found this plugin by xPaw a made some adjustments as shown here:
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

#define VERSION "1.1"

new const g_szClassname[] = "colored_smokenade";

new 
g_szSmokeSprites;
new 
g_Cvar_Enabled;

public 
plugin_init( ) {
    
register_plugin"Colored Smoke"VERSION"xPaw" );
    
    
register_cvar"colored_smoke"VERSIONFCVAR_SERVER FCVAR_SPONLY );
    
set_cvar_string"colored_smoke"VERSION );
    
    
g_Cvar_Enabled register_cvar"sv_colored_smoke""1" );
    
    
register_forwardFM_EmitSound"FwdEmitSound" );
    
register_touchg_szClassname"worldspawn""FwdTouch_FakeSmoke" );
    
register_thinkg_szClassname"FwdThink_FakeSmoke" );
}

public 
logevent_round_end()
{
    
// cleanup, copied from some other plugin
    
new ent = -1
    
while((ent find_ent_by_class(entg_szClassname)))
    {        
        
remove_entityent );
    }
}

public 
plugin_precache( ) {
    
g_szSmokeSprites precache_model"sprites/gas_puff_01g.spr" );
    
    
precache_sound"weapons/grenade_hit1.wav" );
}  

public 
FwdEmitSoundiOrigEntiChannel, const szSample[], Float:fVolFloat:fAttniFlagsiPitch ) {
    new 
iCvar get_pcvar_numg_Cvar_Enabled );
    if( 
iCvar ) {
        static const 
szSmokeSound[] = "weapons/sg_explode.wav";
        
        if( 
equalszSampleszSmokeSound ) ) {
            
// cache origin, angles and model
            
new Float:vOrigin], Float:vAngles], szModel64 ], iOwner;
            
iOwner entity_get_edictiOrigEntEV_ENT_owner );
            
entity_get_vectoriOrigEntEV_VEC_originvOrigin );
            
entity_get_vectoriOrigEntEV_VEC_anglesvAngles );
            
entity_get_stringiOrigEntEV_SZ_modelszModelcharsmaxszModel ) );
            
            
// remove entity from world
            
entity_set_vectoriOrigEntEV_VEC_originFloat:{ 9999.99999.99999.9 } );
            
entity_set_intiOrigEntEV_INT_flagsFL_KILLME );
            
            
// create new entity
            
new iEntity create_entity"info_target" );
            if( 
iEntity ) {
                
entity_set_stringiEntityEV_SZ_classnameg_szClassname );
                
                
entity_set_originiEntityvOrigin );
                
entity_set_vectoriEntityEV_VEC_anglesvAngles );
                
                
entity_set_intiEntityEV_INT_movetypeMOVETYPE_TOSS );
                
entity_set_intiEntityEV_INT_solidSOLID_BBOX );
                
                
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + 21.5 );
                
entity_set_floatiEntityEV_FL_gravity0.5 );
                
entity_set_floatiEntityEV_FL_friction0.8 );
                
                
entity_set_modeliEntityszModel );
                
                new 
Float:vVelocity];
                
vVelocity] = random_float( -220.0220.0 );
                
vVelocity] = random_float( -220.0220.0 );
                
vVelocity] = random_float(  200.0300.0 );
                
entity_set_vectoriEntityEV_VEC_velocityvVelocity );
                
                
emit_soundiEntityiChannelszSamplefVolfAttniFlagsiPitch );
                
                
// Create fake smoke
                
new iSmoke;
                
                if( 
iCvar == )
                    
iSmoke get_user_teamiOwner ); // i did indexes as team, 1 - red, 2 - blue, 3 - green( spec oO )
                
else
                    
iSmoke random_num0);
                
                
// Store the smoke number in entity, we will use it later
                
entity_set_intiEntityEV_INT_iuser4iSmoke );
                
                
message_beginMSG_BROADCASTSVC_TEMPENTITY );
                
write_byteTE_FIREFIELD );
                
engfuncEngFunc_WriteCoordvOrigin] );                //startpos
                
engfuncEngFunc_WriteCoordvOrigin] );
                
engfuncEngFunc_WriteCoordvOrigin] + 50 );
                
write_short90 );                                            //spread
                
write_shortg_szSmokeSprites );                            //sprite
                
write_byte150 );                                            //not scale
                
write_byteTEFIRE_FLAG_ALPHA );
                
write_byte1000 );                                            //time
                
message_end();
                
                
message_beginMSG_BROADCASTSVC_TEMPENTITY );
                
write_byteTE_FIREFIELD );
                
engfuncEngFunc_WriteCoordvOrigin] );                //startpos
                
engfuncEngFunc_WriteCoordvOrigin] );
                
engfuncEngFunc_WriteCoordvOrigin] + 50 );
                
write_short110 );                                            //spread
                
write_shortg_szSmokeSprites );                            //sprite
                
write_byte150 );                                            //not scale
                
write_byteTEFIRE_FLAG_ALPHA );
                
write_byte1000 );                                            //time
                
message_end( );  
            }
        }
    }
}

public 
FwdTouch_FakeSmokeiEntityiWorld ) {
    if( !
is_valid_entiEntity ) )
        return 
PLUGIN_CONTINUE;
    
    
// Bounce sound
    
emit_soundiEntityCHAN_VOICE"weapons/grenade_hit1.wav"0.25ATTN_NORM0PITCH_NORM );
    
    new 
Float:vVelocity];
    
entity_get_vectoriEntityEV_VEC_velocityvVelocity );
    
    if( 
vVelocity] <= 0.0 && vVelocity] <= 0.0 ) {
        new 
Float:vOrigin];
        new 
iSmoke entity_get_intiEntityEV_INT_iuser4 );
        
entity_get_vectoriEntityEV_VEC_originvOrigin );
        
        
// Make small smoke near grenade on ground
        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_FIREFIELD );
        
engfuncEngFunc_WriteCoordvOrigin] );
        
engfuncEngFunc_WriteCoordvOrigin] );
        
engfuncEngFunc_WriteCoordvOrigin] + 10 );
        
write_short);
        
write_shortg_szSmokeSprites );
        
write_byte);
        
write_byteTEFIRE_FLAG_ALLFLOAT TEFIRE_FLAG_ALPHA );
        
write_byte30 );
        
message_end();
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
FwdThink_FakeSmokeiEntity ) {
    if( !
is_valid_entiEntity ) )
        return 
PLUGIN_CONTINUE;
    
    
remove_entityiEntity );
    
    return 
PLUGIN_CONTINUE;

Now my question is - is it possible to make the entities (sprites, idk) bigger ? They're quite small compared to the default smoke.
And also, is there possibly any way to remove the smoke on a new round?

I've also included the custom smoke sprite, just in case.
Thanks in advance.
Attached Files
File Type: zip smoke sprite.zip (2.9 KB, 115 views)

Last edited by uselessguy28; 02-28-2019 at 14:31.
uselessguy28 is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 03-02-2019 , 11:27   Re: Custom smoke
Reply With Quote #2

Quote:
Originally Posted by uselessguy28 View Post
Hello there,
I need some help with making a custom smoke grenade. I mean, when it explodes, the smoke is a custom sprite. I've found this plugin by xPaw a made some adjustments as shown here:
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

#define VERSION "1.1"

new const g_szClassname[] = "colored_smokenade";

new 
g_szSmokeSprites;
new 
g_Cvar_Enabled;

public 
plugin_init( ) {
    
register_plugin"Colored Smoke"VERSION"xPaw" );
    
    
register_cvar"colored_smoke"VERSIONFCVAR_SERVER FCVAR_SPONLY );
    
set_cvar_string"colored_smoke"VERSION );
    
    
g_Cvar_Enabled register_cvar"sv_colored_smoke""1" );
    
    
register_forwardFM_EmitSound"FwdEmitSound" );
    
register_touchg_szClassname"worldspawn""FwdTouch_FakeSmoke" );
    
register_thinkg_szClassname"FwdThink_FakeSmoke" );
}

public 
logevent_round_end()
{
    
// cleanup, copied from some other plugin
    
new ent = -1
    
while((ent find_ent_by_class(entg_szClassname)))
    {        
        
remove_entityent );
    }
}

public 
plugin_precache( ) {
    
g_szSmokeSprites precache_model"sprites/gas_puff_01g.spr" );
    
    
precache_sound"weapons/grenade_hit1.wav" );
}  

public 
FwdEmitSoundiOrigEntiChannel, const szSample[], Float:fVolFloat:fAttniFlagsiPitch ) {
    new 
iCvar get_pcvar_numg_Cvar_Enabled );
    if( 
iCvar ) {
        static const 
szSmokeSound[] = "weapons/sg_explode.wav";
        
        if( 
equalszSampleszSmokeSound ) ) {
            
// cache origin, angles and model
            
new Float:vOrigin], Float:vAngles], szModel64 ], iOwner;
            
iOwner entity_get_edictiOrigEntEV_ENT_owner );
            
entity_get_vectoriOrigEntEV_VEC_originvOrigin );
            
entity_get_vectoriOrigEntEV_VEC_anglesvAngles );
            
entity_get_stringiOrigEntEV_SZ_modelszModelcharsmaxszModel ) );
            
            
// remove entity from world
            
entity_set_vectoriOrigEntEV_VEC_originFloat:{ 9999.99999.99999.9 } );
            
entity_set_intiOrigEntEV_INT_flagsFL_KILLME );
            
            
// create new entity
            
new iEntity create_entity"info_target" );
            if( 
iEntity ) {
                
entity_set_stringiEntityEV_SZ_classnameg_szClassname );
                
                
entity_set_originiEntityvOrigin );
                
entity_set_vectoriEntityEV_VEC_anglesvAngles );
                
                
entity_set_intiEntityEV_INT_movetypeMOVETYPE_TOSS );
                
entity_set_intiEntityEV_INT_solidSOLID_BBOX );
                
                
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + 21.5 );
                
entity_set_floatiEntityEV_FL_gravity0.5 );
                
entity_set_floatiEntityEV_FL_friction0.8 );
                
                
entity_set_modeliEntityszModel );
                
                new 
Float:vVelocity];
                
vVelocity] = random_float( -220.0220.0 );
                
vVelocity] = random_float( -220.0220.0 );
                
vVelocity] = random_float(  200.0300.0 );
                
entity_set_vectoriEntityEV_VEC_velocityvVelocity );
                
                
emit_soundiEntityiChannelszSamplefVolfAttniFlagsiPitch );
                
                
// Create fake smoke
                
new iSmoke;
                
                if( 
iCvar == )
                    
iSmoke get_user_teamiOwner ); // i did indexes as team, 1 - red, 2 - blue, 3 - green( spec oO )
                
else
                    
iSmoke random_num0);
                
                
// Store the smoke number in entity, we will use it later
                
entity_set_intiEntityEV_INT_iuser4iSmoke );
                
                
message_beginMSG_BROADCASTSVC_TEMPENTITY );
                
write_byteTE_FIREFIELD );
                
engfuncEngFunc_WriteCoordvOrigin] );                //startpos
                
engfuncEngFunc_WriteCoordvOrigin] );
                
engfuncEngFunc_WriteCoordvOrigin] + 50 );
                
write_short90 );                                            //spread
                
write_shortg_szSmokeSprites );                            //sprite
                
write_byte150 );                                            //not scale
                
write_byteTEFIRE_FLAG_ALPHA );
                
write_byte1000 );                                            //time
                
message_end();
                
                
message_beginMSG_BROADCASTSVC_TEMPENTITY );
                
write_byteTE_FIREFIELD );
                
engfuncEngFunc_WriteCoordvOrigin] );                //startpos
                
engfuncEngFunc_WriteCoordvOrigin] );
                
engfuncEngFunc_WriteCoordvOrigin] + 50 );
                
write_short110 );                                            //spread
                
write_shortg_szSmokeSprites );                            //sprite
                
write_byte150 );                                            //not scale
                
write_byteTEFIRE_FLAG_ALPHA );
                
write_byte1000 );                                            //time
                
message_end( );  
            }
        }
    }
}

public 
FwdTouch_FakeSmokeiEntityiWorld ) {
    if( !
is_valid_entiEntity ) )
        return 
PLUGIN_CONTINUE;
    
    
// Bounce sound
    
emit_soundiEntityCHAN_VOICE"weapons/grenade_hit1.wav"0.25ATTN_NORM0PITCH_NORM );
    
    new 
Float:vVelocity];
    
entity_get_vectoriEntityEV_VEC_velocityvVelocity );
    
    if( 
vVelocity] <= 0.0 && vVelocity] <= 0.0 ) {
        new 
Float:vOrigin];
        new 
iSmoke entity_get_intiEntityEV_INT_iuser4 );
        
entity_get_vectoriEntityEV_VEC_originvOrigin );
        
        
// Make small smoke near grenade on ground
        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_FIREFIELD );
        
engfuncEngFunc_WriteCoordvOrigin] );
        
engfuncEngFunc_WriteCoordvOrigin] );
        
engfuncEngFunc_WriteCoordvOrigin] + 10 );
        
write_short);
        
write_shortg_szSmokeSprites );
        
write_byte);
        
write_byteTEFIRE_FLAG_ALLFLOAT TEFIRE_FLAG_ALPHA );
        
write_byte30 );
        
message_end();
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
FwdThink_FakeSmokeiEntity ) {
    if( !
is_valid_entiEntity ) )
        return 
PLUGIN_CONTINUE;
    
    
remove_entityiEntity );
    
    return 
PLUGIN_CONTINUE;

Now my question is - is it possible to make the entities (sprites, idk) bigger ? They're quite small compared to the default smoke.
And also, is there possibly any way to remove the smoke on a new round?

I've also included the custom smoke sprite, just in case.
Thanks in advance.
There is already a fixed version by bionext

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

#if !defined write_coord_f
    #define write_coord_f(%1)   engfunc( EngFunc_WriteCoord, %1 )
#endif

#define VERSION "1.06"
#define SMOKE_SPRITE "sprites/gas_puff_gray_opaque.spr"

new const g_szClassname[] = "custom_smoke";
new 
g_fwid
new g_evCreateSmoke;
new 
g_szSmokeSprite;
new 
g_Cvar_Enabled;
new 
g_Cvar_Duration;
new 
g_Cvar_CountSprites;
new 
g_Clear;
new 
g_iCvar_Enebled;
new 
g_iCountSprites;

public 
plugin_init( )
{
    
register_plugin"Custom Smoke"VERSION"bionext" );

    
g_Clear 0;
    
g_iCvar_Enebled 0;
    
g_Cvar_Enabled register_cvar"sv_customsmoke""1" );
    
g_Cvar_Duration register_cvar"sv_smokeduration""10.0" );
    
g_Cvar_CountSprites register_cvar"sv_smokespritescount""100" );

    
unregister_forward(FM_PrecacheEventg_fwid1);

    
register_thinkg_szClassname"FwdThink_BlackSmoke" );
    
register_forward(FM_PlaybackEvent"FwdPlaybackEvent");
    
register_logevent("FwdClear"2"1=Round_End");
    
register_logevent("FwdStart"2"1=Round_Start");
    
register_event("TextMsg""FwdClear""a""2=#Game_will_restart_in","2=#Game_Commencing");
}

public 
FwdClear( )
{
    
g_Clear 1;
}

public 
FwdStart( )
{
    
g_iCvar_Enebled get_pcvar_numg_Cvar_Enabled );
    
g_Clear 0;
}

public 
plugin_precache( )
{
    
g_szSmokeSprite precache_modelSMOKE_SPRITE );
    
g_fwid register_forward(FM_PrecacheEvent"FwdPrecacheEvent"1);
    
force_unmodified(force_exactfile, {0,0,0},{0,0,0}, SMOKE_SPRITE);
}

public 
FwdPlaybackEventiFlags iEntity iEventindexFloat:fDelayFloat:vOrigin[3], Float:vAngles[3], Float:fParam1Float:fParam2iParam1iParam2iBparam1iBparam2 )
{
    if(
iEventindex != g_evCreateSmoke || iBparam2 || !g_iCvar_Enebled)
        return 
FMRES_IGNORED;

    new 
iEnt create_entity"info_target" );

    if( !
iEnt )
        return 
FMRES_IGNORED;
  
    
g_iCountSprites get_pcvar_numg_Cvar_CountSprites );
    new 
Float:fDuration get_pcvar_floatg_Cvar_Duration );
          
    
entity_set_stringiEntEV_SZ_classnameg_szClassname );
    
entity_set_floatiEntEV_FL_nextthinkget_gametime( ));
    
entity_set_vectoriEntEV_VEC_originvOrigin );
    
entity_set_floatiEntEV_FL_animtimefDuration );

    return 
FMRES_SUPERCEDE;
}

public 
FwdPrecacheEvent(type, const name[])
{
    if (
equal("events/createsmoke.sc"name))
    {
        
g_evCreateSmoke get_orig_retval();
        return 
FMRES_HANDLED;
    }

    return 
FMRES_IGNORED;
}

public 
FwdThink_BlackSmokeiEntity )
{
    if( !
is_valid_entiEntity ) )
        return 
PLUGIN_CONTINUE;

    if( 
g_Clear )
    {
        
entity_set_intiEntity,EV_INT_flagsFL_KILLME );
        return 
PLUGIN_CONTINUE;
    }

    new 
Float:vOrigin[3];
    
entity_get_vectoriEntityEV_VEC_originvOrigin );

    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_FIREFIELD );
    
write_coord_fvOrigin] );
    
write_coord_fvOrigin] );
    
write_coord_fvOrigin] + 50 );
    
write_short100 );
    
write_shortg_szSmokeSprite );
    
write_byteg_iCountSprites );
    
write_byteTEFIRE_FLAG_ALPHA );
    
write_byte11 );
    
message_end();

    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_FIREFIELD );
    
write_coord_fvOrigin] );
    
write_coord_fvOrigin] );
    
write_coord_fvOrigin] + 50 );
    
write_short150 );
    
write_shortg_szSmokeSprite );
    
write_byte10 );
    
write_byteTEFIRE_FLAG_ALPHA TEFIRE_FLAG_SOMEFLOAT );
    
write_byte11 );
    
message_end( );

    new 
Float:time entity_get_float(iEntity,EV_FL_animtime);
    
time time 1.0;

    if( 
time 0.0 )
    {
        
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + 1.0 );
        
entity_set_floatiEntityEV_FL_animtimetime );
    }
    else
    {
        
entity_set_intiEntity,EV_INT_flagsFL_KILLME );
    }

    return 
PLUGIN_CONTINUE;
}

tarsisd2 is offline
uselessguy28
New Member
Join Date: Feb 2019
Old 03-03-2019 , 13:19   Re: Custom smoke
Reply With Quote #3

Thanks, but it seems there are some other issues. The smoke is sort of flickering - some particles appear and the dissapear, again and again. Tried different sprites and settings, no luck.
I managed to find the source, but i can't post any comments or download anything.

Last edited by uselessguy28; 03-03-2019 at 14:14.
uselessguy28 is offline
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 03-07-2019 , 12:26   Re: Custom smoke
Reply With Quote #4

Quote:
Originally Posted by uselessguy28 View Post
Thanks, but it seems there are some other issues. The smoke is sort of flickering - some particles appear and the dissapear, again and again. Tried different sprites and settings, no luck.
I managed to find the source, but i can't post any comments or download anything.
You have to register to download, simple as that, the plugin even got updated 2 days ago
tarsisd2 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 01:35.


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