home *** CD-ROM | disk | FTP | other *** search
- class Enemy_Sapper extends MovieClip
- {
- var gunFlagOne;
- var flagExplode;
- var guns;
- var haltMovie;
- var safetyTurn;
- var numLife;
- var numSpeed;
- var numFramesToTurn;
- var numAmountToTurn;
- var minFramesToHoldTurning;
- var strCreatedBy;
- var intState;
- var rotateAngle;
- var rotateSpeed;
- var _type;
- var blnVoid;
- var enemyOff;
- var numLastAngle;
- function Enemy_Sapper()
- {
- 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 = 6;
- this.numFramesToTurn = 0;
- this.numAmountToTurn = 0;
- this.minFramesToHoldTurning = 0;
- this.strCreatedBy = "";
- this.intState = 3;
- this.rotateAngle = 0;
- this.rotateSpeed = 0.1;
- this._type = 2;
- this.blnVoid = false;
- }
- function onEnterFrame()
- {
- if(!this.enemyOff)
- {
- if(this.intState == 3 || this.intState == 5)
- {
- if(this.haltMovie == false)
- {
- this.numLastAngle = this.GetAnglePos();
- this.MoveMe();
- var _loc10_ = this.AboutToExit();
- }
- if(this.intState == 3)
- {
- 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() <= 20)
- {
- this.gotoAndStop(11);
- var _loc4_ = new Vector();
- _loc4_._x = _root.avatar._x;
- _loc4_._y = _root.avatar._y;
- _root.game.CreateEffect("effect",_loc4_,true,"avatar");
- _root.ReportAvatarDamage(1);
- this.intState = 5;
- }
- }
- }
- else if(this.intState == 5)
- {
- if(this.minFramesToHoldTurning > 0)
- {
- this.minFramesToHoldTurning = this.minFramesToHoldTurning - 1;
- }
- else
- {
- _loc3_ = new Vector();
- _loc3_._x = _root[this.strCreatedBy]._x - this._x;
- _loc3_._y = _root[this.strCreatedBy]._y - this._y;
- _loc6_ = Math.atan2(_loc3_._y,_loc3_._x);
- _loc7_ = 360 * _loc6_ / 6.283185307179586;
- this._rotation = _loc7_;
- }
- if(this.GetDistance2Source() <= 20)
- {
- this.intState = 3;
- _root[this.strCreatedBy].ReportLifeIncrease(3);
- this.gotoAndStop(1);
- }
- }
- }
- else if(this.intState == 2)
- {
- var _loc5_ = _root[this.strCreatedBy]._width + 2;
- var _loc9_ = _loc5_ * Math.cos(this.rotateAngle) + _root[this.strCreatedBy]._x;
- var _loc8_ = _loc5_ * Math.sin(this.rotateAngle) + _root[this.strCreatedBy]._y;
- this.rotateAngle += this.rotateSpeed;
- if(this.rotateAngle > 360)
- {
- this.rotateAngle = 0;
- }
- this._x = _loc9_;
- this._y = _loc8_;
- this._rotation = _root[this.strCreatedBy]._rotation;
- if(this.GetDistance2Avatar() <= 85)
- {
- this.intState = 3;
- }
- }
- }
- }
- function Explode()
- {
- this.gotoAndPlay(2);
- this.intState = 4;
- }
- function Terminate()
- {
- this.blnVoid = true;
- this.Explode();
- }
- function KillMe()
- {
- if(this.blnVoid == false)
- {
- _root.ReportAvatarDamage(8);
- }
- _root.ReportDeath(this._name);
- _root[this.strCreatedBy].ReportSeekerDeath(this._name);
- this.removeMovieClip();
- }
- function SetCreatedFrom(strFrom)
- {
- this.strCreatedBy = strFrom;
- }
- function ReceiveDamage(amountDamage)
- {
- var _loc3_ = false;
- this.numLife -= amountDamage;
- if(this.numLife < 1)
- {
- _loc3_ = true;
- _root.ReportDeath(this._name);
- _root[this.strCreatedBy].ReportSeekerDeath(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 GetDistance2Source()
- {
- var _loc4_ = this._x - _root[this.strCreatedBy]._x;
- var _loc3_ = this._y - _root[this.strCreatedBy]._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;
- }
- }
-