home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Diversos / stat.swf / scripts / frame_3 / DoAction.as
Encoding:
Text File  |  2006-06-13  |  9.1 KB  |  337 lines

  1. function startgame()
  2. {
  3.    soundelectric = new Sound();
  4.    soundelectric.attachSound("electric");
  5.    soundfanfare = new Sound();
  6.    soundfanfare.attachSound("harp");
  7.    soundfire = new Sound();
  8.    soundfire.attachSound("fire");
  9.    soundtick = new Sound();
  10.    soundtick.attachSound("tick");
  11.    soundbell = new Sound();
  12.    soundbell.attachSound("bell");
  13.    s_sc1 = new Sound();
  14.    s_sc1.attachSound("scream1");
  15.    s_sc2 = new Sound();
  16.    s_sc2.attachSound("scream2");
  17.    s_sc3 = new Sound();
  18.    s_sc3.attachSound("scream3");
  19.    s_sc4 = new Sound();
  20.    s_sc4.attachSound("scream4");
  21.    pulse = [-1,-2,-3,-4,-5,5,4,3,2,1];
  22.    nchat = ["You have wonderful hands !","You sure saved HIS sorry ass !","You\'ve got Clooney\'s heart","You have much to teach us.","I get off at 3am, do you fancy a kebab?","Chocolates?, MALTEESERS !","You\'re a magician !","You\'re so good we should CLONE you..","That was worth doing overtime for !","You\'ve got the reflexes of a HOT CAT !","EXCELLENT !","Is it getting hot in here?","I love your... technique","This guy makes my heart STOP!","My friend, electric.","You give me such a buzz!","Can you feel it too? It\'s like electricity","He\'s a sharp dresser too!","Wow. Next time, I\'m going private","Doc, you\'re a stunner!","I feel a Finger Frenzy coming on!","Set phasers to stunned!","...and who is this Bambos guy anyway?","It\'s Hank Zapper!","Set the controls for the heart of the stun","Loving your bedside manner","You have the power","It\'s ALIVE!","You\'re the guv\'nor","My hero","That was the business","That made me moist.","He\'s not on fire, but you are.","You\'re the Un-terminator.","Watt\'s up, doc!","Do you play tennis with Dr Bambos?","A great STAT of mind"," He lives on Electric Avenue","Smells like chicken..."];
  23.    body = _root.thebody;
  24.    body._x = 361;
  25.    body._y = 270;
  26.    fibs = _root.fibs;
  27.    danger = _root.danger;
  28.    clock = _root.clock;
  29.    meter = _root.meter;
  30.    slider = _root.slider;
  31.    alive = _root.alive;
  32.    tally = _root.tally;
  33.    playbut = _root.i_submit;
  34.    stat = _root.title;
  35.    myface = _root.face;
  36.    nurse = _root.nurse;
  37.    charger = _root.charger;
  38.    window = _root.window;
  39.    savedscore = _root.savedscore;
  40.    charger._alpha = 99;
  41.    sliderox = slider._x;
  42.    bar = 300;
  43.    electro = 0;
  44.    clocktime = 0;
  45.    dead_off_frame = 30;
  46.    alive_off_frame = 44;
  47.    timeout_frame = 108;
  48.    next_person_frame = 120;
  49.    flatline_frame = 10;
  50.    bodyrest_frame = 1;
  51.    bodyshock_frame = 4;
  52.    resetgame();
  53. }
  54. function game()
  55. {
  56.    if(st == 3)
  57.    {
  58.       if(Math.floor(Math.random(1) * 300) > 297 and window._currentframe == 1)
  59.       {
  60.          window.gotoAndPlay("walk" + (1 + Math.floor(Math.random(1) * 2)));
  61.       }
  62.       if(saved > 24 and saved < 30)
  63.       {
  64.          alivezone += Math.floor(Math.random(1) * 3) - 1;
  65.          dangerzone = alivezone - 8;
  66.          danger._width = dangerzone;
  67.          alive._width = alivezone;
  68.       }
  69.       if(saved > 29 and saved < 35 or saved > 14 and saved < 20)
  70.       {
  71.          alivezone -= pulse[zonetimer];
  72.          dangerzone += pulse[zonetimer];
  73.          zonetimer += 1;
  74.          if(zonetimer == 9)
  75.          {
  76.             zonetimer = 0;
  77.          }
  78.          danger._width = dangerzone;
  79.          alive._width = alivezone;
  80.       }
  81.       if(saved > 34 and saved < 40)
  82.       {
  83.          alivezone -= 4;
  84.          dangerzone = alivezone - 8;
  85.          if(alivezone < 5)
  86.          {
  87.             alivezone = 250;
  88.          }
  89.          danger._width = dangerzone;
  90.          alive._width = alivezone;
  91.       }
  92.       if(electro > 0)
  93.       {
  94.          myface.gotoAndPlay(body._currentframe + facechoice * 10);
  95.          slider._x += electroinc;
  96.          if(electroinc > 6)
  97.          {
  98.             electroinc -= 0.2;
  99.          }
  100.       }
  101.       if(slider._x - sliderox > bar - dangerzone)
  102.       {
  103.          body.gotoAndPlay("die");
  104.          playscream();
  105.          st = 4;
  106.          soundfire.start();
  107.       }
  108.    }
  109.    if(st == 4)
  110.    {
  111.       if(body._currentframe == dead_off_frame or body._currentframe == timeout_frame)
  112.       {
  113.          st = 21;
  114.          electro = 0;
  115.          slider._x = sliderox;
  116.          savedscore._visible = false;
  117.          tally._visible = true;
  118.          playbut._visible = true;
  119.          tally.finalsaved = saved;
  120.          _global.finalTime = saved;
  121.          tally.gotoAndPlay(1);
  122.       }
  123.       if(body._currentframe == alive_off_frame)
  124.       {
  125.          st = 22;
  126.          electro = 0;
  127.          slider._x = sliderox;
  128.       }
  129.    }
  130.    if(st == 5)
  131.    {
  132.       savedscore.saved = saved;
  133.       tally._visible = false;
  134.       initbars();
  135.       danger._width = dangerzone;
  136.       alive._width = alivezone;
  137.       electro = 0;
  138.       slider._x = sliderox;
  139.       body.gotoAndPlay(1);
  140.       st = 20;
  141.       fibs._visible = true;
  142.    }
  143.    if(st == 20)
  144.    {
  145.       savedscore._visible = true;
  146.       myface.gotoAndStop("face" + (facechoice + 1));
  147.       body._x -= 20;
  148.       nurse._alpha += 6;
  149.       if(body._x < 34)
  150.       {
  151.          st = 3;
  152.          clocktime = 0;
  153.          soundtick.start(0,1000);
  154.       }
  155.    }
  156.    if(st == 21)
  157.    {
  158.       body._y += 20;
  159.       if(body._y > 460)
  160.       {
  161.          st = 2;
  162.          soundtick.stop("tick");
  163.       }
  164.    }
  165.    if(st == 22)
  166.    {
  167.       body._x += 20;
  168.       if(body._x > 360)
  169.       {
  170.          st = 5;
  171.          body._x = 361;
  172.          body._y = 270;
  173.          soundtick.stop("tick");
  174.       }
  175.    }
  176.    face._x = body._x + 48;
  177.    face._y = body._y + 65;
  178. }
  179. function clickup()
  180. {
  181.    soundelectric.stop("electric");
  182.    if(slider._x - sliderox > bar - alivezone and st == 3)
  183.    {
  184.       body.gotoAndPlay("alive");
  185.       st = 4;
  186.       soundfanfare.start();
  187.       fibs._visible = true;
  188.       myface.gotoAndPlay("face" + (facechoice + 1));
  189.       nurse.nursechat = nchat[Math.floor(Math.random(1) * 39)];
  190.       nurse.gotoAndPlay("talk");
  191.       saved += 1;
  192.    }
  193.    if(body._currentframe > bodyrest_frame and st == 3)
  194.    {
  195.       body.gotoAndPlay("rest");
  196.       fibs._visible = true;
  197.       electro = 0;
  198.       slider._x = sliderox;
  199.       myface.gotoAndPlay("face" + (facechoice + 1));
  200.       nurse.nursechat = "wooof ! ..better charge up again";
  201.       nurse.gotoAndPlay("talk");
  202.    }
  203. }
  204. function clickdown()
  205. {
  206.    if(st == 3 and electroinc > 0 and body._currentframe == bodyrest_frame)
  207.    {
  208.       body.gotoAndPlay("shock");
  209.       fibs._visible = false;
  210.       electro = 1;
  211.       electroinc = 6;
  212.       soundelectric.start(0,1000);
  213.       fibs.gotoAndPlay(1);
  214.    }
  215. }
  216. function initbars()
  217. {
  218.    facechoice = saved;
  219.    zonetimer = 0;
  220.    if(saved > 50)
  221.    {
  222.       facechoice = Math.floor(Math.random(1) * 40);
  223.       nurse.nursechat = "I still can\'t believe you got over 50 !";
  224.       nurse.gotoAndPlay("talk");
  225.    }
  226.    if(saved < 6)
  227.    {
  228.       alivezone = 30 + Math.floor(Math.random(1) * 220);
  229.       dangerzone = alivezone - 26;
  230.    }
  231.    if(saved < 11 and saved > 4)
  232.    {
  233.       alivezone = 130;
  234.       dangerzone = alivezone - 40 + saved * 3;
  235.    }
  236.    if(saved < 16 and saved > 10)
  237.    {
  238.       alivezone = 30 + Math.floor(Math.random(1) * 250);
  239.       dangerzone = alivezone - 12;
  240.    }
  241.    if(saved < 21 and saved > 15)
  242.    {
  243.       alivezone = 30 + Math.floor(Math.random(1) * 250);
  244.       dangerzone = alivezone - 20 + (saved - 15) * 2;
  245.    }
  246.    if(saved > 20 and saved < 30)
  247.    {
  248.       alivezone = 30 + Math.floor(Math.random(1) * 250);
  249.       dangerzone = alivezone - 8;
  250.    }
  251.    if(saved > 29 and saved < 41)
  252.    {
  253.       alivezone = 30 + Math.floor(Math.random(1) * 250);
  254.       dangerzone = alivezone - 6;
  255.       zonetimer = 0;
  256.    }
  257.    if(saved > 39)
  258.    {
  259.       alivezone = 30 + Math.floor(Math.random(1) * 220);
  260.       dangerzone = alivezone - 6;
  261.       zonetimer = 0;
  262.    }
  263. }
  264. function playscream()
  265. {
  266.    randomnum = Math.floor(Math.random(1) * 4);
  267.    if(randomnum == 1)
  268.    {
  269.       s_sc1.start();
  270.    }
  271.    if(randomnum == 2)
  272.    {
  273.       s_sc2.start();
  274.    }
  275.    if(randomnum == 3)
  276.    {
  277.       s_sc3.start();
  278.    }
  279.    if(randomnum == 0)
  280.    {
  281.       s_sc4.start();
  282.    }
  283. }
  284. function resetgame()
  285. {
  286.    st = 20;
  287.    savedscore.saved = 0;
  288.    facechoice = 0;
  289.    electroinc = 5;
  290.    saved = 0;
  291.    electro = 0;
  292.    clocktime = 0;
  293.    dangerzone = 10;
  294.    alivezone = 70;
  295.    alivedeac = 20;
  296.    savedscore._visible = true;
  297.    myface._visible = true;
  298.    stat._visible = false;
  299.    playbut._visible = false;
  300.    body._visible = true;
  301.    myface._visible = true;
  302.    fibs._visible = true;
  303.    danger._visible = true;
  304.    alive._visible = true;
  305.    danger._width = dangerzone;
  306.    alive._width = alivezone;
  307.    meter._visible = true;
  308.    slider._visible = true;
  309.    body.gotoAndStop(1);
  310.    body._x = 361;
  311.    body._y = 270;
  312.    slider._x = 30.35;
  313.    slider._y = 60.35;
  314.    tally._visible = false;
  315.    nurse._alpha = 0;
  316.    gotoAndStop(3);
  317. }
  318. function clocky()
  319. {
  320.    if(st == 3)
  321.    {
  322.       clocktime += 1;
  323.       clock.hand._rotation = clocktime;
  324.       if(clocktime > 358)
  325.       {
  326.          nurse.nursechat = "time up ! - don\'t blame yourself....MUCH!";
  327.          nurse.gotoAndPlay("talk");
  328.          body.gotoAndPlay("timeout");
  329.          st = 4;
  330.          soundbell.start();
  331.          soundtick.stop("tick");
  332.       }
  333.    }
  334. }
  335. startgame();
  336. stop();
  337.