PDA

View Full Version : how to tell if a door is not locked



Cheeseh
04-11-2018, 05:34 PM
So, IsLockedByMaster doesn't appear to work, so I tried the method below, it seems to work fine for most doors on the auspices map, but the osprey map, doesn't appear to work on the SECURE ACCESS door to AREA 2. Seems to be caused when door is only activated by button and not by master. any ideas??

this is what I've got so far:



bool UTIL_DoorIsOpen ( CBaseDoor@ door, CBaseEntity@ pActivator )
{
string masterName = door.m_sMaster;

CBaseEntity@ pMaster = FIND_ENTITY_BY_TARGETNAME(null,masterName);
CBaseEntity@ pButton;

if ( pMaster !is null )
{
return pMaster.IsTriggered(pActivator);
}

// no master , find button
@pButton = FIND_ENTITY_BY_TARGET(null, door.pev.targetname );

if ( pButton !is null )
{
CBaseToggle@ pToggle = cast<CBaseToggle@>( pButton );

// something needed in here???

@pMaster = FIND_ENTITY_BY_TARGETNAME(null,pToggle.m_sMaster);

if ( pMaster !is null )
{
return pMaster.IsTriggered(pActivator);
}

return pButton.IsTriggered(pActivator);
}

// no master / no button
return door.IsTriggered(pActivator);
}

}

w00tguy123
04-11-2018, 11:45 PM
If its master is triggered, then the door is not itself locked. Any door with a targetname will require something else to trigger it though (unless the "USE only" flag is set). The entity that triggers the door might be locked by a master, but that's not the case for osprey.

If the point is to check if you can pass through the door, then another options is to check if it's already open (like in osprey after the button is pressed). To do that you can compare the current position/angle with the open position/angle (m_vecPosition2/m_vecAngle2):
https://baso88.github.io/SC_AngelScript/docs/CBaseDoor.htm

anggara_nothing
05-11-2018, 12:53 AM
Also, you can check them with CBaseDoor.GetToggleState() or CBaseDoor.m_toggle_state

https://baso88.github.io/SC_AngelScript/docs/TOGGLE_STATE.htm

TS_AT_TOP => door is open.
TS_AT_BOTTOM => door is closed.
TS_GOING_UP => door is about to open. (moving)
TS_GOING_DOWN => door is about to close. (moving)

https://github.com/ValveSoftware/halflife/blob/master/dlls/doors.cpp#L535-L554