Raised This Month: $12 Target: $400
 3% 

[CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 07-07-2013 , 11:14   [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #1

Here's the deal. I'm manually creating hegrenade_projectile, but i can't make it explode. I tried different values to set from several threads of the forum, but nothing works.
Right now code looks like this:
PHP Code:
new iHe CreateEntityByName("hegrenade_projectile");
if ((
iHe != -1) && DispatchSpawn(iHe)) {
    new 
Float:fAng[3], Float:fPos[3], fVel[3], fPVel[3];
    new 
Float:fSpin[3] = {4877.40.00.0};
    
    
GetClientEyeAngles(clientfAng);
    
GetClientEyePosition(clientfPos);
    
    
GetAngleVectors(fAngfVelNULL_VECTORNULL_VECTOR);
    
ScaleVector(fVel3000.0);
    
GetEntPropVector(clientProp_Data"m_vecVelocity"fPVel);
    
AddVectors(fVelfPVelfVel);
    
SetEntPropVector(iHeProp_Data"m_vecAngVelocity"fSpin);

    
SetEntPropEnt(iHeProp_Send"m_hOwnerEntity"client);
    
SetEntPropEnt(iHeProp_Send"m_hThrower"client);
    
SetEntPropFloat(iHeProp_Send"m_flElasticity"0.2);
    
SetEntProp(iHeProp_Send"m_iTeamNum"GetClientTeam(client));
    
SetEntProp(iHeProp_Send"m_bIsLive"1);

    
TeleportEntity(iHefPosfAngfVel);

Projectile creates just fine, flies and bounces like regular one. But it doesn't explode. Same goes for decoy - it can't even reach it's 'working' state, just laying on the ground and does nothing.

I searched for virtual function to call, but i failed to find one. Some people were saying to try manually exploding it with SDKCall, but isn't it the same as calling virtual function?
xf117 is offline
Send a message via ICQ to xf117
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 07-07-2013 , 14:17   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #2

This is what I use for CS:S, so it should work in CS:GO:

PHP Code:
g_fDurationGrenade is how long until the grenade explodes.
public 
OnEntityCreated(entity, const String:classname[])
{
    if(!
strcmp(classname"hegrenade_projectile"false))
    {
        new 
iReference EntIndexToEntRef(entity);
        
CreateTimer(0.1Timer_OnGrenadeCreatediReference);
        if(
g_fDurationGrenade)
            
CreateTimer(g_fDurationGrenadeTimer_OnStartDetonateiReference);
    }
}

public 
Action:Timer_OnGrenadeCreated(Handle:timerany:ref)
{
    new 
entity EntRefToEntIndex(ref);
    if(
entity != INVALID_ENT_REFERENCE)
    {
        if(
g_fDurationGrenade)
            
SetEntProp(entityProp_Data"m_nNextThinkTick", -1);
    }
}

public 
Action:Timer_OnStartDetonate(Handle:timerany:ref)
{
    new 
entity EntRefToEntIndex(ref);
    if(
entity != INVALID_ENT_REFERENCE)
        
SetEntProp(entityProp_Data"m_nNextThinkTick"1);

__________________

Last edited by thetwistedpanda; 07-07-2013 at 14:17.
thetwistedpanda is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 07-07-2013 , 16:39   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #3

stopping the grenade thinking will only allow you to increase the detonation timer not reduce it as you're only stopping it from checking if the detonation time has passed until you allow it to think again. i had that issue in an earlier version of my homing missiles back when i used to code in eventscripts.

what you want to do is disable thinking then when you want it to detonate make it damagable(m_takedamage 2) then set its health 1 and use sdkhooks takedamage native to damage it by 1 which will cause the entity to detonate, well in css anyway. before the sdkhook native i ignited the entity to damage it which worked but was buggy for some reason, at times it would detonate but still be there and detonate randomly a second time.

you can use an sdkcall but the offset can end up changing when updates are released, i find it easier to find other methods that won't break after updates.

Last edited by blodia; 07-07-2013 at 16:41.
blodia is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 07-07-2013 , 20:42   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #4

Thank you very much for the answers!
m_nNextThinkTick 1 or -1 does nothing for me.

Blodia's method does work on hegrenade_projectile perfectly. Both methods perform just fine.
Unfortunately, it seems to be doing nothing to a decoy_projectile, nothing at all.

I would prefer a SDKCall even tho it might break after an update. Even better, i would love to learn how to find that kind of stuff myself. My knowledge pretty much ends up on virtual functions, and it didn't help me
xf117 is offline
Send a message via ICQ to xf117
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 07-11-2013 , 18:37   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #5

Quote:
Originally Posted by blodia View Post
stopping the grenade thinking will only allow you to increase the detonation timer not reduce it as you're only stopping it from checking if the detonation time has passed until you allow it to think again. i had that issue in an earlier version of my homing missiles back when i used to code in eventscripts.

what you want to do is disable thinking then when you want it to detonate make it damagable(m_takedamage 2) then set its health 1 and use sdkhooks takedamage native to damage it by 1 which will cause the entity to detonate, well in css anyway. before the sdkhook native i ignited the entity to damage it which worked but was buggy for some reason, at times it would detonate but still be there and detonate randomly a second time.

you can use an sdkcall but the offset can end up changing when updates are released, i find it easier to find other methods that won't break after updates.
This is gold. I wanted that a long time ago.

Thanks for sharing blodia <3

edit : and do you remember how you found that ? ASM, SDK and/or trial & errors ?

And I think Panda's one would work too; as he's setting to 1 in Timer_OnStartDetonate (not only -1 as you said) I get what you said blodia; Panda's method can make it longer, not shorter :/

re-edit : It seems an hybrid version is needed to be flexible. Panda for long ones, and blodia when short. This is when throwing the grenade that is (which is not OP's case).
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work

Last edited by RedSword; 07-11-2013 at 21:10.
RedSword is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 07-11-2013 , 19:57   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #6

for the entity thinking i found info on that in the sdk and the rest was trial and error.

m_nNextThinkTick is the game time the entity will next think at, setting it to -1 disables thinking, anything else will enable it again, since the game time of 1 will have been passed when the entity checks whether to think or not it will do immediately.

from what i remember the grenades detonation timer is either 1.5 or 2.5 so if you enable thinking before then after disbaling thinking on entity spawn then the grenade will not detonate until that time has passed. i can't remember if i tried this but you could try setting "m_flDetonateTime" before dispatch spawning a projectile, i know it doesn't work after the entity is already spawned so it may only work with entities created manually.

Last edited by blodia; 07-12-2013 at 14:45.
blodia is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 07-11-2013 , 20:04   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #7

blodia is correct, the method I've used doesn't actually work correctly. I never tried to use it with times < default (I needed double/triple values) :X. But I threw it on a server and tried 0.1-0.5 detonation times and no dice.

Tested his suggestion and it works fine.
Spoiler
__________________

Last edited by thetwistedpanda; 07-11-2013 at 20:12.
thetwistedpanda is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 07-11-2013 , 21:30   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #8

I'm going to post a plugin. I didn't take a look at your post; thought it is the same thing as you're posting Panda.
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 07-12-2013 , 14:44   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #9

i'd move the code to make it damagable and health change to just before detonation as players can shoot and destroy the nade , same with map entities that do damage.

my old eventscripts version of homing missiles had the missile destroyable but would cause nasty chain reactions when many missiles were in blast radius of each other and also the map entity issue made me not bother with that feature when i converted it over to sm.
blodia is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 08-18-2016 , 20:21   Re: [CS:Go] Forcing hegrenade_projectile / decoy_projectile to explode
Reply With Quote #10

Any update on this? Non of the examples provides trigger a smoke grenade from exploding
__________________
ImACow is offline
Reply


Thread Tools
Display Modes

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 13:16.


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