AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Change effect of HE Grenade.. (https://forums.alliedmods.net/showthread.php?t=152861)

Screeaam.. 03-15-2011 09:18

Change effect of HE Grenade..
 
Hello. How can I change effect when HE Grenade is exploding and block his DMG?

Exolent[jNr] 03-15-2011 09:20

Re: Change effect of HE Grenade..
 
Hook when grenade will explode and block it.
Then you can add your own effects when it should explode.

Screeaam.. 03-15-2011 09:25

Re: Change effect of HE Grenade..
 
But how to hook?

Exolent[jNr] 03-15-2011 10:18

Re: Change effect of HE Grenade..
 
Look at FrostNades code by XxAvalanchexX.
It is in the Unapproved Plugins section.

Screeaam.. 03-15-2011 14:59

Re: Change effect of HE Grenade..
 
I found..

Should it run?

PHP Code:

RegisterHam(Ham_Think,"grenade","ham_grenade_think",0); 

Can someone translate each of the lines of the code? :

PHP Code:

// grenade is ticking away
public ham_grenade_think(ent)
{
    
// not a frostnade
    
if(!pev(ent,pev_bInDuck)) return FMRES_IGNORED;
    
    new 
Float:dmgtime;
    
pev(ent,pev_dmgtime,dmgtime);
    if(
dmgtime get_gametime()) return FMRES_IGNORED;
    
    
// and boom goes the dynamite
    
frostnade_explode(ent);

    return 
FMRES_SUPERCEDE;


And into my code must I include this:

PHP Code:

fw_setmodel(ent,model[]) 

?

Exolent[jNr] 03-15-2011 16:48

Re: Change effect of HE Grenade..
 
PHP Code:

// -- handling function for "grenade" entity thinking
public ham_grenade_think(ent// -- "ent" is the entity index
{
    
// -- ignore this part because it isn't needed here
    // not a frostnade
    //if(!pev(ent,pev_bInDuck)) return FMRES_IGNORED;
    
    // -- get the gametime value of when the grenade should explode
    
new Float:dmgtime;
    
pev(ent,pev_dmgtime,dmgtime);
    
    
// -- check if the explode time has not happened yet
    
if(dmgtime get_gametime()) return FMRES_IGNORED;
    
    
// -- call function made for frostnade damage/effects.
    // -- this can be ignore and/or changed to your own function
    // and boom goes the dynamite
    
frostnade_explode(ent);

    
// -- block grenade from exploding
    
return FMRES_SUPERCEDE;


Quote:

Originally Posted by Screeaam.. (Post 1433754)
And into my code must I include this:

PHP Code:

fw_setmodel(ent,model[]) 

?

No. The author only included that for trails.

Screeaam.. 03-15-2011 17:34

Re: Change effect of HE Grenade..
 
Thanks.

I have to do a certain condition in the function that she knew that it was a grenade HE and not eg Smoke Grenade ? Or this just know "This is HE" ?


Can I give You some reputation or so on this forum?

tuty 03-15-2011 18:10

Re: Change effect of HE Grenade..
 
exolent, the return type shouldn't be with HAM_* prefix?

Screeaam.. 03-15-2011 18:33

Re: Change effect of HE Grenade..
 
In FrostNades code by XxAvalanchexX in this function is return FMRES_SUPERCEDE;


But tell me, I need to do a certain condition what Grenade is it?

Exolent[jNr] 03-15-2011 21:26

Re: Change effect of HE Grenade..
 
Quote:

Originally Posted by tuty (Post 1433859)
exolent, the return type shouldn't be with HAM_* prefix?

PHP Code:

#define HAM_IGNORED        1    /**< Calls target function, returns normal value */
#define HAM_HANDLED        2    /**< Tells the module you did something, still calls target function and returns normal value */
#define HAM_OVERRIDE    3    /**< Still calls the target function, but returns whatever is set with SetHamReturn*() */
#define HAM_SUPERCEDE    4    /**< Block the target call, and use your return value (if applicable) (Set with SetHamReturn*()) */ 

PHP Code:

#define FMRES_IGNORED    1    // Calls target function, returns normal value
#define FMRES_HANDLED    2    // Tells metamod you did something, still calls target function and returns normal value
#define FMRES_OVERRIDE    3    // Supposed to still call the target function but return your value instead
                            // however this does not work properly with metamod; use supercede instead.
#define FMRES_SUPERCEDE    4    // Block the target call, and use your return value (if applicable) 

The effect would be no different as you can see they are the same values.
The only benefit would be readability, which I agree it should be changed to HAM_SUPERCEDE.


All times are GMT -4. The time now is 14:39.

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