/*-----d͐ݒ--------------------------*/
hspeed = 0;
if( air ){
	gravity = global.G;
	gravity_direction = global.Gdir;
}else{
	gravity = 0;
	gravity_direction = 0;
}

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);
}
Process[ProcessNum[PARTS_BODY]].sprite_index = global.EnemySprite[index,SPRITE_BODY];

if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			with(Draw[DrawNum[PARTS_BODY]]){ if(image_alpha < 1) image_alpha += 0.1; }

			if(!air && global.PlayerHP>0){
				if(playerDistance<150){
					MotionChange(VORE,0,5);
					break;
				}
			}
			break;
		case VORE :
			switch(KeyFrmNum){
				case 6 : 
					if(KEYFRAME){
						col = collision_circle( x, y, 128, objPlayerDoll,0,1);
						with(col){
							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 = 2*other.Direction*-1;
								vspeed = -18;
								sound_play(sndBulletHit);
								Quake(15,5);
								with(other){ MotionChange(VORE2,0,10); break; }
							}
						}
					}
					break;
			}
			if(MOTIONEND){
				MotionChange(STAND,0,10);
			}
			break;
		case VORE2 :
			switch(KeyFrmNum){
				case 4 : 
					if(KEYFRAME){
						col = collision_circle( x, y-48, 70, objPlayerDoll,0,1);
						with(col){
							if(!INV && !BINDED){
								with(other){
									startBind( col,BIND_VORE3,0,other.BINDED_VOREPLANT_VORE3,0,1 );
									MotionChange( VORE3 , 0 , 1 );
									sound_play(sndLotion);
									sound_play(sndVore01);
									Fluid(x,y-100,c_white,25,5,10,45,90,0.5);
								}
								Direction = other.Direction;
								Quake(5,5);
							}
						}
					}
					break;
			}
			if(MOTIONEND){
				MotionChange(STAND,0,10);
			}
			break;
		case VORE3 : 
			Process[ProcessNum[PARTS_BODY]].sprite_index = global.EnemySprite[index,SPRITE_BODY2];
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }
			with(Draw[DrawNum[PARTS_BODY_INSIDE]]){ depth = objPlayerDoll.depth + 1000; }
			if(MOTIONEND){
				with(objPlayerDoll){
					with(other){
						VoreVoiceRandom_Mid();
						startBind( objPlayerDoll,BIND_VORE3_2,0,other.BINDED_VOREPLANT_VORE3_2,0,1 );
						MotionChange( VORE3_2 , 0 , 1 );
						Fluid(x,y-100,c_white,25,5,10,45,90,0.5);
					}
					Direction = other.Direction;
					Quake(25,15);
					sound_play(sndVore04);
					Flash(c_red,1,0.05);
				}
			}
			break;
		case VORE3_2 : 
			Process[ProcessNum[PARTS_BODY]].sprite_index = global.EnemySprite[index,SPRITE_BODY2];
			addDamage(0.1,-1, -1, -1, -1, -1, -1);
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }
			with(Draw[DrawNum[PARTS_BODY_INSIDE]]){ depth = objPlayerDoll.depth + 1000; }

			if(global.PlayerHP<=0){
				VoreVoiceRandom_High();
				Flash(c_red,1,0.001);
				sound_play(sndVore04);
				MotionChange(VORE_FINISH,0,1);
				startBind( objPlayerDoll,BIND_VORE3_2,0,-1,-1,-1);
			}

			if(MOTIONEND){
				VoreVoiceRandom_Mid();
				Quake(10,10);
				sound_play(sndLotion);
				sound_play(sndVore01);
				addDamage(5,-1, -1, -1, -1, -1, -1);
				MotionChange(VORE3_2,0,1);
				startBind( objPlayerDoll,BIND_VORE3_2,0,-1,-1,-1);
				Flash(c_red,0.5,0.01);
				Fluid(x,y-100,c_white,5,5,10,45,90,0.5);
			}
			if(BindTarget){
				if(!BindTarget.BINDED){
					MotionChange(STAND,0,5);
					with(BindTarget){
						y -= 64;
						hspeed = 8*(-1+2*round(random(1)));
						vspeed = -25;
						MotionChange(FLYING_SPIN,0,2);
					}
					endBind();
				}
			}
			break;
		case VORE_FINISH : 
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }
			with(Draw[DrawNum[PARTS_BODY_INSIDE]]){ depth = objPlayerDoll.depth + 1000; }

			if(MOTIONEND){
				MotionChange(VORE_FINISH,9,1);
			}
			break;
		case DEAD_MOTION : 
			if(MOTIONEND){
				effect_create_above(ef_explosion,x,y-64,2,c_olive);
				Flash(c_white,0.1,0.05);
				Fluid(x,y-64,c_green,35,5,20,0,180,0.5);

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