/*-----重力設定--------------------------*/
if( place_free(x,y+1) ){
	air = true;
	gravity = 0.98;
	gravity_direction = 270;
}else{
	air = false;
	hspeed = hspeed*0.85;
	gravity = 0;
	gravity_direction = 0;
}

/*-----拘束解除時-------------------------*/
BIND_CHECK(0,0,2);

/*-----キャラクタとの情報の取得---------------*/
distance = point_distance(x,y,objPlayer.x,objPlayer.y);


/*-----モーション毎の処理--------------------*/
switch(motion){
	case 0 :	/* ----------通常待機---------- */
		/* 相手の方を向く */
		if(objPlayer.x > x) image_xscale = -1;
		else				image_xscale =  1;

		/* 攻撃してきたらカウンター */
		if( IF_ATTACK() ){ force_motion(8,0,2); break; }

		if(distance<50) force_motion(8,6,5);
		else if(distance<220){
			if(random(100)<10){
				/* 攻撃へ遷移 */
				if(random(100)<33) force_motion(7,0,3);
				else if(random(100)<50) force_motion(5,0,3);
				else force_motion(6,0,3);
			}
		}else if(distance<400){
			force_motion(4,0,3);
		}
		break;
	case 1 :	/* ----------弱ダメージ---------- */
		break;

	case 2 :	/* ----------中ダメージ---------- */
		break;

	case 3 :	/* ----------強ダメージ---------- */
		break;
	case 4 : 	/* -------------歩行------------- */
		/* ---移動する--- */
		MOVE(4*-image_xscale,0);

		/* ---攻撃してきたらカウンター--- */
		if( IF_ATTACK() ){ force_motion(8,0,2); break; }

		/* ---攻撃へ遷移--- */
		if(50<distance && distance<90) force_motion(0,0,3);
		else if(80<distance && distance<220){
			if(random(100)<10){
				/* ---相手の方を向く--- */
				if(objPlayer.x > x) image_xscale = -1;
				else				image_xscale =  1;
				/* 攻撃へ遷移 */
				if(random(100)<33) force_motion(7,0,3);
				else if(random(100)<50) force_motion(5,0,3);
				else force_motion(6,0,3);
			}
		}
		break;
	case 5 : 	/* -------------縦切り------------- */
		switch(number){
			case 4 : if(KEYFRAME) sound_play(sndSwing4); break;
			case 5 : 
			case 6 : 
				if(BIND_ABLE()){
					if(image_xscale) check = collision_enemy(Parts[5].x,Parts[5].y,50,20,250,-1,1,30,30);
					else check = collision_enemy(Parts[5].x,Parts[5].y,50,20,300,-1,1,30,30);
					if(check){
						sound_play(sndHit05);
						quake(20,5);
						Blood(check.x,check.y,20,0.1,0.5,0,180,5,10,c_red);
						if(objPlayer.HP<70){
							BIND_ON();
							force_other_motion(objPlayer,DAMAGE_CUTTER[0],0,3);
							force_motion(9,0,3);
						}
					}
				}
				MOVE(12*-image_xscale,0);
				break;
		}
		break;
	case 9 : 	/* -------------縦切りフィニッシュ------------- */
		Parts[09].depth_mode = true; Parts[09].depth = objPlayer.depth+1;
		BIND_POSITION(05,35*-image_xscale,10);
		switch(number){
			case 5:
				if(KEYFRAME){
					with(objBody_Top){ event_user(1) };
					flash(c_red,0.5,0.2);
					collision_enemy(Parts[5].x,Parts[5].y,150,20,250,NULL,0,40,0);
					quake(20,5);
					Blood(objPlayer.x,objPlayer.y,20,0.1,0.5,0,180,5,10,c_red);
					sound_play(sndHit00);
				}
				break;
			case 10 :
				if(KEYFRAME){
					flash(c_red,0.5,0.1);
					sound_play(sndGoku02);
					if(per(30))	force_other_motion(objPlayer,DAMAGE_CUTTER[0],6,3);
					else		force_other_motion(objPlayer,DAMAGE_CUTTER[0],0,3);
				}
				break;
			case 11 :
			case 12 :
			case 13 :
			case 15 :
				if(per(2)){ quake(20,5);force_other_motion(objPlayer,DAMAGE_CUTTER[0],0,2); }
				if(KEYFRAME){
					collision_enemy(Parts[5].x,Parts[5].y,150,20,250,NULL,0,5,0);
					quake(20,5);
					Blood(objPlayer.x,objPlayer.y,5,0.1,0.5,45,90,5,10,c_red);
					if(per(25))			sound_play(sndGoku00);
					else if(per(33))	sound_play(sndGoku01);
					else if(per(50))	sound_play(sndGoku02);
					else 				sound_play(sndFluid);
				}
				break;
			case 17 : 
			case 18 : 
			case 19 : 
				if(per(1)){
					force_motion(9,9,3);
				}
				break;
		}
		break;
	case 6 : 	/* -------------突き上げ------------- */
		switch(number){
			case 4 : if(KEYFRAME) sound_play(sndSwing4); break;
			case 5 : 
			case 6 : 
				if(BIND_ABLE()){
					if(image_xscale) check = collision_enemy(Parts[9].x,Parts[9].y,50,20,180,-1,1,40,60);
					else check = collision_enemy(Parts[9].x,Parts[9].y,50,20,0,-1,1,40,60);
					if(check){
						sound_play(sndHit05);
						quake(20,5);
						Blood(check.x,check.y,20,0.1,0.5,0,180,5,10,c_red);
						if(objPlayer.HP<60){
							with(objBody_Top){ event_user(1) };
							BIND_ON();
							force_other_motion(objPlayer,DAMAGE_CUTTER[1],0,3);
							force_motion(10,0,3);
						}
					}
				}
				MOVE(12*-image_xscale,0);
				break;
		}
		break;
	case 10 : 	/* -------------突き上げフィニッシュ------------- */
		Parts[09].depth_mode = true; Parts[09].depth = objPlayer.depth+1;
		BIND_POSITION(09,8*-image_xscale,-8);
		if(per(5)){
			Blood(objPlayer.x,objPlayer.y,3,0.1,0.5,250,40,0,5,c_red);
			blood = Lotion(objPlayer,0,0,random(360),random(5));
			blood.image_blend = c_red;
		}
		with(objPlayer){
			HP -= 0.1;
			RECOVER = 0;
			if(number>17 && per(1)) force_motion(motion,16,1);
		}
		break;
	case 7 : 	/* -------------突き------------- */
		switch(number){
			case 3 : if(KEYFRAME) sound_play(sndSwing4); break;
			case 4 : 
				if(BIND_ABLE()){
					if(image_xscale) check = collision_enemy(Parts[5].x,Parts[5].y,50,20,180,-1,2,40,60);
					else check = collision_enemy(Parts[5].x,Parts[5].y,50,20,0,-1,2,40,60);
					if(check){
						sound_play(sndHit05);
						quake(20,5);
						Blood(check.x,check.y,20,0.1,0.5,0,180,5,10,c_red);
						if(objPlayer.HP < 60){
							quake(20,10);
							with(objBody_Top){ event_user(1) };
							BIND_ON();
							force_other_motion(objPlayer,DAMAGE_CUTTER[2],0,3);
							force_motion(11,0,3);
						}
					}
				}
				MOVE(12*-image_xscale,0);
				break;
		}
		break;
	case 11 : 	/* -------------突きフィニッシュ------------- */
		if( number == 6 && KEYFRAME ){
			objPlayer.HP -= 30;
			sound_play(sndHit05);
			Blood(check.x,check.y,20,0.1,0.5,0,180,5,10,c_red);
			quake(20,10);
			BIND_POSITION(05,0,-30);
			BIND_OFF();
			if(objPlayer.HP < 0){
				blood = Lotion(objPlayer,0,0,random(180),random(10));
				blood.image_blend = c_red;
				blood = Lotion(objPlayer,0,0,random(180),random(10));
				blood.image_blend = c_red;
				blood = Lotion(objPlayer,0,0,random(180),random(10));
				blood.image_blend = c_red;
				objPlayer.free_motion = false;
				force_other_motion(objPlayer,DAMAGE_CUTTER[2],14,1);
			}
		}else if( number < 6 ){
			with(objPlayer){
				Parts[4].depth_mode = true; Parts[4].depth = other.depth-1;
				Parts[5].depth_mode = true; Parts[5].depth = other.depth-1;
				Parts[8].depth_mode = true; Parts[8].depth = other.depth-1;
			}
			Parts[05].depth_mode = true; Parts[05].depth = objPlayer.depth+1;
			BIND_POSITION(05);
		}
		break;
	case 8 : 	/* -------------カウンター------------- */
		switch(number){
			case 1 : 
			case 2 : 
			case 3 : 
				INV = 30;
				if(CATCH) force_motion(8,6,1);
				break;
			case 5 : force_motion(0,0,3);
				break;
			case 6 :
			case 7 :
			case 8 :
				MOVE(15*image_xscale,0);
				break;
			case 9 :
				if(random(100)<50) force_motion(7,0,3);
				break;	 			
		}
		break;
}