Advertisement
snake5

[sgs] brsd4game level script

Sep 3rd, 2015
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. function onLevelStart()
  4. {
  5.     SendMessage( MT_Info, "Objective added" );
  6.     SendMessage( MT_Warning, "Hold TAB to view objectives", 10 );
  7.     global
  8.         LS =
  9.         {
  10.             room1dooropened = false,
  11.             room1powerfixed = false,
  12.             room2door1state = false,
  13.             room2door2state = false,
  14.             room2door3state = false,
  15.             room2doorsopened = false,
  16.         }
  17.         ,OBJ_ROOM_1 = ObjectiveAdd( "Find a way to open the door", OS_Hidden )
  18.         ,OBJ_ROOM_1a = ObjectiveAdd( "Fix power lines for the door", OS_Hidden )
  19.         ,OBJ_ROOM_2 = ObjectiveAdd( "Find a way to open all 3 doors", OS_Hidden )
  20.         ,OBJ_ROOM_2a = ObjectiveAdd( "Find a way to bypass all 3 doors", OS_Hidden )
  21.         ,OBJ_ENDING = ObjectiveAdd( "Get to the flag!", OS_Open )
  22.     ;
  23. }
  24.  
  25. function objstate( id, state )
  26. {
  27.     if( state == ObjectiveGetState( id ) )
  28.         return;
  29.     if( state == OS_Open )
  30.     {
  31.         SendMessage( MT_Info, "Objective added" );
  32.         SendMessage( MT_Continued, ObjectiveGetText( id ) );
  33.     }
  34.     if( state == OS_Done )
  35.     {
  36.         SendMessage( MT_Info, "Objective completed" );
  37.         SendMessage( MT_Continued, ObjectiveGetText( id ) );
  38.     }
  39.     ObjectiveSetState( id, state );
  40. }
  41. function callent( name, arg )
  42. {
  43.     CallEntity( name, arg );
  44. }
  45.  
  46. //
  47. // ROOM 1
  48. //
  49. function onRoom1Enter(enter)
  50. {
  51.     if(!enter)return;
  52.     objstate( OBJ_ROOM_1, OS_Open );
  53. }
  54. function updateRoom1Door()
  55. {
  56.     if( LS.room1powerfixed == false && LS.room1dooropened )
  57.     {
  58.         callent( "room1pboxspark", "trigger_enter" );
  59.         objstate( OBJ_ROOM_1a, OS_Open );
  60.     }
  61.     if( LS.room1powerfixed && LS.room1dooropened )
  62.     {
  63.         callent( "room1pboxspark", "trigger_leave" );
  64.         callent( "room1door", "trigger_enter" );
  65.         objstate( OBJ_ROOM_1, OS_Done );
  66.     }
  67. }
  68. function onRoom1SwitchTop()
  69. {
  70.     LS.room1dooropened = true;
  71.     updateRoom1Door();
  72. }
  73. function testRoom1PboxTop()
  74. {
  75.     return PlayerHasItem( "wrench" );
  76. }
  77. function onRoom1PboxTop()
  78. {
  79.     objstate( OBJ_ROOM_1a, OS_Done );
  80.     LS.room1powerfixed = true;
  81.     updateRoom1Door();
  82. }
  83.  
  84. //
  85. // SUB
  86. //
  87. function onSubSwitch( on, evname )
  88. {
  89.     callent( "subdoor1", evname );
  90.     callent( "subdoor2", evname );
  91. }
  92.  
  93. //
  94. // ROOM 2
  95. //
  96. function onRoom2Enter(enter)
  97. {
  98.     if(!enter)return;
  99.     objstate( OBJ_ROOM_2, OS_Open );
  100. }
  101. function testRoom2SwitchAny()
  102. {
  103.     return LS.room2doorsopened == false;
  104. }
  105. function updateRoom2()
  106. {
  107.     if( LS.room2door1state && LS.room2door2state && LS.room2door3state )
  108.     {
  109.         LS.room2doorsopened = true;
  110.         callent( "room2sparks", "trigger_once" );
  111.         objstate( OBJ_ROOM_2, OS_Done );
  112.     }
  113. }
  114. function onRoom2Exit()
  115. {
  116.     objstate( OBJ_ROOM_2, OS_Cancelled );
  117.     objstate( OBJ_ROOM_2a, OS_Done );
  118. }
  119. function onRoom2Switch1()
  120. {
  121.     callent( "room2door2", "trigger_enter" ); LS.room2door2state = true;
  122.     callent( "room2door3", "trigger_switch" ); LS.room2door3state = !LS.room2door3state;
  123.     updateRoom2();
  124. }
  125. function onRoom2Switch2()
  126. {
  127.     callent( "room2door1", "trigger_enter" ); LS.room2door1state = true;
  128.     callent( "room2door2", "trigger_switch" ); LS.room2door2state = !LS.room2door2state;
  129.     callent( "room2door3", "trigger_leave" ); LS.room2door3state = false;
  130.     updateRoom2();
  131. }
  132. function onRoom2Switch3()
  133. {
  134.     callent( "room2door1", "trigger_switch" ); LS.room2door1state = !LS.room2door1state;
  135.     callent( "room2door2", "trigger_leave" ); LS.room2door2state = false;
  136.     callent( "room2door3", "trigger_enter" ); LS.room2door3state = true;
  137.     updateRoom2();
  138. }
  139.  
  140. //
  141. // END
  142. //
  143. function onLevelEnd(enter)
  144. {
  145.     if(!enter)return;
  146.     objstate( OBJ_ENDING, OS_Done );
  147.     EndLevel( true );
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement