/*-----d͐ݒ--------------------------*/
GSet(global.G,global.Gdir,0.1,1,0,0,0.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){
	if(!INV) playEnemySound(SOUND_DAMAGE1);
	else	 playEnemySound(SOUND_DAMAGE2);
}

switch(MotionNum){
	case CATCH :
		DepthSet(objPlayerDoll.depth - 1000);
		with(objController){
			with(CtrlTarget){
				if( other.BindCounter>10 ){
					other.BindCounter = 0;
					move_outside_afterBind();
					BINDED = 0;
				}
			}
			BindCounter -= 0.20 ;
		}
		break;
}

INV = 1;
if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			if( !air && collision_line(x,y,x-Direction*300,y,objPlayerDoll,0,1)) MotionChange(ATTACK,0,2);
			break;
		case ATTACK : 
			INV = 0;
			switch(KeyFrmNum){
				case  1 : HitFlag = 0; break;
				case  2 : Move(-25*Direction,0);
				case  3 : Move(-13*Direction,0);
				case  4 : Move(- 5*Direction,0);
					if(KEYFRAME && !HitFlag){
						with( collision_circle( x, y, 32,objPlayerDoll,0,1) ){
							if(!INV && !BINDED){
								with(other){ HitFlag = 1; }
								if(Direction!=other.Direction){
									DamageVoiceRandom_Mid();
									with(other){
										startBind( objPlayerDoll,0,BIND_CATCH,other.BINDED_SHELL_CATCH,0,1 );
										MotionChange(CATCH,0,1);
									}
								}else{
									VoreVoiceRandom_Mid();
									Direction = other.Direction*-1;
									with(other){
										startBind( objPlayerDoll,0,BIND_CATCH,other.BINDED_SHELL_CATCH,0,1 );
										MotionChange(CATCH,0,1);
										chk = 0;
										with(objController){ other.chk = BindCounter; }
									}
								}
								Quake(15,15);
							}
						}
					}
					break;
				case  5 : if(KEYFRAME) playEnemySound(SOUND_ATTACK); break;
			}
			if(MOTIONEND) MotionChange(STAND,0,20);
			break;
		case CATCH:
			chk = 0;
			with(objController){ other.chk = 30+BindCounter; }
			if(BindTarget){
				if(!BindTarget.BINDED){
						DamageVoiceRandom_Low();
						with(BindTarget){ MotionChange(STAND_0,0,2); }
						endBind();
						MotionChange(CATCH,5,2);
						break;
				}
			}
			if(KeyFrmNum<5){
				if(35<chk && chk<= 40){ Quake(0.10, 2);MotionChange(CATCH,0, 5); with(BindTarget){MotionChange(BINDED_SHELL_CATCH,0, 5);} }
				if(30<chk && chk<= 35){ Quake(0.10, 5);MotionChange(CATCH,1,10); with(BindTarget){MotionChange(BINDED_SHELL_CATCH,1,10);} }
				if(25<chk && chk<= 30){ Quake(0.25,15);MotionChange(CATCH,2,20); with(BindTarget){MotionChange(BINDED_SHELL_CATCH,2,20);} }
				if(20<chk && chk<= 25){ Quake(0.50,15);MotionChange(CATCH,3,20); with(BindTarget){MotionChange(BINDED_SHELL_CATCH,3,20);} }
				if( 0<chk && chk<= 20){ Quake(0,50, 5);MotionChange(CATCH,4,10); with(BindTarget){MotionChange(BINDED_SHELL_CATCH,4,10);} }
				if( 0>=chk) 		  { MotionChange(CATCH,5, 2); with(BindTarget){MotionChange(BINDED_SHELL_CATCH,5, 2);} }
				if(KeyFrmNum==4 && KEYFRAME) DamageVoiceRandom_Low();
			}else{
				switch(KeyFrmNum){
					case  6 : 
						if(KEYFRAME){
							Quake(15,5);
							playEnemySound(SOUND_ATTACK);
							VoreVoiceRandom_Mid();
						}
						break;
				}
			}
			if(MOTIONEND){
				if(BindTarget){
					MotionChange(CATCH,7,1);
					with(BindTarget){MotionChange(BINDED_SHELL_CATCH,7,1);}
				}else{
					MotionChange(STAND,0,10);
				}
			}
			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;
	}
}