/*-----d͐ݒ--------------------------*/
GSet(global.G,global.Gdir,0.95,1,0,0.95,1,1);

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);
}

switch(MotionNum){
	case STAND :
		break;
	case WALK : 
		switch(KeyFrmNum){
			case  3 : 
			case  4 : 
			case  5 : 
			case  6 : Move(-5.0*Direction,0); break;
		}
		break;
}

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

			/* ߂Â */
			if( !air && 100<playerDistance && playerDistance<350) MotionChange(WALK,0,2);

			/* Ȃɋ߂ÂU */
			if( !air && 120>playerDistance ) MotionChange(ATTACK,0,5);

			break;
		case WALK : 
			switch(KeyFrmNum){
				case  1 : Move(-2.0*Direction,0); break;
				case  2 : Move(-4.0*Direction,0); break;
				case  6 : if(KEYFRAME) MotionChange(MotionNum,3,3); break;
			}
			/* ߂Â */
			if( !air && playerDistance>350) MotionChange(STAND,0,5);

			/* Ȃɋ߂ÂU */
			if( !air && 180>playerDistance ) MotionChange(ATTACK,2,5);
			break;
		case ATTACK :
			switch(KeyFrmNum){
				case 3 : Move(-1.0*Direction,0); break;
				case 4 : Move(-2.0*Direction,0); break;
				case 5 : 
					Move(-2.0*Direction,0);
					if(KEYFRAME){
						sound_play(sndSwing00);
						with( collision_circle( x-96*Direction, y, 80,objPlayerDoll,0,1) ){
							if(!INV && !BINDED){
								DamageVoiceRandom_Mid();
								if(Direction!=other.Direction)	addDamage(10,FLYING_0, 0, 1, FLYING_0, 0, 2);
								else							addDamage(10,FLYING_1, 0, 1, FLYING_1, 0, 2);
								hspeed = 50*other.Direction*-1;
								vspeed = -6;
								sound_play(sndHit00);
								Quake(15,15);
							}
						}
					}
					break;
				case 6 : Move(-1.0*Direction,0); break;
				case 7 : Move(-0.5*Direction,0); 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,x,y,1,make_color_rgb(163,73,164));
				Flash(c_white,0.1,0.05);
				Fluid(x,y-64,make_color_rgb(163,73,164),35,5,20,0,180,0.5);
				Quake(5,5);
				sound_play(sndFluid);
				instance_destroy();
			}
			break;
	}
}