PDA

View Full Version : Detecting Ground Touch


RedRobster
06-28-2010, 21:51
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
if ( pev( iEnt, pev_flags ) & FL_ONGROUND )
{
// code
}You can also use engine:
entity_get_int( iEnt, EV_INT_flags ) & FL_ONGROUND;And take this in account:
const FL_ONGROUND2 = (FL_CONVEYOR|FL_ONGROUND|FL_PARTIALGROUND|FL_ INWATER|FL_FLOAT);

RedRobster
06-28-2010, 22:00
And take this in account:
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
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
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
How would I enable the think forward?
Ham_Think
RegisterHam()
EnableHamForward()
DisableHamForward()

FM_Think
register_forward()
unregister_forward()

RedRobster
06-28-2010, 22:32
Ham_Think
RegisterHam()
EnableHamForward()
DisableHamForward()

FM_Think
register_forward()
unregister_forward()

Muchos gracias. Much appreciated.

wrecked_
06-28-2010, 22:40
Muchos gracias. Much appreciated.
No problemo.

Emp`
06-28-2010, 22:48
Why not register_touch (http://www.amxmodx.org/funcwiki.php?go=func&id=463) ?

RedRobster
06-28-2010, 23:06
Why not register_touch (http://www.amxmodx.org/funcwiki.php?go=func&id=463) ?
You would

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

register_touch( "player", "world", "touch")


^Nevermind.

drekes
06-28-2010, 23:14
register_touch("weaponbox", "worldspawn", "touch");
I think this is a good way to do that.