AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detecting Ground Touch (https://forums.alliedmods.net/showthread.php?t=130904)

RedRobster 06-28-2010 21:51

Detecting Ground Touch
 
I am trying to find the best way to determine when a weapon touches the ground after it has been dropped. I was thinking about either hooking the "drop" command or forwarding Ham_Item_Drop to know when it drops, but I wasn't sure about the best way to tell when it hits the ground. Any information at all is helpful. Thanks.

fezh 06-28-2010 21:55

Re: Detecting Ground Touch
 
PHP Code:

if ( peviEntpev_flags ) & FL_ONGROUND )
{
    
// code 


You can also use engine:
PHP Code:

entity_get_intiEntEV_INT_flags ) & FL_ONGROUND

And take this in account:
PHP Code:

const FL_ONGROUND2 = (FL_CONVEYOR|FL_ONGROUND|FL_PARTIALGROUND|FL_INWATER|FL_FLOAT); 


RedRobster 06-28-2010 22:00

Re: Detecting Ground Touch
 
Quote:

Originally Posted by fezh (Post 1223189)
And take this in account:
PHP Code:

const FL_ONGROUND2 = (FL_CONVEYOR|FL_ONGROUND|FL_PARTIALGROUND|FL_INWATER|FL_FLOAT); 


About the FL_INWATER: if I remove that, if it is on the bottom of the pool/water, will that be considered on the ground?

wrecked_ 06-28-2010 22:00

Re: Detecting Ground Touch
 
If you really want to do this for a certain weapon drop event, you can enable the Think forward for that weapon once it is dropped, check if it is on the ground in the think, and if it's on the ground, do what you need to do there and then unregister the forward.

RedRobster 06-28-2010 22:05

Re: Detecting Ground Touch
 
Quote:

Originally Posted by wrecked_ (Post 1223193)
If you really want to do this for a certain weapon drop event, you can enable the Think forward for that weapon once it is dropped, check if it is on the ground in the think, and if it's on the ground, do what you need to do there and then unregister the forward.

How would I enable the think forward?

wrecked_ 06-28-2010 22:31

Re: Detecting Ground Touch
 
Quote:

Originally Posted by RedRobster (Post 1223197)
How would I enable the think forward?

Ham_Think
RegisterHam()
EnableHamForward()
DisableHamForward()

FM_Think
register_forward()
unregister_forward()

RedRobster 06-28-2010 22:32

Re: Detecting Ground Touch
 
Quote:

Originally Posted by wrecked_ (Post 1223219)
Ham_Think
RegisterHam()
EnableHamForward()
DisableHamForward()

FM_Think
register_forward()
unregister_forward()

Muchos gracias. Much appreciated.

wrecked_ 06-28-2010 22:40

Re: Detecting Ground Touch
 
Quote:

Originally Posted by RedRobster (Post 1223221)
Muchos gracias. Much appreciated.

No problemo.

Emp` 06-28-2010 22:48

Re: Detecting Ground Touch
 
Why not register_touch ?

RedRobster 06-28-2010 23:06

Re: Detecting Ground Touch
 
Quote:

Originally Posted by Emp` (Post 1223238)
Why not register_touch ?

You would
PHP Code:

register_touch"player""func_wall""touch"//I don't know the entity for the floor...I assume that's it o.o 

or could you
PHP Code:

register_touch"player""world""touch"

^Nevermind.


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

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