View Single Post
Old 27 January 2005, 11:16   #18
Ironclaw
Banned
Ironclaw's Avatar
 
Join Date: Oct 2004
Location: ...
Age: 39
Posts: 3,313
I don't "write" in Flash, I "code"... and alot of coding has been done already. Have you checked my Moonstone Remake?

Here's some code from the enemy knight:

Code:
onClipEvent (enterFrame) {
	//This enemy being hit -------------------------------------------------
	if (this.hitTest(_root.Game.BlueKnight.HighSwing.box) and _parent.HitPlankk == "yes") {
		HitByHighSwing = new Sound();
		HitByHighSwing.attachSound("HitByHighSwing");
		HitByHighSwing.start(0, 0);
		_root.Game.BlueKnight.HighSwing.gotoAndPlay(29);
		trace("MMMMMMMMMMMMM");
		_parent.gotoAndStop("HitHigh");
	} else if (this.hitTest(_root.Game.BlueKnight.LowSwing.box) and _parent.HitPlankk == "yes") {
		HitByLowSwing = new Sound();
		HitByLowSwing.attachSound("HitByLowSwing");
		HitByLowSwing.start(0, 0);
		_root.Game.BlueKnight.LowSwing.gotoAndPlay(29);
		trace("MMMMMMMMMMMMM");
		_parent.gotoAndStop("HitLow");
	}
}
// End -------------------------------------------------
// Throw Knife -------------------------------------------------
onClipEvent (enterFrame) {
	if (_parent._x<_root.Game.BlueKnight._x and _parent._x<_root.Game.BlueKnight._x-130 and _parent._x>_root.Game.BlueKnight._x-280 and _parent._y>=_root.Game.BlueKnight._y-20 and _parent._y<=_root.Game.BlueKnight._y+20 and _parent.ThrowKnife == "on") {
		trace("0000");
		r = random(2);
		if (r == 1) {
			trace("0001");
			if (_parent.Knifes<=0) {
				_parent.ThrowKnife == "off";
			} else {
				_parent.Knifes -= 1;
				_parent.gotoAndStop("ThrowKnife");
			}
		}
	}
}
onClipEvent (enterFrame) {
	if (_parent._x>_root.Game.BlueKnight._x and _parent._x<_root.Game.BlueKnight._x+300 and _parent._x>_root.Game.BlueKnight._x+130 and _parent._y>=_root.Game.BlueKnight._y-20 and _parent._y<=_root.Game.BlueKnight._y+20 and _parent.ThrowKnife == "on") {
		trace("0000");
		r = random(2);
		if (r == 1) {
			trace("0001");
			if (_parent.Knifes<=0) {
				_parent.ThrowKnife == "off";
			} else {
				_parent.Knifes -= 1;
				_parent.gotoAndStop("ThrowKnife");
			}
		}
	}
}
// End -------------------------------------------------
onClipEvent (enterFrame) {
	if (_parent._y<_root.Game.BlueKnight._y) {
		_root.Game.BlueKnight.swapDepths(3);
	} else {
		_root.Game.BlueKnight.swapDepths(1);
	}
}
/*onClipEvent (enterFrame) {
	if (_parent._y<_root.Game.BlueKnight._y and _parent._x<_root.Game.BlueKnight._x-DistanceB and _parent._x>_root.Game.BlueKnight._x-DistanceA) {
		trace("lklklk")
		_root.Game.BlueKnight.swapDepths(3);
	} else {
		_root.Game.BlueKnight.swapDepths(1);
	}
	//and _parent._x>_root.Game.BlueKnight._x and _parent._x<_root.Game.BlueKnight._x+DistanceA and _parent._x>_root.Game.BlueKnight._x+DistanceB
}*/
onClipEvent (enterFrame) {
	if (getTimer()-timegone>20) {
		if (!attacking) {
			var moved = false;
			// player is right
			if (_parent._x<_root.Game.BlueKnight._x) {
				_xscale = _parent._xscale=+100;
				// If the player is longer away than 2 meters,
				// move closer till the enemy is at 2 meters distance
				if (_parent._x<_root.Game.BlueKnight._x-_parent.DistanceA) {
					_parent.gotoAndStop("Move");
					_parent._x += _parent.MoveSpeed;
					moved = true;
				} else if (_parent._x>_root.Game.BlueKnight._x-_parent.DistanceB) {
					// If the player is closer than 1 meter,
					// move away till the player is at 1 meters distance.
					_xscale = _parent._xscale=+100;
					_parent.gotoAndStop("Move");
					_parent._x -= _parent.MoveSpeed;
					moved = true;
				}
				// player is left
			} else {
				if (_parent._x>_root.Game.BlueKnight._x+_parent.DistanceA) {
					_xscale = _parent._xscale=-100;
					_parent.gotoAndStop("Move");
					_parent._x -= _parent.MoveSpeed;
					moved = true;
				} else if (_parent._x<_root.Game.BlueKnight._x+_parent.DistanceB) {
					// If the player is closer than 1 meter,
					// move away till the player is at 1 meters distance.
					_xscale = _parent._xscale=-100;
					_parent.gotoAndStop("Move");
					_parent._x += _parent.MoveSpeed;
					moved = true;
				}
			}
			// If the player below, move down, enemy right side
			//------------------------------------
			if (_parent._y<_root.Game.BlueKnight._y-1 and _parent._x<_root.Game.BlueKnight._x-_parent.DistanceB and _parent._x>_root.Game.BlueKnight._x-_parent.DistanceA) {
				_xscale = _parent._xscale=+100;
				_parent.gotoAndStop("MoveDown");
				_parent._y += _parent.MoveUpDownSpeed;
				moved = true;
			} else if (_parent._y>_root.Game.BlueKnight._y+1 and _parent._x<_root.Game.BlueKnight._x-_parent.DistanceB and _parent._x>_root.Game.BlueKnight._x-_parent.DistanceA) {
				_xscale = _parent._xscale=+100;
				_parent.gotoAndStop("MoveUp");
				_parent._y -= _parent.MoveUpDownSpeed;
				moved = true;
				//------------------------
			} else if (_parent._y<_root.Game.BlueKnight._y-1 and _parent._x>_root.Game.BlueKnight._x and _parent._x<_root.Game.BlueKnight._x+_parent.DistanceA and _parent._x>_root.Game.BlueKnight._x+_parent.DistanceB) {
				_xscale = _parent._xscale=-100;
				_parent.gotoAndStop("MoveDown");
				_parent._y += _parent.MoveUpDownSpeed;
				moved = true;
			} else if (_parent._y>_root.Game.BlueKnight._y+1 and _parent._x>_root.Game.BlueKnight._x and _parent._x<_root.Game.BlueKnight._x+_parent.DistanceA and _parent._x>_root.Game.BlueKnight._x+_parent.DistanceB) {
				_xscale = _parent._xscale=-100;
				_parent.gotoAndStop("MoveUp");
				_parent._y -= _parent.MoveUpDownSpeed;
				moved = true;
				//-----------------
			} else if (_parent._y<_root.Game.BlueKnight._y-1 and _parent._x>_root.Game.BlueKnight._x) {
				_xscale = _parent._xscale=-100;
				_parent.gotoAndStop("Move");
				_parent._y += _parent.MoveUpDownSpeed;
				moved = true;
			} else if (_parent._y<_root.Game.BlueKnight._y-1) {
				_xscale = _parent._xscale=+100;
				_parent.gotoAndStop("Move");
				_parent._y += _parent.MoveUpDownSpeed;
				moved = true;
				// If the player above, move up.
			} else if (_parent._y>_root.Game.BlueKnight._y+1 and _parent._x>_root.Game.BlueKnight._x) {
				_xscale = _parent._xscale=-100;
				_parent.gotoAndStop("Move");
				_parent._y -= _parent.MoveUpDownSpeed;
				moved = true;
			} else if (_parent._y>_root.Game.BlueKnight._y+1) {
				_xscale = _parent._xscale=+100;
				_parent.gotoAndStop("Move");
				_parent._y -= _parent.MoveUpDownSpeed;
				moved = true;
				//------------------------------------
			}
			
			// THIS PART MAKES THIS ENEMY BACK UP WHEN THE PLAYER GETS TO CLOSE
			if (_parent._x<_root.Game.BlueKnight._x and _parent._x>_root.Game.BlueKnight._x-70) {
				trace("nigggaaaaaaaaaaaaaaa");
				// If the player is closer than 1 meter,
				// move away till the player is at 1 meters distance.
				_xscale = _parent._xscale=+100;
				_parent.gotoAndStop("Move");
				_parent._x -= _parent.MoveSpeed;
				moved = true;
				// -----------------------------------------------------------
			}
			timegone = getTimer();
		}
		if (!moved) {
			//start attacking
			if (!attacking) {
				f = ["LowSwing", "HighSwing"];
				r = random(2);
				frame = f[r];
				_parent.gotoAndStop(frame);
				attackTime = getTimer();
				attacking = 1;
				_root.attackDone = false;
				//wait 1 sec
			} else if (getTimer()-attackTime>200 and attacking == 1) {
				var mustAttack = false;
				if (Math.abs(_parent._x-_root.Game.BlueKnight._x)<=_parent.DistanceA) {
					if (Math.abs(_parent._x-_root.Game.BlueKnight._x)>=_parent.DistanceB) {
						if (_parent._y>=_root.Game.BlueKnight._y-1) {
							if (_parent._y<=_root.Game.BlueKnight._y+1) {
								mustAttack = true;
							}
						}
					}
				}
				if (mustAttack) {
					//attack
					trace("die!");
					attacking = 2;
					_parent.enemy.gotoAndPlay(2);
				} else {
					//player has moved
					attacking = 0;
				}
			}
		}
	}
	if (_root.attackDone) {
		attacking = 0;
	}
}
onClipEvent (load) {
	timegone = getTimer();
	attacking = 0;
}
Ironclaw is offline  
 
Page generated in 0.05621 seconds with 9 queries