' Manual door script by kolik212 (based on stock script by Rьdiger Hьlsmann and Marcel Kuhnt | 28.10.2009)
' Coded by kolik212 (omsimods.ru)
'   							 ######## From Russia With Love =) ########
' Changelog:
' 3.06.2012 - First release
' 3.06.2012 - Added PAX triggers for entrypoints (by kolik212)
' 4.06.2012 - Added physics for first door, sweet =) (by kolik212)
' 5.06.2012 - Added sound triggers for open and close (by kolik212)
' 5.06.2012 - Fix PAX passenger exit and entry points (by kolik212)

'А теперь дохуя кода в который я бы без знаний не совался) Омся очень капризная, имейте это ввиду)

{macro:door_manual_frame}
	(M.L.door_m_1_physics)
{end}


'Add main trigger (animation and mouseevent)

{trigger:door_m_1_drag}

	1 (S.L.door_m_1_dragged)
	(L.L.door_m_1_pos) (S.L.door_m_1_lastpos)

	(L.S.mouse_x) 150 / (L.L.door_m_1_pos) + (S.L.door_m_1_pos) s0
	l0 0 <
	{if}
		0 (S.L.door_m_1_pos)		
	{endif}
	l0 1 >
	{if}
		1 (S.L.door_m_1_pos)
	{endif}

	(L.L.door_m_1_pos) (L.L.door_m_1_lastpos) - (L.S.Timegap) / (S.L.door_m_1_speed)

{end}

{trigger:door_m_1_off}
	0 (S.L.door_m_1_dragged)
{end}

'Physics for door_m_1 here ^_^

{macro:door_m_1_physics}

	(L.L.door_m_1_dragged) !
		{if}
		(L.L.door_m_1_pos) (L.S.Timegap) (L.L.door_m_1_speed) * + (S.L.door_m_1_pos)

		(L.L.door_m_1_pos) 1 >
		{if}
			1 (S.L.door_m_1_pos)
			(L.L.door_m_1_speed) /-/ 0.7 * (S.L.door_m_1_speed)
		{endif}
		(L.L.door_m_1_pos) 0 <
		{if}
			0 (S.L.door_m_1_speed) (S.L.door_m_1_pos)
		{endif}

		(L.L.door_m_1_pos) 0 >
		{if}
			(L.L.door_m_1_speed) (L.S.Timegap) (L.L.A_Trans_Y) (C.L.door_m_1_pet) * (L.L.A_Trans_X) /-/ + 0.9 * (L.L.door_m_1_globalangle) * * + (S.L.door_m_1_speed)
		{endif}
	
		(L.L.door_m_1_speed) s0 (S.L.door_m_1_lastspeed)
		l0 0 >
		{if}
			l0 (L.S.Timegap) 0.2 * - (S.L.door_m_1_speed)
		{endif}
		l0 0 <
		{if}
			l0 (L.S.Timegap) 0.2 * + (S.L.door_m_1_speed)
		{endif}


		(L.L.door_m_1_speed) 0 > (L.L.door_m_1_lastspeed) 0 < &&
		(L.L.door_m_1_speed) 0 < (L.L.door_m_1_lastspeed) 0 > && ||
		{if}
			0 (S.L.door_m_1_speed)
		{endif}	 
	
	{endif}

		(L.L.door_m_1_pos) 0.83 >=
		{if}
			  (S.L.PAX_Entry0_Open) (S.L.PAX_Entry1_Open)
		{else}
			0 (S.L.PAX_Entry1_Open) (S.L.PAX_Entry1_Open)
{endif}

	(L.L.door_m_1_pos) 0 > (L.L.door_m_1_open) ! &&
	{if}
		(T.L.door_m_1_auf)
		1 (S.L.door_m_1_open)
	{endif}

	(L.L.door_m_1_pos) 0 = (L.L.door_m_1_open) &&
	{if}
		(T.L.door_m_1_zu)
		0 (S.L.door_m_1_open)
	{endif}

	(L.L.door_m_1_pos) 140 * 27 + 3.14 * 180 / sin (S.L.door_m_1_globalangle) 

	(L.L.velocity) (L.L.cp_velocity_last) - (S.L.cp_acceleration)
	(L.L.velocity) (S.L.cp_velocity_last)
	

{end}

