Raised This Month: $ Target: $400
 0% 

HE is touching wall


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BoBzY
AlliedModders Donor
Join Date: Aug 2010
Location: Bruxelles
Old 09-05-2011 , 13:54   HE is touching wall
Reply With Quote #1

Hello, any way to detect when an HE grenade is touching a wall/ground?

thanks
BoBzY is offline
mjmfighter
Member
Join Date: Jun 2010
Old 09-05-2011 , 14:13   Re: HE is touching wall
Reply With Quote #2

Yes there is a way to detect when it touches a wall or ground or even a person. With SDKHooks its something like this:

PHP Code:
#include <sdkhooks>

public OnEntityCreated(iEntity, const String:classname[]) 
{
    new 
iGrenade iEntity;
    if(
StrEqual(classname"hegrenade_projectile")) 
    {    
        
SDKHook(iGrenadeSDKHook_StartTouchGrenadeTouch);
    }
}

public 
GrenadeTouch(iGrenadeiEntity
{
    
//code here when nade touches someone or something.  if it touches someone iEntity will be > 0 (client index)

mjmfighter is offline
BoBzY
AlliedModders Donor
Join Date: Aug 2010
Location: Bruxelles
Old 09-05-2011 , 14:16   Re: HE is touching wall
Reply With Quote #3

Thanks you dude!!!

And any way to force this he to explode :>?

Last edited by BoBzY; 09-05-2011 at 14:21.
BoBzY is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-05-2011 , 15:15   Re: HE is touching wall
Reply With Quote #4

Try
PHP Code:
SetEntPropFloat(iGrenadeProp_Data"m_flDetonateTime"GetGameTime()); 
__________________
Peace-Maker is offline
BoBzY
AlliedModders Donor
Join Date: Aug 2010
Location: Bruxelles
Old 09-05-2011 , 15:18   Re: HE is touching wall
Reply With Quote #5

Nop, it doesnt work

Last edited by BoBzY; 09-05-2011 at 15:32.
BoBzY is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-05-2011 , 16:53   Re: HE is touching wall
Reply With Quote #6

Try this. It's linux only though. If it does work, post back and we put some nicer gamedata file together

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

// SDKCall
new Handle:g_hDetonate;

public 
OnPluginStart()
{
    
// Prepare Detonate call
    
StartPrepSDKCall(SDKCall_Entity);
    if(!
PrepSDKCall_SetSignature(SDKLibrary_Server"@_ZN20CHEGrenadeProjectile8DetonateEv"0))
        
SetFailState("Can't find CHEGrenadeProjectile::Detonate(void) symbol");
    
g_hDetonate EndPrepSDKCall();
}

public 
OnEntityCreated(iEntity, const String:classname[]) 
{
    if(
StrEqual(classname"hegrenade_projectile")) 
    {    
        
SDKHook(iEntitySDKHook_StartTouchGrenadeTouch);
    }
}

public 
GrenadeTouch(iGrenadeiEntity
{
    
SDKCall(g_hDetonateiGrenade);

This will hopefully get the HE to detonate on first touch with anything, not only walls though. You need some more checks on iEntity if you need to have it to detonate on walls. like if(iEntity == 0).. would detonate on the floor either.
__________________
Peace-Maker is offline
BoBzY
AlliedModders Donor
Join Date: Aug 2010
Location: Bruxelles
Old 09-05-2011 , 17:05   Re: HE is touching wall
Reply With Quote #7

It work perfectly, good job :-)

But I have a new question

It is possible for the projectile to have a longest life?
BoBzY is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-05-2011 , 17:14   Re: HE is touching wall
Reply With Quote #8

Longest life? Like after 3 seconds without touching anything they explode anyway?
You could create a timer while hooking StartTouch and do the SDKCall in the callback. Make sure to pass entity index as reference (EntIndexToEntRef/EntRefToEntIndex)
__________________
Peace-Maker is offline
BoBzY
AlliedModders Donor
Join Date: Aug 2010
Location: Bruxelles
Old 09-05-2011 , 17:31   Re: HE is touching wall
Reply With Quote #9

Like after 3 secs WITHOUT touching something, they dont explode
So, I can throw HE, if he dont touch anything in 7 secs, she still 'flying'
gtg sleep, if you know how to do, Ill try tomorrow

I rly appreciate your help, thanks for your time dude ;)

peace & gn8
BoBzY is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-05-2011 , 18:23   Re: HE is touching wall
Reply With Quote #10

Don't know it is possible to block detonation with sourcepawn. I don't know of any way. You'd need to detour the Detonate method in an extension..

Still here's the better variant using a gamedata file. Added the windows signature either. YAY - FIRST SIGNATURE SEARCH FOR ME
Attached Files
File Type: sp Get Plugin or Get Source (hetouchdetonate.sp - 285 views - 768 Bytes)
File Type: smx hetouchdetonate.smx (2.5 KB, 89 views)
File Type: txt detonate.games.txt (496 Bytes, 125 views)
__________________
Peace-Maker 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 22:38.


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