/*-----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){
	if(!ChangeMotion){
		switch(MotionNum){
			case STAND :
			case DODGE :
				MotionChange(DODGE,1,2);
				break;
			default :
				Fluid(x, y,make_color_rgb(163,73,164),5,0,5,90,360,0.75);
				playEnemySound(SOUND_DAMAGE);
				break;
		}
	}
}

INV = 0;
if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			INV = 1;

			/* ̕ */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			/* ߂Â */
			if( !air && 100<playerDistance && playerDistance<350){
				switch(irandom(1)){
					case 0: MotionChange(JUMPATTACK,0,5); break;
					case 1: MotionChange(TACKLE,0,5);     break;
				}
			}
			break;

		case JUMPATTACK:
			switch(KeyFrmNum){
				case  1 : HitFlag = 0; break;
				case  5 : 
				case  6 : 
					if(HitFlag) Fluid(Process[PARTS_HAND_ABOVE].x, Process[PARTS_HAND_ABOVE].y-24,COLOR_BLOOD,15,0,5,90,Direction*-180,1.0);
					if(KEYFRAME && !HitFlag){
						with( collision_circle( Process[PARTS_HAND_ABOVE].x, Process[PARTS_HAND_ABOVE].y+64, 64,objPlayerDoll,0,1) ){
							if(!INV && !BINDED){
								with(other){ HitFlag = 1; }
								if(Direction!=other.Direction)	addDamage(30,DOWN_1, 0, 2, DOWN_1, 0, 2);
								else							addDamage(30,DOWN_1, 0, 2, DOWN_1, 0, 2);
								hspeed = -10*other.Direction*-1;
								sound_play(sndHit02);
								Quake(15,15);

								if(global.PlayerHP>0) DamageVoiceRandom_Mid();
								else{
									Macro_CutHead();
									with(other){ playEnemySound(SOUND_HEAD); }
								}
							}
						}
					}
					break;
			}

			switch(KeyFrmNum){
				case  3 : if(place_free(x-20*Direction,y)) x -= 30.0*Direction; break;
				case  4 : if(place_free(x-20*Direction,y)) x -= 30.0*Direction; break;
				case  5 : if(KEYFRAME){ playEnemySound(SOUND_STEP); sound_play(sndSwing01); }
						  if(place_free(x-3*Direction,y)) x -= 15.5*Direction;
				case  6 : if(place_free(x-3*Direction,y)) x -= 10.5*Direction; break;
				case  7 : if(place_free(x-3*Direction,y)) x -=  8.5*Direction; break;
				case  8 : if(place_free(x-3*Direction,y)) x -=  6.5*Direction; break;
				case  9 : if(place_free(x-3*Direction,y)) x -=  4.5*Direction; break;
			}
			if(MOTIONEND) MotionChange(STAND,0,5);
			break;
		case TACKLE:
			switch(KeyFrmNum){
				case 1 : HitFlag = 0; break;
				case 3 : 
				case 4 : 
				case 5 : 
					if(!HitFlag){
						depth = objPlayerDoll.depth - 1000;
						for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }
						with( collision_circle( x,y+48, 24,objPlayerDoll,0,1) ){
							other.HitFlag = 1;
							if(!INV && !BINDED){
								sound_play(sndHit00);
								Quake(15,15);
								HitStop(5,null);
								if(Direction!=other.Direction)	addDamage(20,FLYING_0, 0, 1, FLYING_0, 0, 2);
								else							addDamage(20,FLYING_1, 0, 1, FLYING_1, 0, 2);
								if(global.PlayerHP<0 && objPlayerDoll.HEAD.image_alpha){
									VoreVoiceRandom_Mid();
									with(other){
										if(Direction!=other.Direction)	startBind( objPlayerDoll,0,BIND_TACKLE_FINISH,other.BINDED_SLIME_MEDIUM_ATTACKHIT,0,1 );
										else							startBind( objPlayerDoll,0,BIND_TACKLE_FINISH,other.BINDED_SLIME_MEDIUM_ATTACKHIT2,3,1 );
										MotionChange(TACKLE_FINISH,0,1);
									}
								}else{
									DamageVoiceRandom_High();
									hspeed = 50*other.Direction*-1;
									vspeed = -6;
								}
							}
						}
					}
					break;
			}
			switch(KeyFrmNum){
				case  3 : if(place_free(x-50*Direction,y)) x -= 50.0*Direction; break;
				case  4 : if(place_free(x-50*Direction,y)) x -= 40.0*Direction; break;
				case  5 : if(KEYFRAME) playEnemySound(SOUND_STEP);
						  if(place_free(x-50*Direction,y)) x -= 15.5*Direction; break;
				case  6 : if(place_free(x-50*Direction,y)) x -= 10.5*Direction; break;
				case  7 : if(place_free(x-50*Direction,y)) x -=  8.5*Direction; break;
				case  8 : if(place_free(x-50*Direction,y)) x -=  6.5*Direction; break;
				case  9 : if(place_free(x-50*Direction,y)) x -=  4.5*Direction; break;
			}
			if(MOTIONEND) MotionChange(STAND,0,5);
			break;
		case TACKLE_FINISH:
			depth = objPlayerDoll.depth + 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }
			Process[PARTS_BODYTOP    ].depth = objPlayerDoll.depth - 1000;
			Process[PARTS_BODYBOTTOM ].depth = objPlayerDoll.depth - 1001;
			Process[PARTS_ARM1_ABOVE ].depth = objPlayerDoll.depth - 1006;
			Process[PARTS_ARM2_ABOVE ].depth = objPlayerDoll.depth - 1007;
			Process[PARTS_HAND_ABOVE ].depth = objPlayerDoll.depth - 1008;
			Process[PARTS_LEG1_ABOVE ].depth = objPlayerDoll.depth - 1002;
			Process[PARTS_LEG2_ABOVE ].depth = objPlayerDoll.depth - 1003;
			Process[PARTS_FOOT1_ABOVE].depth = objPlayerDoll.depth - 1004;
			Process[PARTS_FOOT2_ABOVE].depth = objPlayerDoll.depth - 1005;

			switch(KeyFrmNum){
				case 1 :if(place_free(x-30*Direction,y)) x -= 20.0*Direction; break;
				case 2 :if(place_free(x-30*Direction,y)) x -= 10.0*Direction; break;
				case 3 :if(place_free(x-30*Direction,y)) x -=  5.0*Direction; break;
				case 4 :if(place_free(x-30*Direction,y)) x -=  2.0*Direction; break;
				case 7 :
					Flash(c_red,0.7,0.1);
					Quake(10,10);
					if(KEYFRAME){
						DamageVoiceRandom_High();
						SpecialVoice(V_MUSE,0);
						with( objPlayerDoll ){
							PartsDamage(objCommon_Body,-100,0);
							PartsBloodDamage(objCommon_Body,-100,0);
							PartsBloodDamage(objCommon_Head,-100,0);
						}
						sound_play(sndGusha);
						if(Direction!=objPlayerDoll.Direction)	with( objPlayerDoll ){ MotionChange(DEATHPRESS_DOWN_0,0,1); }
						else									with( objPlayerDoll ){ MotionChange(DEATHPRESS_DOWN_1,3,1); }
					}
					break;
				case 8 : Fluid(Process[PARTS_HAND_BELOW].x, Process[PARTS_HAND_BELOW].y-24,COLOR_BLOOD,15,5,15,70,40,1.0);
				case 12 :
					Quake(10,10);
					if(KEYFRAME){
						with( objPlayerDoll ){
							DamageVoiceRandom_Low();
							PartsDamage(objCommon_Body,-100,0);
							PartsBloodDamage(objCommon_Body,-100,0);
							PartsBloodDamage(objCommon_Head,-100,0);
						}
						playEnemySound(SOUND_HEAD);
						if(Direction!=objPlayerDoll.Direction)	with( objPlayerDoll ){ MotionChange(DEATHPRESS_DOWN_0,0,1); }
						else									with( objPlayerDoll ){ MotionChange(DEATHPRESS_DOWN_1,3,1); }
					}
					break;
				case 13 :
				case 14 :
					Fluid(Process[PARTS_HAND_BELOW].x-32*Direction,Process[PARTS_HAND_BELOW].y,COLOR_BLOOD,5,0,5,0,360,0.5);
					break;
			}
			if(MOTIONEND) MotionChange(STAND_WAIT,0,5);
			break;
		case DODGE:
			INV = 1;
			switch(KeyFrmNum){
				case  1 : if(place_free(x-60*Direction,y)) x -= 60.0*Direction; break;
				case  2 : if(place_free(x-60*Direction,y)) x -= 50.0*Direction; if(KEYFRAME) playEnemySound(SOUND_STEP); break;
				case  3 : if(place_free(x-60*Direction,y)) x -= 40.0*Direction; break;
				case  4 : if(place_free(x-60*Direction,y)) x -= 10.0*Direction; break;
			}
			if(MOTIONEND) MotionChange(STAND,0,1);
			break;
		case DEAD_MOTION :
			if(KeyFrmNum==1 && KEYFRAME){
				sound_play(sndHit02);
				Fluid(x,y,make_color_rgb(163,73,164),35,5,20,0,180,0.5);
				Quake(5,5);
			}
			if(MOTIONEND){
				effect_create_above(ef_explosion,Process[PARTS_BODYTOP].x,Process[PARTS_BODYTOP].y,1,make_color_rgb(163,73,164));
				Flash(c_white,0.1,0.05);
				Fluid(Process[PARTS_BODYTOP].x,Process[PARTS_BODYTOP].y-64,make_color_rgb(163,73,164),35,5,20,0,180,0.5);
				Quake(5,5);
				sound_play(sndFluid);
				instance_destroy();
			}
			break;
	}
}