home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / the_beard.swf / scripts / frame_3 / DoAction_2.as next >
Encoding:
Text File  |  2008-09-23  |  48.4 KB  |  2,035 lines

  1. function updateHUD()
  2. {
  3.    if(d.powa >= 100 && !hud.pbar.cycle)
  4.    {
  5.       hud.pbar.gotoAndPlay(2);
  6.       hud.pbar.cycle = true;
  7.    }
  8.    else
  9.    {
  10.       hud.pbar.cycle = false;
  11.       hud.pbar.gotoAndStop(1);
  12.    }
  13.    hud.numlives = ": " + this.lives;
  14.    hud.score = "XP:" + this.score;
  15.    if(this.nex != undefined)
  16.    {
  17.       hud.nex = "NEXT: " + this.nex;
  18.    }
  19.    else
  20.    {
  21.       hud.nex = "MAXED OUT";
  22.    }
  23.    hud.lbar._xscale = d.life / d.maxlife * 100;
  24.    hud.pbar._xscale = d.powa;
  25.    hud.bbar._xscale = b.life / b.maxlife * 100;
  26.    if(hud.bbar._xscale < 0)
  27.    {
  28.       hud.bbar._xscale = 0;
  29.    }
  30.    if(this.score >= this.nex && !summoning && this.nex != undefined)
  31.    {
  32.       flashIt();
  33.       blackOut();
  34.       summoning = true;
  35.       this.pausy = true;
  36.       if(this.lev <= 2)
  37.       {
  38.          lut = this.attachMovie("leveluptext","lup",789);
  39.       }
  40.       else
  41.       {
  42.          lut = this.attachMovie("fabuloustext","lup",789);
  43.       }
  44.       lut._y = 20;
  45.       g = wrap.attachMovie("summon","summon",777);
  46.       g._xscale = 87;
  47.       g._yscale = g._xscale;
  48.       g._x = d._x - 30;
  49.       g._y = d._y + 20;
  50.    }
  51. }
  52. function blackOut()
  53. {
  54.    bgmusic.stop();
  55.    if(this.lev <= 2)
  56.    {
  57.       wrap.blackout.gotoAndPlay(2);
  58.    }
  59.    else
  60.    {
  61.       wrap.blackout2.gotoAndPlay(2);
  62.    }
  63.    i = 0;
  64.    while(i < stones.length)
  65.    {
  66.       yib = stones[i];
  67.       yib._visible = false;
  68.       i++;
  69.    }
  70. }
  71. function switchGuy()
  72. {
  73.    this.lev += 1;
  74.    d.attachMovie("k" + dudes[this.lev],"guts",0);
  75.    d.id = dudes[this.lev];
  76. }
  77. function endSummon()
  78. {
  79.    stopAllSounds();
  80.    if(!this.mute)
  81.    {
  82.       bgmusic.start(0,99);
  83.    }
  84.    hud.holder.guts.attachMovie("levicon" + this.lev,"guts",0);
  85.    this.nex = levreqs[this.lev];
  86.    hud.holder.gotoAndPlay(2);
  87.    wrap.blackout.gotoAndStop(1);
  88.    flashIt();
  89.    this.pausy = false;
  90.    summoning = false;
  91.    i = 0;
  92.    while(i < stones.length)
  93.    {
  94.       yib = stones[i];
  95.       yib._visible = true;
  96.       i++;
  97.    }
  98.    d.xvel = 0;
  99.    d.anum = 0;
  100. }
  101. function phys(who)
  102. {
  103.    if(who.blinking)
  104.    {
  105.       if(wrap.you._x == undefined)
  106.       {
  107.          yo = wrap.attachMovie("you","you",788766679);
  108.          yo._xscale = 80;
  109.          yo._yscale = yo._xscale;
  110.          yo.onEnterFrame = function()
  111.          {
  112.             this._x = _root.d._x + 5;
  113.             this._y = _root.d._y;
  114.             if(!_root.d.blinking)
  115.             {
  116.                this.unloadMovie();
  117.                this.removeMovieClip();
  118.                delete this.onEnterFrame;
  119.             }
  120.          };
  121.       }
  122.       who._visible = !who._visible;
  123.       who.blinkcv = who.blinkcv + 1;
  124.       if(who.blinkcv >= 70)
  125.       {
  126.          who.blinking = false;
  127.          who._visible = true;
  128.       }
  129.    }
  130.    if(who.inv)
  131.    {
  132.       who.invcv = who.invcv + 1;
  133.       if(who.invcv >= 15)
  134.       {
  135.          who.invcv = 0;
  136.          who.inv = false;
  137.       }
  138.    }
  139.    if(!who.dead)
  140.    {
  141.       who.powa += who.regen;
  142.       if(who.powa > 100)
  143.       {
  144.          who.powa = 100;
  145.       }
  146.    }
  147.    else
  148.    {
  149.       who.life = 0;
  150.    }
  151.    updateHUD();
  152.    if(!who.stoned)
  153.    {
  154.       who.xvel *= fric;
  155.       who.yvel += grav;
  156.       who._x += who.xvel;
  157.       who._y += who.yvel;
  158.    }
  159.    who.virtx = wrap._x + who._x;
  160.    who.virty = wrap._y + who._y;
  161.    who.rig = who.virtx + 15;
  162.    who.lef = who.virtx - 15;
  163.    who.topp = who.virty - 70;
  164.    while(wrap.bg.hitTest(who.virtx,who.topp,true))
  165.    {
  166.       who._y += 1;
  167.       who.virty += 1;
  168.       who.topp += 1;
  169.       if(who.yvel < 0)
  170.       {
  171.          who.yvel *= -1;
  172.       }
  173.    }
  174.    while(wrap.bg.hitTest(who.virtx,who.virty,true))
  175.    {
  176.       who._y -= 1;
  177.       who.virty -= 1;
  178.       who.topp -= 1;
  179.       if(!who.squashed)
  180.       {
  181.          who.hurt = false;
  182.       }
  183.       if(!who.jlo)
  184.       {
  185.          who.yvel = 0;
  186.          who.jlo = false;
  187.          if(who.jumping && who.life > 0)
  188.          {
  189.             if(!who.attacking)
  190.             {
  191.                who.guts.gotoAndStop("landit");
  192.             }
  193.             else
  194.             {
  195.                jumpRecover(who);
  196.             }
  197.          }
  198.       }
  199.       if(who.life <= 0)
  200.       {
  201.          if(!d.carrot)
  202.          {
  203.             if(d.soundcount != 1)
  204.             {
  205.                cannot.start();
  206.                d.soundcount = 1;
  207.             }
  208.             else
  209.             {
  210.                d.soundcount = 0;
  211.                resistance.start();
  212.             }
  213.             d.carrot = true;
  214.          }
  215.          d.hurt = false;
  216.          d.squashed = false;
  217.          who.guts.gotoAndStop("ground");
  218.       }
  219.    }
  220.    while(wrap.bg.hitTest(who.rig,who.virty - 25,true))
  221.    {
  222.       who.virtx -= 1;
  223.       who._x -= 1;
  224.       who.rig -= 1;
  225.       who.xvel = 0;
  226.    }
  227.    while(wrap.bg.hitTest(who.lef,who.virty - 25,true))
  228.    {
  229.       who.virtx += 1;
  230.       who._x += 1;
  231.       who.lef += 1;
  232.       who.xvel = 0;
  233.    }
  234.    if(!wrap.bg.hitTest(who.virtx,who.virty + 20,true))
  235.    {
  236.       who.jumping = true;
  237.    }
  238. }
  239. function squashrecover(who)
  240. {
  241.    who.attacking = false;
  242.    who.squashed = false;
  243.    who.hurt = false;
  244.    who.guts.gotoAndStop("rest");
  245. }
  246. function controls(who)
  247. {
  248.    if(!who.attacking)
  249.    {
  250.       if(Key.isDown(39))
  251.       {
  252.          who.xvel += who.speed;
  253.          who._xscale = 100;
  254.          if(!who.jumping)
  255.          {
  256.             who.guts.gotoAndStop("run");
  257.          }
  258.       }
  259.       if(Key.isDown(37))
  260.       {
  261.          who.xvel -= who.speed;
  262.          who._xscale = -100;
  263.          if(!who.jumping)
  264.          {
  265.             who.guts.gotoAndStop("run");
  266.          }
  267.       }
  268.       if(!Key.isDown(39) && !Key.isDown(37) && !who.jumping)
  269.       {
  270.          who.guts.gotoAndStop("rest");
  271.       }
  272.       if(Key.isDown(65))
  273.       {
  274.          if(who.powa > 3)
  275.          {
  276.             who.charge += 3;
  277.             if(who.charge > 9)
  278.             {
  279.                who.powa -= 1;
  280.             }
  281.          }
  282.          if(who.charge > 400)
  283.          {
  284.             who.charge = 400;
  285.          }
  286.          if(who.charge > 9)
  287.          {
  288.             i = 0;
  289.             while(i < who.charge / 25)
  290.             {
  291.                t = wrap.attachMovie("twinkle","star" + starcv,starcv);
  292.                starcv++;
  293.                t._xscale = who.charge * 1.5;
  294.                if(t._xscale > 200)
  295.                {
  296.                   t._xscale = 200;
  297.                }
  298.                t.gotoAndPlay(random(3) + 1);
  299.                t._yscale = t._xscale;
  300.                t._x = who._x + (random(70) - 35);
  301.                t._y = who._y - random(100);
  302.                t.yvel = random(4);
  303.                t.xvel = random(6) - 3;
  304.                t.onEnterFrame = function()
  305.                {
  306.                   this._y -= this.yvel;
  307.                   if(!this.esc)
  308.                   {
  309.                      this.yvel *= 0.9;
  310.                      this._alpha -= 10;
  311.                   }
  312.                   else
  313.                   {
  314.                      this._alpha -= 3;
  315.                      this.yvel -= 3;
  316.                   }
  317.                   this._x += this.xvel;
  318.                   this.xvel *= 0.9;
  319.                   if(_root.d.charge == 0 && !this.esc)
  320.                   {
  321.                      this.xvel *= 10;
  322.                      this.yvel *= random(20);
  323.                      if(_root.d._xscale == 100)
  324.                      {
  325.                         this._x += 90;
  326.                      }
  327.                      else
  328.                      {
  329.                         this._x -= 90;
  330.                      }
  331.                      this.esc = true;
  332.                   }
  333.                   if(this._alpha <= 10)
  334.                   {
  335.                      this.unloadMovie();
  336.                      this.removeMovieClip();
  337.                      delete this.onEnterFrame;
  338.                   }
  339.                };
  340.                i++;
  341.             }
  342.          }
  343.       }
  344.       if(Key.isDown(65) && who.aup)
  345.       {
  346.          who.attacking = true;
  347.          who.aup = false;
  348.          who.guts.gotoAndStop("attack" + who.anum);
  349.          who.anum += 1;
  350.          if(who.anum == 3)
  351.          {
  352.             who.anum = 0;
  353.          }
  354.          if(who.jumping)
  355.          {
  356.             who.guts.gotoAndStop("airslash");
  357.          }
  358.          var sou = eval("swin" + who.anum);
  359.          sou.start();
  360.       }
  361.    }
  362.    if(!Key.isDown(65))
  363.    {
  364.       if(who.charge > 9)
  365.       {
  366.          who.guts.gotoAndStop("chargerelease");
  367.          who.attacking = true;
  368.       }
  369.       else
  370.       {
  371.          who.charge = 0;
  372.       }
  373.       who.aup = true;
  374.    }
  375.    if(!Key.isDown(83))
  376.    {
  377.       who.sup = true;
  378.    }
  379.    if(!Key.isDown(JUMPBUT))
  380.    {
  381.       who.jup = true;
  382.    }
  383.    if(Key.isDown(JUMPBUT))
  384.    {
  385.       if(!who.jumping && who.jup)
  386.       {
  387.          who.jumping = true;
  388.          if(!who.attacking)
  389.          {
  390.             who.guts.gotoAndStop("jumpload");
  391.          }
  392.          else
  393.          {
  394.             runJump(who);
  395.          }
  396.          who.jup = false;
  397.          who.jlo = true;
  398.       }
  399.    }
  400. }
  401. function makeFireball(who)
  402. {
  403.    flashIt();
  404.    who.biggun = false;
  405.    if(!who.biggun)
  406.    {
  407.       f = wrap.attachMovie("special" + who.id,"fireball",899);
  408.       discharge.start();
  409.       amt = who.charge * 0.5;
  410.       f._xscale = amt;
  411.       f._yscale = f._xscale;
  412.       if(who._xscale == 100)
  413.       {
  414.          f.dir = 1;
  415.          f._x = who._x + 150;
  416.       }
  417.       else
  418.       {
  419.          f.dir = -1;
  420.          f._xscale = - amt;
  421.          f._x = who._x - 150;
  422.       }
  423.       f._y = who._y - 30;
  424.       f.onEnterFrame = function()
  425.       {
  426.          this._x += 6 * this.dir;
  427.          testHit(this.hitzone,Math.abs(this._xscale / 90),this,true);
  428.       };
  429.    }
  430.    if(who.powa < 0)
  431.    {
  432.       who.powa = 0;
  433.    }
  434.    who.charge = 0;
  435. }
  436. function flashIt()
  437. {
  438.    wrap.flasher.gotoAndPlay(2);
  439. }
  440. function testHit(box, amt, who, cl)
  441. {
  442.    if(!summoning && !d.dead)
  443.    {
  444.       i = 0;
  445.       while(i < stones.length)
  446.       {
  447.          var bh = stones[i];
  448.          if(bh.hitTest(box))
  449.          {
  450.             hit2.start();
  451.             bh.inair = true;
  452.             r = wrap.attachMovie("hitpoof","poof" + starcv,starcv + 999999);
  453.             r._xscale = 70;
  454.             r._yscale = r._xscale;
  455.             if(who._xscale > 0)
  456.             {
  457.                bh.xvel += 7 + random(5);
  458.             }
  459.             else
  460.             {
  461.                bh.xvel -= 7 - random(5);
  462.             }
  463.             if(who._xscale > 0)
  464.             {
  465.                var pg = 10;
  466.                bh._xscale = -100;
  467.             }
  468.             else
  469.             {
  470.                bh._xscale = 100;
  471.                pg = -10;
  472.                r._xscale = -70;
  473.             }
  474.             if(!cl)
  475.             {
  476.                r._x = bh._x + pg;
  477.                var ix = r._x;
  478.             }
  479.             else
  480.             {
  481.                r._x = bh._x;
  482.                var ix = r._x;
  483.             }
  484.             r._y = bh._y - 55;
  485.             var iy = r._y;
  486.             bh.yvel = -13;
  487.             bh.juggle += 1;
  488.             s = wrap.attachMovie("ptcounter","pcount" + i,8888888 + i);
  489.             s._x = ix;
  490.             s._y = iy;
  491.             s.pt = "+ " + bh.juggle;
  492.             s.cv = 0;
  493.             s.onEnterFrame = function()
  494.             {
  495.                this._y -= 2;
  496.                this.cv = this.cv + 1;
  497.                if(this.cv >= 30)
  498.                {
  499.                   this.unloadMovie();
  500.                   this.removeMovieClip();
  501.                   delete this.onEnterFrame;
  502.                }
  503.             };
  504.             this.score += bh.juggle;
  505.          }
  506.          i++;
  507.       }
  508.       if(wrap.bad.hitarea.hitTest(box) && !b.inv && !b.finaldead)
  509.       {
  510.          var ra = random(3);
  511.          var plain = eval("hit" + ra);
  512.          plain.start();
  513.          var rak = random(10);
  514.          if(rak > 7)
  515.          {
  516.             rak = 1;
  517.          }
  518.          var gil = eval("groan" + rak);
  519.          gil.start();
  520.          if(wrap.bad.expirecv <= 0 || wrap.bad.expirecv == undefined)
  521.          {
  522.             wrap.bad.pax = 1;
  523.          }
  524.          else if(!cl)
  525.          {
  526.             wrap.bad.pax += 1;
  527.          }
  528.          wrap.bad.expirecv = wrap.bad.maxexpire;
  529.          wrap.bad.gotoAndPlay("hit");
  530.          if(!b.attacking && !b.nohit)
  531.          {
  532.             wrap.bad.guts.gotoAndStop("hit");
  533.          }
  534.          wrap.bad.life -= amt;
  535.          var dist = Math.abs(wrap.bad._x - who._x);
  536.          if(who._xscale > 0)
  537.          {
  538.             wrap.bad.xvel = 7;
  539.          }
  540.          else
  541.          {
  542.             wrap.bad.xvel = -7;
  543.          }
  544.          if(!cl)
  545.          {
  546.             if(who._xscale > 0)
  547.             {
  548.                var ix = who._x + 90;
  549.             }
  550.             else
  551.             {
  552.                var ix = who._x - 90;
  553.             }
  554.          }
  555.          else
  556.          {
  557.             var ix = who._x;
  558.          }
  559.          iy = who._y - 40;
  560.          if(!b.predead)
  561.          {
  562.             i = 0;
  563.             while(i < 4)
  564.             {
  565.                j = wrap.attachMovie("bits" + i,"bit" + i,starcv);
  566.                starcv++;
  567.                j._x = ix + (random(20) - 10);
  568.                j._y = iy - (random(20) - 10);
  569.                j.xvel = random(20) - 10;
  570.                j.yvel = random(20) * -1;
  571.                j.onEnterFrame = function()
  572.                {
  573.                   this._x += this.xvel;
  574.                   this._y += this.yvel;
  575.                   this.xvel *= 0.9;
  576.                   this.yvel += grav;
  577.                   if(this._y > 500)
  578.                   {
  579.                      this.unloadMovie();
  580.                      this.removeMovieClip();
  581.                      delete this.onEnterFrame;
  582.                   }
  583.                };
  584.                i++;
  585.             }
  586.          }
  587.          var num = ncv - 1;
  588.          var turd = eval("wrap.pcount" + num);
  589.          if(cl)
  590.          {
  591.             var mult = Math.round(amt);
  592.          }
  593.          else
  594.          {
  595.             var mult = 0;
  596.          }
  597.          wrap.bad.pax += mult;
  598.          if(turd._x == undefined)
  599.          {
  600.             s = wrap.attachMovie("ptcounter","pcount" + ncv,8888888 + ncv);
  601.             s._x = ix;
  602.             s._y = iy;
  603.             s.pt = "+ " + wrap.bad.pax;
  604.             s.prev = wrap.bad.pax;
  605.             s.cv = 0;
  606.             s.onEnterFrame = function()
  607.             {
  608.                this._y -= 2;
  609.                this.cv = this.cv + 1;
  610.                if(this.cv >= 30)
  611.                {
  612.                   this.unloadMovie();
  613.                   this.removeMovieClip();
  614.                   delete this.onEnterFrame;
  615.                }
  616.             };
  617.             ncv++;
  618.          }
  619.          else
  620.          {
  621.             turd.pt = "+ " + wrap.bad.pax;
  622.          }
  623.          this.score += wrap.bad.pax;
  624.       }
  625.    }
  626. }
  627. function runSpecial(x, y, id, dir)
  628. {
  629.    flashIt();
  630.    sp = wrap.attachMovie("special" + id,"special",999);
  631.    sp._x = x;
  632.    sp._y = y;
  633.    sp._xscale = 100 * dir;
  634.    sp.dir = dir;
  635.    sp.onEnterFrame = function()
  636.    {
  637.       this._x += dir * 3;
  638.    };
  639. }
  640. function hitRecover(who)
  641. {
  642.    if(!who.attacking)
  643.    {
  644.       who.guts.gotoAndStop("rest");
  645.    }
  646. }
  647. function jumpRecover(who)
  648. {
  649.    who.jumping = false;
  650.    if(!who.attacking)
  651.    {
  652.       who.guts.gotoAndStop("rest");
  653.    }
  654. }
  655. function runJump(who)
  656. {
  657.    who.yvel = -23;
  658.    who.jlo = false;
  659.    if(!who.attacking)
  660.    {
  661.       who.guts.gotoAndStop("inair");
  662.    }
  663. }
  664. function momentum(who, amt)
  665. {
  666.    if(who._xscale == 100)
  667.    {
  668.       who.xvel += amt;
  669.    }
  670.    else
  671.    {
  672.       who.xvel -= amt;
  673.    }
  674. }
  675. function endAttack(who)
  676. {
  677.    who.attacking = false;
  678.    who.guts.gotoAndStop("rest");
  679.    who.jlo = false;
  680.    if(who.jumping)
  681.    {
  682.       who.guts.gotoAndStop("inair");
  683.    }
  684.    if(Key.isDown(65) && who.aup)
  685.    {
  686.       who.attacking = true;
  687.       who.aup = false;
  688.       if(who.jumping)
  689.       {
  690.          who.anum = 1;
  691.       }
  692.       who.guts.gotoAndStop("attack" + who.anum);
  693.       who.anum += 1;
  694.       if(who.anum == 3)
  695.       {
  696.          who.anum = 0;
  697.       }
  698.       var sou = eval("swin" + who.anum);
  699.       sou.start();
  700.    }
  701. }
  702. function centerOn(who)
  703. {
  704.    goalx = 320 - who._x;
  705.    distx = goalx - wrap._x;
  706.    wrap._x += distx / 4;
  707. }
  708. function restrainBG()
  709. {
  710.    if(wrap._x > -25)
  711.    {
  712.       wrap._x = -25;
  713.    }
  714.    var _loc1_ = - screenw + 650;
  715.    if(wrap._x < _loc1_)
  716.    {
  717.       wrap._x = _loc1_;
  718.    }
  719. }
  720. function restrainDude(who)
  721. {
  722.    if(who._x < 70)
  723.    {
  724.       who._x = 70;
  725.       who.xvel = 0;
  726.    }
  727.    if(who._x > wrap.bg._width - 60)
  728.    {
  729.       who._x = wrap.bg._width - 60;
  730.       who.xvel = 0;
  731.    }
  732.    if(who._y < 60)
  733.    {
  734.       who._y = 60;
  735.    }
  736. }
  737. function endBossAttack(who)
  738. {
  739.    who.attacking = false;
  740.    who.guts.gotoAndStop("rest");
  741.    who.inv = false;
  742.    who.overr = false;
  743. }
  744. function runEndEffects()
  745. {
  746.    d.dead = true;
  747. }
  748. function checkBossHit(box, fire, flame)
  749. {
  750.    if(!summoning)
  751.    {
  752.       i = 0;
  753.       while(i < stones.length)
  754.       {
  755.          var yi = stones[i];
  756.          if(box.hitTest(yi) && !yi.hurt)
  757.          {
  758.             hit2.start();
  759.             r = wrap.attachMovie("hitpoof","poof" + starcv,starcv + 999999);
  760.             starcv++;
  761.             r._xscale = 70;
  762.             r._x = yi._x;
  763.             r._y = yi._y - 30;
  764.             if(b._x > r._x)
  765.             {
  766.                r._xscale = -70;
  767.             }
  768.             else
  769.             {
  770.                r._xscale = 70;
  771.             }
  772.             r._yscale = r._xscale;
  773.             yi.yvel = -20;
  774.             yi.hurt = true;
  775.             if(yi._x > b._x)
  776.             {
  777.                yi.xvel += 10;
  778.                yi._xscale = -100;
  779.             }
  780.             else
  781.             {
  782.                yi.xvel -= 10;
  783.                yi._xscale = 100;
  784.             }
  785.          }
  786.          i++;
  787.       }
  788.       if(box.hitTest(d.guts.box) && !d.hurt && !d.dead && !d.blinking)
  789.       {
  790.          d.inv = true;
  791.          var ra = random(3);
  792.          var plain = eval("hit" + ra);
  793.          plain.start();
  794.          flashIt();
  795.          d.hurt = true;
  796.          if(!fire)
  797.          {
  798.             d.guts.gotoAndStop("airhit");
  799.             d.yvel = -20;
  800.          }
  801.          if(fire)
  802.          {
  803.             d.guts.gotoAndStop("burned");
  804.             d.yvel = -20;
  805.          }
  806.          if(flame)
  807.          {
  808.             d.guts.gotoAndStop("burn");
  809.             d.yvel = -20;
  810.          }
  811.          d.life -= 20;
  812.          if(!nox)
  813.          {
  814.             if(d._x > b._x)
  815.             {
  816.                d.xvel = 30;
  817.                d._xscale = -100;
  818.             }
  819.             else
  820.             {
  821.                d.xvel = -30;
  822.                d._xscale = 100;
  823.             }
  824.             if(b._xscale == -100)
  825.             {
  826.                d.xvel = -35;
  827.                d._xscale = 100;
  828.             }
  829.          }
  830.          d.attacking = false;
  831.          d.jlo = false;
  832.          if(d.life <= 0)
  833.          {
  834.             d.life = 0;
  835.             runEndEffects();
  836.          }
  837.       }
  838.    }
  839. }
  840. function makeInv()
  841. {
  842.    b.inv = true;
  843. }
  844. function bossMove()
  845. {
  846.    if(b.ploy == 1)
  847.    {
  848.       if(!b.doneit)
  849.       {
  850.          b.pattern = 2;
  851.          b.doneit = true;
  852.       }
  853.       else if(!b.dunn)
  854.       {
  855.          b.pattern = 4;
  856.          if(!b.laffed)
  857.          {
  858.             laugh.start();
  859.             b.laffed = true;
  860.          }
  861.          else
  862.          {
  863.             b.laffed = false;
  864.             nochance.start();
  865.          }
  866.          b.dunn = true;
  867.       }
  868.       else
  869.       {
  870.          b.pattern = 4;
  871.       }
  872.       b.aicv = 0;
  873.       b._xscale = 100;
  874.    }
  875.    if(b.ploy == 0)
  876.    {
  877.       b.ploy = 1;
  878.    }
  879. }
  880. function switchBoss()
  881. {
  882.    flashIt();
  883.    bgmusic.stop();
  884.    if(!this.mute)
  885.    {
  886.       bgmusic2.start(0,999);
  887.    }
  888.    this.bgmuse2 = true;
  889.    kl = wrap.attachMovie("bigsplode","sploder",569648999);
  890.    kl._x = b._x;
  891.    kl._y = b._y;
  892.    b.nohit = true;
  893.    b.guts.gotoAndStop("skull");
  894.    b.skullit = true;
  895. }
  896. function skullChange()
  897. {
  898.    b.guts.gotoAndStop("skull");
  899. }
  900. function makeFireballzRight()
  901. {
  902.    fireballsound.start();
  903.    fireballsound.start();
  904.    flashIt();
  905.    f = wrap.attachMovie("fireball","mball" + starcv,starcv);
  906.    starcv++;
  907.    f._x = b._x + 20;
  908.    f._y = b._y + 45;
  909.    f.onEnterFrame = function()
  910.    {
  911.       if(!_root.pausy)
  912.       {
  913.          this._x += 10;
  914.          checkBossHit(this.box,false,true);
  915.          if(this._x > 2800)
  916.          {
  917.             this.unloadMovie();
  918.             this.removeMovieClip();
  919.             delete this.onEnterFrame;
  920.          }
  921.          if(this._y > 800)
  922.          {
  923.             this.unloadMovie();
  924.             this.removeMovieClip();
  925.             delete this.onEnterFrame;
  926.          }
  927.          if(this._y < -300)
  928.          {
  929.             this.unloadMovie();
  930.             this.removeMovieClip();
  931.             delete this.onEnterFrame;
  932.          }
  933.       }
  934.    };
  935.    f = wrap.attachMovie("fireball","mball" + starcv,starcv);
  936.    starcv++;
  937.    f._x = b._x - 20;
  938.    f._y = b._y + 45;
  939.    f._xscale = -100;
  940.    f.onEnterFrame = function()
  941.    {
  942.       if(!_root.pausy)
  943.       {
  944.          this._x -= 10;
  945.          checkBossHit(this.box,false,true);
  946.          if(this._x > 2800)
  947.          {
  948.             this.unloadMovie();
  949.             this.removeMovieClip();
  950.             delete this.onEnterFrame;
  951.          }
  952.          if(this._y > 800)
  953.          {
  954.             this.unloadMovie();
  955.             this.removeMovieClip();
  956.             delete this.onEnterFrame;
  957.          }
  958.          if(this._y < -300)
  959.          {
  960.             this.unloadMovie();
  961.             this.removeMovieClip();
  962.             delete this.onEnterFrame;
  963.          }
  964.       }
  965.    };
  966.    f = wrap.attachMovie("fireball","fball" + starcv,starcv);
  967.    starcv++;
  968.    f._x = b._x + 20;
  969.    f._y = b._y + 25;
  970.    f._rotation = -45;
  971.    f.onEnterFrame = function()
  972.    {
  973.       if(!_root.pausy)
  974.       {
  975.          checkBossHit(this.box,false,true);
  976.          this._x += 10;
  977.          this._y -= 10;
  978.          if(this._x > 2800 || this._x < 0)
  979.          {
  980.             this.unloadMovie();
  981.             this.removeMovieClip();
  982.             delete this.onEnterFrame;
  983.          }
  984.          if(this._y > 800)
  985.          {
  986.             this.unloadMovie();
  987.             this.removeMovieClip();
  988.             delete this.onEnterFrame;
  989.          }
  990.          if(this._y < -300)
  991.          {
  992.             this.unloadMovie();
  993.             this.removeMovieClip();
  994.             delete this.onEnterFrame;
  995.          }
  996.       }
  997.    };
  998.    f = wrap.attachMovie("fireball","fball" + starcv,starcv);
  999.    starcv++;
  1000.    f._x = b._x - 20;
  1001.    f._y = b._y + 25;
  1002.    f._rotation = 45;
  1003.    f._xscale = -100;
  1004.    f.onEnterFrame = function()
  1005.    {
  1006.       if(!_root.pausy)
  1007.       {
  1008.          checkBossHit(this.box,false,true);
  1009.          this._x -= 10;
  1010.          this._y -= 10;
  1011.          if(this._x > 2800 || this._x < 0)
  1012.          {
  1013.             this.unloadMovie();
  1014.             this.removeMovieClip();
  1015.             delete this.onEnterFrame;
  1016.          }
  1017.          if(this._y > 800)
  1018.          {
  1019.             this.unloadMovie();
  1020.             this.removeMovieClip();
  1021.             delete this.onEnterFrame;
  1022.          }
  1023.          if(this._y < -300)
  1024.          {
  1025.             this.unloadMovie();
  1026.             this.removeMovieClip();
  1027.             delete this.onEnterFrame;
  1028.          }
  1029.       }
  1030.    };
  1031.    f = wrap.attachMovie("fireball","fball" + starcv,starcv);
  1032.    starcv++;
  1033.    f._x = b._x + 20;
  1034.    f._y = b._y + 65;
  1035.    f._rotation = 45;
  1036.    f.onEnterFrame = function()
  1037.    {
  1038.       if(!_root.pausy)
  1039.       {
  1040.          checkBossHit(this.box,false,true);
  1041.          this._x += 10;
  1042.          this._y += 10;
  1043.          if(this._x > 2800 || this._x < 0)
  1044.          {
  1045.             this.unloadMovie();
  1046.             this.removeMovieClip();
  1047.             delete this.onEnterFrame;
  1048.          }
  1049.          if(this._y > 800)
  1050.          {
  1051.             this.unloadMovie();
  1052.             this.removeMovieClip();
  1053.             delete this.onEnterFrame;
  1054.          }
  1055.          if(this._y < -300)
  1056.          {
  1057.             this.unloadMovie();
  1058.             this.removeMovieClip();
  1059.             delete this.onEnterFrame;
  1060.          }
  1061.       }
  1062.    };
  1063.    f = wrap.attachMovie("fireball","fball" + starcv,starcv);
  1064.    starcv++;
  1065.    f._x = b._x - 20;
  1066.    f._y = b._y + 65;
  1067.    f._rotation = -45;
  1068.    f._xscale = -100;
  1069.    f.onEnterFrame = function()
  1070.    {
  1071.       if(!_root.pausy)
  1072.       {
  1073.          checkBossHit(this.box,false,true);
  1074.          this._x -= 10;
  1075.          this._y += 10;
  1076.          if(this._x > 2800 || this._x < 0)
  1077.          {
  1078.             this.unloadMovie();
  1079.             this.removeMovieClip();
  1080.             delete this.onEnterFrame;
  1081.          }
  1082.          if(this._y > 800)
  1083.          {
  1084.             this.unloadMovie();
  1085.             this.removeMovieClip();
  1086.             delete this.onEnterFrame;
  1087.          }
  1088.          if(this._y < -300)
  1089.          {
  1090.             this.unloadMovie();
  1091.             this.removeMovieClip();
  1092.             delete this.onEnterFrame;
  1093.          }
  1094.       }
  1095.    };
  1096.    f = wrap.attachMovie("fireball","fball" + starcv,starcv);
  1097.    starcv++;
  1098.    f._x = b._x;
  1099.    f._y = b._y + 65;
  1100.    f._rotation = 90;
  1101.    f._xscale = 100;
  1102.    f.onEnterFrame = function()
  1103.    {
  1104.       if(!_root.pausy)
  1105.       {
  1106.          checkBossHit(this.box,false,true);
  1107.          this._y += 10;
  1108.          if(this._y > 800)
  1109.          {
  1110.             this.unloadMovie();
  1111.             this.removeMovieClip();
  1112.             delete this.onEnterFrame;
  1113.          }
  1114.          if(this._y < -300)
  1115.          {
  1116.             this.unloadMovie();
  1117.             this.removeMovieClip();
  1118.             delete this.onEnterFrame;
  1119.          }
  1120.       }
  1121.    };
  1122. }
  1123. function winIt()
  1124. {
  1125.    if(!d.jumping)
  1126.    {
  1127.       d.guts.gotoAndStop("rest");
  1128.    }
  1129.    go = this.attachMovie("winscreen","winner",998799);
  1130.    go.aup = false;
  1131.    pausy = true;
  1132.    won = true;
  1133. }
  1134. function winPresses()
  1135. {
  1136.    go = this.winner;
  1137.    go.onEnterFrame = function()
  1138.    {
  1139.       if(!Key.isDown(65))
  1140.       {
  1141.          this.aup = true;
  1142.       }
  1143.       if(Key.isDown(65) && this.aup)
  1144.       {
  1145.          this.unloadMovie();
  1146.          this.removeMovieClip();
  1147.          delete this.onEnterFrame;
  1148.          delete this.onPress;
  1149.          _root.gotoAndStop(2);
  1150.       }
  1151.    };
  1152. }
  1153. function ai()
  1154. {
  1155.    if(!b.finaldead)
  1156.    {
  1157.       if(wrap.flasher._currentframe != 1 && !pausy)
  1158.       {
  1159.          wrap.flasher.play();
  1160.       }
  1161.       if(b.life <= 0 && !b.predead)
  1162.       {
  1163.          b.home = b._x;
  1164.          b.predead = true;
  1165.          b.inv = true;
  1166.          b.tranny = true;
  1167.          b.guts.gotoAndStop("die0");
  1168.       }
  1169.       if(b.life < 0 && b.predead && !b.tranny)
  1170.       {
  1171.          stopAllSounds();
  1172.          b.guts.gotoAndStop("die1");
  1173.          death.start();
  1174.          b.finaldead = true;
  1175.       }
  1176.       if(b.predead && b.inv && !b.skullit)
  1177.       {
  1178.          if(b.rig)
  1179.          {
  1180.             b.rig = false;
  1181.             b._x = b.home + 5;
  1182.          }
  1183.          else
  1184.          {
  1185.             b.rig = true;
  1186.             b._x = b.home - 5;
  1187.          }
  1188.       }
  1189.       if(b.skullit)
  1190.       {
  1191.          if(b.life < 60)
  1192.          {
  1193.             b.maxlife = 60;
  1194.             b.life += 2;
  1195.          }
  1196.          else if(!b.boogah)
  1197.          {
  1198.             b.tranny = false;
  1199.             b.inv = false;
  1200.             b.endbattle = true;
  1201.             b.boogah = true;
  1202.             b.skullit = false;
  1203.             b.aicv = 0;
  1204.          }
  1205.       }
  1206.       if(b.endbattle)
  1207.       {
  1208.          b.chasex = false;
  1209.          b.chasey = false;
  1210.          if(!b.goright && !b.gocenter || b.goleft)
  1211.          {
  1212.             goalx = 190;
  1213.             goaly = 200;
  1214.             b.goleft = true;
  1215.          }
  1216.          if(b.goright)
  1217.          {
  1218.             goalx = 1220;
  1219.             goaly = 200;
  1220.          }
  1221.          if(b.gocenter)
  1222.          {
  1223.             goalx = 600;
  1224.             goaly = 100;
  1225.          }
  1226.          distx = goalx - b._x;
  1227.          disty = goaly - b._y;
  1228.          b.xvel += distx / 105;
  1229.          b.yvel += disty / 105;
  1230.          tax = Math.abs(distx);
  1231.          tay = Math.abs(disty);
  1232.          if(tax < 70 && tay < 70)
  1233.          {
  1234.             b.aicv = b.aicv + 1;
  1235.             if(b.aicv > 15 && !b.finaldead)
  1236.             {
  1237.                b.guts.gotoAndStop("fireballz");
  1238.             }
  1239.             if(b.aicv >= 30 && !b.finaldead)
  1240.             {
  1241.                b.endbattle = false;
  1242.                b.waiting = true;
  1243.                b.aicv = 0;
  1244.                if(b._x < 400)
  1245.                {
  1246.                   makeFireballzRight();
  1247.                }
  1248.                if(b._x > 400 && b._x < 1000)
  1249.                {
  1250.                   makeFireballzRight();
  1251.                }
  1252.                if(b._x > 1000)
  1253.                {
  1254.                   makeFireballzRight();
  1255.                }
  1256.             }
  1257.          }
  1258.       }
  1259.       if(b.waiting)
  1260.       {
  1261.          b.aicv = b.aicv + 1;
  1262.          if(b.aicv > 50)
  1263.          {
  1264.             b.waiting = false;
  1265.             b.endbattle = true;
  1266.             b.inv = false;
  1267.             if(b.goright)
  1268.             {
  1269.                b.goleft = false;
  1270.                b.gocenter = true;
  1271.                b.goright = false;
  1272.                return undefined;
  1273.             }
  1274.             if(b.goleft)
  1275.             {
  1276.                b.goleft = false;
  1277.                b.gocenter = false;
  1278.                b.goright = true;
  1279.                return undefined;
  1280.             }
  1281.             if(b.gocenter)
  1282.             {
  1283.                b.goleft = true;
  1284.                b.gocenter = false;
  1285.                b.goright = false;
  1286.                return undefined;
  1287.             }
  1288.          }
  1289.       }
  1290.       if(!b.predead)
  1291.       {
  1292.          if(b.pattern == 6)
  1293.          {
  1294.             b.aicv = b.aicv + 1;
  1295.             if(b.aicv >= 70)
  1296.             {
  1297.                b.doneit = false;
  1298.                b.dunn = false;
  1299.                b.pattern = 0;
  1300.                b.aicv = 0;
  1301.             }
  1302.          }
  1303.          if(b.pattern == 5)
  1304.          {
  1305.             h = wrap.attachMovie("hairball0","ball1",889987666);
  1306.             h.box.heavy = true;
  1307.             h._x = 200 + (random(200) - 100);
  1308.             h._y = -100;
  1309.             h.yvel = 0;
  1310.             h.hitit = false;
  1311.             h.onEnterFrame = function()
  1312.             {
  1313.                if(!_root.pausy)
  1314.                {
  1315.                   if(!this.gothim)
  1316.                   {
  1317.                      _root.checkBossHit(this.box);
  1318.                   }
  1319.                   if(this.box.hitTest(d.guts.box))
  1320.                   {
  1321.                      this.gothim = true;
  1322.                   }
  1323.                   this._y += this.yvel;
  1324.                   this.yvel += grav * 0.7;
  1325.                   this.virtx = this._x + wrap._x;
  1326.                   this.virty = this._y + wrap._y;
  1327.                   if(!this.hitit)
  1328.                   {
  1329.                      while(wrap.bg.hitTest(this.virtx,this.virty,true))
  1330.                      {
  1331.                         this._y -= 1;
  1332.                         this.virty -= 1;
  1333.                         this.yvel = -10;
  1334.                         this.hitit = true;
  1335.                      }
  1336.                      if(this.hitit)
  1337.                      {
  1338.                         groundhit.start();
  1339.                      }
  1340.                   }
  1341.                   if(this.virty > 800)
  1342.                   {
  1343.                      this.unloadMovie();
  1344.                      this.removeMovieClip();
  1345.                      delete this.onEnterFrame;
  1346.                   }
  1347.                }
  1348.             };
  1349.             h = wrap.attachMovie("hairball0","ball0",889987665);
  1350.             h.box.heavy = true;
  1351.             h._x = 400 + (random(200) - 100);
  1352.             h._y = -150;
  1353.             h.yvel = 0;
  1354.             h.hitit = false;
  1355.             h.onEnterFrame = function()
  1356.             {
  1357.                if(!_root.pausy)
  1358.                {
  1359.                   if(!this.gothim)
  1360.                   {
  1361.                      _root.checkBossHit(this.box);
  1362.                   }
  1363.                   if(this.box.hitTest(d.guts.box))
  1364.                   {
  1365.                      this.gothim = true;
  1366.                   }
  1367.                   this._y += this.yvel;
  1368.                   this.yvel += grav * 0.7;
  1369.                   this.virtx = this._x + wrap._x;
  1370.                   this.virty = this._y + wrap._y;
  1371.                   if(!this.hitit)
  1372.                   {
  1373.                      while(wrap.bg.hitTest(this.virtx,this.virty,true))
  1374.                      {
  1375.                         this._y -= 1;
  1376.                         this.virty -= 1;
  1377.                         this.yvel = -10;
  1378.                         this.hitit = true;
  1379.                      }
  1380.                      if(this.hitit)
  1381.                      {
  1382.                         groundhit.start();
  1383.                      }
  1384.                   }
  1385.                   if(this.virty > 800)
  1386.                   {
  1387.                      this.unloadMovie();
  1388.                      this.removeMovieClip();
  1389.                      delete this.onEnterFrame;
  1390.                   }
  1391.                }
  1392.             };
  1393.             h = wrap.attachMovie("hairball0","ball3",889987667);
  1394.             h.box.heavy = true;
  1395.             h._x = 650 + (random(200) - 100);
  1396.             h._y = -190;
  1397.             h.yvel = 0;
  1398.             h.hitit = false;
  1399.             h.onEnterFrame = function()
  1400.             {
  1401.                if(!_root.pausy)
  1402.                {
  1403.                   if(!this.gothim)
  1404.                   {
  1405.                      _root.checkBossHit(this.box);
  1406.                   }
  1407.                   if(this.box.hitTest(d.guts.box))
  1408.                   {
  1409.                      this.gothim = true;
  1410.                   }
  1411.                   this._y += this.yvel;
  1412.                   this.yvel += grav * 0.7;
  1413.                   this.virtx = this._x + wrap._x;
  1414.                   this.virty = this._y + wrap._y;
  1415.                   if(!this.hitit)
  1416.                   {
  1417.                      while(wrap.bg.hitTest(this.virtx,this.virty,true))
  1418.                      {
  1419.                         this._y -= 1;
  1420.                         this.virty -= 1;
  1421.                         this.yvel = -10;
  1422.                         this.hitit = true;
  1423.                      }
  1424.                      if(this.hitit)
  1425.                      {
  1426.                         groundhit.start();
  1427.                      }
  1428.                   }
  1429.                   if(this.virty > 800)
  1430.                   {
  1431.                      this.unloadMovie();
  1432.                      this.removeMovieClip();
  1433.                      delete this.onEnterFrame;
  1434.                   }
  1435.                }
  1436.             };
  1437.             h = wrap.attachMovie("hairball0","ball4",889987669);
  1438.             h.box.heavy = true;
  1439.             h._x = 1000 + (random(200) - 100);
  1440.             h._y = -100;
  1441.             h.yvel = 0;
  1442.             h.hitit = false;
  1443.             h.onEnterFrame = function()
  1444.             {
  1445.                if(!_root.pausy)
  1446.                {
  1447.                   if(!this.gothim)
  1448.                   {
  1449.                      _root.checkBossHit(this.box);
  1450.                   }
  1451.                   if(this.box.hitTest(d.guts.box))
  1452.                   {
  1453.                      this.gothim = true;
  1454.                   }
  1455.                   this._y += this.yvel;
  1456.                   this.yvel += grav * 0.7;
  1457.                   this.virtx = this._x + wrap._x;
  1458.                   this.virty = this._y + wrap._y;
  1459.                   if(!this.hitit)
  1460.                   {
  1461.                      while(wrap.bg.hitTest(this.virtx,this.virty,true))
  1462.                      {
  1463.                         this._y -= 1;
  1464.                         this.virty -= 1;
  1465.                         this.yvel = -10;
  1466.                         this.hitit = true;
  1467.                      }
  1468.                      if(this.hitit)
  1469.                      {
  1470.                         groundhit.start();
  1471.                      }
  1472.                   }
  1473.                   if(this.virty > 800)
  1474.                   {
  1475.                      this.unloadMovie();
  1476.                      this.removeMovieClip();
  1477.                      delete this.onEnterFrame;
  1478.                   }
  1479.                }
  1480.             };
  1481.             h = wrap.attachMovie("hairball0","ball5",889987670);
  1482.             h.box.heavy = true;
  1483.             h._x = 1290 + (random(200) - 100);
  1484.             h._y = -150;
  1485.             h.yvel = 0;
  1486.             h.hitit = false;
  1487.             h.onEnterFrame = function()
  1488.             {
  1489.                if(!_root.pausy)
  1490.                {
  1491.                   if(!this.gothim)
  1492.                   {
  1493.                      _root.checkBossHit(this.box);
  1494.                   }
  1495.                   if(this.box.hitTest(d.guts.box))
  1496.                   {
  1497.                      this.gothim = true;
  1498.                   }
  1499.                   this._y += this.yvel;
  1500.                   this.yvel += grav * 0.7;
  1501.                   this.virtx = this._x + wrap._x;
  1502.                   this.virty = this._y + wrap._y;
  1503.                   if(!this.hitit)
  1504.                   {
  1505.                      while(wrap.bg.hitTest(this.virtx,this.virty,true))
  1506.                      {
  1507.                         this._y -= 1;
  1508.                         this.virty -= 1;
  1509.                         this.yvel = -10;
  1510.                         this.hitit = true;
  1511.                      }
  1512.                      if(this.hitit)
  1513.                      {
  1514.                         groundhit.start();
  1515.                      }
  1516.                   }
  1517.                   if(this.virty > 800)
  1518.                   {
  1519.                      this.unloadMovie();
  1520.                      this.removeMovieClip();
  1521.                      delete this.onEnterFrame;
  1522.                   }
  1523.                }
  1524.             };
  1525.             b.aicv = 0;
  1526.             b.pattern = 6;
  1527.          }
  1528.          if(b.pattern == 4)
  1529.          {
  1530.             b.above = true;
  1531.             goalx = 660;
  1532.             goaly = -300;
  1533.             distx = goalx - b._x;
  1534.             disty = goaly - b._y;
  1535.             b.xvel += distx / 75;
  1536.             b.yvel += disty / 295;
  1537.             tay = Math.abs(disty);
  1538.             if(tay < 80)
  1539.             {
  1540.                b.pattern = 5;
  1541.                b.aicv = 0;
  1542.             }
  1543.          }
  1544.          if(b.pattern == 1)
  1545.          {
  1546.             b.chasex = false;
  1547.             b.chasey = false;
  1548.             if(b.side == 0)
  1549.             {
  1550.                if(b.ploy == 0)
  1551.                {
  1552.                   goalx = 150;
  1553.                   goaly = 150;
  1554.                }
  1555.                if(b.ploy == 1)
  1556.                {
  1557.                   goalx = 150;
  1558.                   goaly = 400;
  1559.                }
  1560.             }
  1561.             if(b.side == 1)
  1562.             {
  1563.                if(b.ploy == 0)
  1564.                {
  1565.                   goalx = 1300;
  1566.                   goaly = 150;
  1567.                }
  1568.                if(b.ploy == 1)
  1569.                {
  1570.                   goalx = 1300;
  1571.                   goaly = 400;
  1572.                }
  1573.             }
  1574.             if(!b.attacking)
  1575.             {
  1576.                distx = goalx - b._x;
  1577.                disty = goaly - b._y;
  1578.                b.xvel += distx / 95;
  1579.                b.yvel += disty / 95;
  1580.                tax = Math.abs(distx);
  1581.                tay = Math.abs(disty);
  1582.                if(tax < 90 && tay < 90)
  1583.                {
  1584.                   b.attacking = true;
  1585.                   b.guts.gotoAndStop("attack2");
  1586.                   if(b.side == 1)
  1587.                   {
  1588.                      b._xscale = -100;
  1589.                   }
  1590.                }
  1591.             }
  1592.          }
  1593.          if(b.pattern == 0 || b.pattern == 2 || b.pattern == 3)
  1594.          {
  1595.             b.aicv = b.aicv + 1;
  1596.             if(b.aicv >= 230)
  1597.             {
  1598.                b.aicv = 0;
  1599.                b.chasex = false;
  1600.                b.chasey = false;
  1601.                b.ploy = 0;
  1602.                if(b.pattern == 0)
  1603.                {
  1604.                   b.side = 0;
  1605.                }
  1606.                else if(b.side == 0)
  1607.                {
  1608.                   b.side = 1;
  1609.                }
  1610.                else
  1611.                {
  1612.                   b.side = 0;
  1613.                }
  1614.                b.pattern = 1;
  1615.             }
  1616.             b.distx = d._x - b._x;
  1617.             b.disty = d._y - (b._y + 150);
  1618.             b.dist = Math.sqrt(b.distx * b.distx + b.disty * b.disty);
  1619.             if(!d.hurt)
  1620.             {
  1621.                if(!b.attacking)
  1622.                {
  1623.                   if(b.dist > 220)
  1624.                   {
  1625.                      b.chasex = true;
  1626.                      b.chasey = true;
  1627.                   }
  1628.                   else
  1629.                   {
  1630.                      b.chasex = false;
  1631.                      b.deccount += 1;
  1632.                      if(b.deccount >= 50)
  1633.                      {
  1634.                         b.deccount = 0;
  1635.                         b.attacking = true;
  1636.                         var _loc5_ = Math.abs(b.distx);
  1637.                         if(_loc5_ > 120 || b.disty > 70)
  1638.                         {
  1639.                            b.guts.gotoAndStop("attack0");
  1640.                         }
  1641.                         else
  1642.                         {
  1643.                            b.guts.gotoAndStop("attack1");
  1644.                            b.overr = true;
  1645.                         }
  1646.                      }
  1647.                   }
  1648.                }
  1649.                if(b.overr)
  1650.                {
  1651.                   b.xvel += b.distx / 72;
  1652.                }
  1653.             }
  1654.             else
  1655.             {
  1656.                var _loc4_ = 650 - b._x;
  1657.                var _loc3_ = 80 - b._y;
  1658.                b.xvel += _loc4_ / 50;
  1659.                b.yvel += _loc3_ / 50;
  1660.             }
  1661.          }
  1662.       }
  1663.    }
  1664. }
  1665. function loseLife()
  1666. {
  1667.    this.lives = this.lives - 1;
  1668.    if(this.lives > 0)
  1669.    {
  1670.       d.carrot = false;
  1671.       gs = this.wrap.attachMovie("gstone","gstone" + stones.length + 1,99555 + stones.length + 1);
  1672.       gs._x = d._x;
  1673.       gs._y = d._y;
  1674.       gs._xscale = d._xscale;
  1675.       gs.gotoAndStop(37);
  1676.       gs.xvel = 0;
  1677.       gs.yvel = 0;
  1678.       stones.push(gs);
  1679.       d.guts.gotoAndStop("rest");
  1680.       d.hurt = false;
  1681.       d.dead = false;
  1682.       d.stoned = false;
  1683.       d.xvel = 0;
  1684.       d.yvel = 0;
  1685.       d._x = 220;
  1686.       d._y = 120;
  1687.       d._xscale = 100;
  1688.       d.blinking = true;
  1689.       d.life = 100;
  1690.       d.powa = 0;
  1691.       d.attacking = false;
  1692.       d.jumping = false;
  1693.       d.jlo = false;
  1694.       d.charge = 0;
  1695.       d.blinkcv = 0;
  1696.    }
  1697.    else
  1698.    {
  1699.       stones.push(d);
  1700.       stopAllSounds();
  1701.       if(!this.grover)
  1702.       {
  1703.          nothing.start();
  1704.          this.grover = true;
  1705.       }
  1706.       go = this.attachMovie("gameover","gameover",99);
  1707.       go.aup = false;
  1708.    }
  1709. }
  1710. function showOver()
  1711. {
  1712.    pausy = true;
  1713.    go = this.gameover;
  1714.    go.onPress = function()
  1715.    {
  1716.       this.unloadMovie();
  1717.       this.removeMovieClip();
  1718.       delete this.onEnterFrame;
  1719.       delete this.onPress;
  1720.       _root.gotoAndStop(2);
  1721.    };
  1722.    go.onEnterFrame = function()
  1723.    {
  1724.       if(!Key.isDown(65))
  1725.       {
  1726.          this.aup = true;
  1727.       }
  1728.       if(Key.isDown(65) && this.aup)
  1729.       {
  1730.          this.unloadMovie();
  1731.          this.removeMovieClip();
  1732.          delete this.onEnterFrame;
  1733.          delete this.onPress;
  1734.          _root.gotoAndStop(2);
  1735.       }
  1736.    };
  1737. }
  1738. function gameOver()
  1739. {
  1740.    trace("GAME OVER");
  1741. }
  1742. function aifuncs()
  1743. {
  1744.    b._y += b.yvel;
  1745.    b.yvel *= 0.8;
  1746.    b.xvel *= 0.8;
  1747.    if(b.expirecv > 0)
  1748.    {
  1749.       b.expirecv -= 1;
  1750.    }
  1751.    var _loc3_ = b.guts.e0;
  1752.    var _loc2_ = b.guts.e1;
  1753.    if(b._xscale < 0)
  1754.    {
  1755.       mult = -1;
  1756.    }
  1757.    else
  1758.    {
  1759.       mult = 1;
  1760.    }
  1761.    _loc3_.distx = d._x - (b._x + b.guts._x + _loc3_._x);
  1762.    _loc3_.disty = d._y - (b._y + b.guts._y + _loc3_._y);
  1763.    _loc3_.rads = Math.atan2(_loc3_.disty,_loc3_.distx * mult);
  1764.    _loc3_._rotation = _loc3_.rads * 180 / 3.141592653589793;
  1765.    _loc2_.distx = d._x - (b._x + b.guts._x + _loc2_._x);
  1766.    _loc2_.disty = d._y - (b._y + b.guts._y + _loc2_._y);
  1767.    _loc2_.rads = Math.atan2(_loc2_.disty,_loc2_.distx * mult);
  1768.    _loc2_._rotation = _loc2_.rads * 180 / 3.141592653589793;
  1769.    if(b.chasex)
  1770.    {
  1771.       var _loc7_ = d._x - b._x;
  1772.       b.xvel += _loc7_ / 155;
  1773.    }
  1774.    var _loc5_ = b._x + b.xvel;
  1775.    if(b.chasey)
  1776.    {
  1777.       var _loc6_ = d._y - (b._y + 150);
  1778.       b.yvel += _loc6_ / 155;
  1779.    }
  1780.    if(b._y < 100 && !b.above)
  1781.    {
  1782.       b._y = 100;
  1783.    }
  1784.    var _loc4_ = _loc5_ - b._x;
  1785.    b._x = _loc5_;
  1786.    i = 0;
  1787.    while(i < stones.length)
  1788.    {
  1789.       var _loc1_ = stones[i];
  1790.       if(p.hitTest(_loc1_))
  1791.       {
  1792.          _loc1_._x += _loc4_;
  1793.       }
  1794.       i++;
  1795.    }
  1796.    if(p.hitTest(d))
  1797.    {
  1798.       d._x += _loc4_;
  1799.    }
  1800.    p._x = b._x - 320;
  1801.    p._y = b._y - 20;
  1802. }
  1803. function stonePhys()
  1804. {
  1805.    i = 0;
  1806.    while(i < stones.length)
  1807.    {
  1808.       var _loc1_ = stones[i];
  1809.       _loc1_.virtx = wrap._x + _loc1_._x;
  1810.       _loc1_.virty = wrap._y + _loc1_._y;
  1811.       _loc1_._y += _loc1_.yvel;
  1812.       _loc1_._x += _loc1_.xvel;
  1813.       var _loc2_ = Math.abs(_loc1_.xvel);
  1814.       if(_loc2_ < 1)
  1815.       {
  1816.          _loc1_.xvel = 0;
  1817.       }
  1818.       _loc1_.xvel *= 0.8;
  1819.       _loc1_.yvel += grav;
  1820.       _loc1_.virty += _loc1_.yvel;
  1821.       _loc1_.topp = _loc1_.virty - _loc1_._height;
  1822.       while(wrap.bg.hitTest(_loc1_.virtx,_loc1_.topp,true))
  1823.       {
  1824.          _loc1_._y += 1;
  1825.          _loc1_.virty += 1;
  1826.          _loc1_.topp += 1;
  1827.          _loc1_.yvel = 5;
  1828.       }
  1829.       while(wrap.bg.hitTest(_loc1_.virtx,_loc1_.virty,true))
  1830.       {
  1831.          _loc1_._y -= 1;
  1832.          _loc1_.virty -= 1;
  1833.          _loc1_.yvel = 0;
  1834.          _loc1_.inair = false;
  1835.          _loc1_.juggle = 0;
  1836.          _loc1_.hurt = false;
  1837.       }
  1838.       i++;
  1839.    }
  1840. }
  1841. JUMPBUT = 38;
  1842. this.mute = false;
  1843. this.bgmuse2 = false;
  1844. this.pdiddy._visible = false;
  1845. this.pausy = false;
  1846. this.summoning = false;
  1847. this.grover = false;
  1848. wrap.bg.plat.unloadMovie();
  1849. wrap.bg.plat.removeMovieClip();
  1850. slowmult = 1;
  1851. this.lives = 3;
  1852. grav = 2;
  1853. fric = 0.75;
  1854. this.ncv = 0;
  1855. screenw = wrap.bg._width - 50;
  1856. this.score = 0;
  1857. this.lev = 0;
  1858. this.levreqs = new Array(100,250,650,950);
  1859. this.nex = levreqs[0];
  1860. this.starcv = 0;
  1861. hud.holder.guts.attachMovie("levicon" + this.lev,"guts",0);
  1862. stones = new Array();
  1863. i = 0;
  1864. while(i < 4)
  1865. {
  1866.    gs = this.wrap.attachMovie("gstone","gstone" + i,99555 + i);
  1867.    gs._x = random(1250) + 70;
  1868.    while(!wrap.bg.hitTest(gs._x,gs._y,true) || gs.hitTest(wrap.bg.plat))
  1869.    {
  1870.       gs._y += 1;
  1871.    }
  1872.    var sc = random(2);
  1873.    if(sc == 0)
  1874.    {
  1875.       gs._xscale = 100;
  1876.    }
  1877.    else
  1878.    {
  1879.       gs._xscale = -100;
  1880.    }
  1881.    gs.gotoAndStop(37);
  1882.    gs.xvel = 0;
  1883.    gs.yvel = 0;
  1884.    stones.push(gs);
  1885.    i++;
  1886. }
  1887. d = wrap.dude;
  1888. d.invcv = 0;
  1889. d.blinkcv = 0;
  1890. d.blinking = true;
  1891. d.anum = 0;
  1892. d.regen = 0.1;
  1893. d.charge = 0;
  1894. d.chargelim = 20;
  1895. dudes = new Array(3,1,2,0,4);
  1896. d.attachMovie("k" + dudes[this.lev],"guts",0);
  1897. d.id = dudes[this.lev];
  1898. d.speed = 4;
  1899. d.life = 100;
  1900. d.maxlife = 100;
  1901. d.powa = 0;
  1902. d.xvel = 0;
  1903. d.yvel = 0;
  1904. d.hurtcv = 0;
  1905. b = wrap.bad;
  1906. b.life = 130;
  1907. b.maxlife = b.life;
  1908. b.maxexpire = 20;
  1909. b.xvel = 0;
  1910. b.yvel = 0;
  1911. b.deccount = 0;
  1912. b.pattern = 0;
  1913. b.aicv = 0;
  1914. b.inv = false;
  1915. b.finaldead = false;
  1916. b.predead = false;
  1917. b.pattern = 0;
  1918. b.dunn = false;
  1919. b.aicv = 0;
  1920. b.skullit = false;
  1921. b.home = undefined;
  1922. b.boogah = false;
  1923. b.endbattle = false;
  1924. b.chasex = false;
  1925. b.chasey = false;
  1926. b.gocenter = false;
  1927. b.goleft = true;
  1928. b.goright = false;
  1929. b.waiting = false;
  1930. b.above = false;
  1931. b.side = 0;
  1932. b.attacking = false;
  1933. b.overr = false;
  1934. b.nohit = false;
  1935. won = false;
  1936. p = wrap.bg.plat;
  1937. updateHUD();
  1938. eyesc = b.guts.e0._xscale;
  1939. this.onEnterFrame = function()
  1940. {
  1941.    if(!this.pausy)
  1942.    {
  1943.       ai();
  1944.       aifuncs();
  1945.       if(!d.hurt && !d.dead)
  1946.       {
  1947.          controls(d);
  1948.       }
  1949.       phys(d);
  1950.       stonePhys();
  1951.       if(!b.finaldead)
  1952.       {
  1953.          centerOn(d);
  1954.       }
  1955.       else
  1956.       {
  1957.          centerOn(b);
  1958.       }
  1959.       restrainBG();
  1960.       restrainDude(d);
  1961.    }
  1962.    if(!Key.isDown(77))
  1963.    {
  1964.       this.mib = true;
  1965.    }
  1966.    if(Key.isDown(77) && this.mib)
  1967.    {
  1968.       this.mib = false;
  1969.       if(!this.mute)
  1970.       {
  1971.          this.mute = true;
  1972.          if(this.bgmuse2)
  1973.          {
  1974.             bgmusic2.stop();
  1975.          }
  1976.          else
  1977.          {
  1978.             bgmusic.stop();
  1979.          }
  1980.       }
  1981.       else
  1982.       {
  1983.          this.mute = false;
  1984.          if(this.bgmuse2)
  1985.          {
  1986.             bgmusic2.start(0,999);
  1987.          }
  1988.          else
  1989.          {
  1990.             bgmusic.start(0,999);
  1991.          }
  1992.       }
  1993.    }
  1994.    if(!Key.isDown(80))
  1995.    {
  1996.       this.pawup = true;
  1997.    }
  1998.    if(Key.isDown(80) && this.pawup && !d.dead && !won && this.gameover._x == undefined)
  1999.    {
  2000.       if(this.paws)
  2001.       {
  2002.          this.pdiddy._visible = false;
  2003.          this.paws = false;
  2004.          this.pausy = false;
  2005.          pausesound.start();
  2006.          b.guts.innards.play();
  2007.       }
  2008.       else if(!this.pausy)
  2009.       {
  2010.          pausesound.start();
  2011.          this.pdiddy._visible = true;
  2012.          this.paws = true;
  2013.          this.pausy = true;
  2014.          b.guts.innards.stop();
  2015.          wrap.flasher.stop();
  2016.          d.attacking = false;
  2017.          if(!d.jumping)
  2018.          {
  2019.             d.guts.gotoAndStop("rest");
  2020.          }
  2021.       }
  2022.       this.pawup = false;
  2023.    }
  2024.    if(!Key.isDown(82))
  2025.    {
  2026.       this.rup = true;
  2027.    }
  2028.    if(Key.isDown(82) && this.rup && !won && this.gameover._x == undefined)
  2029.    {
  2030.       lup.unloadMovie();
  2031.       lup.removeMovieClip();
  2032.       _root.gotoAndStop(2);
  2033.    }
  2034. };
  2035.