//
// Used by SUB_UseTargets, when a door is the target of a button.
//
void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	m_hActivator = pActivator;

	if (!UTIL_IsMasterTriggered(m_sMaster, pActivator))
		return;
	if (m_iSpeedMode==1){			//AJH for changing door speeds
		pev->speed+=m_fAcceleration;
		DoorActivate();				
		ALERT(at_debug, "speed increased by %f and is now %f\n", m_fAcceleration,pev->speed);
	}
	else{
		if (m_iOnOffMode)
		{
			if (useType == USE_ON)
			{
				if (m_toggle_state == TS_AT_BOTTOM)
				{
		 			PlayLockSounds(pev, &m_ls, FALSE, FALSE);
		 			DoorGoUp();
				}
				return;
			}
			else if (useType == USE_OFF)
			{
				if (m_toggle_state == TS_AT_TOP)
				{
		         	DoorGoDown();
				}
	         	return;
			}
		}


		// if not ready to be used, ignore "use" command.
		if (m_toggle_state == TS_AT_TOP)
		{
			if (!FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN))
				return;
		}
		else if (m_toggle_state != TS_AT_BOTTOM)
			return;
	
		DoorActivate();
	}
}
Esempio n. 2
0
BOOL CBaseDoor::DoorActivate( void )
{
	if( IsLockedByMaster( ))
		return 0;

	if( FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) && m_iState == STATE_ON )
	{
		// door should close
		DoorGoDown();
	}
	else
	{
		// door should open
		if( m_hActivator != NULL && m_hActivator->IsPlayer( ))
			m_hActivator->TakeHealth( m_bHealthValue, DMG_GENERIC );

		// play door unlock sounds
		PlayLockSounds( pev, &m_ls, FALSE, FALSE );
		DoorGoUp();
	}
	return 1;
}
Esempio n. 3
0
//
// Causes the door to "do its thing", i.e. start moving, and cascade activation.
//
int CBaseDoor::DoorActivate( )
{
	if ( CHalfLifeRules *rules = dynamic_cast<CHalfLifeRules *>( g_pGameRules ) ) {
		if ( rules->EntityShouldBePrevented( edict() ) ) {
			return 0;
		}
	}

	if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
		return 0;

	if (FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP)
	{// door should close
		DoorGoDown();
	}
	else
	{// door should open

		if ( m_hActivator != NULL && m_hActivator->IsPlayer() )
		{// give health if player opened the door (medikit)
		// VARS( m_eoActivator )->health += m_bHealthValue;
	
			m_hActivator->TakeHealth( m_bHealthValue, DMG_GENERIC );

		}

		// play door unlock sounds
		PlayLockSounds(pev, &m_ls, FALSE, FALSE);
		
		DoorGoUp();
	}

	if ( CHalfLifeRules *singlePlayerRules = dynamic_cast< CHalfLifeRules * >( g_pGameRules ) ) {
		singlePlayerRules->HookModelIndex( this->edict() );
	}

	return 1;
}
//-----------------------------------------------------------------------------
// Purpose: Causes the door to "do its thing", i.e. start moving, and cascade activation.
// Output : int
//-----------------------------------------------------------------------------
int CBaseDoor::DoorActivate( )
{
	if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
		return 0;

	if (HasSpawnFlags(SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP)
	{
		// door should close
		DoorGoDown();
	}
	else
	{
		// door should open
		// play door unlock sounds
		PlayLockSounds(this, &m_ls, FALSE, FALSE);

		if ( m_toggle_state != TS_AT_TOP && m_toggle_state != TS_GOING_UP )
		{
			DoorGoUp();
		}
	}

	return 1;
}