/*-----d͐ݒ--------------------------*/
if( place_free(x,y+1) ){
	air = true;
	gravity = 0.9;
	gravity_direction = 270;
}else{
	air = false;
	speed = 0;
	gravity = 0;
	gravity_direction = 0;
}

/*-----S-------------------------*/
BIND_CHECK(0,0,2);

/*-----p[cTCY-------------------*/
for(p=0;p<partsize;p+=1) with(Parts[p]){
	image_xscale=1;image_yscale=1;
};

/*-----LN^Ƃ̏̎擾---------------*/
distance = point_distance(x,y,objPlayer.x,objPlayer.y);
dir = point_direction(x,y,objPlayer.x,objPlayer.y);
/*-----[V̏--------------------*/
image_xscale =  1;
Parts[1].image_index =  PLUG_ANIMATION;
Parts[2].image_index =  ELEC_ANIMATION;
switch(motion){
	case 0 :	/* ----------ʏҋ@---------- */
	case 1 :	/* ----------ʏҋ@---------- */
	case 2 :	/* ----------ʏҋ@---------- */
	case 3 :	/* ----------ʏҋ@---------- */
	case 4 :	/* ----------ʏҋ@---------- */
	case 5 :	/* ----------ʏҋ@---------- */
	case 6 :	/* ----------ʏҋ@---------- */
		switch(round(dir/30)){
			case 0 : if(motion!=0) force_motion(0,0,5);break;
			case 1 : if(motion!=1) force_motion(1,0,5);break;
			case 2 : if(motion!=2) force_motion(2,0,5);break;
			case 3 : if(motion!=3) force_motion(3,0,5);break;
			case 4 : if(motion!=4) force_motion(4,0,5);break;
			case 5 : if(motion!=5) force_motion(5,0,5);break;
			case 6 : if(motion!=6) force_motion(6,0,5);break;
		}

		switch(MOVE_MODE){
			case TARGET : 
				/* ߂Â */
				if( 100 < distance && distance<400 ){
					if(!SOUND_FLAG) sound_play(sndMecha);
					SOUND_FLAG = 1;
					/* ̕ */
					if(objPlayer.x > x){
						MOVE((distance-100)/20 );
					}else{
						MOVE((-distance+100)/20 );
					}
				}else SOUND_FLAG = 0;
				break;
			case RUNAWAY : 
				/* ܂œ */
				if( distance<300 ){
					if(!SOUND_FLAG) sound_play(sndMecha);
					SOUND_FLAG = 1;
					/* ̕ */
					if(objPlayer.x < x){
						MOVE((300-distance)/20 );
					}else{
						MOVE((-300+distance)/20 );
					}
				}else SOUND_FLAG = 0;
				break;
		}
		if(per(1)){
			SOUND_FLAG = 0;
			switch(MOVE_MODE){
				case TARGET : MOVE_MODE = RUNAWAY; break;
				case RUNAWAY : MOVE_MODE = TARGET; break;
			}
		}

		ELEC_ANIMATION = 0;
		if(distance <120 && !force_change ) PLUG_ANIMATION+=0.5;
		else PLUG_ANIMATION-=0.3;
		if(PLUG_ANIMATION<0) PLUG_ANIMATION = 0;
		if(PLUG_ANIMATION>=9){
			PLUG_ANIMATION = 9;
			ELEC_ANIMATION = random(5);
			if(BIND_ABLE()){
				check = collision_enemy(x+lengthdir_x(128,Parts[1].angle),y+lengthdir_y(128,Parts[1].angle),40,20,0,-1,2,5,150);
				if(check){
					if(per(50)) sound_play(sndHit07);
					else sound_play(sndHit08);
					quake(20,5);
					flash(c_white,0.5,0.01);
				}
			}
		}
		break;
}