home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / batman_cobble.swf / scripts / frame_16 / DoAction_14.as < prev    next >
Encoding:
Text File  |  2006-06-13  |  12.3 KB  |  396 lines

  1. _global.roboAI = function()
  2. {
  3.    this.gotoAndStop(this.state);
  4.    var _loc4_ = Math.ceil((300 - this.health) / 50) + 1;
  5.    if(_loc4_ > this.robo.glass._currentframe)
  6.    {
  7.       this.robo.glass.gotoAndStop(_loc4_);
  8.    }
  9.    if(this.health > 0)
  10.    {
  11.       this.range = Math.abs(this._x - _root.game.player._x);
  12.       if(this.range > 180 && this.range < 240)
  13.       {
  14.          if(this.state != "attack" && this.state != "attack2" && this.state != "attack3")
  15.          {
  16.             if(this._x > _root.game.player._x)
  17.             {
  18.                this.dir = -1;
  19.             }
  20.             else if(this._x < _root.game.player._x)
  21.             {
  22.                this.dir = 1;
  23.             }
  24.             var _loc5_ = random(10);
  25.             if(_loc5_ > 3)
  26.             {
  27.                this.state = "attack";
  28.                this.attackCount = 0;
  29.             }
  30.             else if(_loc5_ > 7)
  31.             {
  32.                this.state = "attack2";
  33.                this.attackCount = 0;
  34.             }
  35.             else
  36.             {
  37.                this.state = "retreat";
  38.             }
  39.          }
  40.       }
  41.       else if(this.range > 240 && this.state == "stand" && this.state != "attack" && this.state != "attack2" && this.state != "attack3")
  42.       {
  43.          if(this._x > _root.game.player._x)
  44.          {
  45.             this.dir = -1;
  46.          }
  47.          else if(this._x < _root.game.player._x)
  48.          {
  49.             this.dir = 1;
  50.          }
  51.          _loc5_ = random(10);
  52.          if(_loc5_ > 3)
  53.          {
  54.             this.state = "attack2";
  55.             this.attackCount = 0;
  56.          }
  57.          else if(_loc5_ > 8)
  58.          {
  59.             this.state = "attack3";
  60.             this.attackCount = 0;
  61.             this.dx = 2;
  62.          }
  63.       }
  64.       else if(this.range < 180 && _root.playerAttacking && (this.dir == 1 && _root.playerDir == 1 && this._x > _root.game.player._x || this.dir == -1 && _root.playerDir == -1 && this._x < _root.game.player._x))
  65.       {
  66.          this.state = "attack";
  67.          this.attackCount = 0;
  68.          this.dir *= -1;
  69.       }
  70.       else if(this.range < 80 && this.state != "attack" && this.state != "attack2" && this.state != "attack3" && this.state != "hurt" && this.attackCount > 10)
  71.       {
  72.          _loc5_ = random(10);
  73.          if(_loc5_ > 5)
  74.          {
  75.             this.state = "attack";
  76.             this.attackCount = 0;
  77.          }
  78.          else
  79.          {
  80.             this.state = "retreat";
  81.          }
  82.       }
  83.       else if(this.range < 50 && this.state != "attack" && this.state != "attack2" && this.state != "attack3" && this.state != "hurt")
  84.       {
  85.          this.state = "retreat";
  86.       }
  87.       if(this.range > 400)
  88.       {
  89.          if(this._x > _root.game.player._x)
  90.          {
  91.             this.dir = -1;
  92.          }
  93.          else if(this._x < _root.game.player._x)
  94.          {
  95.             this.dir = 1;
  96.          }
  97.       }
  98.       this._xscale = this.dir * Math.abs(this._xscale);
  99.       if(this.state == "idle")
  100.       {
  101.          if(this.range < 320)
  102.          {
  103.             this.state = "attack";
  104.          }
  105.       }
  106.       else if(this.state == "stand")
  107.       {
  108.          this.attackCount = this.attackCount + 1;
  109.          this.attackCount -= random(1);
  110.          _loc5_ = Math.random() - Math.random();
  111.          if(this.range < 100 && this.attackCount > 15 && _loc5_ > 0.7)
  112.          {
  113.             this.state = "attack";
  114.             this.attackCount = 0;
  115.          }
  116.          else if(this.range < 150 && this.attackCount < 18)
  117.          {
  118.             _loc5_ = Math.random() - Math.random();
  119.             if(_loc5_ > 0.5)
  120.             {
  121.                this.state = "retreat";
  122.                this.attackCount = int((- Math.random()) * 30);
  123.                if(_loc5_ > 0.5)
  124.                {
  125.                   this.dir *= -1;
  126.                }
  127.             }
  128.             else
  129.             {
  130.                this.state = "walk";
  131.             }
  132.          }
  133.          else if(this.attackCount > Math.random() * 20 + 25 || this.range > 300)
  134.          {
  135.             this.state = "walk";
  136.          }
  137.       }
  138.       else if(this.state == "walk")
  139.       {
  140.          this._x += this.speed * this.dir;
  141.          this.attackCount = this.attackCount + 1;
  142.       }
  143.       else if(this.state == "retreat")
  144.       {
  145.          this._x -= this.speed * this.dir * 1.3;
  146.          if(this._x > this.xMax)
  147.          {
  148.             this.dir = -1;
  149.             this.state = "attack3";
  150.             this.dx = 2;
  151.          }
  152.          else if(this._x < this.xMin)
  153.          {
  154.             this.dir = 1;
  155.             this.state = "attack3";
  156.             this.dx = 2;
  157.          }
  158.          else
  159.          {
  160.             this.state = "attack";
  161.             this.attackCount = 0;
  162.          }
  163.          this.attackCount = this.attackCount + 1;
  164.          if(this.attackCount > 25 || this.range > Math.random() * 100 + 250)
  165.          {
  166.             _loc5_ = Math.random() - Math.random();
  167.             if(_loc5_ > 0)
  168.             {
  169.                this.state = "walk";
  170.             }
  171.          }
  172.       }
  173.       else if(this.state == "attack3")
  174.       {
  175.          if(this.roboFlying)
  176.          {
  177.             if(this.dx > 0)
  178.             {
  179.                if(this._x > 100 && this._x < 2100)
  180.                {
  181.                   this._x += (this.speed + this.dx) * this.dir;
  182.                }
  183.                else if(this._x < 100)
  184.                {
  185.                   this.dir = 1;
  186.                   this._x += (this.speed + this.dx) * this.dir;
  187.                }
  188.                else if(this._x > 2100)
  189.                {
  190.                   this.dir = -1;
  191.                   this._x += (this.speed + this.dx) * this.dir;
  192.                }
  193.                if(flipped)
  194.                {
  195.                   this.dx -= 4;
  196.                }
  197.                else
  198.                {
  199.                   this.dx += 3;
  200.                }
  201.                if((this.dx > 100 || this.dx < -100 || this.range > 1000) && !flipped)
  202.                {
  203.                   flipped = true;
  204.                   this.dir *= -1;
  205.                }
  206.             }
  207.             else if(flipped)
  208.             {
  209.                flipped = false;
  210.                this.dx = 0;
  211.                this.robo.play();
  212.                this.roboFlying = false;
  213.             }
  214.          }
  215.          if(this.hitTest(_root.game.player) && !_root.playerInvincible && _root.playerState != "hurt")
  216.          {
  217.             _root["metal" + Math.ceil(Math.random() * 3)].start();
  218.             _root.playerState = "hurt";
  219.             _root.playerHealth -= this.strength;
  220.             _root.playerInvincible = true;
  221.          }
  222.       }
  223.       else if(this.state == "hurt")
  224.       {
  225.          if(this._x < this.xMax && this._x > this.xMin)
  226.          {
  227.             this._x -= 8 * this.dir;
  228.          }
  229.          else if(this._x > this.xMax)
  230.          {
  231.             this._x -= (this._x - this.xMax) / 2;
  232.          }
  233.          else if(this._x < this.xMin)
  234.          {
  235.             this._x -= (this._x - this.xMin) / 2;
  236.          }
  237.       }
  238.       if(this.hitTest(_root.game.player))
  239.       {
  240.          if((_root.playerState == "jumppunch" || _root.playerState == "jumpkick") && _root.playerAttacking && _root.playerJumping && this.state != "hurt" && this.state != "attack2" && this.state != "attack3" && this.state != "idle")
  241.          {
  242.             this.health -= 5;
  243.             this.state = "hurt";
  244.             _root["metal" + Math.ceil(Math.random() * 3)].start();
  245.             if(this.health <= 0)
  246.             {
  247.                _root.score += 3000;
  248.                this.state = "die";
  249.             }
  250.          }
  251.       }
  252.       if(this.robo.hitBox.hitTest(_root.game.player) && (this.state == "attack" || this.state == "attack2") && _root.playerState != "hurt" && !_root.playerInvincible)
  253.       {
  254.          _root["metal" + Math.ceil(Math.random() * 3)].start();
  255.          _root.playerState = "hurt";
  256.          _root.playerHealth -= this.strength;
  257.          _root.playerInvincible = true;
  258.       }
  259.       if(_global.checkBatarang(this))
  260.       {
  261.          if(this.state != "hurt" && this.state != "attack" && this.state != "attack2" && this.state != "attack3" && this.state != "block" && this.state != "idle")
  262.          {
  263.             _loc5_ = random(10);
  264.             if(_loc5_ > 3)
  265.             {
  266.                this.state = "block";
  267.                _root["metal" + Math.ceil(Math.random() * 3)].start();
  268.                _root.curBat._visible = false;
  269.             }
  270.             else
  271.             {
  272.                this.health -= 15;
  273.                this.state = "hurt";
  274.                _root["metal" + Math.ceil(Math.random() * 3)].start();
  275.             }
  276.          }
  277.          if(this.health <= 0)
  278.          {
  279.             _root.score += 3000;
  280.             this.state = "die";
  281.          }
  282.       }
  283.       if(_global.checkPlayer(this,this.dir,-20))
  284.       {
  285.          _root.playerDx = 0;
  286.          if(this.state != "idle" && !(this.state == "attack" && this.robo._currentframe > 6) && this.state != "attack2" && this.state != "attack3")
  287.          {
  288.             if(_root.playerAttacking && this.state != "hurt")
  289.             {
  290.                this.invincible = true;
  291.                if(_root.playerState == "lowkick")
  292.                {
  293.                   _root["metal" + Math.ceil(Math.random() * 3)].start();
  294.                   this.health -= 15;
  295.                   this.state = "hurt";
  296.                   fallCount = 0;
  297.                }
  298.                else if(_root.playerState == "highpunch")
  299.                {
  300.                   _root["metal" + Math.ceil(Math.random() * 3)].start();
  301.                   this.health -= 15;
  302.                   this.state = "hurt";
  303.                   fallCount = 0;
  304.                }
  305.                else if(_root.playerState == "highkick")
  306.                {
  307.                   _root["metal" + Math.ceil(Math.random() * 3)].start();
  308.                   this.health -= 15;
  309.                   this.state = "hurt";
  310.                   fallCount = 0;
  311.                }
  312.                else
  313.                {
  314.                   _root["metal" + Math.ceil(Math.random() * 3)].start();
  315.                   this.health -= 10;
  316.                   this.state = "hurt";
  317.                }
  318.                _root.hitCount = _root.hitCount + 1;
  319.                _root.comboCount = 50;
  320.                if(_root.hitCount > 2)
  321.                {
  322.                   _root.comboMeter = true;
  323.                }
  324.                if(this.health <= 0)
  325.                {
  326.                   _root.score += 3000;
  327.                   this.state = "die";
  328.                   _root.hitCount = 0;
  329.                }
  330.             }
  331.             if((this.state == "attack" || this.state == "attack2" || this.state == "attack3") && _root.playerState != "hurt" && !_root.playerInvincible)
  332.             {
  333.                _root["metal" + Math.ceil(Math.random() * 3)].start();
  334.                _root.playerState = "hurt";
  335.                _root.playerHealth -= this.strength;
  336.                _root.playerInvincible = true;
  337.             }
  338.             else if(this.state != "attack" && this.state == "attack2" && this.state == "attack3" && this.state != "hurt" && this.attackCount > 10)
  339.             {
  340.                this.state = "attack";
  341.                this.attackCount = 0;
  342.             }
  343.          }
  344.          else if(_global.checkPlayer(this,this.dir,-100))
  345.          {
  346.             _root.playerDx = 0;
  347.             if(_root.playerAttacking && this.state != "hurt")
  348.             {
  349.                _root.punch2.start();
  350.                this.health -= 20;
  351.                this.state = "hurt";
  352.                this.invincible = true;
  353.                if(this.health <= 0)
  354.                {
  355.                   _root.score += 3000;
  356.                   this.state = "die";
  357.                }
  358.             }
  359.          }
  360.       }
  361.       else if(!(!_global.checkWall(this,this._height) && this.state != "attack" && this.state != "hurt"))
  362.       {
  363.          if(this.state != "attack" && this.state != "hurt")
  364.          {
  365.             if(this.dir > 0)
  366.             {
  367.             }
  368.          }
  369.       }
  370.    }
  371.    else
  372.    {
  373.       if(!this.flash)
  374.       {
  375.          this.gotoAndStop("die");
  376.          this.flash = 1;
  377.       }
  378.       else
  379.       {
  380.          this.flash = this.flash + 1;
  381.       }
  382.       if(this.flash > 100)
  383.       {
  384.          _root.gotoNext = "card:end";
  385.          _root.fadeout.play();
  386.          if(!played)
  387.          {
  388.             _root.ignition.start();
  389.             played = true;
  390.          }
  391.          this._visible = true;
  392.          delete this.onEnterFrame;
  393.       }
  394.    }
  395. };
  396.