home *** CD-ROM | disk | FTP | other *** search
- _global.roboAI = function()
- {
- this.gotoAndStop(this.state);
- var _loc4_ = Math.ceil((300 - this.health) / 50) + 1;
- if(_loc4_ > this.robo.glass._currentframe)
- {
- this.robo.glass.gotoAndStop(_loc4_);
- }
- if(this.health > 0)
- {
- this.range = Math.abs(this._x - _root.game.player._x);
- if(this.range > 180 && this.range < 240)
- {
- if(this.state != "attack" && this.state != "attack2" && this.state != "attack3")
- {
- if(this._x > _root.game.player._x)
- {
- this.dir = -1;
- }
- else if(this._x < _root.game.player._x)
- {
- this.dir = 1;
- }
- var _loc5_ = random(10);
- if(_loc5_ > 3)
- {
- this.state = "attack";
- this.attackCount = 0;
- }
- else if(_loc5_ > 7)
- {
- this.state = "attack2";
- this.attackCount = 0;
- }
- else
- {
- this.state = "retreat";
- }
- }
- }
- else if(this.range > 240 && this.state == "stand" && this.state != "attack" && this.state != "attack2" && this.state != "attack3")
- {
- if(this._x > _root.game.player._x)
- {
- this.dir = -1;
- }
- else if(this._x < _root.game.player._x)
- {
- this.dir = 1;
- }
- _loc5_ = random(10);
- if(_loc5_ > 3)
- {
- this.state = "attack2";
- this.attackCount = 0;
- }
- else if(_loc5_ > 8)
- {
- this.state = "attack3";
- this.attackCount = 0;
- this.dx = 2;
- }
- }
- 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))
- {
- this.state = "attack";
- this.attackCount = 0;
- this.dir *= -1;
- }
- else if(this.range < 80 && this.state != "attack" && this.state != "attack2" && this.state != "attack3" && this.state != "hurt" && this.attackCount > 10)
- {
- _loc5_ = random(10);
- if(_loc5_ > 5)
- {
- this.state = "attack";
- this.attackCount = 0;
- }
- else
- {
- this.state = "retreat";
- }
- }
- else if(this.range < 50 && this.state != "attack" && this.state != "attack2" && this.state != "attack3" && this.state != "hurt")
- {
- this.state = "retreat";
- }
- if(this.range > 400)
- {
- if(this._x > _root.game.player._x)
- {
- this.dir = -1;
- }
- else if(this._x < _root.game.player._x)
- {
- this.dir = 1;
- }
- }
- this._xscale = this.dir * Math.abs(this._xscale);
- if(this.state == "idle")
- {
- if(this.range < 320)
- {
- this.state = "attack";
- }
- }
- else if(this.state == "stand")
- {
- this.attackCount = this.attackCount + 1;
- this.attackCount -= random(1);
- _loc5_ = Math.random() - Math.random();
- if(this.range < 100 && this.attackCount > 15 && _loc5_ > 0.7)
- {
- this.state = "attack";
- this.attackCount = 0;
- }
- else if(this.range < 150 && this.attackCount < 18)
- {
- _loc5_ = Math.random() - Math.random();
- if(_loc5_ > 0.5)
- {
- this.state = "retreat";
- this.attackCount = int((- Math.random()) * 30);
- if(_loc5_ > 0.5)
- {
- this.dir *= -1;
- }
- }
- else
- {
- this.state = "walk";
- }
- }
- else if(this.attackCount > Math.random() * 20 + 25 || this.range > 300)
- {
- this.state = "walk";
- }
- }
- else if(this.state == "walk")
- {
- this._x += this.speed * this.dir;
- this.attackCount = this.attackCount + 1;
- }
- else if(this.state == "retreat")
- {
- this._x -= this.speed * this.dir * 1.3;
- if(this._x > this.xMax)
- {
- this.dir = -1;
- this.state = "attack3";
- this.dx = 2;
- }
- else if(this._x < this.xMin)
- {
- this.dir = 1;
- this.state = "attack3";
- this.dx = 2;
- }
- else
- {
- this.state = "attack";
- this.attackCount = 0;
- }
- this.attackCount = this.attackCount + 1;
- if(this.attackCount > 25 || this.range > Math.random() * 100 + 250)
- {
- _loc5_ = Math.random() - Math.random();
- if(_loc5_ > 0)
- {
- this.state = "walk";
- }
- }
- }
- else if(this.state == "attack3")
- {
- if(this.roboFlying)
- {
- if(this.dx > 0)
- {
- if(this._x > 100 && this._x < 2100)
- {
- this._x += (this.speed + this.dx) * this.dir;
- }
- else if(this._x < 100)
- {
- this.dir = 1;
- this._x += (this.speed + this.dx) * this.dir;
- }
- else if(this._x > 2100)
- {
- this.dir = -1;
- this._x += (this.speed + this.dx) * this.dir;
- }
- if(flipped)
- {
- this.dx -= 4;
- }
- else
- {
- this.dx += 3;
- }
- if((this.dx > 100 || this.dx < -100 || this.range > 1000) && !flipped)
- {
- flipped = true;
- this.dir *= -1;
- }
- }
- else if(flipped)
- {
- flipped = false;
- this.dx = 0;
- this.robo.play();
- this.roboFlying = false;
- }
- }
- if(this.hitTest(_root.game.player) && !_root.playerInvincible && _root.playerState != "hurt")
- {
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- _root.playerState = "hurt";
- _root.playerHealth -= this.strength;
- _root.playerInvincible = true;
- }
- }
- else if(this.state == "hurt")
- {
- if(this._x < this.xMax && this._x > this.xMin)
- {
- this._x -= 8 * this.dir;
- }
- else if(this._x > this.xMax)
- {
- this._x -= (this._x - this.xMax) / 2;
- }
- else if(this._x < this.xMin)
- {
- this._x -= (this._x - this.xMin) / 2;
- }
- }
- if(this.hitTest(_root.game.player))
- {
- if((_root.playerState == "jumppunch" || _root.playerState == "jumpkick") && _root.playerAttacking && _root.playerJumping && this.state != "hurt" && this.state != "attack2" && this.state != "attack3" && this.state != "idle")
- {
- this.health -= 5;
- this.state = "hurt";
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- if(this.health <= 0)
- {
- _root.score += 3000;
- this.state = "die";
- }
- }
- }
- if(this.robo.hitBox.hitTest(_root.game.player) && (this.state == "attack" || this.state == "attack2") && _root.playerState != "hurt" && !_root.playerInvincible)
- {
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- _root.playerState = "hurt";
- _root.playerHealth -= this.strength;
- _root.playerInvincible = true;
- }
- if(_global.checkBatarang(this))
- {
- if(this.state != "hurt" && this.state != "attack" && this.state != "attack2" && this.state != "attack3" && this.state != "block" && this.state != "idle")
- {
- _loc5_ = random(10);
- if(_loc5_ > 3)
- {
- this.state = "block";
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- _root.curBat._visible = false;
- }
- else
- {
- this.health -= 15;
- this.state = "hurt";
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- }
- }
- if(this.health <= 0)
- {
- _root.score += 3000;
- this.state = "die";
- }
- }
- if(_global.checkPlayer(this,this.dir,-20))
- {
- _root.playerDx = 0;
- if(this.state != "idle" && !(this.state == "attack" && this.robo._currentframe > 6) && this.state != "attack2" && this.state != "attack3")
- {
- if(_root.playerAttacking && this.state != "hurt")
- {
- this.invincible = true;
- if(_root.playerState == "lowkick")
- {
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- this.health -= 15;
- this.state = "hurt";
- fallCount = 0;
- }
- else if(_root.playerState == "highpunch")
- {
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- this.health -= 15;
- this.state = "hurt";
- fallCount = 0;
- }
- else if(_root.playerState == "highkick")
- {
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- this.health -= 15;
- this.state = "hurt";
- fallCount = 0;
- }
- else
- {
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- this.health -= 10;
- this.state = "hurt";
- }
- _root.hitCount = _root.hitCount + 1;
- _root.comboCount = 50;
- if(_root.hitCount > 2)
- {
- _root.comboMeter = true;
- }
- if(this.health <= 0)
- {
- _root.score += 3000;
- this.state = "die";
- _root.hitCount = 0;
- }
- }
- if((this.state == "attack" || this.state == "attack2" || this.state == "attack3") && _root.playerState != "hurt" && !_root.playerInvincible)
- {
- _root["metal" + Math.ceil(Math.random() * 3)].start();
- _root.playerState = "hurt";
- _root.playerHealth -= this.strength;
- _root.playerInvincible = true;
- }
- else if(this.state != "attack" && this.state == "attack2" && this.state == "attack3" && this.state != "hurt" && this.attackCount > 10)
- {
- this.state = "attack";
- this.attackCount = 0;
- }
- }
- else if(_global.checkPlayer(this,this.dir,-100))
- {
- _root.playerDx = 0;
- if(_root.playerAttacking && this.state != "hurt")
- {
- _root.punch2.start();
- this.health -= 20;
- this.state = "hurt";
- this.invincible = true;
- if(this.health <= 0)
- {
- _root.score += 3000;
- this.state = "die";
- }
- }
- }
- }
- else if(!(!_global.checkWall(this,this._height) && this.state != "attack" && this.state != "hurt"))
- {
- if(this.state != "attack" && this.state != "hurt")
- {
- if(this.dir > 0)
- {
- }
- }
- }
- }
- else
- {
- if(!this.flash)
- {
- this.gotoAndStop("die");
- this.flash = 1;
- }
- else
- {
- this.flash = this.flash + 1;
- }
- if(this.flash > 100)
- {
- _root.gotoNext = "card:end";
- _root.fadeout.play();
- if(!played)
- {
- _root.ignition.start();
- played = true;
- }
- this._visible = true;
- delete this.onEnterFrame;
- }
- }
- };
-