home *** CD-ROM | disk | FTP | other *** search
- class BlimpAI extends Position
- {
- var color;
- var target_clip;
- var onEnterFrame;
- var attack_clip;
- var miss;
- var speed_x = 0;
- var speed_y = 0;
- var speed_z = 0;
- var air_resistance_factor = 0.4;
- var air_resistance_factor_xy = 0.05;
- var stop_list = null;
- var targs_hit = [false,false,false,false];
- var fire_left = true;
- var has_missiles = false;
- var health = 100;
- var redded_out = false;
- var red = {ra:100,rb:255,ga:100,gb:0,ba:100,bb:0,aa:100,ab:255};
- var normal = {ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0};
- function BlimpAI()
- {
- super();
- this.color = new Color(this);
- this.target_clip = this._parent.player;
- this.onEnterFrame = function()
- {
- if(!_global.game_paused)
- {
- if(this.stop_list != null)
- {
- this.startMoving();
- this.stop();
- }
- if(this.redded_out)
- {
- this.redded_out = null;
- }
- else if(this.redded_out == null)
- {
- this.unRed();
- }
- this.followTarget();
- if(Math.random() < 0.01 && this._currentframe == 1 && this.render_z < 500)
- {
- this.targs_hit = [false,false,false,false];
- this.attack();
- }
- this.moveX();
- this.moveY();
- this.moveZ();
- }
- else if(this.stop_list == null)
- {
- this.stopMoving();
- }
- };
- }
- function stopMoving()
- {
- this.stop_list = [];
- for(var _loc5_ in this)
- {
- this.stop_list.push(this[_loc5_]);
- this[_loc5_].stop();
- for(var _loc4_ in this[_loc5_])
- {
- this.stop_list.push(this[_loc5_][_loc4_]);
- this[_loc5_][_loc4_].stop();
- for(var _loc3_ in this[_loc5_][_loc4_])
- {
- this.stop_list.push(this[_loc5_][_loc4_][_loc3_]);
- this[_loc5_][_loc4_][_loc3_].stop();
- for(var _loc2_ in this[_loc5_][_loc4_][_loc3_])
- {
- this.stop_list.push(this[_loc5_][_loc4_][_loc3_][_loc2_]);
- this[_loc5_][_loc4_][_loc3_][_loc2_].stop();
- }
- }
- }
- }
- }
- function startMoving()
- {
- for(var _loc2_ in this.stop_list)
- {
- this.stop_list[_loc2_].play();
- }
- this.stop_list = null;
- }
- function followTarget()
- {
- var _loc2_ = this.distance2D(this.target_clip);
- var _loc3_ = this.posZ - (this.target_clip.posZ + 700);
- var _loc4_ = 1 - 2 * (this.posX > this.target_clip.posX);
- var _loc5_ = 1 - 2 * (this.posY > this.target_clip.posY);
- this.accelerateX(_loc4_ * _loc2_ / 600);
- this.accelerateY(_loc5_ * _loc2_ / 600);
- this.accelerateZ((- _loc3_) / 70);
- }
- function attack()
- {
- var _loc2_ = Math.ceil(Math.random() * 3) + 1;
- this.gotoAndStop(_loc2_);
- }
- function fireEnergyBall()
- {
- this._parent.objects[this._parent.objects.length] = this._parent.attachMovie("energy_ball","eball" + this._parent.objects.length,this._parent.getNextHighestDepth()).launch(this,80,-10);
- }
- function getShot(p_hittest)
- {
- var _loc2_ = 1;
- while(_loc2_ < 5)
- {
- var _loc3_ = this.attack_clip["chainout" + _loc2_];
- if(_loc3_.targ.hitTest(p_hittest))
- {
- _loc3_.gotoAndStop(28);
- this.targs_hit[_loc2_ - 1] = true;
- }
- else if(_loc3_.chain.targ.hitTest(p_hittest))
- {
- _loc3_.chain.gotoAndStop(11);
- this.targs_hit[_loc2_ - 1] = true;
- }
- else if(this.miss._currentframe == 1)
- {
- this.miss.play();
- }
- if(this.targs_hit[0] && this.targs_hit[1] && this.targs_hit[2] && this.targs_hit[3])
- {
- this.attack_clip.nose.gotoAndStop(3);
- }
- if(this.attack_clip.nose._currentframe == 3 && this.attack_clip.nose.hitTest(p_hittest))
- {
- this.targs_hit = [false,false,false,false];
- this.gotoAndStop(1);
- this.getHurt();
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function getHurt()
- {
- this.redOut();
- this.health -= 20;
- this.gotoAndStop(6);
- if(this.health <= 0)
- {
- this.die();
- }
- }
- function die()
- {
- this.gotoAndStop(5);
- }
- function redOut()
- {
- if(!this.redded_out)
- {
- this.color.setTransform(this.red);
- this.redded_out = true;
- }
- }
- function unRed()
- {
- this.color.setTransform(this.normal);
- this.redded_out = false;
- }
- function moveX()
- {
- this.pos_x += this.speed_x;
- if(this.speed_x > 20)
- {
- this.speed_x = 20;
- }
- else if(this.speed_x < -20)
- {
- this.speed_x = -20;
- }
- }
- function moveY()
- {
- this.pos_y += this.speed_y;
- if(this.speed_y > 20)
- {
- this.speed_y = 20;
- }
- else if(this.speed_y < -20)
- {
- this.speed_y = -20;
- }
- }
- function moveZ()
- {
- this.pos_z += this.speed_z;
- }
- function accelerateX(p_a)
- {
- this.speed_x += p_a;
- this.speed_x -= this.speed_x * this.air_resistance_factor_xy;
- }
- function accelerateY(p_a)
- {
- this.speed_y += p_a;
- this.speed_y -= this.speed_y * this.air_resistance_factor_xy;
- }
- function accelerateZ(p_a)
- {
- this.speed_z += p_a;
- this.speed_z -= this.speed_z * this.air_resistance_factor;
- }
- }
-