/*-----重力設定--------------------------*/
GSet(global.G*3,global.Gdir,0.99,1,0,0.99,1,1);

with(objEnemyEdit){ if(Edit_Play) exit; }
/*-----キャラクタとの情報の取得---------------*/
playerDistanceX = abs(x - objPlayerDoll.x);
playerDistance = point_distance(x,y,objPlayerDoll.x,objPlayerDoll.y);
playerDirection = point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y);

/*-----モーション毎の処理--------------------*/
DAMAGE_ACTIVE = 0;
INV = 1;

FootHeadPosX[0] = PartsParam(PARTS_LEGL2).x; FootHeadPosX[1] = PartsParam(PARTS_LEGR2).x;
FootHeadPosY[0] = PartsParam(PARTS_LEGL2).y; FootHeadPosY[1] = PartsParam(PARTS_LEGR2).y;
for(i=0;i<2;i+=1){
	with(FootCollision[i]){
		     if(other.MotionNum == other.TUMBLE      ){ INV = 1; DAMAGE_ACTIVE = 0; }
		else if(other.MotionNum == other.TRANSFORM   ){ INV = 1; DAMAGE_ACTIVE = 0; }
		else if(other.MotionNum == other.DEAD_MOTION ){ INV = 1; DAMAGE_ACTIVE = 0; }
		else if(other.MotionNum == other.DEAD_MOTION2){ INV = 1; DAMAGE_ACTIVE = 0; }
		else                                          { INV = 0; DAMAGE_ACTIVE = 1; }

		if(RECV_DAMAGE){
			if(!INV){
				with(other){ playEnemySound(SOUND_DAMAGE); }
				Fluid(x,y,make_color_rgb(263,73,164),15,5,20,0,360,0.7);
			}
		}
		depth = -100000;
		x = other.FootHeadPosX[other.i];
		y = other.FootHeadPosY[other.i];
		/*
		if(place_meeting(x,y,objBlock)){
			x = xprevious;
			y = yprevious;
		}
		*/
		if(HP<-600){
			Quake(10,10);
			with(other){
				Direction = -1+2*irandom(1);
				playEnemySound(SOUND_SMASH);
				MotionChange(TUMBLE,0,5);
			}
			HP = 0;
		}
	}
}

HeadPosX = PartsParam(PARTS_EYE).x;
HeadPosY = PartsParam(PARTS_EYE).y;
with(HeadCollision){
	     if(other.MotionNum == other.TRANSFORM   ){ INV = 1; DAMAGE_ACTIVE = 0; }
	else if(other.MotionNum == other.DEAD_MOTION ){ INV = 1; DAMAGE_ACTIVE = 0; }
	else if(other.MotionNum == other.DEAD_MOTION2){ INV = 1; DAMAGE_ACTIVE = 0; }
	else                                          { INV = 0; DAMAGE_ACTIVE = 1; }

	if(RECV_DAMAGE){
		if(!INV){
			with(other){ playEnemySound(SOUND_DAMAGE); }
			Fluid(x,y,make_color_rgb(263,73,164),15,5,20,0,360,0.7);
		}
	}
	depth = -100000;
	x = other.HeadPosX;
	y = other.HeadPosY;
	/*
	if(place_meeting(other.HeadPosX,other.HeadPosY,objBlock)){
		x = xprevious;
		y = yprevious;
	}
	*/

	other.HP = HP + global.BOSSHPMAX;
}

if(HP<0){
	if(!ChangeMotion){
		if(MotionNum!=DEAD_MOTION && MotionNum!=DEAD_MOTION2){
			Quake(35,35);
			MotionChange(DEAD_MOTION,0,1);
		}
	}
}

if(random(100)<3){
	var tmp_parts;
	tmp_parts = Process[ProcessNum[PARTS_BODY]];
	new = instance_create(tmp_parts.x,tmp_parts.y,objSpring);
	new.Points[0,new.ATTACH]    = tmp_parts;
	new.Points[0,new.ATTACHDIS] = 96;
	new.Points[0,new.ATTACHDIR] = 240+random(60);
}

with(objPlayerDoll){
	switch(MotionNum){
	case FINISHED_BOSSHITOANG_STAMP:
		switch(KeyFrmNum){
		case 6 : 
			HEAD.image_alpha = 0;
			break;
		}
	}
}

DepthSet(objPlayerDoll.depth + 1000);
if(!ChangeMotion){
	switch(MotionNum){
		case TARNSFORM :
			INV = 1;
			for(i=0;i<PARTS_MAX;i+=1){
				with(Draw[i]){
					Fluid(x,y,c_black,2,2,10,image_angle,2,0.5);
					if(random(100)<20) effect_create_above(ef_smokeup, x -32+64*random(1),y -32+64*random(1), 1,c_black);
					image_blend = make_color_rgb(other.Color,other.Color,other.Color);
					if(other.Color>255){
						image_blend = c_white;
					}else if(other.KeyFrmNum>15) other.Color += 1;
				}
			}
			if( MOTIONEND ){
				MotionChange(STAND,0,3);
				Color = 255;
				for(i=0;i<PARTS_MAX;i+=1){
					with(Draw[i]){ image_blend = c_white; }
				}
				break;
			}
			break;
		case JUMP :
			switch(KeyFrmNum){
				case 5: 
					if(!air){
						vspeed = -50;
						if(playerDistanceX<100) hspeed = -50+random(100);
						else                    hspeed = -0.1*(x - objPlayerDoll.x);
					}
					break;
				case 8:
					if(air) MotionChange(JUMP,7,2);
				case 6:
				case 7:
					if(!air) MotionChange(JUMP,10,1);
					break;
				case 11:
					if(KEYFRAME){
						Quake(10,5); playEnemySound(SOUND_TAKEON);
						col = collision_line(x-150,y+300,x+150,y+300, objPlayerDoll,0,1);
						with( col ){
							if(!INV && !BINDED && !air){
								if( Direction ){
									with(other){ playEnemySound(SOUND_SMASH); }
									addDamage(50,DOWN_0, 0, 1, DEATHPRESS_DOWN_0, 0, 2);
									if(!isGameOver()) DamageVoiceRandom_High();
									PartsBloodDamage(objExtParts,	-30,0);
									if(isGameOver()){
										StopVoice(V_MUSE,0);
										SpecialVoice(V_MUSE,0);
									}
								}else{
									if(global.PlayerHP>0){
										Flash(COLOR_BLOOD,1.0,0.001);
										with(other){ playEnemySound(SOUND_SMASH);playEnemySound(SOUND_HEAD); }
										addDamage(50,DOWN_1_FRONT, 2, 1, FINISHED_BOSSHITOANG_STAMP, 2, 2);
										if(!isGameOver()) DamageVoiceRandom_High();
										PartsBloodDamage(objExtParts,	-50,0);
										if(isGameOver()){
											var tmp_parts;
											repeat(5){
												with(other){ tmp_parts = PartsParam(PARTS_LEGL3); }
												new = instance_create(tmp_parts.x,tmp_parts.y,objSpring);
												new.Points[0,new.ATTACH]    = tmp_parts;
												new.Points[0,new.ATTACHDIS] = random(96);
												new.Points[0,new.ATTACHDIR] = 180;
												new.Points[9,new.ATTACH]    = objPlayerDoll.HEAD;
												new.Points[9,new.ATTACHDIS] = random(32);
												new.Points[9,new.ATTACHDIR] = 180+random(180);
												new.image_blend = COLOR_BLOOD;
											}
											FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,25,2,20,  0, 20,0.5,1,depth-1);
											FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,25,2,20,180,-20,0.5,1,depth-1);
											StopAllVoice();
										}
									}
								}
							}
						}
					}
					break;
				case 13:
					if(KEYFRAME){
						if(random(100)<50) MotionChange(JUMP,4,2);
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		/*-----------------------------------------------*/

		case STAND :
			if(random(100)<2){ MotionChange(JUMP,0,1); break; }
			/* 相手の方を向く */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			switch(irandom(7)){
				case 0: if( searchPlayer(300,200,100, 10) ) MotionChange(SPEAR,0,2);      break;
				case 1: if( searchPlayer(400,220,50,  5) ) MotionChange(MULTSPEAR,0,2);   break;
				case 2: if( searchPlayer(360,235,50,  5) ) MotionChange(MULTSPEAR,0,2);   break;
				case 3: if( searchPlayer(450,210,100, 10) ) MotionChange(HATCHETS,0,2);   break;
				case 4: if( searchPlayer(400,225,150, 5) ) MotionChange(DOUBLESLICE,0,2); break;
				case 5: if( searchPlayer(400,230,150, 5) ) MotionChange(STAMP,0,2);       break;
				case 6: if( searchPlayer(330,245,50, 10) ) MotionChange(WALKSPEAR,0,2);   break;
				case 7: if( searchPlayer(100,270,100, 10) ) MotionChange(JUMP,0,2);           break;
			}
			if( searchPlayer(150, 90,150, 2) ){ MotionChange(FINGERPRESS,0,2); break; }
			if( objPlayerDoll.HEAD.image_alpha && searchPlayer(300,270, 50, 10) ){ MotionChange(NECKCUT,0,2); break; }

			/* 近づいたら歩く */
			if( random(100)<15 && !air && 10<playerDistanceX){ MotionChange(WALK,0,2); break; }

			break;
		/*-----------------------------------------------*/
		case WALK :
			if(random(100)<2){ MotionChange(JUMP,0,1); break; }
			/* 相手の方を向く */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			switch(irandom(7)){
				case 0: if( searchPlayer(300,200,100, 10) ) MotionChange(SPEAR,0,2);      break;
				case 1: if( searchPlayer(400,220,50,  5) ) MotionChange(MULTSPEAR,0,2);   break;
				case 2: if( searchPlayer(360,235,50,  5) ) MotionChange(MULTSPEAR,0,2);   break;
				case 3: if( searchPlayer(450,210,100, 10) ) MotionChange(HATCHETS,0,2);   break;
				case 4: if( searchPlayer(400,225,150, 5) ) MotionChange(DOUBLESLICE,0,2); break;
				case 5: if( searchPlayer(400,230,150, 5) ) MotionChange(STAMP,0,2);       break;
				case 6: if( searchPlayer(330,245,50, 10) ) MotionChange(WALKSPEAR,0,2);   break;
				case 7: if( searchPlayer(100,270,100, 10) ) MotionChange(JUMP,0,2);           break;
			}
			if( searchPlayer(150, 90,150, 2) ){ MotionChange(FINGERPRESS,0,2); break; }
			if( objPlayerDoll.HEAD.image_alpha && searchPlayer(300,270, 50, 10) ){ MotionChange(NECKCUT,0,2); break; }

			switch(KeyFrmNum){
				case 2 : 
				case 6 : Move(-5*Direction,0); if(KEYFRAME){ Quake(2,2); playEnemySound(SOUND_TAKEON); } break;
				default: Move(-12*Direction,0); break;
			}
			/* 近づきすぎたり離れたりしたら止まる */
			if( 10>playerDistanceX ) MotionChange(STAND,0,3);
			break;
		/*-----------------------------------------------*/
		case NECKCUT :
			DepthSet(objPlayerDoll.depth + 1000);
			with(PartsParam(PARTS_BODY)){ depth = objPlayerDoll.depth - 2000; }
			with(PartsParam(PARTS_EYE)){  depth = objPlayerDoll.depth - 1000; }
			/* 相手の方を向く */
			switch(KeyFrmNum){
				case 5 : 
					if(KEYFRAME){
						col = collision_circle( x,y+300, 64,objPlayerDoll,0,1);
						with(col){
							if(!INV && HEAD.image_alpha && abs(HEAD.image_xscale)>0.3){
								var tmp_parts;
								repeat(5){
									with(other){ tmp_parts = PartsParam(PARTS_BODY); }
									new = instance_create(tmp_parts.x,tmp_parts.y,objSpring);
									new.Points[0,new.ATTACH]    = tmp_parts;
									new.Points[0,new.ATTACHDIS] = 96;
									new.Points[0,new.ATTACHDIR] = 265+random(10);
									new.Points[9,new.ATTACH]    = objPlayerDoll.HEAD;
									new.Points[9,new.ATTACHDIS] = random(32);
									new.Points[9,new.ATTACHDIR] = 180+random(180);
									new.image_blend = COLOR_BLOOD;
								}
								StopAllVoice();
								with(other){playEnemySound(SOUND_NIKU);}
								Fluid(x,y,COLOR_BLOOD,30,2,10,180,0,0.5);
								Fluid(x,y-32,COLOR_BLOOD,30,5,20,  0, 10,0.5);
								Fluid(x,y-32,COLOR_BLOOD,30,5,20,180,-10,0.5);
								Flash(c_red,1,0.05);
								Quake(30,30);
								HEAD.image_alpha = 0;
								with(objCommon_Head){ image_alpha = 0; }
								with(objCommon_Body){ if(random(100)<50) FluidBreak = true; }
								addDamage(500, -1, -1, -1, -1, -1, -1);
								MotionChange(DOWN_1,0,5);
							}
						}
					}
					break;
			}

			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		/*-----------------------------------------------*/
		case DOUBLESLICE :
			switch(KeyFrmNum){
				case  1 : 
				case  9 : 
					HitFlag = 0;
					break;
				case  6 : 
					if(KEYFRAME){ sound_play(sndSwing00); }
				case  7 : 
					if(KEYFRAME && !HitFlag && abs(objPlayerDoll.HEAD.image_xscale)>0.3){
						col = collision_line(     x-100,y+300,x-400,y+250, objPlayerDoll,0,1);
						if(!col){
							col = collision_line( x+100,y+300,x+400,y+250, objPlayerDoll,0,1);
						}
						with( col ){
							if(!INV && !BINDED){
								other.HitFlag = true;
								sound_play(sndHit02);
								Quake(15,15);
								with(other){
									switch(irandom(3)){
										case 0 : playEnemySound(SOUND_SLASH0); break;
										case 1 : playEnemySound(SOUND_SLASH1); break;
										case 2 : playEnemySound(SOUND_SLASH2); break;
										case 3 : playEnemySound(SOUND_SLASH3); break;
									}
								}

								if(global.PlayerHP<30 && objPlayerDoll.HEAD.image_alpha){
									addDamage(50,DOWN_1, 0, 1, DOWN_1, 0, 2);
									head = Macro_CutHead();
									if(head){
										repeat(1){
											tmp_parts = head;
											new = instance_create(tmp_parts.x,tmp_parts.y,objSpring);
											new.Points[0,new.ATTACH]    = tmp_parts;
											new.Points[9,new.ATTACH]    = objPlayerDoll.BODY_TOP;
											new.image_blend = COLOR_BLOOD;
										}
										head.speed = 40;
										if( other.x > x ){
											head.direction = 135;
											Fluid(objPlayerDoll.HEAD.x,objPlayerDoll.HEAD.y,COLOR_BLOOD,30,15,5,90, 90,1.0);
										}else{
											head.direction =  45;
											Fluid(objPlayerDoll.HEAD.x,objPlayerDoll.HEAD.y,COLOR_BLOOD,30,15,5,90,-90,1.0);
										}
									}
									with(other){ playEnemySound(SOUND_HEAD); }
								}else{
									DamageVoiceRandom_Mid();
									if(Direction){
										if( other.x > x ) addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
										else              addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
									}else{
										if( other.x > x ) addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
										else              addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
									}
									if( other.x > x ){
										hspeed = -40;
										with(other){ Fluid(x-300,y+200,COLOR_BLOOD,25,5,25,90, 180,1.0); }
									}else{
										hspeed =  40;
										with(other){ Fluid(x+300,y+200,COLOR_BLOOD,25,5,25,90,-180,1.0); }
									}
									PartsDamage(objExtParts,		-30,0);
									PartsBloodDamage(objExtParts,	-30,0);
									vspeed = -20;
								}
							}
						}
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		/*-----------------------------------------------*/
		case HATCHETS :
			switch(KeyFrmNum){
				case  1 : 
				case  9 : 
					HitFlag = 0;
					break;
				case  6 : 
					if(KEYFRAME){ Quake(10,5); sound_play(sndSwing00); playEnemySound(SOUND_TAKEON); }
				case  7 : 
					if(KEYFRAME && !HitFlag){
						         col = collision_line(x+Direction*-350,y,x+Direction*-450,y+300, objPlayerDoll,0,1);
						if(!col) col = collision_line(x+Direction*-300,y,x+Direction*-400,y+300, objPlayerDoll,0,1);
						if(!col) col = collision_line(x+Direction*-250,y,x+Direction*-350,y+300, objPlayerDoll,0,1);
						with( col ){
							if(!INV && !BINDED){
								if(!INV && !BINDED){
									other.HitFlag = true;
									with(other){ playEnemySound(SOUND_SMASH); }
									if( Direction ) addDamage(50,DOWN_0, 0, 1, DEATHPRESS_DOWN_0, 0, 2);
									else		    addDamage(50,DOWN_1_FRONT, 2, 1, DEATHPRESS_DOWN_1, 2, 2);
									vspeed = 40;
									PartsDamage(objExtParts,		-30,0);
									PartsBloodDamage(objExtParts,	-30,0);
									DamageVoiceRandom_High();
									if(isGameOver()){
										Direction = -1*other.Direction;
										with(other){
											startBind( objPlayerDoll,BIND_HATCHETS,0,other.FINISHED_BOSSHITOANG_HATCHETS ,0,1 );
											MotionChange(HATCHETS_FINISH,0,1);
										}
										StopVoice(V_MUSE,0);
										SpecialVoice(V_MUSE,0);
									}
								}
							}
						}
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		/*-----------------------------------------------*/
		case SPEAR :
			switch(KeyFrmNum){
				case  1 : 
				case  9 : 
					HitFlag = 0;
					break;
				case  3 : 
					if(KEYFRAME){ sound_play(sndSwing03); }
				case  4 : 
					if(KEYFRAME && !HitFlag){
						col = collision_line(x+Direction*-150,y+150,x+Direction*-450,y+50, objPlayerDoll,0,1);
						with( col ){
							if(!INV && !BINDED){
								other.HitFlag = true;
								if(Direction){
									if( other.x > x ) addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
									else              addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
								}else{
									if( other.x > x ) addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
									else              addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
								}
								if( other.x > x ){
									with(other){ Fluid(x-300,y+50,COLOR_BLOOD,25,5,25,90, 180,1.0); }
								}else{
									with(other){ Fluid(x+300,y+50,COLOR_BLOOD,25,5,25,90,-180,1.0); }
								}

								with(other){
									switch(irandom(3)){
										case 0 : playEnemySound(SOUND_SLASH0); break;
										case 1 : playEnemySound(SOUND_SLASH1); break;
										case 2 : playEnemySound(SOUND_SLASH2); break;
										case 3 : playEnemySound(SOUND_SLASH3); break;
									}
								}

								PartsDamage(objExtParts,		-30,0);
								PartsBloodDamage(objExtParts,	-30,0);
								hspeed = other.Direction*-50;
								vspeed = -10;
								DamageVoiceRandom_High();
								if(isGameOver()){
									if(Direction){
										with(other){
											if(Direction) startBind( objPlayerDoll,BIND_SPEAR,0,other.FINISHED_BOSSHITOANG_SPEAR2,0,1 );
											else          startBind( objPlayerDoll,BIND_SPEAR,0,other.FINISHED_BOSSHITOANG_SPEAR ,0,1 );
											MotionChange(SPEAR_FINISH,0,1);
										}
									}else{
										with(other){
											if(Direction) startBind( objPlayerDoll,BIND_SPEAR,0,other.FINISHED_BOSSHITOANG_SPEAR ,0,1 );
											else          startBind( objPlayerDoll,BIND_SPEAR,0,other.FINISHED_BOSSHITOANG_SPEAR2,0,1 );
											MotionChange(SPEAR_FINISH,0,1);
										}
									}
									StopVoice(V_MUSE,0);
									SpecialVoice(V_MUSE,0);
								}
							}
							
						}
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		/*-----------------------------------------------*/
		case WALKSPEAR :
			switch(KeyFrmNum){
				case  1 : 
				case  9 : 
					HitFlag = 0;
					break;
				case  3 : 
					if(KEYFRAME){ sound_play(sndSwing03); }
				case  4 : 
					if(KEYFRAME && !HitFlag){
						col = collision_line(x+Direction*50,y+200,x+Direction*-200,y+300, objPlayerDoll,0,1);
						with( col ){
							if(!INV && !BINDED){
								other.HitFlag = true;
								if(Direction){
									if( other.x > x ) addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
									else              addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
								}else{
									if( other.x > x ) addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
									else              addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
								}
								if( other.x > x ){
									Fluid(x,y,COLOR_BLOOD,25,5,25,90, 180,1.0);
								}else{
									Fluid(x,y,COLOR_BLOOD,25,5,25,90,-180,1.0);
								}

								with(other){
									switch(irandom(3)){
										case 0 : playEnemySound(SOUND_SLASH0); break;
										case 1 : playEnemySound(SOUND_SLASH1); break;
										case 2 : playEnemySound(SOUND_SLASH2); break;
										case 3 : playEnemySound(SOUND_SLASH3); break;
									}
								}

								PartsDamage(objExtParts,		-30,0);
								PartsBloodDamage(objExtParts,	-30,0);
								hspeed = other.Direction*-50;
								vspeed = -10;
								DamageVoiceRandom_High();
								if(isGameOver()){
									Direction = -1*other.Direction;
									with(other){
										startBind( objPlayerDoll,BIND_WALKSPEAR,0,other.FINISHED_BOSSHITOANG_WALKSPEAR ,0,1 );
										MotionChange(WALKSPEAR_FINISH,0,1);
									}
									StopVoice(V_MUSE,0);
									SpecialVoice(V_MUSE,0);
								}
							}
							
						}
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		/*-----------------------------------------------*/
		case MULTSPEAR :
			switch(KeyFrmNum){
				case  3 : 
				case  7 : 
				case 10 : 
					if(KEYFRAME){ sound_play(sndSwing03); }
					if(KEYFRAME){
						switch(KeyFrmNum){
							case  3:
							col = collision_line(x,y+180,x+Direction*-220,y+280, objPlayerDoll,0,1); break;
							case  7:
							col = collision_line(x,y+180,x+Direction*-270,y+200, objPlayerDoll,0,1); break;
							case 10:
							col = collision_line(x,y+180,x+Direction*-220,y+380, objPlayerDoll,0,1); break;
						}
						with( col ){
							if(!INV && !BINDED){
								other.HitFlag = true;
								if(Direction){
									if( other.x > x ) addDamage(10,FLYING_1, 0, 1, FLYING_1, 0, 2);
									else              addDamage(10,FLYING_0, 0, 1, FLYING_0, 0, 2);
								}else{
									if( other.x > x ) addDamage(10,FLYING_0, 0, 1, FLYING_0, 0, 2);
									else              addDamage(10,FLYING_1, 0, 1, FLYING_1, 0, 2);
								}
								if( other.x > x ){
									Fluid(x,y,COLOR_BLOOD,25,5,25,90, 180,1.0);
								}else{
									Fluid(x,y,COLOR_BLOOD,25,5,25,90,-180,1.0);
								}
								with(other){
									switch(irandom(3)){
										case 0 : playEnemySound(SOUND_SLASH0); break;
										case 1 : playEnemySound(SOUND_SLASH1); break;
										case 2 : playEnemySound(SOUND_SLASH2); break;
										case 3 : playEnemySound(SOUND_SLASH3); break;
									}
								}
								PartsDamage(objExtParts,		-30,0);
								PartsBloodDamage(objExtParts,	-30,0);
								hspeed = other.Direction*-10;
								vspeed = -10;
								DamageVoiceRandom_High();
								if(isGameOver()){
									Direction = -1*other.Direction;
									with(other){
										startBind( objPlayerDoll,BIND_MULTSPEAR2,0,other.FINISHED_BOSSHITOANG_MULTSPEAR2 ,0,1 );
										MotionChange(MULTSPEAR_FINISH2,0,1);
									}
									StopVoice(V_MUSE,0);
									SpecialVoice(V_MUSE,0);
								}
							}
						}
						/*--------------------------------------*/
						col = noone;
						switch(KeyFrmNum){
							case  3:
							col = collision_line(x+Direction*-250,y+160,x+Direction*-500,y+280, objPlayerDoll,0,1); break;
							case  7:
							col = collision_line(x+Direction*-250,y+200,x+Direction*-400,y+320, objPlayerDoll,0,1); break;
							case 10:
							col = collision_line(x+Direction*-300,y+160,x+Direction*-500,y+80, objPlayerDoll,0,1); break;
						}
						with( col ){
							if(!INV && !BINDED){
								other.HitFlag = true;
								if(Direction){
									if( other.x > x ) addDamage(10,FLYING_1, 0, 1, FLYING_1, 0, 2);
									else              addDamage(10,FLYING_0, 0, 1, FLYING_0, 0, 2);
								}else{
									if( other.x > x ) addDamage(10,FLYING_0, 0, 1, FLYING_0, 0, 2);
									else              addDamage(10,FLYING_1, 0, 1, FLYING_1, 0, 2);
								}
								if( other.x > x ){
									Fluid(x,y,COLOR_BLOOD,25,5,25,90, 180,1.0);
								}else{
									Fluid(x,y,COLOR_BLOOD,25,5,25,90,-180,1.0);
								}
								with(other){
									switch(irandom(3)){
										case 0 : playEnemySound(SOUND_SLASH0); break;
										case 1 : playEnemySound(SOUND_SLASH1); break;
										case 2 : playEnemySound(SOUND_SLASH2); break;
										case 3 : playEnemySound(SOUND_SLASH3); break;
									}
								}
								PartsDamage(objExtParts,		-30,0);
								PartsBloodDamage(objExtParts,	-30,0);
								hspeed = other.Direction*-10;
								vspeed = -10;
								DamageVoiceRandom_High();
								if(isGameOver()){
									Direction = -1*other.Direction;
									with(other){
										startBind( objPlayerDoll,BIND_MULTSPEAR,0,other.FINISHED_BOSSHITOANG_MULTSPEAR ,0,1 );
										MotionChange(MULTSPEAR_FINISH,0,1);
									}
									StopVoice(V_MUSE,0);
									SpecialVoice(V_MUSE,0);
								}
							}
						}
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		/*-----------------------------------------------*/
		case FINGERPRESS :
			switch(KeyFrmNum){
				case  3 : 
					if(KEYFRAME){
						Quake(10,5); sound_play(sndSwing00); playEnemySound(SOUND_TAKEON);
						col = collision_circle(x,y-140,64, objPlayerDoll,0,1);
						with( col ){
							if(!INV && !BINDED){
								with(other){ playEnemySound(SOUND_SMASH); }
								if( Direction ) addDamage(50,DOWN_0, 0, 1, FINISHED_BOSSHITOANG_FINGERPRESS, 0, 2);
								else		    addDamage(50,DOWN_1_FRONT, 2, 1, FINISHED_BOSSHITOANG_FINGERPRESS, 2, 2);
								PartsBloodDamage(objExtParts,	-30,0);
								DamageVoiceRandom_High();
								if(isGameOver()){
									StopVoice(V_MUSE,0);
									SpecialVoice(V_MUSE,0);
								}
							}
						}
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		/*-----------------------------------------------*/
		case STAMP :
			switch(KeyFrmNum){
				case  3 : 
				case  6 : 
				case  9 : 
					if(KEYFRAME){
						switch(KeyFrmNum){
							case  3 : col = collision_circle(x+Direction*-150,y+320,64, objPlayerDoll,0,1); break;
							case  6 : col = collision_circle(x+Direction*-320,y+320,64, objPlayerDoll,0,1); break;
							case  9 : col = collision_circle(x+Direction*-200,y+320,64, objPlayerDoll,0,1); break;
							break;
						}
						Quake(10,5); sound_play(sndSwing00); playEnemySound(SOUND_TAKEON);
						with( col ){
							if(!INV && !BINDED){
								if( Direction ){
									with(other){ playEnemySound(SOUND_SMASH); }
									addDamage(50,DOWN_0, 0, 1, DEATHPRESS_DOWN_0, 0, 2);
									if(!isGameOver()) DamageVoiceRandom_High();
									PartsBloodDamage(objExtParts,	-30,0);
									if(isGameOver()){
										StopVoice(V_MUSE,0);
										SpecialVoice(V_MUSE,0);
									}
								}else{
									if(global.PlayerHP>0){
										Flash(COLOR_BLOOD,1.0,0.001);
										with(other){ playEnemySound(SOUND_SMASH);playEnemySound(SOUND_HEAD); }
										addDamage(50,DOWN_1_FRONT, 2, 1, FINISHED_BOSSHITOANG_STAMP, 2, 2);
										if(!isGameOver()) DamageVoiceRandom_High();
										PartsBloodDamage(objExtParts,	-50,0);
										if(isGameOver()){
											var tmp_parts;
											repeat(5){
												with(other){ tmp_parts = PartsParam(PARTS_LEGL3); }
												new = instance_create(tmp_parts.x,tmp_parts.y,objSpring);
												new.Points[0,new.ATTACH]    = tmp_parts;
												new.Points[0,new.ATTACHDIS] = random(96);
												new.Points[0,new.ATTACHDIR] = 180;
												new.Points[9,new.ATTACH]    = objPlayerDoll.HEAD;
												new.Points[9,new.ATTACHDIS] = random(32);
												new.Points[9,new.ATTACHDIR] = 180+random(180);
												new.image_blend = COLOR_BLOOD;
											}

											FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,25,2,20,  0, 20,0.5,1,depth-1);
											FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,25,2,20,180,-20,0.5,1,depth-1);
											StopAllVoice();
										}
									}
								}

							}
						}
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		case SPEAR_FINISH :
			switch(KeyFrmNum){
				case 8:
					if(KEYFRAME){
						with(BindTarget){ MotionChange(FLYING_0,0,2); hspeed = 40*other.Direction;  }
						endBind();
						sound_play(sndSwing00);
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		case WALKSPEAR_FINISH :
			switch(KeyFrmNum){
				case  4 : 
				case  7 : 
				case 10 : 
				case 13 : 
				case 16 : 
					if(KEYFRAME){
						repeat(1){
							with(other){ tmp_parts = PartsParam(PARTS_YUBI1L2); }
							new = instance_create(tmp_parts.x,tmp_parts.y,objSpring);
							new.Points[0,new.ATTACH]    = tmp_parts;
							new.Points[0,new.ATTACHDIS] = 100+random(96);
							new.Points[0,new.ATTACHDIR] = 90+150*other.Direction;
							new.Points[9,new.ATTACH]    = objPlayerDoll.BODY_TOP;
							new.Points[9,new.ATTACHDIS] = random(32);
							new.Points[9,new.ATTACHDIR] = random(180);
							new.image_blend = COLOR_BLOOD;
						}

						Flash(COLOR_BLOOD,1.0,0.1);
						with(objPlayerDoll){
							FluidWithScale(x-Direction*128,y,COLOR_BLOOD,25,2,20, 90-Direction*30, 30,0.75,1,depth-1000);
							FluidWithScale(x-Direction*128,y,COLOR_BLOOD,25,2,20,270-Direction*30,-30,0.75,1,depth-1000);
						}
						StopAllVoice();
						Quake(10,5);

						switch(irandom(3)){
							case 0 : playEnemySound(SOUND_SLASH0); break;
							case 1 : playEnemySound(SOUND_SLASH1); break;
							case 2 : playEnemySound(SOUND_SLASH2); break;
							case 3 : playEnemySound(SOUND_SLASH3); break;
						}
						PartsDamage(objExtParts,		-30,0);
						PartsBloodDamage(objExtParts,	-30,0);
					}
					break;
				case  6 : 
				case  9 : 
				case 12 : 
				case 15 : 
				case 18 : 
					switch(irandom(5)){
						case 0 : MotionChange(WALKSPEAR_FINISH, 3,2); with(objPlayerDoll){ MotionChange(FINISHED_BOSSHITOANG_WALKSPEAR, 3,2); } break;
						case 1 : MotionChange(WALKSPEAR_FINISH, 6,2); with(objPlayerDoll){ MotionChange(FINISHED_BOSSHITOANG_WALKSPEAR, 6,2); } break;
						case 2 : MotionChange(WALKSPEAR_FINISH, 9,2); with(objPlayerDoll){ MotionChange(FINISHED_BOSSHITOANG_WALKSPEAR, 9,2); } break;
						case 3 : MotionChange(WALKSPEAR_FINISH,12,2); with(objPlayerDoll){ MotionChange(FINISHED_BOSSHITOANG_WALKSPEAR,12,2); } break;
						case 4 : MotionChange(WALKSPEAR_FINISH,15,2); with(objPlayerDoll){ MotionChange(FINISHED_BOSSHITOANG_WALKSPEAR,15,2); } break;
					}
					
					break;
			}
			break;
		case MULTSPEAR_FINISH :
			switch(KeyFrmNum){
				case  9  : 
					if(KEYFRAME){
						SpecialVoice(V_OE,irandom(5));
						Quake(10,5);
						sound_play(sndSwing00);
						playEnemySound(SOUND_SMASH);
					}
					break;
				case  14 : 
					if(KEYFRAME){
						Flash(COLOR_BLOOD,1.0,0.01);
						with(objPlayerDoll){
							FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,25,2,20,  0, 30,0.75,1,depth-1);
							FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,25,2,20,180,-30,0.75,1,depth-1);
						}
						StopAllVoice();
						Quake(10,5);
						sound_play(sndSwing00);
						playEnemySound(SOUND_TAKEON);
						playEnemySound(SOUND_HEAD);
						endBind();
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		case MULTSPEAR_FINISH2:
			switch(KeyFrmNum){
				case  6 : 
					if(KEYFRAME){
						PartsBloodDamage(objExtParts,	-300,0);
						Flash(COLOR_BLOOD,1.0,0.01);
						with(objPlayerDoll){
							FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,25,2,20,  0, 20,0.5,1,depth-1);
							FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,25,2,20,180,-20,0.5,1,depth-1);
						}
						StopAllVoice();
						Quake(10,5);
						sound_play(sndSwing00);
						playEnemySound(SOUND_TAKEON);
						playEnemySound(SOUND_HEAD);
					}
					break;
				case  7 : 
				case  8 : 
				case  9 : 
					with(objPlayerDoll){ FluidWithScale(HEAD.x+Direction*16,HEAD.y,COLOR_BLOOD,5,2,20, 80, 20,0.5,1,depth-1000); }
			}
			if( MOTIONEND ){
				endBind();
				MotionChange(STAND,0,3);
				break;
			}
			break;
		case HATCHETS_FINISH :
			with(objPlayerDoll){ FluidWithScale(HEAD.x,HEAD.y,COLOR_BLOOD,5,2,20,  90-Direction*20, 20,0.5,1,depth-1); }
			switch(KeyFrmNum){
				case  7 : 
					if(KEYFRAME){
						with(BindTarget){ MotionChange(FLYING_0,0,2); }
						endBind();
						Flash(COLOR_BLOOD,1.0,0.01);
						StopAllVoice();
						Quake(10,5);
						playEnemySound(SOUND_TAKEON);
						sound_play(sndSwing00);
					}
					break;
			}
			if( MOTIONEND ){ MotionChange(STAND,0,3); break; }
			break;
		case DEAD_MOTION:
			if(MOTIONEND){
				MotionChange(DEAD_MOTION2,0,3);
			}
			break;
		case DEAD_MOTION2:
			switch(KeyFrmNum){
				case  1 : 
					HitFlag = 0;
					break;
				case  3 : 
					if(KEYFRAME){ sound_play(sndSwing00); }
				case  4 : 
					if(KEYFRAME && !HitFlag && abs(objPlayerDoll.HEAD.image_xscale)>0.3){
						col = collision_line(     x-100,y+300,x-400,y+250, objPlayerDoll,0,1);
						if(!col){
							col = collision_line( x+100,y+300,x+400,y+250, objPlayerDoll,0,1);
						}
						with( col ){
							if(!INV && !BINDED){
								other.HitFlag = true;
								sound_play(sndHit02);
								Quake(15,15);
								with(other){
									switch(irandom(3)){
										case 0 : playEnemySound(SOUND_SLASH0); break;
										case 1 : playEnemySound(SOUND_SLASH1); break;
										case 2 : playEnemySound(SOUND_SLASH2); break;
										case 3 : playEnemySound(SOUND_SLASH3); break;
									}
								}

								if(objPlayerDoll.HEAD.image_alpha){
									addDamage(500,DOWN_1, 0, 1, DOWN_1, 0, 2);
									head = Macro_CutHead();
									if(head){
										repeat(1){
											tmp_parts = head;
											new = instance_create(tmp_parts.x,tmp_parts.y,objSpring);
											new.Points[0,new.ATTACH]    = tmp_parts;
											new.Points[9,new.ATTACH]    = objPlayerDoll.BODY_TOP;
											new.image_blend = COLOR_BLOOD;
										}
										head.speed = 40;
										if( other.x > x ){
											head.direction = 135;
											Fluid(objPlayerDoll.HEAD.x,objPlayerDoll.HEAD.y,COLOR_BLOOD,30,15,5,90, 90,1.0);
										}else{
											head.direction =  45;
											Fluid(objPlayerDoll.HEAD.x,objPlayerDoll.HEAD.y,COLOR_BLOOD,30,15,5,90,-90,1.0);
										}
									}
									with(other){ playEnemySound(SOUND_HEAD); }
								}
							}
						}
					}
					break;
				case  23 : 
					if(KEYFRAME){
						Quake(50,50);
						playEnemySound(SOUND_TAKEON);
						new = instance_create(x,y,objAna);
						with(new){
							move_contact_solid(270,-1);
							event_user(0);
						}
					}
					break;
			}
			if(KeyFrmNum > 10){
				with(PartsParam(PARTS_EYE)){
					depth = objPlayerDoll.depth - 1000;
					image_blend = c_white;
				}
			}else if(KeyFrmNum > 4){
				for(i=0;i<PARTS_MAX;i+=1){
					with(Draw[i]){
						Fluid(x,y,c_black,2,2,10,image_angle,2,0.5);
						if(random(100)<20) effect_create_above(ef_smokeup, x -32+64*random(1),y -32+64*random(1), 1,c_black);
						image_blend = make_color_rgb(other.Color,other.Color,other.Color);
						if(other.Color<0){
							image_blend = c_black;
						}else other.Color -= 1;
					}
				}
			}
			if(MOTIONEND){
				instance_destroy();
			}
			break;
		case TUMBLE :
			switch(KeyFrmNum){
				case 1 : 
					HitFlag = 0;
					break;
				case 8 : 
					if(KEYFRAME){ sound_play(sndSwing00); }
				case 9 : 
					if(KEYFRAME && !HitFlag && abs(objPlayerDoll.HEAD.image_xscale)>0.3){
						col = collision_line(x-100*Direction,y+300,x-400*Direction,y+250, objPlayerDoll,0,1);
						with( col ){
							if(!INV && !BINDED){
								other.HitFlag = true;
								sound_play(sndHit02);
								Quake(15,15);
								with(other){
									switch(irandom(3)){
										case 0 : playEnemySound(SOUND_SLASH0); break;
										case 1 : playEnemySound(SOUND_SLASH1); break;
										case 2 : playEnemySound(SOUND_SLASH2); break;
										case 3 : playEnemySound(SOUND_SLASH3); break;
									}
								}

								if(global.PlayerHP<30 && objPlayerDoll.HEAD.image_alpha){
									addDamage(50,DOWN_1, 0, 1, DOWN_1, 0, 2);
									head = Macro_CutHead();
									if(head){
										repeat(1){
											tmp_parts = head;
											new = instance_create(tmp_parts.x,tmp_parts.y,objSpring);
											new.Points[0,new.ATTACH]    = tmp_parts;
											new.Points[9,new.ATTACH]    = objPlayerDoll.BODY_TOP;
											new.image_blend = COLOR_BLOOD;
										}
										head.speed = 40;
										if( other.x > x ){
											head.direction = 135;
											Fluid(objPlayerDoll.HEAD.x,objPlayerDoll.HEAD.y,COLOR_BLOOD,30,15,5,90, 90,1.0);
										}else{
											head.direction =  45;
											Fluid(objPlayerDoll.HEAD.x,objPlayerDoll.HEAD.y,COLOR_BLOOD,30,15,5,90,-90,1.0);
										}
									}
									with(other){ playEnemySound(SOUND_HEAD); }
								}else{
									DamageVoiceRandom_Mid();
									if(Direction){
										if( other.x > x ) addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
										else              addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
									}else{
										if( other.x > x ) addDamage(30,FLYING_0, 0, 1, FLYING_0, 0, 2);
										else              addDamage(30,FLYING_1, 0, 1, FLYING_1, 0, 2);
									}
									if( other.x > x ){
										hspeed = -40;
										with(other){ Fluid(x-300,y+200,COLOR_BLOOD,25,5,25,90, 180,1.0); }
									}else{
										hspeed =  40;
										with(other){ Fluid(x+300,y+200,COLOR_BLOOD,25,5,25,90,-180,1.0); }
									}
									PartsDamage(objExtParts,		-30,0);
									PartsBloodDamage(objExtParts,	-30,0);
									vspeed = -20;
								}
							}
						}
					}
					break;
			}
			if( MOTIONEND ) MotionChange(STAND,0,3);
			break;
	}
}

switch(MotionNum){
	case SPEAR_FINISH :
	case WALKSPEAR_FINISH :
	case MULTSPEAR_FINISH :
	case MULTSPEAR_FINISH2:
	case HATCHETS_FINISH :
		DepthSet(objPlayerDoll.depth + 1000);
		break;
}
/*
	case HATCHETS_FINISH :
		with(PartsParam(PARTS_BODY)){ depth = objPlayerDoll.depth + 1001; }
		break;
	Line = drawLine(x,y+180,x+Direction*-200,y+280);
	Line.Color = c_red; Line.Width = 3; Line.depth = -1000000;
*/