![]() |
Detecting when func_door_rotating entities open
Just wondering: how can I determine what state {open, closed} a rotating door entity is in? I know how to get the edict of the door entity, but I'm not sure if there's anything to check in that edict- the angle?
In Worldcraft, there's a parameter for this kind of entity called "message"- I tried adding a new message name for a door, but it never seemed to be sent when I opened that door. Any hints? -JB |
Re: Detecting when func_door_rotating entities open
I've been searching this for a while too, but there's no miracle solution here AFAIK.
You can check pEdict->v.nextthink. If it is greater than zero, the door is either opening, either in open state and about to close, either closing. If it is equal or smaller to zero, the door is closed. Else, if you know the location of the door, just do a TraceLine through it. If the TraceLine passes, the door is open, if the TraceLine is blocked, then it is closed. |
Re: Detecting when func_door_rotating entities open
I was peeking around in the source code and found a variable called m_toggle_state. When the door is at the top/open it gets set to TS_AT_TOP.
Code:
void CBaseDoor::DoorHitTop( void ) Digging further, I find this: Code:
typedef enum |
Re: Detecting when func_door_rotating entities open
You'll also need to use the pvPrivateData pointer and determine the offset of this class member variable yourself (although more than likely, it's the same offset used by the Half-Life SDK), since you can't access class member variables directly outside the MOD source code.
botman |
Re: Detecting when func_door_rotating entities open
...and as botman says, this is a very unreliable method. More advanced MODs may very well decide to change the way the door code works in HL. Then you will read an incorrect variable. Or they simply relocated this variable elsewhere.
I'd not advise anybody to do anything with pvPrivateData if you want robust code. You will figure out the offset and it will work, but it will be guaranteed to work ONLY for your version of the engine and your version of the MOD. The only thing that'll work for sure no matter which MOD you play is v.nextthink. |
All times are GMT +2. The time now is 06:24. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.