/*-----重力設定--------------------------*/
GSet(global.G,global.Gdir,0.95,1,0,0.95,1,1);

with(objEnemyEdit){ if(Edit_Play) exit; }
/*-----キャラクタとの情報の取得---------------*/
playerDistance = point_distance(x,y,objPlayerDoll.x,objPlayerDoll.y);
playerDirection = point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y);

/*-----モーション毎の処理--------------------*/
if(RECV_DAMAGE){
	playEnemySound(SOUND_DAMAGE);
}

INV = 1;
if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			MotionChange(WALK,0,2);
			break;
		case WALK : 
			if(Move(-15.0*Direction,0)){
				MotionChange(TURN,0,2);
			}else{
				if(random(100)<10){
					MotionChange(TACKLE,0,3);
				}
			}
			break;
		case TACKLE :
			switch(KeyFrmNum){
				case 4 :
					if(Move(-20.0*Direction,0)) MotionChange(TACKLE,8,1);
				case 5 :
					if(Move(-20.0*Direction,0)) MotionChange(TACKLE,8,1);
				case 6 :
					if(Move(-20.0*Direction,0)) MotionChange(TACKLE,8,1);
				case 7 :
					if(Move(-60.0*Direction,0)) MotionChange(TACKLE,8,1);
					break;
				case 8 :
					if(KEYFRAME){
						Quake(15,15);
					}
				case 9 :
				case 10 :
				case 11 :
					gravity = 0;
					speed   = 0;
					break;
			}
			if(MOTIONEND){
				MotionChange(WALK,1,1);
			}
			break;
		case TURN :
			switch(KeyFrmNum){
				case 12 :
					if(KEYFRAME){
						Move(300.0*Direction,0);
						Direction = Direction*-1;
						Move(-50.0*Direction,0);
					}
					break;
			}
			if(MOTIONEND){
				MotionChange(WALK,1,1);
				Move(-30.0*Direction,0);
			}
			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,2,make_color_rgb(163,73,164));
				Flash(c_white,0.1,0.05);
				Fluid(x,y,make_color_rgb(163,73,164),35,5,20,0,180,0.5);
				Quake(5,5);
				sound_play(sndFluid);
				instance_destroy();
			}
			break;
	}
}

HeadPosX = Process[ProcessNum[PARTS_HEAD]].x;
HeadPosY = Process[ProcessNum[PARTS_HEAD]].y;
with(HeadCollision){
	depth = -100000;
	x = other.HeadPosX;
	y = other.HeadPosY;
	if(HP<-300){
		with(other){
			HP = -1;
			MotionChange(DEAD_MOTION,0,10);
		}
	}
}