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

with(objEnemyEdit){ if(Edit_Play) exit; }

/*-----LN^Ƃ̏̎擾---------------*/
PlayerNext_x = objPlayerDoll.x + (objPlayerDoll.x-objPlayerDoll.xprevious)*10;
playerDistance = point_distance(x,y,PlayerNext_x,objPlayerDoll.y);
playerDirection = point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y);

/*-----[V̏--------------------*/
if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			/* ̕ */
			if(PlayerNext_x > x) Direction = Right;
			else Direction = Left;

			/* ݍ */
			if( !air && 96>playerDistance){ MotionChange(ATTACK,1,2); break; }

			/* ߂Â */
			if( !air && playerDistance<400){ MotionChange(WALK,0,3); break; }
			break;
		case WALK :
			/* ̕ */
			if(PlayerNext_x > x) Direction = Right;
			else Direction = Left;

			switch(KeyFrmNum){
				case 1 : Move(-0.3*Direction,0); break;
				case 2 : Move(-3.5*Direction,0); break;
				case 3 : Move(-12.0*Direction,0); break;
				case 4 : Move(-0.2*Direction,0); break;
				case 5 : Move(-2.5*Direction,0); break;
				case 6 : Move(-6.0*Direction,0); break;
			}

			/* ݍ */
			if( !air && 200>playerDistance){ MotionChange(ATTACK,1,2); break; }

			/* ߂Â藣ꂽ肵~܂ */
			if( 100>playerDistance || playerDistance>400){ MotionChange(STAND,0,3); break; }
			break;
		case ATTACK :
			switch(KeyFrmNum){
				case 3 : Move(-2.0*Direction,0); break;
				case 4 : Move(-4.0*Direction,0); break;
				case 5 : Move(-6.0*Direction,0); break;
				case 6 : Move(-25.5*Direction,0); break;
				case 7 : Move(-15.5*Direction,0); break;
				case 8 : 
						Move(-1.5*Direction,0);
						if(KEYFRAME){
							col = collision_circle(Process[PARTS_MOUTH].x-32*Direction,Process[PARTS_MOUTH].y,64,objPlayerDoll,0,0);
							with(col){
								if(!INV && !BINDED){
									VoreVoiceRandom_Mid();
									with(other){
										MotionChange( VORE , 0 , 1 );
										startBind( col,BIND_VORE,1,other.BINDED_RAMDA,0,1 );
									}
									addDamage(10,-1, -1, -1, -1, -1, -1);
									sound_play(sndLotion);
									sound_play(sndVore03);
									Quake(5,5);
									hspeed = other.Direction*-10;
								}
							}
						}
						break;
			}
			if(MOTIONEND){ MotionChange(STAND,0,5); }
			break;
		case VORE : 
			with(BindTarget){
				if(!BINDED){
					HEAD.visible = 1;
					with(objCommon_Head){ visible = 1; }
					MotionChange(RISE_1_DAMAGE_BACK,5,2);
					with(other){ MotionChange(STAND,0,10); endBind(); }
				}
			}
			if(BindTarget){
				if(!BindTarget.BINDED){
					MotionChange(STAND,0,10);
					with(BindTarget){
						HEAD.visible = 1;
						with(objCommon_Head){ visible = 1; }
						MotionChange(RISE_1_DAMAGE_BACK,5,2);
					}
					endBind();
				}
			}
			addDamage(0.2,-1, -1, -1, -1, -1, -1);
			DepthSet(objPlayerDoll.depth - 1000);

			if(global.PlayerHP<=0){
				VoreVoiceRandom_High();
				Flash(c_red,1,0.01);
				sound_play(sndVore02);
				MotionChange(VORE_FINISH,0,2);
				startBind( col,BIND_VORE_FINISH,0,objPlayerDoll.BINDED_RAMDA_FINISH,0,1);
			}
			if(MOTIONEND){
				VoreVoiceRandom_Low();
				Quake(5,5);
				sound_play(sndVore03);
				addDamage(1,-1, -1, -1, -1, -1, -1);
				MotionChange(VORE,9,1);
				startBind( col,BIND_VORE,9,-1,-1,-1);
			}
			with(BindTarget){
				HEAD.visible = 0;
				with(objCommon_Head){ visible = 0; }
			}
			break;
		case VORE_FINISH : 
			if(BindTarget) BindTarget.Direction = Direction*-1;
			DepthSet(objPlayerDoll.depth - 1000);

			with(BindTarget){
				HEAD.visible = 1;
				with(objCommon_Head){ visible = 1; }
			}
			switch(KeyFrmNum){
				case 10 :	case 11 :	case 12 :	
					if(DrawAlpha>0.4) DrawAlpha -= 0.03;	break;
				case 13 :	case 14 :	case 15 :	case 16 :	case 17 :	
					DrawAlpha = 0.4;			break;
				case 18 :	case 19 :	case 20 :	
					if(DrawAlpha<1.0) DrawAlpha += 0.02;	break;
				default : 
					with(BindTarget){
						HEAD.visible = 0;
						with(objCommon_Head){ visible = 0; }
					}
					break;
			}
			if(KEYFRAME){
				switch(KeyFrmNum){
					case 6 : sound_play(sndVore01);Quake(15,15);Flash(c_red,1,0.05);	break;
					case 13 : sound_play(sndVore04);Quake(25,15);Flash(c_red,3,0.01);	break;
				}
			}
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ image_alpha=other.DrawAlpha ; }

			if(MOTIONEND){
				Quake(5,5);
				with(BindTarget){ MotionChange(BINDED_RAMDA_FINISH,19,1); }
				MotionChange(VORE_FINISH,19,1);
				startBind( BindTarget,BIND_VORE_FINISH,19,-1,-1,-1);
			}
			break;
		case DEAD_MOTION :
			if(MOTIONEND){
				effect_create_above(ef_explosion,x,y,1,c_green);
				Flash(c_white,0.1,0.05);
				Fluid(x,y,c_lime,25,5,20,0,180,0.5);

				Quake(5,5);
				sound_play(sndFluid);
				playEnemySound(SOUND_DEATH);
				instance_destroy();
			}
			break;
	}
}