/*-----d͐ݒ--------------------------*/
if( air ){
	gravity = global.G;
	gravity_direction = global.Gdir;
}else{
	gravity = 0;
	gravity_direction = 0;
	hspeed *= 0.3;
}

with(objEnemyEdit){ if(Edit_Play) exit; }

/*-----LN^Ƃ̏̎擾---------------*/
playerDistance = point_distance(x,y,objPlayerDoll.x,objPlayerDoll.y);
playerDirection = point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y);

/*-----[V̏--------------------*/
if(RECV_DAMAGE){
	playEnemySound(SOUND_DAMAGE);
	if(!ChangeMotion){
		switch(MotionNum){
			case STAND :
				MotionChange(RUN,0,2);
				break;
			case WALK :
				MotionChange(RUN,KeyFrmNum,2);
				break;
		}
	}
}

if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			/* ̕ */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			/* ߂Â */
			if( !air && 100<playerDistance && playerDistance<400){ MotionChange(WALK,0,5); break; }
			if(80>playerDistance){ MotionChange(PUNCH,0,2); break; }
			break;
		case WALK :
			switch(KeyFrmNum){
				case  1 : if(place_free(x-3*Direction,y)) x -= 2.0*Direction; break;
				case  2 : if(KEYFRAME) playEnemySound(SOUND_STEP);
						  if(place_free(x-3*Direction,y)) x -= 0.5*Direction; break;
				case  5 : if(place_free(x-3*Direction,y)) x -= 2.0*Direction; break;

				case  6 : if(place_free(x-3*Direction,y)) x -= 2.0*Direction; break;
				case  7 : if(KEYFRAME) playEnemySound(SOUND_STEP);
						  if(place_free(x-3*Direction,y)) x -= 0.5*Direction; break;
				case 10 : if(place_free(x-3*Direction,y)) x -= 2.0*Direction; break;
			}

			/* }ڋ */
			if( 200>playerDistance ){ MotionChange(RUN,KeyFrmNum,2); break; }

			/* ߂Â藣ꂽ肵~܂ */
			if( 100>playerDistance || playerDistance>500){ MotionChange(STAND,0,5); break; }
			break;
		case RUN :
			/* ̕ */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			switch(KeyFrmNum){
				case  1 : if(place_free(x-3*Direction,y)) x -= 10.0*Direction; break;
				case  2 : if(KEYFRAME) playEnemySound(SOUND_STEP);
						  if(place_free(x-3*Direction,y)) x -= 1.5*Direction; break;
				case  5 : if(place_free(x-3*Direction,y)) x -= 10.0*Direction; break;

				case  6 : if(place_free(x-3*Direction,y)) x -= 10.0*Direction; break;
				case  7 : if(KEYFRAME) playEnemySound(SOUND_STEP);
						  if(place_free(x-3*Direction,y)) x -= 1.5*Direction; break;
				case 10 : if(place_free(x-3*Direction,y)) x -= 10.0*Direction; break;
			}
			/* ߂Â藣ꂽ肵~܂ */
			if(playerDistance>600){ MotionChange(WALK,0,5); break; }
			if(80>playerDistance){ MotionChange(PUNCH,0,2); break; }
			break;
		case DEAD_MOTION :
			switch(KeyFrmNum){
				case 1 : 
					if(KEYFRAME) effect_create_above(ef_smokeup,x,y,0,c_black);
					break;
			}
			if(MOTIONEND){
				instance_create(x,y,objExplosionSmall);
				Flash(c_white,0.1,0.05);

				Quake(5,5);
				sound_play(sndBomb);
				instance_destroy();
			}
			break;
		case PUNCH :
			switch(KeyFrmNum){
				case 6 : 
					if(KEYFRAME){
						with( collision_circle( Process[PARTS_ARM3_ABOVE].x+40*Direction*-1, Process[PARTS_ARM3_ABOVE].y, 64,objPlayerDoll,0,1) ){
							if(!INV){
								DamageVoiceRandom_Mid();
								if(BINDED){
									if(Direction!=other.Direction)	addDamage(30, -1, -1, -1, -1, -1, -1);
									else							addDamage(30, -1, -1, -1, -1, -1, -1);
								}else{
									if(Direction!=other.Direction)	addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
	                                else							addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
									hspeed = 30*other.Direction*-1;
									vspeed = -6;
								}
								sound_play(sndHit00);
								Quake(15,15);
							}
						}
					}
					break;
			}

			if(MOTIONEND){
				MotionChange(STAND,0,1);
			}
			break;
	}
}