home *** CD-ROM | disk | FTP | other *** search
- class Enemy_Seeker extends MovieClip
- {
- var gunFlagOne;
- var flagExplode;
- var guns;
- var haltMovie;
- var safetyTurn;
- var numLife;
- var numSpeed;
- var numFramesToTurn;
- var numAmountToTurn;
- var minFramesToHoldTurning;
- var enemyOff;
- var _type;
- var blnVoid;
- var numLastAngle;
- function Enemy_Seeker()
- {
- super();
- this.gunFlagOne = true;
- this.flagExplode = false;
- this.guns = new Array();
- this.haltMovie = false;
- this.safetyTurn = false;
- this.numLife = 1;
- this.gotoAndPlay(this.numLife);
- this.numSpeed = 2.5;
- this.numFramesToTurn = 0;
- this.numAmountToTurn = 0;
- this.minFramesToHoldTurning = 0;
- this.enemyOff = false;
- this._type = 2;
- this.blnVoid = false;
- }
- function onEnterFrame()
- {
- if(!this.enemyOff)
- {
- if(this.flagExplode == false)
- {
- if(this.haltMovie == false)
- {
- this.numLastAngle = this.GetAnglePos();
- this.MoveMe();
- var _loc5_ = this.AboutToExit();
- if(this.numFramesToTurn == 0 || _loc5_ == true && this.safetyTurn == false)
- {
- if(_loc5_ == true)
- {
- var _loc4_ = this.GetAnglePos();
- if(_loc4_ < 0)
- {
- if(_loc4_ < this.numLastAngle)
- {
- this.numAmountToTurn = Math.round(Math.random() * -90) - 90;
- }
- else
- {
- this.numAmountToTurn = Math.round(Math.random() * 90) + 90;
- }
- }
- else if(_loc4_ > this.numLastAngle)
- {
- this.numAmountToTurn = Math.round(Math.random() * 90) + 90;
- }
- else
- {
- this.numAmountToTurn = Math.round(Math.random() * -90) - 90;
- }
- this.numFramesToTurn = Math.round(Math.abs(this.numAmountToTurn) / 2);
- this.numAmountToTurn = 2 * (this.numAmountToTurn / Math.abs(this.numAmountToTurn));
- this.minFramesToHoldTurning = 90;
- this.safetyTurn = true;
- }
- }
- else
- {
- this.numFramesToTurn = this.numFramesToTurn - 1;
- this._rotation += this.numAmountToTurn;
- }
- }
- if(this.minFramesToHoldTurning > 0)
- {
- this.minFramesToHoldTurning = this.minFramesToHoldTurning - 1;
- }
- else
- {
- var _loc3_ = new Vector();
- _loc3_._x = _root.avatar._x - this._x;
- _loc3_._y = _root.avatar._y - this._y;
- var _loc6_ = Math.atan2(_loc3_._y,_loc3_._x);
- var _loc7_ = 360 * _loc6_ / 6.283185307179586;
- this._rotation = _loc7_;
- }
- if(_root.game.intAssembledState == 0)
- {
- if(this.GetDistance2Avatar() <= 35)
- {
- this.gotoAndPlay(2);
- this.flagExplode = true;
- }
- }
- }
- }
- }
- function Explode()
- {
- this.gotoAndPlay(2);
- this.flagExplode = true;
- }
- function Terminate()
- {
- this.blnVoid = true;
- this.Explode();
- }
- function KillMe()
- {
- if(this.blnVoid == false)
- {
- _root.ReportAvatarDamage(8);
- }
- _root.ReportDeath(this._name);
- this.removeMovieClip();
- }
- function OperateWeapons()
- {
- var i = 0;
- while(i < this.guns.length)
- {
- if(this.guns[i].type == 1)
- {
- var ObjRef = eval("this." + this.guns[i].name);
- var point = {x:ObjRef._x,y:ObjRef._y};
- ObjRef.localToGlobal(point);
- var vecDirection = new Vector();
- vecDirection._x = _root.avatar._x - point.x;
- vecDirection._y = _root.avatar._y - point.y;
- var myRadians = Math.atan2(vecDirection._y,vecDirection._x);
- var myDegrees = 360 * myRadians / 6.283185307179586;
- ObjRef._rotation = myDegrees - this._rotation;
- if(this.guns[i].counter < 1)
- {
- var posVector = new Vector();
- var ObjRefTwo = eval("this." + this.guns[i].name + ".emitter");
- var pointTwo = {x:ObjRefTwo._x,y:ObjRefTwo._y};
- ObjRefTwo.localToGlobal(pointTwo);
- posVector._x = pointTwo.x;
- posVector._y = pointTwo.y;
- _root.EnemyShoot(posVector,ObjRef._rotation + this._rotation,this.guns[i].speed,this.guns[i].size,this.guns[i].damage);
- this.guns[i].counter = Math.round(Math.random() * (this.guns[i].fireTimerMax - this.guns[i].fireTimerMin)) + this.guns[i].fireTimerMin;
- }
- else
- {
- this.guns[i].counter--;
- }
- }
- i++;
- }
- }
- function ReceiveDamage(amountDamage)
- {
- var _loc3_ = false;
- this.numLife -= amountDamage;
- if(this.numLife < 1)
- {
- _loc3_ = true;
- _root.ReportDeath(this._name);
- this.removeMovieClip();
- }
- else
- {
- this.gotoAndStop(this.numLife);
- }
- return _loc3_;
- }
- function RemoveGun(strName)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.guns.length)
- {
- if(strName == this.guns[_loc2_].name)
- {
- this.guns.splice(_loc2_,1);
- break;
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function MoveMe()
- {
- var _loc2_ = new Vector();
- _loc2_._x = Math.cos(3.141592653589793 * this._rotation / 180) * this.numSpeed + this._x;
- _loc2_._y = Math.sin(3.141592653589793 * this._rotation / 180) * this.numSpeed + this._y;
- this._x = _loc2_._x;
- this._y = _loc2_._y;
- }
- function GetAnglePos()
- {
- var _loc3_ = new Vector();
- _loc3_._x = this._x - _root.bg._x;
- _loc3_._y = this._y - _root.bg._y;
- var _loc4_ = Math.atan2(_loc3_._y,_loc3_._x);
- var _loc5_ = 360 * _loc4_ / 6.283185307179586;
- return _loc5_;
- }
- function GetDistance()
- {
- var _loc4_ = this._x - _root.bg._x;
- var _loc3_ = this._y - _root.bg._y;
- return Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
- }
- function GetDistance2Avatar()
- {
- var _loc4_ = this._x - _root.avatar._x;
- var _loc3_ = this._y - _root.avatar._y;
- return Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
- }
- function AboutToExit()
- {
- var _loc5_ = false;
- var _loc6_ = Math.cos(3.141592653589793 * this._rotation / 180) * (this._width + 30 * this.numSpeed) + this._x;
- var _loc7_ = Math.sin(3.141592653589793 * this._rotation / 180) * (this._width + 30 * this.numSpeed) + this._y;
- var _loc4_ = _loc6_ - _root.bg._x;
- var _loc3_ = _loc7_ - _root.bg._y;
- if(Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_) > _root.bg.inside._width / 2)
- {
- _loc5_ = true;
- }
- return _loc5_;
- }
- function TurnOff()
- {
- this.enemyOff = true;
- }
- function TurnOn()
- {
- this.enemyOff = false;
- }
- }
-