/*-----重力設定--------------------------*/
gravity = 0;
gravity_direction = 0;
speed = 0;

/*-----キャラクタとの情報の取得---------------*/
playerDistance = point_distance(x,y,objPlayerDoll.x,objPlayerDoll.y);
playerDirection = point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y);
gun_x = Process[ProcessNum[PARTS_GUN]].x;
gun_y = Process[ProcessNum[PARTS_GUN]].y;

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

/*-----飛び道具の処理--------------------*/
for(i=0;i<20;i+=1){
	with(Bullet[i]){
		image_angle = direction;
		if( checkBlock(x,y) ){
			var Num,VarianceX,VarianceY,Gravity,AngleMin,AngleRange,SpeedMin,SpeedRange,TimeMin,TimeRange;
			Num = 10+random(20);
			Gravity		= 1;
			VarianceX	= 8;
			VarianceY	= 8;
			AngleMin	= 180+direction-10;
			AngleRange	= 20;
			SpeedMin	= 0;
			SpeedRange	= 5;
			TimeMin		= 5;
			TimeRange	= 5;
			Spark(Num,VarianceX,VarianceY,Gravity,AngleMin,AngleRange,SpeedMin,SpeedRange,TimeMin,TimeRange);
			destroyBullet();
		}
		with(checkPlayer(x,y)){
			if(!INV && other.Time < 999999){
				DamageVoiceRandom_Low();
				if(BINDED) addDamage(5, -1, -1, -1, -1, -1, -1);
				else{
					addDamage(5,DAMAGE_0, 0, 1, DOWN_1, 0, 2); 
					hspeed = other.hspeed/10;
				}
				if(other.hspeed>0){
					Fluid(x,y,COLOR_BLOOD,10,2,10,90, 180,0.5);
				}else{
					Fluid(x,y,COLOR_BLOOD,10,2,10,90,-180,0.5);
				}
				Fluid(x,y,COLOR_BLOOD,20,5,15,direction-5,10,0.5);

				sound_play(sndBulletHit);
				Quake(5,5);
				other.Time = 999999;

				with(objExtParts){
					with(DrawTarget){
						PartsDamage(other.id,-random(15),0);
						PartsBloodDamage(other.id,-random(15),0);
					}
				}

				with(other){ speed *= 0.8+random(0.2);gravity = 0.3; }
			}
		}
		if(Time){
			new = instance_create(x,y,objLine);
			new.xpos = x-hspeed;
			new.ypos = y-vspeed;
		}
	}
}

for(i=0;i<6;i+=1){
	with(Pile[i]){
		depth = other.Process[other.PARTS_BODY].depth - 1000;
		image_angle = direction;
		if( checkBlockLine() && Time<9950){
			if(Flag[0]){
				SpecialVoice(V_MUSE,irandom(2));
				with(objCommon_Body){
					with(DrawTarget){
						PartsDamage(other.id,-random(100),0);
						PartsBloodDamage(other.id,-random(100),0);
					}
				}
				with(objPlayerDoll){
					if(other.hspeed){
						if(Direction) MotionChange(FINISHED_BOSSMACHINE_PILE_FRONT,0,1);
						else		   MotionChange(FINISHED_BOSSMACHINE_PILE_BACK,0,1);
					}else{
						if(Direction) MotionChange(FINISHED_BOSSMACHINE_PILE_BACK,0,1);
						else		   MotionChange(FINISHED_BOSSMACHINE_PILE_FRONT,0,1);
					}
				}
			}
			Quake(5,5); with(other){playEnemySound(SOUND_STEP);}
			var Num,VarianceX,VarianceY,Gravity,AngleMin,AngleRange,SpeedMin,SpeedRange,TimeMin,TimeRange;
			Num = 10+random(20);
			Gravity		= 1; VarianceX	= 8;
			VarianceY	= 8; AngleMin	= 180+direction-10;
			AngleRange	= 20; SpeedMin	= 0;
			SpeedRange	= 5; TimeMin		= 5;
			TimeRange	= 5; Spark(Num,VarianceX,VarianceY,Gravity,AngleMin,AngleRange,SpeedMin,SpeedRange,TimeMin,TimeRange);
			move_outside_solid(direction+180,speed);
			x = x - lengthdir_x(10,direction);
			y = y - lengthdir_y(10,direction);
			speed   = 0;
			gravity = 0;
			Time = 9950;
		}
		with(checkPlayer(x,y)){
			if(!INV && other.Time < 1000){
				if(BINDED) addDamage(10, -1, -1, -1, -1, -1, -1);
				else{
					addDamage(5,DAMAGE_0, 0, 1, FLYING_1, 0, 2); 
					hspeed = other.hspeed/10;
				}
				if(isGameOver()){
					other.Flag[0] = 1;
					other.Flag[1] = 100;
					DamageVoiceRandom_High();
				}else DamageVoiceRandom_Low();

				Fluid(x,y,COLOR_BLOOD,20,5,15,direction-5,    10,0.5);
				Fluid(x,y,COLOR_BLOOD,10,5,15,direction-5+180,10,0.5);

				sound_play(sndBulletHit);
				Quake(5,5);
				other.Time = 1000;

				with(objExtParts){
					with(DrawTarget){
						PartsDamage(other.id,-random(15),0);
						PartsBloodDamage(other.id,-random(15),0);
					}
				}
			}
		}
		if(Flag[0]){
			with(objPlayerDoll){
				mask_index = sprEmpty;
				INV = true;
				x = other.x-lengthdir_x(5,other.image_angle);
				y = other.y-lengthdir_y(5,other.image_angle);
				speed = 0;
				if(other.Flag[1]){
					Fluid(x,y,COLOR_BLOOD,other.Flag[1]/5,0,other.Flag[1]/4,other.image_angle-5,    10,0.5);
					Fluid(x,y,COLOR_BLOOD,other.Flag[1]/5,0,other.Flag[1]/4,other.image_angle-5+180,10,0.5);
					other.Flag[1] -= 1;
				}else{
					if(random(100)<10) Fluid(x,y,COLOR_BLOOD,1,0,3,other.image_angle-5,    10,0.5);
					if(random(100)<10) Fluid(x,y,COLOR_BLOOD,1,0,3,other.image_angle-5+180,10,0.5);
				}
			}
		}

		if(Time<9950){
			new = instance_create(x,y,objLine);
			new.xpos = x-hspeed;
			new.ypos = y-vspeed;
		}
		if(Time==10000){
			if(!Flag[0]) destroyBullet();
		}
	}
}

for(i=0;i<6;i+=1){
	with(Missile[i]){
		depth = other.Process[other.PARTS_BODY].depth - 1000;
		image_angle = direction;
		if( checkBlockLine() || Time==1000 || Time==2000){
			instance_create(x,y,objExplosionSmall);
			Flash(c_white,0.1,0.05);
			Quake(5,5);
			sound_play(sndBomb);
			destroyBullet();
		}
		if(Time<1000){
			if(HitCount!=0){
				Time = 1980;
				with(other){playEnemySound(SOUND_DAMAGE1);}
			}
			effect_create_above(ef_smoke,x-hspeed*2,y-vspeed*2,0,c_white);
			motion_add(point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y),0.2);
			if(speed>7) speed = 7;

			with(checkPlayer(x,y)){
				if(!INV){
					DamageVoiceRandom_Mid();
					if(BINDED) addDamage(10, -1, -1, -1, -1, -1, -1);
					else{
						if(x > other.x){
							if(Direction)	addDamage(10,FLYING_0, 0, 1, FLYING_0, 0, 2);
							else			addDamage(10,FLYING_1, 0, 1, FLYING_1, 0, 2);
							hspeed = 30;
							vspeed = -5;
						}else{
							if(!Direction)	addDamage(10,FLYING_0, 0, 1, FLYING_0, 0, 2);
							else			addDamage(10,FLYING_1, 0, 1, FLYING_1, 0, 2);
							hspeed = -30;
							vspeed = -5;
						}
					}

					with(objExtParts){
						with(DrawTarget){
							PartsDamage(other.id,-random(15),0);
							PartsBloodDamage(other.id,-random(15),0);
						}
					}
					with(other){
						Time = 999;
						instance_create(x,y,objExplosionSmall);
						Flash(c_white,0.1,0.05);
						Quake(5,5);
						sound_play(sndBomb);
					}
				}
			}
		}else if(Time<2000){
			gravity = 1;
			direction += -20+random(40);
			effect_create_above(ef_smokeup,x,y,0,c_black);
		}
	}
}

/*-----モーション毎の処理--------------------*/
Process[ProcessNum[PARTS_GUN]].PartPicture		= AnimationIndex;
Process[ProcessNum[PARTS_GUNFIRE]].PartPicture	= AnimationIndex;
Process[ProcessNum[PARTS_GUNFIRE]].image_alpha	= 0;

Counter+=1;

FootLTPosX = Process[ProcessNum[PARTS_FOOTLT]].x;
FootLTPosY = Process[ProcessNum[PARTS_FOOTLT]].y;
FootLBPosX = Process[ProcessNum[PARTS_FOOTLB]].x;
FootLBPosY = Process[ProcessNum[PARTS_FOOTLB]].y;
FootRTPosX = Process[ProcessNum[PARTS_FOOTRT]].x;
FootRTPosY = Process[ProcessNum[PARTS_FOOTRT]].y;
FootRBPosX = Process[ProcessNum[PARTS_FOOTRB]].x;
FootRBPosY = Process[ProcessNum[PARTS_FOOTRB]].y;

if(countLiveFoot){
	INV = 1;
	Process[ProcessNum[PARTS_BODY]].PartPicture = 0;
}else{
	INV = 0;
	Process[ProcessNum[PARTS_BODY]].PartPicture = 1 + (Counter mod 2);
}

if(RECV_DAMAGE){
	if(INV){
		if(GuideFlag<3 && MotionNum!=START_WAIT && !instance_exists(objGuide)){
			GuideFlag += 1;
			new = instance_create(x,y,objGuide);
			new.Target = FootCollisionLT;
			new = instance_create(x,y,objGuide);
			new.Target = FootCollisionRT;
			new = instance_create(x,y,objGuide);
			new.Target = FootCollisionLB;
			new = instance_create(x,y,objGuide);
			new.Target = FootCollisionRB;
		}
		playEnemySound(SOUND_DAMAGE2);
	}else	playEnemySound(SOUND_DAMAGE1);
}

/*足の衝突判定*/
with(FootCollisionLT){
	depth = -100000;
	x = other.FootLTPosX;
	y = other.FootLTPosY;
	if(!INV){
		if(RECV_DAMAGE) with(other){playEnemySound(SOUND_DAMAGE1)};
		RECV_DAMAGE = 0;

		if(HP< -300) effect_create_above(ef_smokeup,x+random(32),y-random(32),0,c_black);
		if(HP<-1200) effect_create_above(ef_smokeup,x+random(32),y-random(32),0,c_black);
		if(HP<-1500){
			other.countLiveFoot -= 1;
			INV = true;
			instance_create(x,y,objExplosionSmall);
			Flash(c_white,0.5,0.05);
			HitStop(40,null);
			Quake(15,5);
			sound_play(sndBomb);
			with( other ){
				if(countLiveFoot)	MotionChange(DROP_SMALL,0,1);
				else				MotionChange(DROP_LARGE,0,1);
			}
		}
	}else{
		if(!HP){
			effect_create_above(ef_smokeup,x+random(64),y-random(64),1,c_black);
		}
	}
}
with(FootCollisionLB){
	depth = -100000;
	x = other.FootLBPosX;
	y = other.FootLBPosY;
	if(!INV){
		if(RECV_DAMAGE) with(other){playEnemySound(SOUND_DAMAGE1)};
		RECV_DAMAGE = 0;

		if(HP< -300) effect_create_above(ef_smokeup,x+random(32),y-random(32),0,c_black);
		if(HP<-1200) effect_create_above(ef_smokeup,x+random(32),y-random(32),0,c_black);
		if(HP<-1500){
			other.countLiveFoot -= 1;
			INV = true;
			instance_create(x,y,objExplosionSmall);
			Flash(c_white,0.5,0.05);
			HitStop(40,null);
			Quake(15,5);
			sound_play(sndBomb);
			with( other ){
				if(countLiveFoot)	MotionChange(DROP_SMALL,0,1);
				else				MotionChange(DROP_LARGE,0,1);
			}
		}
	}else{
		if(!HP){
			effect_create_above(ef_smokeup,x+random(64),y-random(64),1,c_black);
		}
	}
}
with(FootCollisionRT){
	depth = -100000;
	x = other.FootRTPosX;
	y = other.FootRTPosY;
	if(!INV){
		if(RECV_DAMAGE) with(other){playEnemySound(SOUND_DAMAGE1)};
		RECV_DAMAGE = 0;

		if(HP< -300) effect_create_above(ef_smokeup,x-random(32),y-random(32),0,c_black);
		if(HP<-1200) effect_create_above(ef_smokeup,x-random(32),y-random(32),0,c_black);
		if(HP<-1500){
			other.countLiveFoot -= 1;
			INV = true;
			instance_create(x,y,objExplosionSmall);
			Flash(c_white,0.5,0.05);
			HitStop(40,null);
			Quake(15,5);
			sound_play(sndBomb);
			with( other ){
				if(countLiveFoot)	MotionChange(DROP_SMALL,0,1);
				else				MotionChange(DROP_LARGE,0,1);
			}
		}
	}else{
		if(!HP){
			effect_create_above(ef_smokeup,x-random(64),y-random(64),1,c_black);
		}
	}
}
with(FootCollisionRB){
	depth = -100000;
	x = other.FootRBPosX;
	y = other.FootRBPosY;
	if(!INV){
		if(RECV_DAMAGE) with(other){playEnemySound(SOUND_DAMAGE1)};
		RECV_DAMAGE = 0;

		if(HP< -300) effect_create_above(ef_smokeup,x-random(32),y-random(32),0,c_black);
		if(HP<-1200) effect_create_above(ef_smokeup,x-random(32),y-random(32),0,c_black);
		if(HP<-1500){
			other.countLiveFoot -= 1;
			INV = true;
			instance_create(x,y,objExplosionSmall);
			Flash(c_white,0.5,0.05);
			HitStop(40,null);
			Quake(15,5);
			sound_play(sndBomb);
			with( other ){
				if(countLiveFoot)	MotionChange(DROP_SMALL,0,1);
				else				MotionChange(DROP_LARGE,0,1);
			}
		}
	}else{
		if(!HP){
			effect_create_above(ef_smokeup,x-random(64),y-random(64),1,c_black);
		}
	}
}

/*ガトリングの制御*/
if(!ChangeMotion){
	switch(MotionNum){
		case START_WAIT :
			break;
		default :
			if( FootCollisionLB.HP + FootCollisionRB.HP + FootCollisionLT.HP + FootCollisionRT.HP > -1500 ) break;
			if(global.PlayerHP && objPlayerDoll.y > gun_y || AnimationIndex!=0){
				AnimationIndex += 1;
				if(AnimationIndex == 1) playEnemySound(SOUND_MOTOR);
				if(AnimationIndex > 40){
					Process[ProcessNum[PARTS_GUNFIRE]].image_alpha = 0.75;
					playEnemySound(SOUND_ATTACK);
					if(AnimationIndex mod 3 == 0){
						/* 弾の作成 */
						for(i=0;i<20;i+=1){
							if(!instance_exists(Bullet[i])){
								Bullet[i] = createBullet(gun_x+lengthdir_x(100,Process[ProcessNum[PARTS_GUN]].image_angle+180),gun_y+lengthdir_y(100,Process[ProcessNum[PARTS_GUN]].image_angle+180));
								Bullet[i].speed		= 60;
								Bullet[i].direction	= Process[ProcessNum[PARTS_GUN]].image_angle+180-random(5);
								Bullet[i].hspeed	*= Direction;
								Bullet[i].Picture	= -1;
								break;
							}
						}
					}
				}
				if( AnimationIndex > 120) AnimationIndex = 0;
			}
			break;
	}
}

/* 本体の制御(モーション中でも) */
switch(MotionNum){
	case ROLLER :
		DepthSet(objPlayerDoll.depth - 1000);
		Process[PARTS_BODY].image_alpha = 0.6;
		Process[PARTS_ROLLL].image_alpha = 1;
		Process[PARTS_ROLLR].image_alpha = 1;
	case WALKPRESS_1STSTEP :
	case WALKPRESS_2NDSTEP :
		DepthSet(objPlayerDoll.depth - 1000);
		break;
}

/*本体の制御*/
if(!ChangeMotion){
	switch(MotionNum){
		case START_WAIT :
			for(i=0;i<PARTS_MAX;i+=1) Process[ProcessNum[i]].image_blend = make_color_rgb(108,98,91);

			with(FootCollisionLT){ INV = true; }
			with(FootCollisionLB){ INV = true; }
			with(FootCollisionRT){ INV = true; }
			with(FootCollisionRB){ INV = true; }
			INV = true;
			FireDirection = 270;
			if(objPlayerDoll.y < 6048){
				for(i=0;i<PARTS_MAX;i+=1) Process[ProcessNum[i]].image_blend = c_white;
				with(FootCollisionLT){ INV = false; }
				with(FootCollisionLB){ INV = false; }
				with(FootCollisionRT){ INV = false; }
				with(FootCollisionRB){ INV = false; }

				with(objBossHealth){visible = true;}
				y = view_yview + 480+256;
				MotionChange(WALKUP,0,1);
				if(global.bgm==-1) global.bgm = bGM_play("Sound/BGM/Stage3_Boss.mp3", global.config_BGMVolume*0.5, true, 0.0, 1.0);
			}
			break;
		case DROP_LARGE :
			Mode = 1;
			switch(KeyFrmNum){
				case 1 : 
					if(KEYFRAME){
						Counter = 0;
						Flash_Rect(COLOR_BLOOD,0.5,0.05);
						with(objPassAbleBlock){
							instance_create(x,y,objGarekiHahen);
							instance_create(x,y,objGarekiHahen);
							instance_create(x,y,objGarekiHahen);
							instance_destroy();
						};
						new = instance_create(540,7812,objGareki);
						new.image_index = 0; new.image_speed = 0; new.depth = -900001;
						tile_layer_delete(-100);
						
					}
				case 2 : 
					y += Counter;
					break;
			}
			if(MOTIONEND || y > 7720){
				sound_play(sndEbara);
				y = 7720;
				MotionChange(DROP_SMALL,3,1);
			}
			break;
		case DROP_SMALL :
			switch(KeyFrmNum){
				case 1 : 
				case 2 : 
					y += 5;
					break;
				case 3 : 
					if(KEYFRAME){
						Quake(25,25);
						playEnemySound(SOUND_STEP);
						playEnemySound(SOUND_CLASH);
						break;
					}
					break;
			}
			if(MOTIONEND) MotionChange(STAND_C,0,2);
			break;
		case MISSILE_SHOT :
			switch(KeyFrmNum){
				case 2 : 
					if(KEYFRAME) sound_play(sndReload);
					break;
				case 4 :
				case 7 :
				case 10 :
					if(KEYFRAME){
						playEnemySound(SOUND_SHOT); Quake(5,5);
						for(m=0;m<2;m+=1){
							for(i=0;i<6;i+=1){
								if(!instance_exists(Missile[i])){
									Missile[i] = createBullet(x-48+96*m,y-128);
									Missile[i].speed		= 5;
									Missile[i].direction	= 60+m*60;
									Missile[i].hspeed		= Direction;
									Missile[i].Picture		= SPRITE_MISSILE;
									Missile[i].depth		= Process[ProcessNum[PARTS_BODY]].depth-1;
									Missile[i].mask_index	= sprMask32;
									break;
								}
							}
						}
					}
			}
			if(MOTIONEND) MotionChange(STAND_C,0,2);
			break;
		case STAND_C :
			with( collision_circle(x,y-200,16,objPlayerDoll,0,1) ){
				if(vspeed && !INV && !isGameOver() ){
					if(!BINDED){
						DamageVoiceRandom_Mid();
						sound_play(sndGishi00);
						Quake(15,15);
						with(other){
							startBind( objPlayerDoll,BIND_ROLLER,0,other.BINDED_BOSSMACHINE_ROLLER,0,1 );
							MotionChange(ROLLER,0,1);
						}
					}
				}
				break;
			}

			if(Mode==0){ /* 通常時 */
				if(collision_circle(x+ 40,y-200, 48,objPlayerDoll,0,1)){ MotionChange(DRILL_RIGHT,0,1);    break; }
				if(collision_circle(x-180,y-200, 48,objPlayerDoll,0,1)){ MotionChange(DRILL_LEFTUP,0,1);   break; }
				if(collision_circle(x-180,y    , 48,objPlayerDoll,0,1)){ MotionChange(DRILL_LEFTDOWN,0,1); break; }
				if(collision_circle(x- 40,y-200, 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_LEFT,0,1);    break; }
				if(collision_circle(x+180,y-200, 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_RIGHTUP,0,1);   break; }
				if(collision_circle(x+180,y    , 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_RIGHTDOWN,0,1); break; }
				if(random(100)<50){
					if(y-160 > objPlayerDoll.y){ /* キャラが上にいる */
						if(random(100)<70)	MotionChange(WALKUP,0,1);
						else				MotionChange(MISSILE_SHOT,0,1);
						break;
					}else{
						if(random(100) < 10){
							if(random(100)<80){ MotionChange(WALKUP,0,1); break; }
							else{ 				MotionChange(MISSILE_SHOT,0,1); break; }
						}
					}
					if(objPlayerDoll.y < gun_y){ /* アーム・ドリルの範囲内に居ない，かつガトリング銃よりは上 */
						if(x+64 < objPlayerDoll.x){ MotionChange(STAND_C2L,0,5) break; }
						if(x-64 > objPlayerDoll.x){ MotionChange(STAND_C2R,0,5) break; }
					}
				}
			}else{ /* 落下後 */
				if(collision_circle(x+ 40,y-200, 48,objPlayerDoll,0,1)){ MotionChange(DRILL_RIGHT,0,1);    break; }
				if(collision_circle(x-180,y-200, 48,objPlayerDoll,0,1)){ MotionChange(DRILL_LEFTUP,0,1);   break; }
				if(collision_circle(x-180,y    , 48,objPlayerDoll,0,1)){ MotionChange(DRILL_LEFTDOWN,0,1); break; }
				if(collision_circle(x- 40,y-200, 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_LEFT,0,1);    break; }
				if(collision_circle(x+180,y-200, 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_RIGHTUP,0,1);   break; }
				if(collision_circle(x+180,y    , 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_RIGHTDOWN,0,1); break; }
				if(random(100)<50){
					if(y-160 > objPlayerDoll.y){ /* キャラが上にいる */
						if(random(100)<10)	MotionChange(MISSILE_SHOT,0,1);
						break;
					}

					if(random(100)<50){
						if(x+64 < objPlayerDoll.x){ MotionChange(ARMHOLD_RIGHTDOWN,0,5) break; }
						if(x-64 > objPlayerDoll.x){ MotionChange(DRILL_LEFTDOWN,0,5) break; }

						if(x+32 < objPlayerDoll.x){ MotionChange(STAND_C2L,0,5) break; }
						if(x-32 > objPlayerDoll.x){ MotionChange(STAND_C2R,0,5) break; }
					}

					if(random(100) < 10){
						MotionChange(MISSILE_SHOT,0,1);
						break;
					}
				}
			}
			break;
		case STAND_L :
			switch(KeyFrmNum){
				case 1 :
					if(KEYFRAME){
						playEnemySound(SOUND_SHOT); Quake(5,5);
						for(i=0;i<3;i+=1){
							if(!instance_exists(Pile[i])){
								Pile[i] = createBullet(x-128,y);
								Pile[i].speed		= 60;
								Pile[i].direction	= 35-i*8;
								Pile[i].hspeed		*= Direction;
								Pile[i].Picture		= SPRITE_PILE;
								Pile[i].depth		= Process[ProcessNum[PARTS_BODY]].depth-1;
							}
						}
						for(i=3;i<6;i+=1){
							if(!instance_exists(Pile[i])){
								Pile[i] = createBullet(x+64,y);
								Pile[i].speed		= 60;
								Pile[i].direction	=-35+(i-3)*8;
								Pile[i].hspeed		*= Direction;
								Pile[i].Picture		= SPRITE_PILE;
								Pile[i].depth		= Process[ProcessNum[PARTS_BODY]].depth-1;
							}
						}
					}
					break;
			}
			if(MOTIONEND) MotionChange(WALKUP,0,5);
			break;
		case STAND_C2L :
			if(MOTIONEND){
				sound_play(sndReload);
				MotionChange(STAND_L,0,2);
			}
			break;
		case STAND_L2C :
			if(MOTIONEND) MotionChange(STAND_C,0,2);
			break;
		case STAND_R :
			switch(KeyFrmNum){
				case 1 :
					if(KEYFRAME){
						playEnemySound(SOUND_SHOT); Quake(5,5);
						for(i=0;i<3;i+=1){
							if(!instance_exists(Pile[i])){
								Pile[i] = createBullet(x+128,y);
								Pile[i].speed		= 60;
								Pile[i].direction	= 35-i*8;
								Pile[i].hspeed		*= -Direction;
								Pile[i].Picture		= SPRITE_PILE;
								Pile[i].depth		= Process[ProcessNum[PARTS_BODY]].depth-1;
							}
						}
						for(i=3;i<6;i+=1){
							if(!instance_exists(Pile[i])){
								Pile[i] = createBullet(x-64,y);
								Pile[i].speed		= 60;
								Pile[i].direction	=-35+(i-3)*8;
								Pile[i].hspeed		*= -Direction;
								Pile[i].Picture		= SPRITE_PILE;
								Pile[i].depth		= Process[ProcessNum[PARTS_BODY]].depth-1;
							}
						}
					}
					break;
			}
			if(MOTIONEND) MotionChange(WALKUP,0,5);
			break;
		case STAND_C2R :
			if(MOTIONEND){
				sound_play(sndReload);
				MotionChange(STAND_R,0,2);
			}
			break;
		case STAND_R2C :
			if(MOTIONEND) MotionChange(STAND_C,0,2);
			break;
		case WALKUP : 
			if(Mode==1) MotionChange(STAND_C,0,1);

			with( collision_circle(x,y-200,16,objPlayerDoll,0,1) ){
				if(vspeed && !INV && !isGameOver() ){
					if(!BINDED){
						DamageVoiceRandom_Mid();
						sound_play(sndGishi00);
						Quake(15,15);
						with(other){
							startBind( objPlayerDoll,BIND_ROLLER,0,other.BINDED_BOSSMACHINE_ROLLER,0,1 );
							MotionChange(ROLLER,0,1);
						}
					}
				}
				break;
			}

			chk = 0;
			switch(KeyFrmNum){
				case 1 : HitFlag = false; break;
				case 5 : 
					col = collision_circle(Process[PARTS_FOOTRT].x+32,Process[PARTS_FOOTRT].y,32,objPlayerDoll,0,1);
					if(!col) col = collision_circle(Process[PARTS_FOOTLB].x-32,Process[PARTS_FOOTLB].y,32,objPlayerDoll,0,1);
					else chk = 1;
					with(col){
						if(!INV){
							if(!BINDED){
								DamageVoiceRandom_Mid();
								sound_play(sndHit00);
								Quake(15,15);
								with(objController){ BindCounter = 10; }
								with(other){
									if(chk){startBind( objPlayerDoll,BIND_WALKPRESS_RIGHTUP ,0,other.BINDED_BOSSMACHINE_WALKPRESS,2,1 ); other.Direction = 1; }
									else{   startBind( objPlayerDoll,BIND_WALKPRESS_LEFTDOWN,0,other.BINDED_BOSSMACHINE_WALKPRESS,2,1 ); other.Direction =-1; }
									MotionChange(WALKPRESS_1STSTEP,0,1);
								}
							}
						}
					}
					break;
				case 12 : 
					col = collision_circle(Process[PARTS_FOOTLT].x-32,Process[PARTS_FOOTLT].y,32,objPlayerDoll,0,1);
					if(!col) col = collision_circle(Process[PARTS_FOOTRB].x+32,Process[PARTS_FOOTRB].y,32,objPlayerDoll,0,1);
					else chk = 1;
					with(col){
						if(!INV){
							if(!BINDED){
								DamageVoiceRandom_Mid();
								sound_play(sndHit00);
								Quake(15,15);
								with(objController){ BindCounter = 10; }
								with(other){
									if(chk){startBind( objPlayerDoll,BIND_WALKPRESS_LEFTUP ,0,other.BINDED_BOSSMACHINE_WALKPRESS,2,1 );   other.Direction =-1; }
									else{   startBind( objPlayerDoll,BIND_WALKPRESS_RIGHTDOWN,0,other.BINDED_BOSSMACHINE_WALKPRESS,2,1 ); other.Direction = 1; }
									MotionChange(WALKPRESS_2NDSTEP,0,1);
								}
							}
						}
					}
					break;
				case 6  : 
				case 13 : Quake(5,5);playEnemySound(SOUND_STEP); break;
				case 15 : Move(0,-10.0); break;
				case 16 : Move(0,-12.0); break;
			}
			if(MOTIONEND){
				if(collision_circle(x+ 40,y-200, 48,objPlayerDoll,0,1)){ MotionChange(DRILL_RIGHT,0,1);    break; }
				if(collision_circle(x-180,y-200, 48,objPlayerDoll,0,1)){ MotionChange(DRILL_LEFTUP,0,1);   break; }
				if(collision_circle(x-180,y    , 48,objPlayerDoll,0,1)){ MotionChange(DRILL_LEFTDOWN,0,1); break; }
				if(collision_circle(x- 40,y-200, 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_LEFT,0,1);    break; }
				if(collision_circle(x+180,y-200, 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_RIGHTUP,0,1);   break; }
				if(collision_circle(x+180,y    , 48,objPlayerDoll,0,1)){ MotionChange(ARMHOLD_RIGHTDOWN,0,1); break; }
				if(y-160 < objPlayerDoll.y) MotionChange(STAND_C,0,5);
			}
			break;
/*===========================================================*/
		case DRILL_RIGHT :
			switch(KeyFrmNum){
				case 1 : HitFlag = false; break;
				case 4 : 
				case 5 : 
				case 6 : 
					with( collision_circle(Process[PARTS_DRILL].x,Process[PARTS_DRILL].y, 16,objPlayerDoll,0,1) ){
						if(!INV && !other.HitFlag){
							Quake(5,5);
							Fluid(x,y,COLOR_BLOOD,20,5,15,  0,10,0.5);
							Fluid(x,y,COLOR_BLOOD,10,5,15,180,10,0.5);
							with(other){ playEnemySound(SOUND_BLOOD); }
							other.HitFlag = true;
							if(BINDED){
								if(Direction!=other.Direction)	addDamage(30, -1, -1, -1, -1, -1, -1);
								else							addDamage(30, -1, -1, -1, -1, -1, -1);
							}else{
								if(Direction!=other.Direction)	addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
								else							addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
								hspeed = 30*other.Direction;
								vspeed = -6;
							}
							if(isGameOver()){
								Quake(5,5);
								Fluid(x,y,COLOR_BLOOD,20,5,15,  0,10,0.5);
								Fluid(x,y,COLOR_BLOOD,10,5,15,180,10,0.5);
								DamageVoiceRandom_High();
								Direction = -1;
								with(other){
									Flash(COLOR_BLOOD,1.0,0.01);
									SpecialVoice(V_MUSE,irandom(2));
									startBind( objPlayerDoll,BIND_DRILL_RIGHT_FINISH,0,other.BINDED_BOSSMACHINE_DRILL_RIGHT_FINISH,0,1 );
									MotionChange(DRILL_RIGHT_FINISH,0,1);
								}
							}else DamageVoiceRandom_Mid();
						}
					}
					break;
			}
			if(MOTIONEND){
				if(random(100) < 40 && y+160 > objPlayerDoll.y){ MotionChange(WALKUP,0,1); break; }
				MotionChange(STAND_C,0,2);
			}
			break;
		case DRILL_RIGHT_FINISH :
			if(KeyFrmNum>5){
				Quake(2,2);
				playEnemySound(SOUND_DRILL);
				with(BindTarget){
					addDamage(0.01, -1, -1, -1, -1, -1, -1);
					if(random(100)<2){
						chk = false;
						if(!isPlayVoice(V_MUSE,0) && !isPlayVoice(V_MUSE,1) && !isPlayVoice(V_MUSE,2)){
							if(random(100)<40) SpecialVoice(V_MUSE,irandom(2));
							else DamageVoiceRandom_Mid();
						}
					}
					if(random(100)<5){
						Quake(15,15);
						Fluid(x,y-16,COLOR_BLOOD,15,0,25,80,20,0.5);
						Fluid(x,y+16,COLOR_BLOOD,15,0,5,260,20,0.5);
						with(other){ playEnemySound(SOUND_BLOOD); }
						Flash(COLOR_BLOOD,0.75,0.05);
					}
					if(random(100)<80) MotionChange(BINDED_BOSSMACHINE_DRILL_RIGHT_FINISH,14+irandom(5),2+random(5));
					if(random(100)<90) Fluid(x,y+16,COLOR_BLOOD,2,0,5,250,40,0.5);
					if(random(100)<30) Fluid(x,y-16,COLOR_BLOOD,2,0,15,80,20,0.5);
				}
				with(objExtParts){
					if(object_index == objCommon_Head){
						with(DrawTarget){
							PartsBloodDamage(other.id,-random(15),0);
						}
					}else{
						with(DrawTarget){
							PartsDamage(other.id,-random(15),0);
							PartsBloodDamage(other.id,-random(15),0);
						}
					}
				}
			}else{
				with(BindTarget){
					if(random(100)<10) Fluid(x,y,COLOR_BLOOD,5,0,5,250,40,0.5);
				}
				if(KeyFrmNum==5 && KEYFRAME){
					SpecialVoice(V_GYA,3);
					Flash_Rect(COLOR_BLOOD,1.0,0.02);
					playEnemySound(SOUND_MOTOR);
					playEnemySound(SOUND_BLOOD);
					Quake(25,25);
				}
			}
			if(MOTIONEND) MotionChange(DRILL_RIGHT_FINISH,5,1);
			break;
/*-----------------------------------------------------------*/
		case DRILL_LEFTUP :
			switch(KeyFrmNum){
				case 1 : HitFlag = false; break;
				case 4 : 
				case 5 : 
				case 6 : 
					with( collision_circle(Process[PARTS_DRILL].x,Process[PARTS_DRILL].y, 16,objPlayerDoll,0,1) ){
						if(!INV && !other.HitFlag){
							Quake(5,5);
							Fluid(x,y,COLOR_BLOOD,20,5,15,  0,10,0.5);
							Fluid(x,y,COLOR_BLOOD,10,5,15,180,10,0.5);
							with(other){ playEnemySound(SOUND_BLOOD); }
							other.HitFlag = true;
							if(BINDED){
								if(Direction!=other.Direction)	addDamage(30, -1, -1, -1, -1, -1, -1);
								else							addDamage(30, -1, -1, -1, -1, -1, -1);
							}else{
								if(Direction!=other.Direction)	addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
								else							addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
								hspeed = 30*other.Direction*-1;
								vspeed = -6;
							}
							if(isGameOver()){
								Quake(5,5);
								Fluid(x,y,COLOR_BLOOD,20,5,15,  0,10,0.5);
								Fluid(x,y,COLOR_BLOOD,10,5,15,180,10,0.5);
								DamageVoiceRandom_High();
								Direction = -1;
								with(other){
									Flash(COLOR_BLOOD,1.0,0.01);
									SpecialVoice(V_MUSE,irandom(2));
									startBind( objPlayerDoll,BIND_DRILL_LEFTUP_FINISH,0,other.BINDED_BOSSMACHINE_DRILL_LEFTUP_FINISH,0,1 );
									MotionChange(DRILL_LEFTUP_FINISH,0,1);
								}
							}else DamageVoiceRandom_Mid();
						}
					}
					break;
			}
			if(MOTIONEND){
				if(random(100) < 40 && y+160 > objPlayerDoll.y){ MotionChange(WALKUP,0,1); break; }
				MotionChange(STAND_C,0,2);
			}
			break;
		case DRILL_LEFTUP_FINISH :
			if(KeyFrmNum>=10){
				Quake(2,2);
				playEnemySound(SOUND_DRILL);
				with(BindTarget){
					addDamage(0.01, -1, -1, -1, -1, -1, -1);
					if(random(100)<2){
						chk = false;
						if(!isPlayVoice(V_MUSE,0) && !isPlayVoice(V_MUSE,1) && !isPlayVoice(V_MUSE,2)){
							if(random(100)<40) SpecialVoice(V_MUSE,irandom(2));
							else DamageVoiceRandom_Mid();
						}
					}
					if(random(100)<5){
						Quake(15,15);
						Fluid(x,y-16,COLOR_BLOOD,15,0,25,80,20,0.5);
						Fluid(x,y+16,COLOR_BLOOD,15,0,5,260,20,0.5);
						with(other){ playEnemySound(SOUND_BLOOD); }
						Flash(COLOR_BLOOD,0.75,0.05);
					}
					if(random(100)<80) MotionChange(BINDED_BOSSMACHINE_DRILL_LEFTUP_FINISH,5+irandom(17),2+random(5));
					if(random(100)<90) Fluid(x,y+16,COLOR_BLOOD,2,0,5,250,40,0.5);
					if(random(100)<30) Fluid(x,y-16,COLOR_BLOOD,2,0,15,80,20,0.5);
				}
				with(objExtParts){
					if(object_index == objCommon_Head){
						with(DrawTarget){
							PartsBloodDamage(other.id,-random(15),0);
						}
					}else{
						with(DrawTarget){
							PartsDamage(other.id,-random(15),0);
							PartsBloodDamage(other.id,-random(15),0);
						}
					}
				}
			}else{
				with(BindTarget){
					if(random(100)<10) Fluid(x,y,COLOR_BLOOD,5,0,5,250,40,0.5);
				}
				if(KeyFrmNum==9 && KEYFRAME){
					SpecialVoice(V_GYA,3);
					Flash_Rect(COLOR_BLOOD,1.0,0.02);
					playEnemySound(SOUND_MOTOR);
					playEnemySound(SOUND_BLOOD);
					Quake(25,25);
				}
			}
			if(MOTIONEND) MotionChange(DRILL_LEFTUP_FINISH,10,1);
			break;
/*-----------------------------------------------------------*/
		case DRILL_LEFTDOWN :
			switch(KeyFrmNum){
				case 1 : HitFlag = false; break;
				case 4 : 
				case 5 : 
				case 6 : 
					with( collision_circle(Process[PARTS_DRILL].x,Process[PARTS_DRILL].y, 16,objPlayerDoll,0,1) ){
						if(!INV && !other.HitFlag){
							Quake(5,5);
							Fluid(x,y,COLOR_BLOOD,20,5,15,-90,180,0.5);
							with(other){ playEnemySound(SOUND_BLOOD); }
							other.HitFlag = true;
							if(BINDED){
								if(Direction!=other.Direction)	addDamage(30, -1, -1, -1, -1, -1, -1);
								else							addDamage(30, -1, -1, -1, -1, -1, -1);
							}else{
								if(Direction!=other.Direction)	addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
								else							addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
								hspeed = 30*other.Direction*-1;
								vspeed = -6;
							}
							if(isGameOver()){
								Quake(5,5);
								Fluid(x,y,COLOR_BLOOD,20,5,15,-90,180,0.5);
								DamageVoiceRandom_High();
								Direction = -1;
								with(other){
									Flash(COLOR_BLOOD,1.0,0.01);
									SpecialVoice(V_MUSE,irandom(2));
									startBind( objPlayerDoll,BIND_DRILL_LEFTDOWN_FINISH,0,other.BINDED_BOSSMACHINE_DRILL_LEFTDOWN_FINISH,0,1 );
									MotionChange(DRILL_LEFTDOWN_FINISH,0,1);
								}
							}else DamageVoiceRandom_Mid();
						}
					}
					break;
			}
			if(MOTIONEND){
				if(random(100) < 40 && y+160 > objPlayerDoll.y){ MotionChange(WALKUP,0,1); break; }
				MotionChange(STAND_C,0,2);
			}
			break;
		case DRILL_LEFTDOWN_FINISH :
			if(KeyFrmNum>2){
				Quake(2,2);
				playEnemySound(SOUND_DRILL);
				with(BindTarget){
					addDamage(0.01, -1, -1, -1, -1, -1, -1);
					if(random(100)<2){
						chk = false;
						if(!isPlayVoice(V_MUSE,0) && !isPlayVoice(V_MUSE,1) && !isPlayVoice(V_MUSE,2)){
							if(random(100)<40) SpecialVoice(V_MUSE,irandom(2));
							else DamageVoiceRandom_Mid();
						}
					}
					if(random(100)<5){
						Quake(15,15);
						Fluid(x,y,COLOR_BLOOD,10,5,15,-90,180,0.5);
						Fluid(x,y,COLOR_BLOOD,10,5,15,-10,20,0.5);
						with(other){ playEnemySound(SOUND_BLOOD); }
						Flash(COLOR_BLOOD,0.75,0.05);
					}
					if(random(100)<80) MotionChange(BINDED_BOSSMACHINE_DRILL_LEFTDOWN_FINISH,18+irandom(3),2+random(5));
					if(random(100)<90) Fluid(x,y,COLOR_BLOOD,3,0,10,-90,180,0.5);
					if(random(100)<30) Fluid(x,y,COLOR_BLOOD,3,0,10,-10,20,0.5);
				}
				with(objExtParts){
					if(object_index == objCommon_Head){
						with(DrawTarget){
							PartsBloodDamage(other.id,-random(15),0);
						}
					}else{
						with(DrawTarget){
							PartsDamage(other.id,-random(15),0);
							PartsBloodDamage(other.id,-random(15),0);
						}
					}
				}
			}else{
				with(BindTarget){
					if(random(100)<10){
						Fluid(x,y,COLOR_BLOOD,10,0,10,-90,180,0.5);
						Fluid(x,y,COLOR_BLOOD,10,0,10,-10,20,0.5);
					}   
				}
				if(KeyFrmNum==2 && KEYFRAME){
					SpecialVoice(V_GYA,3);
					Flash_Rect(COLOR_BLOOD,1.0,0.02);
					playEnemySound(SOUND_MOTOR);
					playEnemySound(SOUND_BLOOD);
					Quake(25,25);
				}
			}
			if(MOTIONEND) MotionChange(DRILL_LEFTDOWN_FINISH,2,1);
			break;
/*===========================================================*/
		case ARMHOLD_LEFT :
			switch(KeyFrmNum){
				case 1 : HitFlag = false; break;
				case 2 : 
				case 3 : 
				case 4 : 
					with( collision_circle(Process[PARTS_ELECARM].x,Process[PARTS_ELECARM].y, 48,objPlayerDoll,0,1) ){
						if(!INV && !other.HitFlag){
							other.HitFlag = true;
							if(!BINDED){
								DamageVoiceRandom_Mid();
								Quake(5,5);
								Direction = 1;
								with(other){
									startBind( objPlayerDoll,BIND_ARMHOLD_LEFT_CATCH,0,other.BINDED_BOSSMACHINE_ARMHOLD_LEFT_CATCH,0,1 );
									MotionChange(ARMHOLD_LEFT_CATCH,0,1);
								}
							}
						}
					}
					break;
			}
			if(MOTIONEND){
				if(random(100) < 40 && y+160 > objPlayerDoll.y){ MotionChange(WALKUP,0,1); break; }
				MotionChange(STAND_C,0,2);
			}
			break;
		case ARMHOLD_LEFT_CATCH :
			DepthSet(objPlayerDoll.depth + 1000);
			Process[PARTS_WEPARMR1].depth = objPlayerDoll.depth - 1001;
			Process[PARTS_WEPARMR2].depth = objPlayerDoll.depth - 1000;
			Process[PARTS_ELECARM ].depth = objPlayerDoll.depth - 1002;
			with(objPlayerDoll){
				HAND1_ABOVE.depth = objPlayerDoll.depth - 1015;
				HAND2_ABOVE.depth = objPlayerDoll.depth - 1014;
				HAND3_ABOVE.depth = objPlayerDoll.depth - 1013;
			}
			if(BindTarget){
				if(!BindTarget.BINDED){
						StopVoice(V_MUSE,0);
						StopVoice(V_MUSE,1);
						StopVoice(V_MUSE,2);
						DamageVoiceRandom_Low();
						with(BindTarget){ MotionChange(FLYING_1,0,2); }
						endBind();
						MotionChange(STAND_C,0,20);
						break;
				}
			}
			switch(KeyFrmNum){
				case 1 :
					chk = false;
					break;
				case 3 :
					if(KEYFRAME){
						addDamage(20, -1, -1, -1, -1, -1, -1);
						Flash_Rect(COLOR_BLOOD,0.5,0.05);
						Quake(15,15);
						playEnemySound(SOUND_CLASH);
						DamageVoiceRandom_High();
					}
					break;
				case 11:
					if(KEYFRAME){
						addDamage(10, -1, -1, -1, -1, -1, -1);
						Flash_Rect(COLOR_BLOOD,0.5,0.05);
						Quake(15,15);
						playEnemySound(SOUND_CLASH);
						SpecialVoice(V_MUSE,irandom(2));
					}
					break;
				case 14 : 
					addDamage(0.05, -1, -1, -1, -1, -1, -1);
					if( !chk && global.PlayerHP<0){
						chk = true;
						SpecialVoice(V_MUSE,0);
						with(BindTarget){
							MotionChange(BINDED_BOSSMACHINE_ARMHOLD_LEFT_CATCH,27, 30);
						}
						if( random(100)<50 ) objCommon_Body.FluidBreak = true;
					}
					if(!isGameOver()){
						if(random(100)<80){
							with(BindTarget){
								var tmp;
								tmp = (global.PlayerHPMAX - global.PlayerHP)/global.PlayerHPMAX;
								MotionChange(BINDED_BOSSMACHINE_ARMHOLD_LEFT_CATCH,22+irandom(4), tmp*20+random(5));
							}
						}
					}
					break;
			}
			break;
/*-----------------------------------------------------------*/
		case ARMHOLD_RIGHTUP :
			switch(KeyFrmNum){
				case 1 : HitFlag = false; break;
				case 3 : 
				case 4 : 
				case 5 : 
					with( collision_circle(Process[PARTS_ELECARM].x,Process[PARTS_ELECARM].y, 48,objPlayerDoll,0,1) ){
						if(!INV && !other.HitFlag){
							other.HitFlag = true;
							if(!BINDED){
								DamageVoiceRandom_Mid();
								Quake(5,5);
								Direction = -1;
								with(other){
									startBind( objPlayerDoll,BIND_ARMHOLD_RIGHT_CATCH,0,other.BINDED_BOSSMACHINE_ARMHOLD_RIGHTUP_CATCH,0,1 );
									MotionChange(ARMHOLD_RIGHTUP_CATCH,0,1);
								}
							}
						}
					}
					break;
			}
			if(MOTIONEND){
				if(random(100) < 40 && y+160 > objPlayerDoll.y){ MotionChange(WALKUP,0,1); break; }
				MotionChange(STAND_C,0,2);
			}
			break;
		case ARMHOLD_RIGHTUP_CATCH :
			DepthSet(objPlayerDoll.depth + 1000);
			Process[PARTS_WEPARMR1].depth = objPlayerDoll.depth - 1001;
			Process[PARTS_WEPARMR2].depth = objPlayerDoll.depth - 1000;
			Process[PARTS_ELECARM ].depth = objPlayerDoll.depth - 1002;
			with(objPlayerDoll){
				HAND1_ABOVE.depth = objPlayerDoll.depth - 1015;
				HAND2_ABOVE.depth = objPlayerDoll.depth - 1014;
				HAND3_ABOVE.depth = objPlayerDoll.depth - 1013;
			}
			if(BindTarget){
				if(!BindTarget.BINDED){
						DamageVoiceRandom_Low();
						with(BindTarget){
							MotionChange(FLYING_1,0,2);
							hspeed = x - XPREV;
							vspeed = y - YPREV;
						}
						endBind();
						MotionChange(STAND_C,0,20);
						break;
				}
			}
			switch(KeyFrmNum){
				case  4:
				case  9:
					if(KEYFRAME){
						with(objExtParts){
							with(DrawTarget){
								PartsDamage(other.id,-random(15),0);
								PartsBloodDamage(other.id,-random(15),0);
							}
						}
						addDamage(10, -1, -1, -1, -1, -1, -1);
						Flash_Rect(COLOR_BLOOD,0.5,0.05);
						Quake(15,15);
						playEnemySound(SOUND_CLASH);

						with(BindTarget){
							if(random(100)<10){
								if(global.PlayerHP > -100) DamageVoiceRandom_High();
								with(other){
									playEnemySound(SOUND_BLOOD);
									Fluid(Process[PARTS_ELECARM].x+120,Process[PARTS_ELECARM].y-96,COLOR_BLOOD,15,0,10,0,360,0.5);
								}
								Fluid(x,y,COLOR_BLOOD,10,0,10,0,360,0.5);
							}else{
								if(global.PlayerHP > -100) DamageVoiceRandom_Mid();
								with(other){
									Fluid(Process[PARTS_ELECARM].x+120,Process[PARTS_ELECARM].y-96,COLOR_BLOOD,random(5),0,10,0,360,0.5);
								}
							}
						}
					}
					break;
			}
			if(MOTIONEND){
				startBind( objPlayerDoll,BIND_ARMHOLD_RIGHT_CATCH,0,objPlayerDoll.BINDED_BOSSMACHINE_ARMHOLD_RIGHTUP_CATCH,6,1 );
				MotionChange(ARMHOLD_RIGHTUP_CATCH,6,1);
			}
			break;
/*-----------------------------------------------------------*/
		case ARMHOLD_RIGHTDOWN :
			switch(KeyFrmNum){
				case 1 : HitFlag = false; break;
				case 5 : 
				case 6 : 
				case 7 : 
					with( collision_circle(Process[PARTS_ELECARM].x,Process[PARTS_ELECARM].y, 48,objPlayerDoll,0,1) ){
						if(!INV && !other.HitFlag){
							other.HitFlag = true;
							if(!BINDED){
								DamageVoiceRandom_Mid();
								Quake(5,5);
								Direction = -1;
								with(other){
									startBind( objPlayerDoll,BIND_ARMHOLD_RIGHT_CATCH,0,other.BINDED_BOSSMACHINE_ARMHOLD_RIGHTDOWN_CATCH,0,1 );
									MotionChange(ARMHOLD_RIGHTDOWN_CATCH,0,1);
								}
							}
						}
					}
					break;
			}
			if(MOTIONEND){
				if(random(100) < 40 && y+160 > objPlayerDoll.y){ MotionChange(WALKUP,0,1); break; }
				MotionChange(STAND_C,0,2);
			}
			break;
		case ARMHOLD_RIGHTDOWN_CATCH :
			DepthSet(objPlayerDoll.depth + 1000);
			Process[PARTS_WEPARMR1].depth = objPlayerDoll.depth - 1001;
			Process[PARTS_WEPARMR2].depth = objPlayerDoll.depth - 1000;
			Process[PARTS_ELECARM ].depth = objPlayerDoll.depth - 1002;

			if(BindTarget){
				if(!BindTarget.BINDED){
						DamageVoiceRandom_Low();
						with(BindTarget){
							MotionChange(FLYING_1,0,2);
							hspeed = x - XPREV;
							vspeed = y - YPREV;
						}
						endBind();
						MotionChange(STAND_C,0,20);
						break;
				}
			}
			switch(KeyFrmNum){
				case  1:
					chk = random(100) < 1;
					break;
				case  3:
				case  9:
				case 15:
					if(KEYFRAME){
						with(objExtParts){
							with(DrawTarget){
								PartsDamage(other.id,-random(15),0);
								PartsBloodDamage(other.id,-random(15),0);
							}
						}
						addDamage(10, -1, -1, -1, -1, -1, -1);
						Flash_Rect(COLOR_BLOOD,0.5,0.05);
						Quake(15,15);
						playEnemySound(SOUND_CLASH);

						with(BindTarget){
							if(random(100)<10){
								if(global.PlayerHP > -100) DamageVoiceRandom_High();
								with(other){
									playEnemySound(SOUND_BLOOD);
									Fluid(Process[PARTS_ELECARM].x+120,Process[PARTS_ELECARM].y-96,COLOR_BLOOD,15,0,10,0,360,0.5);
								}
								Fluid(x,y,COLOR_BLOOD,10,0,10,0,360,0.5);
							}else{
								if(global.PlayerHP > -100) DamageVoiceRandom_Mid();
								with(other){
									Fluid(Process[PARTS_ELECARM].x+120,Process[PARTS_ELECARM].y-96,COLOR_BLOOD,random(5),0,10,0,360,0.5);
								}
							}
						}
					}
					break;
				case 11:
				case 12:
				case 17:
				case 18:
				case 19:
					if(!chk){
						if(random(100)<5){
							if(random(100)<50){
								startBind( objPlayerDoll,BIND_ARMHOLD_RIGHT_CATCH,0,objPlayerDoll.BINDED_BOSSMACHINE_ARMHOLD_RIGHTDOWN_CATCH,8,1 );
								MotionChange(ARMHOLD_RIGHTDOWN_CATCH,7,1);
							}else{
								startBind( objPlayerDoll,BIND_ARMHOLD_RIGHT_CATCH,0,objPlayerDoll.BINDED_BOSSMACHINE_ARMHOLD_RIGHTDOWN_CATCH,16,1 );
								MotionChange(ARMHOLD_RIGHTDOWN_CATCH,13,1);
							}
						}
					}else{
						if(random(100)<50){
							startBind( objPlayerDoll,BIND_ARMHOLD_RIGHT_CATCH,0,objPlayerDoll.BINDED_BOSSMACHINE_ARMHOLD_RIGHTDOWN_CATCH,8,1 );
							MotionChange(ARMHOLD_RIGHTDOWN_CATCH,7,1);
						}else{
							startBind( objPlayerDoll,BIND_ARMHOLD_RIGHT_CATCH,0,objPlayerDoll.BINDED_BOSSMACHINE_ARMHOLD_RIGHTDOWN_CATCH,16,1 );
							MotionChange(ARMHOLD_RIGHTDOWN_CATCH,13,1);
						}
					}
			}
			if(MOTIONEND){
				startBind( objPlayerDoll,BIND_ARMHOLD_RIGHT_CATCH,0,objPlayerDoll.BINDED_BOSSMACHINE_ARMHOLD_RIGHTDOWN_CATCH,8,1 );
				MotionChange(ARMHOLD_RIGHTDOWN_CATCH,7,1);
			}
			break;
		case ROLLER :
			if(BindTarget){
				if(!BindTarget.BINDED){
					for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ image_alpha = 1; }
					MotionChange(STAND_C,0,5);
					with(BindTarget){
						y -= 64;
						hspeed = 8*(-1+2*round(random(1)));
						vspeed = -25;
						MotionChange(FLYING_SPIN,0,2);
					}
					endBind();
					break;
				}
			}
			switch(KeyFrmNum){
				case  2:
					if(KEYFRAME){
						CryingVoiceRandom_High();
						addDamage(100, -1, -1, -1, -1, -1, -1);
						Flash_Rect(COLOR_BLOOD,0.5,0.05);
						Quake(15,15);
						HitStop(0,5);
						sound_play(sndBone00);
						playEnemySound(SOUND_BLOOD);
						playEnemySound(SOUND_ROLLER);
						Fluid(x,y-200,COLOR_BLOOD,15,0,20,85,10,0.5);
						with(objExtParts){
							with(DrawTarget){
								PartsDamage(other.id,-random(15),0);
								PartsBloodDamage(other.id,-100,0);
							}
						}
					}
					break;
				case  3:
					if(KEYFRAME){
						DamageVoiceRandom_High();
						addDamage(100, -1, -1, -1, -1, -1, -1);
						Flash_Rect(COLOR_BLOOD,0.5,0.01);
						HitStop(0,5);
						Quake(15,15);
						sound_play(sndGusha);
						playEnemySound(SOUND_BLOOD);
						Fluid(x,y-200,COLOR_BLOOD,35,0,20,85,10,0.5);
						with(objExtParts){
							with(DrawTarget){
								PartsDamage(other.id,-random(15),0);
								PartsBloodDamage(other.id,-100,0);
							}
						}
					}
					break;
				case  5:
					if(KEYFRAME) SpecialVoice(V_HA,4);
				case  7:
					if(KEYFRAME){
						addDamage(100, -1, -1, -1, -1, -1, -1);
						Flash_Rect(COLOR_BLOOD,0.5,0.01);
						Quake(15,15);
						sound_play(sndGusha);
						sound_play(sndBone00);
						playEnemySound(SOUND_BLOOD);
						Fluid(x,y-200,COLOR_BLOOD,40,0,30,80,20,0.5);
						HitStop(0,5);
						with(objExtParts){
							with(DrawTarget){
								PartsDamage(other.id,-random(15),0);
								PartsBloodDamage(other.id,-100,0);
							}
						}
					}
					break;
				case  9:
					with(BindTarget){ MotionChange(BINDED_BOSSMACHINE_ROLLER,48,2); }
					endBind();
					break;
			}
			if(MOTIONEND){
				MotionChange(STAND_C,0,1);
			}
			break;
		case WALKPRESS_1STSTEP :
		case WALKPRESS_2NDSTEP :
			Quake(2,2);
			if(BindTarget){
				if(!BindTarget.BINDED){
						DamageVoiceRandom_Low();
						with(BindTarget){
							MotionChange(FLYING_1,0,2);
							hspeed = x - XPREV;
							vspeed = y - YPREV;
						}
						endBind();
						MotionChange(STAND_C,0,20);
						break;
				}
			}
			chk = 10;
			with(objController){ other.chk = BindCounter; }
			if(chk <= 0 ){
				if(BindTarget){
					with(objExtParts){
						with(DrawTarget){
							PartsDamage(other.id,-random(100),0);
							PartsBloodDamage(other.id,-100,0);
						}
					}
					CryingVoiceRandom_High();
					with(BindTarget){
						addDamage(200,FLYING_0, 0, 1, FLYING_0, 0, 2);
						hspeed = x - XPREV;
						vspeed = y - YPREV;
						Flash_Rect(COLOR_BLOOD,0.5,0.05);
						Quake(15,15);
						HitStop(50,null);
						Fluid(x,y-200,COLOR_BLOOD,65,0,20,0,360,0.5);
					}
					sound_play(sndGusha);
					sound_play(sndBone00);
					playEnemySound(SOUND_CLASH);
					endBind();
					if(MotionNum==WALKPRESS_1STSTEP) MotionChange(WALKUP,6,2);
					else							 MotionChange(WALKUP,13,2);
					break;
				}
			}

			switch(KeyFrmNum){
				case 1 :
					if(chk < 15){
						MotionChange(MotionNum,1,2);
						with(BindTarget){ MotionChange(MotionNum,1,2); }
					}
					if(BindTarget){
						if(!BindTarget.BINDED){
								sound_play(sndGishi00);
								DamageVoiceRandom_Low();
								with(BindTarget){
									MotionChange(STAND_0,0,2);
									hspeed = x - XPREV;
									vspeed = y - YPREV;
								}
								endBind();
								MotionChange(STAND_C,0,5);
								break;
						}
					}
					break;
				case 2 :
					if(chk < 10){
						MotionChange(MotionNum,2,5);
						with(BindTarget){ MotionChange(MotionNum,2,5); }
					}
					if(chk > 15){
						MotionChange(MotionNum,0,5);
						with(BindTarget){ MotionChange(MotionNum,0,5); }
					}
					break;
				case 3 :
					if(chk < 5){
						DamageVoiceRandom_Low();
						MotionChange(MotionNum,3,5);
						with(BindTarget){ MotionChange(MotionNum,3,5); }
					}
					if(chk > 10){
						MotionChange(MotionNum,1,5);
						with(BindTarget){ MotionChange(MotionNum,1,5); }
					}
					break;
				case 4 :
					if(chk > 5){
						MotionChange(MotionNum,2,5);
						with(BindTarget){ MotionChange(MotionNum,2,5); }
					}
					break;
				case 5 :
					if(chk > 5){
						MotionChange(MotionNum,2,5);
						with(BindTarget){ MotionChange(MotionNum,2,5); }
					}
					with(BindTarget){ MotionChange(MotionNum,4,1); }
					MotionChange(MotionNum,4,1);
					break;
			}
			break;
		case DEAD_MOTION :
			if(KEYFRAME){
				Quake(10,10);
				sound_play(sndBomb);
				instance_create(x-60+random(120),y-250+random(200),objExplosionSmall);
			}
			if(MOTIONEND){
				effect_create_above(ef_smoke,x,y,2,c_gray);
				effect_create_above(ef_explosion,x,y,1,c_black);
				Flash(c_white,0.1,0.05);

				var Num,VarianceX,VarianceY,Color,Alpha,Gravity,GravityDir,AngleMin,AngleRange,SpeedMin,SpeedRange,TimeMin,TimeRange;
				Num = 50;
				VarianceX = 64;					VarianceY = 64;
				Color = c_yellow;				Alpha = 1;
				Gravity = global.G;				GravityDir = global.Gdir;
				AngleMin = 0;					AngleRange = 180;
				SpeedMin = 10;					SpeedRange = 25;
				TimeMin = 5;					TimeRange = 5;
				Particle(Num,VarianceX,VarianceY,Color,Alpha,Gravity,GravityDir,AngleMin,AngleRange,SpeedMin,SpeedRange,TimeMin,TimeRange);

				Quake(25,15);
				instance_create(x,y,objExplosionBig);
				sound_play(sndBomb);

				objDisplay.alarm[11] = 60;
				instance_destroy();
			}
			break;
	}
}