Advertisement
snake5

defended: b5-7.sgs

Apr 13th, 2016
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.10 KB | None | 0 0
  1.  
  2. include "b5-common";
  3.  
  4. function LevelEnd()
  5. {
  6.     GotoLevel( 8 );
  7. }
  8.  
  9. global enemy1trigger = event();
  10.  
  11. function p0btn_Activate()
  12. {
  13.     level.FindEntity( "p0l0" ).enabled = false;
  14.     level.FindEntity( "p0l1" ).enabled = false;
  15.     level.FindEntity( "p0light" ).enabled = false;
  16.     this.Stop();
  17.     enemy1trigger.signaled = true;
  18. }
  19.  
  20. function p1btn_Activate()
  21. {
  22.     level.FindEntity( "p1l0" ).enabled = false;
  23.     level.FindEntity( "p1l1" ).enabled = false;
  24.     level.FindEntity( "p1light" ).enabled = false;
  25.     this.Stop();
  26. }
  27.  
  28. function p2enemies()
  29. {
  30.     E1 = level.FindEntity( "enemy2a" ).ctrl;
  31.     E2 = level.FindEntity( "enemy2b" ).ctrl;
  32.    
  33.     if( !( action = ActorAction.start( 1, E1, E2 ) ) )
  34.         return;
  35.    
  36.     E1.set_speaker_info( "p2btn", "A" );
  37.     E2.set_speaker_info( "p2btn", "B" );
  38.    
  39.     subtime = 14;
  40.    
  41.     action.wait( 1 );
  42.     E1.play_anim( "standing_idle", true );
  43.     E1.look_at( E2.entity.position );
  44.     E1.speak( "Hey, what happened with the lasers?", subtime );
  45.     action.wait( 2 );
  46.     E2.play_anim( "standing_idle", true );
  47.     E2.look_at( E1.entity.position );
  48.     action.wait( 3 );
  49.     E2.speak( "I've no idea!", subtime );
  50.     action.wait( 2 );
  51.     E1.speak( "Let's go check!", subtime );
  52.     action.wait( 2 );
  53.     E1.stop_anim();
  54.     E2.stop_anim();
  55.     SPEECHSYS.ClearSpeechFor( E1.entity );
  56.     SPEECHSYS.ClearSpeechFor( E2.entity );
  57.     E1.i_speed = 0.4;
  58.     a = subthread E1.run_to_target( level.positions.e2a_pos2 );
  59.     b = subthread E2.run_to_target( level.positions.e2b_pos2 );
  60.     sync( a, b );
  61.     a = subthread E1.look_at( level.positions.e2_look2 );
  62.     b = subthread E2.look_at( level.positions.e2_look2 );
  63.     sync( a, b );
  64.     action.wait( 9999999999999 );
  65.    
  66.     action.end();
  67. }
  68.  
  69. function p2btn_Activate()
  70. {
  71.     level.FindEntity( "p2l0" ).enabled = false;
  72.     level.FindEntity( "p2l1" ).enabled = false;
  73.     level.FindEntity( "p2light" ).enabled = false;
  74.     this.Stop();
  75.     thread p2enemies();
  76. }
  77.  
  78. function Enemy0_Behavior(E)
  79. {
  80.     for(;;)
  81.     {
  82.         E.i_speed = 0.4;
  83.         E.patrol
  84.         ([
  85.             { action = "moveauto", pos = level.positions.enemy0stand },
  86.             { action = "lookat", pos = level.positions.enemy0look },
  87.             { action = "wait", time = 3 },
  88.         ]);
  89.         E.fighter_behavior_1();
  90.     }
  91. }
  92.  
  93. function Enemy1_Behavior(E)
  94. {
  95.     sync( enemy1trigger );
  96.     for(;;)
  97.     {
  98.         E.i_speed = 0.4;
  99.         E.patrol
  100.         ([
  101.             { action = "moveauto", pos = level.positions.e1pp1 },
  102.             { action = "lookat", pos = level.positions.enemy0stand },
  103.             { action = "wait", time = 3 },
  104.             { action = "moveauto", pos = level.positions.e1pp0 },
  105.             { action = "wait", time = 3 },
  106.         ]);
  107.         E.fighter_behavior_1();
  108.     }
  109. }
  110.  
  111. function Enemy2_Behavior(E)
  112. {
  113.     for(;;)
  114.     {
  115.         E.i_speed = 0.4;
  116.         E.patrol
  117.         ([
  118.             { action = "lookat", pos = level.positions.e2look },
  119.             { action = "wait", time = 3 },
  120.         ]);
  121.         E.fighter_behavior_1();
  122.     }
  123. }
  124.  
  125. function Enemy3_Behavior(E)
  126. {
  127.     for(;;)
  128.     {
  129.         E.i_speed = 0.4;
  130.         E.patrol
  131.         ([
  132.             { action = "moveauto", pos = level.positions.e3pp0 },
  133.             { action = "wait", time = 2 },
  134.             { action = "lookat", pos = level.positions.e3pp0look },
  135.             { action = "wait", time = 3 },
  136.             { action = "moveauto", pos = level.positions.e3pp1 },
  137.             { action = "wait", time = 3 },
  138.         ]);
  139.         E.fighter_behavior_1();
  140.     }
  141. }
  142.  
  143. function Enemy4_Behavior(E)
  144. {
  145.     for(;;)
  146.     {
  147.         E.i_speed = 0.4;
  148.         E.patrol
  149.         ([
  150.             { action = "moveauto", pos = level.positions.e4stand },
  151.             { action = "lookat", pos = level.positions.e4look },
  152.             { action = "wait", time = 3 },
  153.         ]);
  154.         E.fighter_behavior_1();
  155.     }
  156. }
  157.  
  158. function onLevelStart()
  159. {
  160.     SetOverlayMusic( "/music2" );
  161.     level.CreateEntity( "TPSPlayer" ).
  162.     {
  163.         position = level.positions.player_start,
  164.         viewDir = vec3(1,0,0),
  165.     };
  166.     MarkExit( "trig_end", LevelEnd );
  167.     level.FindEntity( "p0btn" ).OnActivate = p0btn_Activate;
  168.     level.FindEntity( "p1btn" ).OnActivate = p1btn_Activate;
  169.     level.FindEntity( "p2btn" ).OnActivate = p2btn_Activate;
  170.     level.FindEntity( "enemy0" ).func = Enemy0_Behavior;
  171.     level.FindEntity( "enemy1" ).func = Enemy1_Behavior;
  172.     level.FindEntity( "enemy2a" ).func = Enemy2_Behavior;
  173.     level.FindEntity( "enemy2b" ).func = Enemy2_Behavior;
  174.     level.FindEntity( "enemy3" ).func = Enemy3_Behavior;
  175.     level.FindEntity( "enemy4" ).func = Enemy4_Behavior;
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement