home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / Campaign8Startup.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  8.5 KB  |  347 lines

  1.  
  2. function LightningStrike( pos )
  3.     -- Make sure ON terrain
  4.     local level = G.GetCogName("Level");
  5.     pos[1] = level.GetHeight( pos[0], pos[2] )
  6.     
  7.     G.ZapStrike( pos );
  8.     G.CreateAt( "LightningExplosion", pos )
  9. end
  10.  
  11.  
  12. -- Lightning and storms
  13. function ElectrifriedCinematic()
  14.  
  15.     G.SimpleLoadSoundVar( "Zap", "SFX/ZapperActivate",  4 ) 
  16.  
  17.     TraitorTalk( "It's looking like rather stormy out there!" );
  18.     
  19.     local tower = G.GetCogName("Tower");
  20.     local towerPos = tower.GetPosition();
  21.     
  22.     local CinemaInvader = G.CreateAt( "Basic", Vector3( 122, 0, 134 ) )
  23.     local CinemaInvader2  = G.CreateAt( "Basic", Vector3( 132, 0, 134 ) );
  24.  
  25.     CinemaInvader.TurnOffAI();
  26.     CinemaInvader2.TurnOffAI();
  27.     
  28.     CinemaInvader.SetDirection( Vector3(1,0,0) )
  29.     CinemaInvader2.SetDirection( Vector3(-1,0,0) )
  30.     
  31.     Camera.CinemaMove( towerPos + Vector3(-40,40,-40), towerPos+ Vector3(0,20,0), 3 );
  32.     GameWait(3)
  33.     
  34.     GameWait(1)
  35.     
  36.     -- Lightning strikes!
  37.     LightningStrike( towerPos + Vector3(0, 0, 30) );
  38.     GameWait(0.5)
  39.     LightningStrike( towerPos + Vector3(75, 0, 0) );
  40.         
  41.     TraitorTalk( "Yikes! Lightning!" );
  42.     GameWait(2)
  43.  
  44.     TraitorTalk( "I hope it doesn't hit anything important!" );
  45.     GameWait(4)
  46.     
  47.     -- Hits the tower!
  48.     LightningStrike( towerPos + Vector3(2, 0, 0) );
  49.     GameWait(0.25)
  50.     LightningStrike( towerPos + Vector3(0, 0, 4) );
  51.     GameWait(0.25)
  52.     LightningStrike( towerPos + Vector3(1, 0, -2) );
  53.     GameWait(0.25)
  54.  
  55.     Camera.CinemaMove( towerPos + Vector3(-40,40,-40), towerPos+ Vector3(0,30,0), 0.25 );
  56.     G.ZapStrike( towerPos + Vector3(0, 30, 0 ) );
  57.     G.CreateAt( "LightningExplosion",  towerPos + Vector3(0, 30, 0 ) )
  58.     GameWait(0.5)
  59.  
  60.     G.SimplePlaySound( "Zap" );
  61.     G.ZapIt( Tower );
  62.  
  63.     GameWait(0.3)
  64.     G.SimplePlaySound( "Zap" );
  65.     GameWait(0.3)
  66.     G.SimplePlaySound( "Zap" );
  67.     GameWait(0.3)
  68.     
  69.     Tower.TakeDamage( 250 );
  70.     
  71.     G.SimplePlaySound( "Zap" );
  72.     GameWait(0.3)
  73.     
  74.     -- Damage tower
  75.     
  76.     TraitorTalk( "Oh no! It hit the tower!" );
  77.     GameWait(3)
  78.     
  79.     TraitorTalk( "That's some major damage, repairs will be impossible." );
  80.     GameWait(4)
  81.     
  82.     -- It looks like
  83.     local camPos = Vector3(130,40,170)
  84.     Camera.CinemaMove( camPos, Vector3(126,0,130), 4 );
  85.     TraitorTalk( "What's that? Oh no, not invaders!" )
  86.     GameWait(4)
  87.     
  88.     -- Spawn an invader, and kill with lightning
  89.     local invPos = CinemaInvader.GetPosition()
  90.     local invPos2 = CinemaInvader2.GetPosition()
  91.  
  92.     G.SayPhraseScript( "Darn, \n it's raining.", CinemaInvader2 );
  93.     GameWait( 2 );
  94.     G.EndCurrentPhrase( CinemaInvader2 )
  95.     
  96.     Camera.CinemaMove( camPos, invPos, 0.5 );
  97.     CinemaInvader.Hop( 20 )
  98.     G.SayPhraseScript( "Great, \n now I'm wet." , CinemaInvader );
  99.     GameWait( 2 );
  100.     G.EndCurrentPhrase( CinemaInvader )
  101.     
  102.     LightningStrike( invPos );    
  103.     GameWait(1)
  104.     
  105.     Camera.CinemaMove( camPos, invPos2, 0.5 );
  106.     CinemaInvader2.Hop( 20 )
  107.     G.SayPhraseScript( "AAAAHHHH!" , CinemaInvader2 );
  108.     GameWait( 2 );
  109.     G.EndCurrentPhrase( CinemaInvader2 )    
  110.  
  111.     -- Later: 
  112.     TraitorTalk( "All these lightning strikes makes me think!" )
  113.     LightningStrike( invPos2 );    
  114.     GameWait(5)
  115.  
  116.     G.KillAllInvaders()
  117.  
  118.     TraitorTalk( "Hold off these guys while I develop my idea!" )
  119.     
  120. end
  121.  
  122.  
  123. --Common Level Start Code
  124. function LevelStartup()
  125.  
  126.     G.Create( "MenuData/HudCog.xml" );
  127.     G.Create( "Data/GameCamera.xml" );
  128.     G.Create( "Data/CursorCog.xml" );
  129.  
  130.     MainLevel = G.Create( "Data/Levels/Campaign8.xml" );
  131.     MainLevel.CreateLevel();
  132.  
  133.     G.SetInvSpeed( 20 );
  134.     HUD.EnterLevel();
  135.     G.SetGameState( InLevel );
  136.     G.SetPoints( 0 );
  137.     
  138.     G.SetLightTime( 3 );
  139.     G.PostP( "None" );
  140.     --TraitorTalk(" ");
  141.  
  142.     G.Create( "Data/RainCell.xml" );
  143.  
  144.  
  145.     -- gameStartTime = 10000000;
  146.  
  147.     HUD.Message( "VictoryCondition" , "SetText", "Survive the Chaotic Invasion!"  );
  148.     HUD.Message( "LossCondition" , "SetText", "If the Tower falls you lose." );
  149.         
  150.     TraitorCanBeHidden = true
  151. end
  152.  
  153. LevelStartup()
  154.  
  155. function LevelIntro()
  156.     
  157.     local tempPos = Tower.GetPosition()
  158.     Camera.LookAtPosition( tempPos )
  159.  
  160.     gameStartTime = GameTime;
  161.  
  162.     ColorTextPopup( "Level 8: Electri-fried!", Color(1,1,1,1) )
  163.  
  164.     G.DisableTrapAll()
  165.         
  166.     G.EnableTrap("bomb");
  167.     G.EnableTrap("wall");
  168.     
  169.     G.EnableTrap("fan");
  170.     G.EnableTrap("hammer");
  171.     G.EnableTrap("poison");
  172.     G.EnableTrap("bulb");    
  173.     G.EnableTrap("vortex");
  174.  
  175.     DisableTraitor()
  176.     GameWait(1.5)
  177.     
  178.     StartCinematic()
  179.         ElectrifriedCinematic()
  180.     EndCinematic()
  181.         
  182. end
  183.  
  184. SpawnPoints = {}
  185.  
  186. function LevelSequence()
  187.     
  188.     -- 1st Have a tower and some walls and let the Basic guys attack.
  189.     Traitor.SetGuiPosition( "TraitorWindow"  , Vector3(0.6, -0.5, 1) );
  190.     
  191.     -- Set the spawn points
  192.         
  193.     -- Start Spawning the guys
  194.     BasicWave = createSpawnStruct()
  195.     
  196.     BasicWave.Prob.Basic    = 2.0;
  197.     BasicWave.Prob.Miner    = 1.0;
  198.     BasicWave.Prob.Ninja    = 1.0;
  199.     
  200.     BasicWave.SpawnSpeed    = 1.0;
  201.     BasicWave.MaxSpawn        = 25;
  202.     BasicWave.TotalSpawn    = 48;
  203.     BasicWave.GroupPercent    = 0.15;
  204.     BasicWave.GroupSize        = 1;
  205.     BasicWave.WhereToSpawn    = SmallCircleAroundTower
  206.             
  207.     PsychicWave = createSpawnStruct()
  208.     
  209.     PsychicWave.Prob.Psychic    = 1.0;
  210.     
  211.     PsychicWave.SpawnSpeed        = 0.9;
  212.     PsychicWave.MaxSpawn        = 25;
  213.     PsychicWave.TotalSpawn        = 25;
  214.     PsychicWave.GroupPercent    = 0.15;
  215.     PsychicWave.GroupSize        = 1;
  216.     PsychicWave.WhereToSpawn    = RandomAnywhere
  217.         
  218.     AddWave( "BasicAttack", BasicWave )
  219.     G.EarnPoints( 100 );
  220.     G.SetMaxKills( 50 )
  221.  
  222.     
  223.     
  224. --    GameWait(4)
  225. --    TraitorTalk("That's odd... the vortexes are at this place too.")
  226. --    GameWait(4)
  227. --    TraitorTalk("I don't see any psychics around.")
  228. --    GameWait(3)
  229. --    TraitorTalk("Oh well. We have other things to worry about right now.")
  230. --    GameWait(10)
  231.             
  232.     InvadersKilledWait( 50 )
  233.     
  234.     TraitorTalk("I think I've got almost it...")
  235.     GameWait(3)
  236.     
  237.     TraitorTalk("Huh? What was that?")
  238.     GameWait(3)
  239.     
  240.     AddWave( "PsychicAttack", PsychicWave )
  241.     G.SetMaxKills( 75 )
  242.     
  243.     TraitorTalk("There are Psychics teleporting in!")
  244.     GameWait(6)
  245.             
  246.     InvadersKilledWait( 75 )    
  247.             
  248.     TrapTextPopup("Bug Zapper")
  249.     G.EarnPoints( 200 )
  250.     G.EnableTrap("zapper");
  251.  
  252.     TraitorTalk( "I've figured out how to harness the power of lightning!" )
  253. --    TraitorTalk("Here, I've got something for you.  Its a giant Bug Zapper trap." )
  254.     GameWait(5)    
  255.     TraitorTalk( "Its a giant Bug Zapper trap, it does major damage to anyone close by.");
  256.     GameWait(4)    
  257.     TraitorTalk( "Place them around the base to zap groups of invaders as they appear!")
  258.     GameWaitOrMoney(20)    
  259.     
  260.     BasicWave.TotalSpawn = 75
  261.     BasicWave.Prob.Stacker    = 0.5;
  262.     BasicWave.Prob.Psychic = 1.0;    
  263.     G.SetMaxKills( 150 )
  264.     
  265.     BasicWave.GroupPercent    = 0.5;
  266.     BasicWave.GroupSize        = 5;    
  267.     
  268.     GameWait(10)
  269.         
  270.     InvadersKilledWait( 150 )
  271.     StopWave( "PsychicAttack" )
  272.     StopWave( "BasicAttack" )
  273.     WaitForClearEnemies( 30 ) 
  274.  
  275.     TraitorTalk("Whew, what a rush!")
  276.     GameWait(3)
  277.     TraitorTalk("Now we can harness the power of the elements!")
  278.     GameWait(6)
  279.  
  280.     G.SetGameState( Victory );
  281.  
  282.     TraitorTalk("Those invaders don't stand a chance!")
  283.     GameWait(5)
  284.  
  285.  
  286.  
  287. --    TraitorTalk("So here's where all the vortexes lead to!")
  288. --    GameWait(4)
  289. --    TraitorTalk("Maybe this wasn't the best spot to build a base...")
  290. --    GameWait(7)
  291.  
  292. --    TraitorTalk("With this base here we can use the vortex whenever we want!")
  293. --    GameWait(5)
  294. --    TraitorTalk("I think we might be winning against the invaders.")
  295. --    GameWait(4)
  296. --    TraitorTalk("That attack seemed pretty intense.             Almost desperate...")
  297. --    GameWait(4)
  298.         
  299.     --G.SetGameState( Victory );
  300.     
  301. end
  302.  
  303. lastLightningStrike = GameTime
  304. timeToStrike = 10
  305.  
  306. function LevelUpdate()
  307.     
  308.     -- Random Lightning strikes (after intro)
  309.     if( lastLightningStrike + timeToStrike < GameTime ) then
  310.         lastLightningStrike = GameTime
  311.         timeToStrike = math.random( 15, 25 ) 
  312.         
  313.         local centerPos = Vector3( 256, 0, 256 );
  314.         
  315.         -- Check that the tower still exists, and get it's center:
  316.         if( Tower ~= nil and Tower.IsValid() ) then
  317.             centerPos = Tower.GetPosition()    
  318.         end
  319.  
  320.         -- Min radius == 10
  321.         local offsetPos = Vector3( math.random( 256 ) - 128, 0, math.random( 256 ) - 128 )
  322.         while( offsetPos[0] *  offsetPos[0] + offsetPos[2] * offsetPos[2] < 125 ) do
  323.             offsetPos = Vector3( math.random( 256 ) - 128, 0,math.random( 256 ) - 128 )
  324.         end
  325.         LightningStrike( centerPos + offsetPos )
  326.     end
  327.     
  328.     
  329.     -- Make sure the player isn't trying to exit the level
  330.     CheckLevelCompletion(  )
  331.     UpdateGameMusic()
  332.     -- This is the intro, where you check for level 
  333.     if( levelRoutine ) then    
  334.         local con, error = coroutine.resume( levelRoutine )
  335.  
  336.         -- Start the Level Sequence:
  337.         if( con == false and GameState == InLevel ) then    
  338.             G.Mes( error )
  339.             levelRoutine = coroutine.create( LevelSequence )
  340.         end    
  341.     end    
  342. end
  343.  
  344. levelRoutine = coroutine.create(LevelIntro);
  345.  
  346. GMain["LevelUpdate"] = LevelUpdate;
  347.