/*-----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){
	if(!INV) playEnemySound(SOUND_DAMAGE1);
	else	 playEnemySound(SOUND_DAMAGE2);
}

switch(MotionNum){
	case CATCH :
		DepthSet(objPlayerDoll.depth - 1000);
		with(objPlayerDoll){
			HAND1_ABOVE.depth = other.Process[other.PARTS_TOP].depth-1002;
			HAND2_ABOVE.depth = other.Process[other.PARTS_TOP].depth-1001;
			HAND3_ABOVE.depth = other.Process[other.PARTS_TOP].depth-1000;
			other.Process[other.PARTS_BOTTOM].depth = HAND1_ABOVE.depth-1000;
		}
		if(BindTarget){
			if(KeyFrmNum>6){
				with(objCommon_Head){ visible = false; }
				with(objCommon_Body){ visible = false; }
				with(objController){
					if( global.PlayerHP && (left==2 || right==2 || up==2 || down==2 || b1==2 || b2==2 || b3==2) ){
						with(CtrlTarget){
							MotionChange(MotionNum,9+irandom(4),5+irandom(10));
						}
					}
					with(CtrlTarget){
						if(MOTIONEND) MotionChange(MotionNum,9,10000);
					}
				}
			}
		}
		with(objController){
			with(CtrlTarget){
				global.BindMax = 10;
				if( other.BindCounter>10 ){
					other.BindCounter = 0;
					move_outside_afterBind();
					BINDED = 0;
				}
			}
			addSTDamage(0,0.2,-1,-1,-1,-1,-1,-1);
			BindCounter -= 0.45 - (global.PlayerST/100)*0.2 ;
		}
		break;
}

INV = 1;
if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			if(KeyFrmNum>4) INV = 0;
			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(-35*Direction,0);
				case  3 : Move(-13*Direction,0);
				case  4 : Move(-8*Direction,0);
					if(KEYFRAME && !HitFlag){
						with( collision_circle( x-Direction*64, y, 32,objPlayerDoll,0,1) ){
							if(!INV && !BINDED){
								other.hspeed = other.x - other.xprevious;
								with(other){ HitFlag = 1; }
								if(Direction!=other.Direction){
									DamageVoiceRandom_Mid();
									with(other){
										sound_play(sndHit01);
										startBind( objPlayerDoll,0,BIND_CATCH,other.BINDED_SHELL_CATCH,0,1 );
										MotionChange(CATCH,0,1);
									}
								}else{
									DamageVoiceRandom_Mid();
									with(other){
										startBind( objPlayerDoll,0,BIND_CATCH,other.BINDED_SHELL_CATCH2,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){
				var tmpchk;
				tmpchk = 0;
				with(BindTarget){ if(MotionNum==BINDED_SHELL_CATCH2) tmpchk = 1; }
				if(tmpchk){
					MotionChange(CATCH,5, 2); with(BindTarget){MotionChange(MotionNum,5, 2);}
				}else{
					if(37<chk && chk<= 40){ Quake(0.10, 2);MotionChange(CATCH,0, 5); with(BindTarget){MotionChange(MotionNum,0, 5);} }
					if(35<chk && chk<= 37){ Quake(0.10, 5);MotionChange(CATCH,1,20); with(BindTarget){MotionChange(MotionNum,1,20);} }
					if(30<chk && chk<= 35){ Quake(0.25,15);MotionChange(CATCH,2,20); with(BindTarget){MotionChange(MotionNum,2,20);} }
					if(20<chk && chk<= 30){ Quake(0.50,15);MotionChange(CATCH,3,20); with(BindTarget){MotionChange(MotionNum,3,20);} }
					if( 0<chk && chk<= 20){ Quake(0,50, 5);MotionChange(CATCH,4,10); with(BindTarget){MotionChange(MotionNum,4,10);} }
					if( 0>=chk) 		  { 			   MotionChange(CATCH,5, 2); with(BindTarget){MotionChange(MotionNum,5, 2);} }
					if(KeyFrmNum==4 && KEYFRAME) DamageVoiceRandom_Low();
				}
			}else{
				switch(KeyFrmNum){
					case  6 : 
						if(KEYFRAME){
							Quake(15,5);
							playEnemySound(SOUND_ATTACK);
							if(BindTarget){
								global.GameOver = true;
								VoreVoiceRandom_Mid();
								with(objNana_Gun){
									if(!instance_exists(objGun)){
										new = instance_create(sprite_x[Gun],sprite_y[Gun],objGun);
										new.rot = sprite_angle[Gun];
									}
								}
							}
						}
						break;
					case 8 : 
						if(!BindTarget) MotionChange(STAND,0,10);
						break;
					case  9 :
						if(KEYFRAME){
							Flash(c_red,1.0,0.01);
							Quake(5,50);
							sound_play(sndEbara);
							VoreVoiceRandom_High();
						}
						with(BindTarget){MotionChange(MotionNum,7,1);}
					case 10 : 
					case 11 : 
						addDamage(0.5, -1, -1, -1, -1, -1, -1);
						if(FluidAmount && FluidAmount<100){
							repeat(FluidAmount*0.2){
								FluidWithScale(x-60+120*random(1),y,make_color_rgb(163,73,164),2,0,5,0,180,0.25,random(1.5),Process[PARTS_BOTTOM].depth+1);
							}
							effect_create_above(ef_smokeup,x-30+60*random(1),y+5,0,c_white);
							with(BindTarget){MotionChange(MotionNum,9+irandom(4),2+irandom(10));}
						}else{
							if(random(100)<5){
								if(random(100)<20) VoreSound();
								repeat(5){
									FluidWithScale(x-60+120*random(1),y,make_color_rgb(163,73,164),2,0,5,0,180,0.25,random(1.5),Process[PARTS_BOTTOM].depth+1);
								}
							}
							with(BindTarget){MotionChange(MotionNum,9+irandom(4),2+irandom(100));}
						}
						FluidAmount -= 0.2;
						break;
				}
			}
			if(MOTIONEND){
				MotionChange(CATCH,9,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,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;
	}
}