Raised This Month: $ Target: $400
 0% 

Smoke grenade explosion delay + finding players in radius [SOLVED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 12-26-2014 , 14:25   Smoke grenade explosion delay + finding players in radius [SOLVED]
Reply With Quote #1

Hello, guys! I'm trying to make some type of hallelujah nade (that's what I thought of). It will be in the slot of the smoke nade. So, the first questions are:
- How can I detect when the smoke (and future nade) stays still on the ground (when it stops bouncing and moving and is ready to explode)? I guess with FM_EmitSound would be good to check when the smoke explosion sound is being started, then destroy the ent and etc.?
- How to set a timer before the explosion, after the nade has stopped on the ground? I want to play some creepy "hallelujah" sound while the nade stays on the ground and then, like after 8 seconds, to explode.
- How to create a circle with a radius, where to put a fire ring explosion effect and the most important - to set some damage in this radius. This damage stuff is unfortunately pretty unclear for me and еspecially for the radius. This'd be the most helpful info.
I tried to search for similar functions in some other nades, bub didn't find the exact events/forwards I need. I haven't worked with nades so much before and am some kind of unexperienced with this type of coding. So if someone could be nice enough to explain me long and detailed, I'd be very thankful!
__________________

Last edited by Flick3rR; 12-28-2014 at 13:19.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-26-2014 , 15:41   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #2

1. You mean the moment right before nade explosion ? If so you can hook CGrenade::SG_Detonate() as pre with orpheu and remove the entity there, then spawn another one in it's place. If you don't want to work with orpheu or you don't know I may give you the code or you can use FM_EmitSound too, but it's not a good ideea since you have the direct way with orpheu. You can also hook CGrenade::SG_Detonate() as post, block the smokegrenade effect and use m_SGExplosionPos offset to get it's origin, then spawn your new grenade with this origins.
2. When you create your new nade entity set pev_dmgtime to a higer value so it will explode x seconds later.
3. If you want to set a damage in a specific radius use find_sphere_class( it works like get_players and give you an array of players) then use ExecuteHam(Ham_TakeDamage,...) in the for loop.
About the circle, you mean like an wave that starts from nade origin and go to the "end point" of the radius ? If so, look for TE_BEAMCYLINDER

The function that create the c4(grenade entity) is CGrenade::ShootSatchelCharge(), it can be hooked and you can create very easy a planted c4. I would like to know if this can be done with a smokegrenade too(maybe two minutes of searching into the cssdk but I'm too lazy now).

Glad to see you back :d
__________________

Last edited by HamletEagle; 12-26-2014 at 15:49.
HamletEagle is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 12-26-2014 , 16:05   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #3

Duuuuude, you have gone some lightyears further in the coding. Also glad to see your progress!
1. Also, I've never known anything about orpheu and at this point I'm too afraid to work with it, but there is first time for everything! So I'm gonna try what you have suggested, since it seems to be the most effective method. I'll just need some little example of the function, to create some conception in my mind. Will google a lot, it's obvious.
2. That's clear, I think I'll succeed with it.
3. Aaaand that's again super unknown for me... I mean, the find_sphere_class(), how do I define the end point of the radius and in which value is the distance from the center to the end point of the radius?

And before someone says to google and search - I did that already, but at this point I've understood nothing from the threads around...
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 12-26-2014 , 23:17   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #4

3>http://www.amxmodx.org/doc/index.htm...here_class.htm
RateX is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-27-2014 , 05:47   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #5

http://amxmodx.org/api/engine/find_sphere_class
Better to use the new documentation, more convenient

1. Oprheu it's not hard, the hard part is searching for functions in windows dll( they don't have names so you need to search by used strings ), finding what function do what you want, but you get used with it after some time.

This is the signature:
Code:
{
    "name"        : "SG_Detonate",
    "class"       : "CGrenade",
    "library"     : "mod",
    "identifiers" :
    [
        {
            "os"    : "windows",
            "mod"   : "cstrike",
            "value" : "?SG_Detonate@CGrenade@@QAEXXZ"
        },
        {
            "os"    : "linux",
            "mod"   : "cstrike",
            "value" : "SG_Detonate__8CGrenade"
        },
        {
            "os"    : "linux",
            "mod"   : "cstrike",
            "value" : "_ZN8CGrenade11SG_DetonateEv"
        }
    ]
}
Taken from one of Arkshine's posts, I think he won't have a problem with that.

The code:
PHP Code:
#include <amxmodx>
#include <orpheu>

public plugin_init()
{
      new 
OrpheuFunction:HandleSGDetonateFunc
      HandleSGDetonateFunc 
OrpheuGetFunction("SG_Detonate""CGrenade")
      
OrpheuRegisterHook(HandleSGDetonateFunc"OnSGDetonate"OrpheuHookPre)
}

public 
OnSGDetonate(const GrenadeEntity)
{
    

I think you can go on your own further.

3. You choose your radius as you want.
PHP Code:
new ArrayPlayers32 ], PlayersNumid
    
const DMG_GRENADE 1<<24
    PlayersNum
find_sphere_class(here_you_put_your_new_nade_entity_index"player"radiusArrayPlayerssizeof ArrayPlayers)
    for(new 
iiPlayersNumi++)
    {
        
id ArrayPlayers[i]
        if(
is_user_alive(id))
        {
            
ExecuteHam(Ham_TakeDamageid0here_you_put_your_new_nade_entity_indexhere_you_put_the_damageDMG_GRENADE)
        }
    } 
__________________

Last edited by HamletEagle; 12-27-2014 at 09:48. Reason: Fixed a typo.
HamletEagle is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 12-27-2014 , 08:10   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #6

So, as first I tried that, just to remove the smoke nade before it explodes:
PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new 
OrpheuFunction:HandleSGDetonateFunc
    HandleSGDetonateFunc 
OrpheuGetFunction("SG_Detonate""CGrenade")
    
OrpheuRegisterHook(HandleSGDetonateFunc"OnSGDetonate"OrpheuHookPre)
}

public 
OnSGDetonate(const ent)
{
    static 
idFloat:flOrigin[3]
    
id pev(entpev_owner)
    
pev(entpev_originflOrigin)
    
    
engfunc(EngFunc_RemoveEntityent)
    
client_print(idprint_chat"Smokegren removed")

And guess what, it's not working, the message doesn't show neither Tried with some other natives to remove the ent and stuff, still the same. I think I have a general mistake somewhere...
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-27-2014 , 08:23   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #7

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <orpheu>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new 
OrpheuFunction:HandleSGDetonateFunc
    HandleSGDetonateFunc 
OrpheuGetFunction("SG_Detonate""CGrenade")
    
OrpheuRegisterHook(HandleSGDetonateFunc"OnSGDetonate"OrpheuHookPre)
}

public 
OnSGDetonate(ent)
{
    
client_print(pev(ent,pev_owner), print_chat"It works"

A simple test plugin which is tested and working.
Code:
It works
To block the explosion and to remove the nade just do as below:
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <orpheu>
#include <fakemeta>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new 
OrpheuFunction:HandleSGDetonateFunc
    HandleSGDetonateFunc 
OrpheuGetFunction("SG_Detonate""CGrenade")
    
OrpheuRegisterHook(HandleSGDetonateFunc"OnSGDetonate"OrpheuHookPre)
}

public 
OrpheuHookReturn:OnSGDetonate(ent)
{
    
client_print(pev(ent,pev_owner), print_chat"It works"
    
remove_entity(ent)
    return 
OrpheuSupercede

Your plugin will crash the server because you must supercede the function after removing the nade. But the message should work. Also no reason to use static.

Run orpheu config command into your server console and look into addons/amxmodx/logs. You should see something like
Code:
Parsing folder "CGrenade" started
			Parsing file "SG_Detonate" started
				Searching for name "?SG_Detonate@CGrenade@@QAEXXZ"... FOUND
			Parsing file "SG_Detonate" ended
You need to go to addons/amxmodx/configs/orpheu/functions, create a folder called CGrenade, inside it a file without any extension called SG_Detonate and after that copy the content from the post above( the one with the signature ).
__________________

Last edited by HamletEagle; 12-27-2014 at 08:29.
HamletEagle is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 12-27-2014 , 08:40   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #8

Maybe it's something with the orpheu module itself, that I'm not doing right. Tried the both codes, put some info messages everywhere - nothing. I think the hook doesn't even get called, will check the instalation and return with some answers.
EDIT: It all seems to be alright, I have no idea what's going on... I hate that
__________________

Last edited by Flick3rR; 12-27-2014 at 08:44.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-27-2014 , 08:47   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #9

You didn't installed the plugin right or the signature. Give me the output of the orpheu config command.
__________________
HamletEagle is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 12-27-2014 , 12:41   Re: Hallelujah nade - base questions about nade entities
Reply With Quote #10

Orpheu config command:
Code:
Orpheu configuration started.

	Parsing mods configuration started.
	Parsing mod file "cstrike"
	Parsing mod file "dod"
	Parsing mod file "esf"
	Parsing mod file "esf_openbeta"
	Parsing mod file "ns"
	Parsing mod file "SvenCoop"
	Parsing mod file "tfc"
	Parsing mod file "ts"
	Parsing mod file "valve"
	Parsing mods configuration ended.

	Parsing libraries configuration started.

		Parsing file "monstermod"
			Added library monstermod identified by cvar monster_spawn
		Parsing file "podbot"
			Added library podbot identified by cvar pb_version

	Parsing libraries configuration ended.

	Parsing type aliases started.

		Parsing folder "CBaseEntity"
			Adding alias"CBaseEntity *"
		Parsing folder "CGameRules"
			Adding alias"CGameRules *"
		Parsing folder "charPointer"
			Adding alias"char *"
		Parsing folder "CMBaseMonster"
			Adding alias"CMBaseMonster *"
		Parsing folder "long"
			Adding alias"long"
		Parsing folder "VectorPointer"
			Adding alias"Vector *"


	Parsing type aliases ended.

Orpheu configuration ended.

Orpheu libraries search started.

	Adding library metamod (0x6b200000)
	Adding library amxmodx (0x74900000)
	Adding library fun (0x74760000)
	Adding library fakemeta (0x74710000)
	Adding library regex (0x746d0000)
	Adding library nvault (0x746b0000)
	Adding library cstrike (0x64a0000)
	Adding library csx (0xa1f0000)
	Adding library orpheu (0xa4b0000)
	Adding library hamsandwich (0x74680000)
	Adding library booster (0x6eb0000)
	Adding library podbot (0xa840000)
	Adding library engine (0x74650000)

Orpheu libraries search ended.

Orpheu functions search started.

	Parsing functions started.

	Parsing functions ended.


Orpheu functions search ended.

Orpheu virtual functions search started.

	Parsing virtual functions started.


	Parsing virtual functions ended.

Orpheu virtual functions search ended.

Orpheu memory structures search started.

	Parsing memory structures started.


	Parsing memory structures ended.

Orpheu memory structures search ended.
And yeah, I didnt install that signature. Actually, I didn't know there is something to install with it, thought you just gave it like an example of what I was searching. *Nooby*
__________________

Last edited by Flick3rR; 12-27-2014 at 12:44.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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 15:21.


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