AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Remove smoke from HE Grenade (Black Smoke) (https://forums.alliedmods.net/showthread.php?t=341231)

ChillerX 01-11-2023 14:26

Remove smoke from HE Grenade (Black Smoke)
 
I am looking to remove the black smoke from HE grenade explosion.
If possible also remove the sound from explosion and a toggle so players can turn the plugin on and off.

If it can be added to this plugin that would be great:

https://forums.alliedmods.net/showthread.php?t=204759

If all of this is too hard then a simpler plugin for just the black smoke (uncache sprite) is ok too.

Thanks in advance

shayan123 01-13-2023 12:07

Re: Remove smoke from HE Grenade
 
Removing the black smoke from the HE grenade explosion can be done by uncaching the sprite that is used for the smoke effect. This can be done by calling the "precache_model" function with the path of the sprite, and then passing the "PRECACHE_MODEL_UNLOAD" flag to the "precache_model" function.

To remove the sound from the explosion, you can use the "engfunc(EngFunc_PrecacheEvent, index, soundfile)" function to precache the sound, and then use the "engfunc(EngFunc_KillEvents, index)" function to stop the sound from playing.

To add a toggle for players to turn the plugin on and off, you can create a cvar using the "register_cvar" function and then check the value of the cvar in your plugin code to determine whether or not to run the code for removing the smoke and sound.

To integrate this feature with the plugin you provided, you can add the code to remove the smoke and sound in the "pfn_Explode" function, where it checks the entity classname. If the classname is "hegrenade", it would run the code to remove the smoke and sound.

It's important to note that, changing the behavior of the game in this way may affect the gameplay and it's important to test the plugin before deploying it to a production environment, also it's important to note that some servers may not allow the use of plugins that alter the standard game behavior.

Siska1 01-13-2023 17:09

Re: Remove smoke from HE Grenade
 
you can use unprecacher for a fraction of what you want

deprale 01-13-2023 18:16

Re: Remove smoke from HE Grenade
 
Quote:

Originally Posted by shayan123 (Post 2797088)
Removing the black smoke from the HE grenade explosion can be done by uncaching the sprite that is used for the smoke effect. This can be done by calling the "precache_model" function with the path of the sprite, and then passing the "PRECACHE_MODEL_UNLOAD" flag to the "precache_model" function.

To remove the sound from the explosion, you can use the "engfunc(EngFunc_PrecacheEvent, index, soundfile)" function to precache the sound, and then use the "engfunc(EngFunc_KillEvents, index)" function to stop the sound from playing.

To add a toggle for players to turn the plugin on and off, you can create a cvar using the "register_cvar" function and then check the value of the cvar in your plugin code to determine whether or not to run the code for removing the smoke and sound.

To integrate this feature with the plugin you provided, you can add the code to remove the smoke and sound in the "pfn_Explode" function, where it checks the entity classname. If the classname is "hegrenade", it would run the code to remove the smoke and sound.

It's important to note that, changing the behavior of the game in this way may affect the gameplay and it's important to test the plugin before deploying it to a production environment, also it's important to note that some servers may not allow the use of plugins that alter the standard game behavior.



Bro just asked chatgpt and copy pasted the answer 💀💀💀

ChillerX 01-13-2023 21:56

Re: Remove smoke from HE Grenade
 
Gotta see the positive side—free bump LD

Th3822 01-14-2023 16:00

Re: Remove smoke from HE Grenade
 
with reapi it's easy, hook RG_CGrenade_ExplodeHeGrenade as Post, then delete the grenade (you may need to clear the pfnThink of the grenade, it's doable with set_ent_data)

ChillerX 01-15-2023 15:23

Re: Remove smoke from HE Grenade
 
Quote:

Originally Posted by Th3822 (Post 2797153)
with reapi it's easy, hook RG_CGrenade_ExplodeHeGrenade as Post, then delete the grenade (you may need to clear the pfnThink of the grenade, it's doable with set_ent_data)

I am still quite unexperienced with pawn, would you mind writing that code for me?

I am pretty sure this would be a helpful plugin that will slightly reduce fps drops in cs 1.6 csdm and similar DM servers. Especially for players with older pc`s which are actually the majority still playing it.

Thanks in advance.

Th3822 01-15-2023 15:25

Re: Remove smoke from HE Grenade
 
Quote:

Originally Posted by ChillerX (Post 2797227)
I am still quite unexperienced with pawn, would you mind writing that code for me?

I am pretty sure this would be a helpful plugin that will slightly reduce fps drops in cs 1.6 csdm and similar DM servers. Especially for players with older pc`s which are actually the majority still playing it.

Thanks in advance.

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <reapi>

public plugin_init()
{
    
register_plugin("No HE Smoke""0.1""Th3-822");
    
RegisterHookChain(RG_CGrenade_ExplodeHeGrenade"HE_Exploded"1);
}

public 
HE_Exploded(iEnt)
{
    
// Remove "smoke & remove" think
    
set_ent_data(iEnt"CBaseEntity""m_pfnThink"0);
    
// Remove grenade (yes, there are "better" methods to do this, but i'm lazy to add more lines)
    
engfunc(EngFunc_RemoveEntityiEnt);



deprale 01-15-2023 20:40

Re: Remove smoke from HE Grenade
 
Quote:

Originally Posted by Th3822 (Post 2797228)
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <reapi>

public plugin_init()
{
    
register_plugin("No HE Smoke""0.1""Th3-822");
    
RegisterHookChain(RG_CGrenade_ExplodeHeGrenade"HE_Exploded"1);
}

public 
HE_Exploded(iEnt)
{
    
// Remove "smoke & remove" think
    
set_ent_data(iEnt"CBaseEntity""m_pfnThink"0);
    
// Remove grenade (yes, there are "better" methods to do this, but i'm lazy to add more lines)
    
engfunc(EngFunc_RemoveEntityiEnt);



This is actually sort of a really good thought process, I would have never thought of doing it this way lol.
I would have just unprecached black_smoke1,2,3,4.spr, but idk if its also used in clientside.

Th3822 01-15-2023 20:43

Re: Remove smoke from HE Grenade
 
Quote:

Originally Posted by deprale (Post 2797251)
This is actually sort of a really good thought process, I would have never thought of doing it this way lol.
I would have just unprecached black_smoke1,2,3,4.spr, but idk if its also used in clientside.

just did a quick search on regamedll for the grenade and the explosion (regame has hooks for almost everything, but those are kinda new, they weren't in my old .inc) and found that the smoke was added totally after the explosion function and it was hookable

ChillerX 01-15-2023 22:38

Re: Remove smoke from HE Grenade
 
Works perfectly, thank you!


All times are GMT -4. The time now is 20:04.

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