home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / bossbash.swf / scripts / DefineSprite_261_badzel / frame_1 / DoAction.as
Encoding:
Text File  |  2007-09-28  |  5.9 KB  |  259 lines

  1. function theEnd()
  2. {
  3.    k = this._parent.attachMovie("splode","splode",this._parent.getNextHighestDepth());
  4.    k._x = this._x;
  5.    k._y = this._y;
  6.    this._parent.intransition = true;
  7.    this._parent.finalact = true;
  8.    this._parent.pausy = true;
  9.    this.unloadMovie();
  10. }
  11. function art(who)
  12. {
  13.    who.mydist = real._x - who._x;
  14.    if(who.mydist > 105 && !who.jumping && !who.blinking)
  15.    {
  16.       who.Xvel += 2;
  17.    }
  18.    if(who.mydist < -105 && !who.jumping && !who.blinking)
  19.    {
  20.       who.Xvel -= 2;
  21.    }
  22.    if(who.mydist < 40 && who.mydist > 0 && !who.jumping && !real.jumping && !who.blinking)
  23.    {
  24.       who.jumping = true;
  25.       who.Yvel = 20;
  26.       who.Xvel = -24;
  27.    }
  28.    if(who.mydist > -40 && who.mydist < 0 && !who.jumping && !real.jumping && !who.blinking)
  29.    {
  30.       who.jumping = true;
  31.       who.Yvel = 20;
  32.       who.Xvel = 24;
  33.    }
  34.    if(who.mydist > 40 && who.mydist < 105 && !who.blinking)
  35.    {
  36.       who.guts.gotoAndStop("attack");
  37.       who.attacking = true;
  38.       if(real.jumping && !who.jumping)
  39.       {
  40.          who.jumping = true;
  41.          who.Yvel = 20;
  42.          who.Xvel = real.Xvel;
  43.       }
  44.       if(real.attacking && !who.jumping)
  45.       {
  46.          var _loc3_ = random(5);
  47.          if(_loc3_ == 0)
  48.          {
  49.             who.jumping = true;
  50.             who.Yvel = 20;
  51.             who.Xvel = 10;
  52.             who.downit = true;
  53.          }
  54.       }
  55.    }
  56.    if(who.mydist < -40 && who.mydist > -105 && !who.blinking)
  57.    {
  58.       who.guts.gotoAndStop("attack");
  59.       who.attacking = true;
  60.       if(real.jumping && !who.jumping)
  61.       {
  62.          who.jumping = true;
  63.          who.Yvel = 20;
  64.       }
  65.       if(real.attacking && !who.jumping)
  66.       {
  67.          _loc3_ = random(5);
  68.          if(_loc3_ == 0)
  69.          {
  70.             who.jumping = true;
  71.             who.Yvel = 20;
  72.             who.Xvel = -10;
  73.             who.downit = true;
  74.          }
  75.       }
  76.    }
  77.    if(real._x < who._x)
  78.    {
  79.       who._xscale = -100;
  80.    }
  81.    else
  82.    {
  83.       who._xscale = 100;
  84.    }
  85.    if(who._x < 0)
  86.    {
  87.       who._x = 0;
  88.    }
  89.    if(who._x > 550)
  90.    {
  91.       who._x = 550;
  92.    }
  93.    who.absvel = Math.abs(who.Xvel);
  94.    who._x += who.Xvel;
  95.    who._y -= who.Yvel;
  96.    who.Xvel *= 0.8;
  97.    if(who.jumping)
  98.    {
  99.       if(who.zenith != true)
  100.       {
  101.          if(who.attacking != true && who.blinking != true)
  102.          {
  103.             who.guts.gotoAndStop("jumpup");
  104.          }
  105.          if(who.Yvel <= 0)
  106.          {
  107.             who.zenith = true;
  108.          }
  109.       }
  110.       else if(who.attacking != true)
  111.       {
  112.          who.guts.gotoAndStop("jumpdown");
  113.       }
  114.       who.Yvel -= who.grav;
  115.       if(who._y >= who.ground && who.zenith == true)
  116.       {
  117.          who.jumping = false;
  118.          who.Yvel = 0;
  119.          who.zenith = false;
  120.          who._y = who.ground;
  121.          if(who.attacking != true)
  122.          {
  123.             who.landing = true;
  124.          }
  125.       }
  126.       if(who.downit)
  127.       {
  128.          if(who.attacking != true)
  129.          {
  130.             who.guts.gotoAndStop("downthrust");
  131.             if(real.hitTest(this._x,this._y - 5,true) && real.blinking != true)
  132.             {
  133.                this._parent.hurt.start();
  134.                real.guts.gotoAndStop("hit");
  135.                if(real.fairied != true)
  136.                {
  137.                   real.attacking = true;
  138.                   real.blinking = true;
  139.                   real.jumping = true;
  140.                }
  141.                real.Xvel += 10 * (this._xscale / 100);
  142.                real.Yvel = 15;
  143.                if(real.shielded)
  144.                {
  145.                   real.life -= 10;
  146.                }
  147.                else
  148.                {
  149.                   real.life -= 20;
  150.                }
  151.                if(real.fairied)
  152.                {
  153.                   real.life = 0;
  154.                }
  155.                if(real.life > 0)
  156.                {
  157.                   this._parent.dash.hlth._xscale = real.life;
  158.                }
  159.                else
  160.                {
  161.                   this._parent.dash.hlth._xscale = 0;
  162.                   real.life = 0;
  163.                   this._parent.myDeath();
  164.                   this._parent.pausy = true;
  165.                   real.guts.gotoAndStop("hit");
  166.                }
  167.             }
  168.          }
  169.       }
  170.    }
  171.    if(who.landing == true && who.attacking != true)
  172.    {
  173.       who.guts.gotoAndStop("crouch");
  174.       who.landcount += 1;
  175.       if(who.landcount > 4)
  176.       {
  177.          who.landing = false;
  178.          who.landcount = 0;
  179.       }
  180.    }
  181.    if(who.absvel > 0.5)
  182.    {
  183.       if(who.jumping != true)
  184.       {
  185.          if(who.landing != true)
  186.          {
  187.             who.guts.gotoAndStop("walk");
  188.          }
  189.       }
  190.    }
  191.    else if(who.jumping != true)
  192.    {
  193.       if(who.landing != true)
  194.       {
  195.          if(!who.attacking)
  196.          {
  197.             who.guts.gotoAndStop("rest");
  198.          }
  199.       }
  200.    }
  201.    if(who.blinking && who.hp > 0)
  202.    {
  203.       who.mycv += 1;
  204.       who.guts.gotoAndStop("hit");
  205.       if(who.mycv > 30)
  206.       {
  207.          who.mycv = 0;
  208.          who.blinking = false;
  209.       }
  210.    }
  211.    if(who.hp <= 0)
  212.    {
  213.       this.dead = true;
  214.    }
  215. }
  216. real = this._parent.zel;
  217. this.ground = 330;
  218. this.grav = 2;
  219. this.Xvel = 0;
  220. this.Yvel = 0;
  221. this.landcount = 0;
  222. this.speed = 4;
  223. this.r = true;
  224. this.t = true;
  225. this.shotcounter = 0;
  226. this.shotfreq = 12;
  227. this.fbcount = 500;
  228. this.hp = 8;
  229. this.mycv = 0;
  230. this.finalcv = 0;
  231. this.newb = true;
  232. this.Yvel = 25;
  233. this.Xvel = 25;
  234. this.zenith = false;
  235. this.vuln = true;
  236. this.onEnterFrame = function()
  237. {
  238.    if(!this._parent.pausy)
  239.    {
  240.       art(this);
  241.       if(this.dead)
  242.       {
  243.          this.guts.gotoAndStop("hit");
  244.          this.blinking = true;
  245.          finalcv += 1;
  246.          if(finalcv > 50)
  247.          {
  248.             theEnd();
  249.             delete this.onEnterFrame;
  250.          }
  251.       }
  252.    }
  253.    else
  254.    {
  255.       this.attacking = false;
  256.       this.guts.gotoAndStop("rest");
  257.    }
  258. };
  259.