.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Detecting when func_door_rotating entities open
Old
  (#1)
two_masks
Guest
 
Status:
Posts: n/a
Default Detecting when func_door_rotating entities open - 04-05-2004

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
  
Reply With Quote
Re: Detecting when func_door_rotating entities open
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Detecting when func_door_rotating entities open - 05-05-2004

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.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Detecting when func_door_rotating entities open
Old
  (#3)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Detecting when func_door_rotating entities open - 05-05-2004

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 )
 {
 	if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
 	{
 		STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving) );
 		EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseArrived), 1, ATTN_NORM);
 	}
 
 	ASSERT(m_toggle_state == TS_GOING_UP);
 	m_toggle_state = TS_AT_TOP; //RIGHT HERE RIGHT HERE
 	
 	// toggle-doors don't come down automatically, they wait for refire.
 	if (FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN))
 	{
 		// Re-instate touch method, movement is complete
 		if ( !FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) )
 			SetTouch( DoorTouch );
 	}
 	else
 	{
 		// In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open
 		pev->nextthink = pev->ltime + m_flWait;
 		SetThink( DoorGoDown );
 
 		if ( m_flWait == -1 )
 		{
 			pev->nextthink = -1;
 		}
 	}
 
 	// Fire the close target (if startopen is set, then "top" is closed) - netname is the close target
 	if ( pev->netname && (pev->spawnflags & SF_DOOR_START_OPEN) )
 		FireTargets( STRING(pev->netname), m_hActivator, this, USE_TOGGLE, 0 );
 
 	SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); // this isn't finished
 }


Digging further, I find this:

Code:
typedef enum
 {
   TS_AT_TOP,
   TS_AT_BOTTOM,
   TS_GOING_UP,
   TS_GOING_DOWN
 } TOGGLE_STATE;
m_toggle_state is part of CBaseAnimating. Also, you may need to use some hacks (hope that is the proper term) if the door starts open, is closing, or is opening.
  
Reply With Quote
Re: Detecting when func_door_rotating entities open
Old
  (#4)
botman
Super Moderator
 
Status: Offline
Posts: 280
Join Date: Jan 2004
Location: Plano, TX
Default Re: Detecting when func_door_rotating entities open - 05-05-2004

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
  
Reply With Quote
Re: Detecting when func_door_rotating entities open
Old
  (#5)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Detecting when func_door_rotating entities open - 05-05-2004

...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.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com