/*-----重力設定--------------------------*/
speed = 0; /* 動かないし！ */

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

/*-----キャラクタとの情報の取得---------------*/
playerDistance = point_distance(x,y,objPlayerDoll.x,objPlayerDoll.y);
playerDirection = point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y);

/*-----モーション毎の処理--------------------*/
DAMAGE_ACTIVE = 0;
DepthSet(-30000);

switch(MotionNum){
	case CATCH:
		with(objController){
			with(CtrlTarget){
				global.BindMax = 10+0.1*(100-global.PlayerHP);
				if( other.BindCounter>10+0.1*(100-global.PlayerHP) ){
					other.BindCounter = 0;
					move_outside_afterBind();
					BINDED = 0;
				}
			}
		}
		break;
}

if(!ChangeMotion){
	switch(MotionNum){
		case WAIT :
			col = collision_rectangle( x,y,x+32,y+256,objPlayerDoll,0,1);
			with(col){
				addDamage(5,-1,-1,-1,-1,-1,-1);
				VoreVoiceRandom_Mid();
				Quake(15,15);
				with(other){
					startBind( objPlayerDoll,BIND_CATCH,0,other.BINDED_MEATWALLHOLE_CATCH,0,1 );
					MotionChange(CATCH,0,1);
				}
			}
			break;
		case CATCH :
			if(BindTarget){
				if(!BindTarget.BINDED && !isGameOver()){
						DamageVoiceRandom_Low();
						with(BindTarget){
							MotionChange(FLYING_SPIN,0,1);
							vspeed = -20;
							hspeed = 2*(-1+2*round(random(1)));
						}
						endBind();
						MotionChange(WAIT,0,20);
						break;
				}
			}
			with(BindTarget){
				if(KEYFRAME){
					switch(KeyFrmNum){
						case 2:
						case 5:
						case 8:
						case 10:
						case 13:
							Quake(15,15);
							VoreVoiceRandom_Mid();
							break;
					}
				}
				if(MOTIONEND){
					VoreVoiceRandom_High();
					Flash(COLOR_BLOOD,1.0,0.001);
					Quake(35,25);
					MotionChange(MotionNum,13,1000000);
					with(other){
						sound_play(sndVore04);
						global.GameOver = true;
						MotionChange(FINISH,0,10);
					}
				}
			}
			if(MOTIONEND){
				Quake(5,15);
				switch(irandom(2)){
					case 0: sound_play(sndVore01);break;
					case 1: sound_play(sndVore02);break;
					case 2: sound_play(sndVore03);break;
				}
			}
			break;
		case FINISH :
			with(BindTarget){ MotionChange(MotionNum,13,1000000); }
			if(MOTIONEND){
				MotionChange(FINISH,4,6);
				Quake(5,5);
				switch(irandom(2)){
					case 0: sound_play(sndVore01);break;
					case 1: sound_play(sndVore02);break;
					case 2: sound_play(sndVore03);break;
				}
			}

			global.PlayerHP -= 0.5;
			if(!FinishFlag && global.PlayerHP<0){
				sound_play(sndEbara);
				FinishFlag = true;
				SpecialVoice(V_MUGU,10);
				Flash(COLOR_BLOOD,1.0,0.0001);
				Quake(15,300);
			}
			repeat(FinishFlag*random(3)){
				effect_create_below(ef_smokeup,x+24-8+random(16),y+32-8+random(16),0,c_white);
			}
			break;
	}
}