/*-----重力設定--------------------------*/
if( air ){
	gravity = global.G*0.8;
	gravity_direction = global.Gdir;
}else{
	gravity = 0;
	gravity_direction = 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);

/*-----モーション毎の処理--------------------*/
if(RECV_DAMAGE){
	Fluid(x,y,c_white,2,5,20,0,180,0.5);
	playEnemySound(SOUND_DAMAGE);
}

switch(size){
	case 1 :
		Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
		Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
		Process[ProcessNum[PARTS_SMALL]].image_alpha = 1;
		break;
	case 2 :
	case 3 :
		Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
		Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 1;
		Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
		break;
	default : 
		Process[ProcessNum[PARTS_LARGE]].image_alpha = 1;
		Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
		Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
		break;
}

addCount+=1; /* 合体待機用カウント */
col		= collision_circle( x,y, 32,objPlayerDoll,0,1);
col2	= collision_circle( x,y, 16,object_index,0,1);
if(!ChangeMotion){
	switch(MotionNum){
	/*======================== 小スライム =========================*/
		/*-------- 待機 ---------*/
		case SMALL_STOP :
			atkCount = 0;
			/* 相手の方を向く */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			/* 近づいたら飛ぶ */
			if(playerDirection<200 && random(100)<15 && !air) MotionChange(SMALL_ATTACK,0,5);

			/* 触れたら移動がゆっくりになる */
			with( col ){
				if(!BINDED){
					x -= (x - xprevious)*0.2;
					if(vspeed<0) vspeed *= 0.8;
				}
			}

			if(addCount>60){
				with( col2 ){
					if(atkCount==0){
						Fluid(x,y,c_white,5,5,10,0,180,0.5);
						with(other){ instance_destroy() };
						size+=other.size;
						Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
						Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
						Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
						MotionChange(TRANSFORM,0,1);
					}
				}
			}
			break;
		/*-------- 移動兼攻撃 ---------*/
		case SMALL_ATTACK :
			switch(KeyFrmNum){
				case 3 : 
					vspeed = -5-random(15);
					hspeed = -5-random(15)*Direction;
					break;
				case 4 : 
				case 5 : 
				case 6 : 
				case 7 : 
					if(atkCount==0){
						with( collision_circle( x,y, 4,objPlayerDoll,0,1) ){
							if(!INV && !BINDED){
								if(Direction!=other.Direction)	addDamage(5,DAMAGE_0, 0, 1, DOWN_0, 0, 2);
		                        else							addDamage(5,DAMAGE_0, 0, 1, DOWN_1, 0, 2);
								hspeed = 10*other.Direction*-1;

								Fluid(x,y,c_white,5,5,20,0,180,0.5);
								sound_play(sndHit00);
								Quake(15,15);
								with(other){
									attachX = x - other.x;
									attachY = y - other.y;
									MotionChange(SMALL_ATTACH,0,1);
									atkCount=1;
								}
							}
						}
					}
					if(!air) MotionChange(SMALL_GROUND,0,1);
					break;
			}
			if(MOTIONEND) MotionChange(SMALL_ATTACK,3,1);
			break;
		case SMALL_GROUND :
			if(MOTIONEND) MotionChange(SMALL_STOP,0,1);
			break;
		/*-------- 	天井にひっつく ---------*/
		case SMALL_CEILING : 
			switch(KeyFrmNum){

				/* 天井待機 */
				case 3 : 
					/* 待機モーションループ */
					if(KEYFRAME) MotionChange(SMALL_CEILING,0,1);
				case 0 : 
				case 1 : 
				case 2 : 
					var_hspd = 0;
					with(objPlayerDoll){ other.var_hspd = x - xprevious; }
					if(collision_line(x-var_hspd*5,y,x-var_hspd*5,view_yview+view_hview,objPlayerDoll,0,1)){
						atkCount=1;
						y += 1;
						MotionChange(SMALL_CEILING,4,3);
						break;
					}
					if(atkCount==0){
						move_contact_solid(90,-1);
						speed = 0;
					}
					break;

				/* 落下 */
				case 4 : 
				case 5 : 
				case 6 : 
				case 7 : 
					with( collision_circle( x,y, 4,objPlayerDoll,0,1) ){
						if(!INV){
							if(!BINDED){
								if(Direction!=other.Direction)	addDamage(15,DAMAGE_0, 0, 1, DOWN_0, 0, 2);
			                    else							addDamage(15,DAMAGE_0, 0, 1, DOWN_1, 0, 2);
							}
							Fluid(x,y,c_white,5,5,20,0,180,0.5);
							sound_play(sndHit00);
							Quake(15,15);
							with(other){
								attachX = x - other.x;
								attachY = y - other.y;
								MotionChange(SMALL_ATTACH,0,1);
							}
							atkCount=2;
						}
					}
					/* 着地 */
					if(!air) MotionChange(SMALL_GROUND,0,1);
					break;
			}
			if(MOTIONEND) MotionChange(SMALL_CEILING,4,1);
			break;
		/*-------- 	キャラにひっつく ---------*/
		case SMALL_ATTACH :
			/* キャラより手前に */
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }

			gravity = 0; speed = 0;
			with(objPlayerDoll){
				other.x = x + other.attachX;
				other.y = y + other.attachY;
				if(!BINDED){
					x -= (x - xprevious)*0.15;
					if(vspeed<0) vspeed *= 0.95;
				}
			}
			if(MOTIONEND) MotionChange(SMALL_ATTACH,0,1);
			if( !place_free(x,y) || objPlayerDoll.BINDED || isGameOver() ){
				x = xprevious;
				y = yprevious;
				MotionChange(SMALL_STOP,0,1);
			}
			break;

	/*======================== 中スライム =========================*/
		/*-------- 待機 ---------*/
		case MEDIUM_STOP :
			atkCount = 0;

			/* 相手の方を向く */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			/* 近づいたら飛ぶ */
			if(playerDirection<200 && random(100)<15 && !air) MotionChange(MEDIUM_ATTACK,0,5);

			/* 触れたら移動がゆっくりになる */
			with( col ){
				if(!BINDED){
					x -= (x - xprevious)*0.4;
					if(vspeed<0) vspeed *= 0.6;
				}
			}

			if(addCount>60){
				with( col2 ){
					if(atkCount==0){
						Fluid(x,y,c_white,25,5,10,0,180,0.5);
						with(other){ instance_destroy() };
						size+=other.size;
						Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
						Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
						Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
						MotionChange(TRANSFORM,0,1);
					}
				}
			}
			break;
		/*-------- 移動兼攻撃 ---------*/
		case MEDIUM_ATTACK :
			switch(KeyFrmNum){
				case 3 : 
					vspeed = -5-random(15);
					hspeed = -5-random(15)*Direction;
					break;
				case 4 : 
				case 5 : 
				case 6 : 
				case 7 : 
					if(!air){ MotionChange(MEDIUM_GROUND,0,1); break;}
					if(atkCount==0){
						with( col ){
							if(!INV && !BINDED){
								VoreVoiceRandom_Mid();
								Fluid(x,y,c_white,15,5,20,0,180,0.5);
								if(Direction!=other.Direction){
									addDamage(15,-1, -1, -1, -1, -1, -1);
									with(other){
										Direction = other.Direction;
										startBind( col,BIND_MEDIUM_ATTACKHIT,0,other.BINDED_SLIME_MEDIUM_ATTACKHIT,0,1 );
										MotionChange(MEDIUM_ATTACKHIT,0,1);
										sound_play(sndVore02);
									}
								}else{
									addDamage(15,-1, -1, -1, -1, -1, -1);
									with(other){
										Direction = other.Direction;
										startBind( col,BIND_MEDIUM_ATTACKHIT2,0,other.BINDED_SLIME_MEDIUM_ATTACKHIT2,0,1 );
										MotionChange(MEDIUM_ATTACKHIT2,0,1);
										sound_play(sndVore02);
									}
								}
								other.hspeed *= 0.5;
								if(other.vspeed<0) other.vspeed *= 0.5;
								sound_play(sndHit00);
								Quake(15,15);
								with(other){ atkCount=1; }
							}
						}
					}
					break;
			}
			if(MOTIONEND) MotionChange(MEDIUM_ATTACK,3,1);
			break;

		/*-------- 攻撃ヒット（前から） ---------*/
		case MEDIUM_ATTACKHIT : 

			/* キャラより手前に */
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }

			addDamage(0.1,-1, -1, -1, -1, -1, -1);
			if(isGameOver()){
				VoreVoiceRandom_Mid();
				Flash(c_red,1,0.05);
				Quake(5,5);
				if(global.config_Effect){
					for(i=0;i<40;i+=1){
						new = Bubble(objPlayerDoll.HEAD.x-random(16),objPlayerDoll.HEAD.y-8-random(8),30,20,20);
						new.gravity = -0.1*new.size;
					}
				}
				sound_play(sndVore04);
				startBind( BindTarget,BIND_MEDIUM_ATTACKHIT,0,BindTarget.BINDED_SLIME_MEDIUM_ATTACKHIT_FINISH,0,1 );
				MotionChange(MEDIUM_ATTACKHIT_FINISH,7,1);
				break;
			}
			switch(KeyFrmNum){
				case 13 : 
					if(KEYFRAME){
						VoreVoiceRandom_Low();
						if(global.config_Effect){
							for(i=0;i<3;i+=1){
								new = Bubble(objPlayerDoll.HEAD.x-random(16),objPlayerDoll.HEAD.y-8-random(8),30,20,20);
								new.gravity = -0.1*new.size;
							}
						}
						addDamage(2,-1, -1, -1, -1, -1, -1);
						Fluid(x,y,c_white,5,5,20,0,180,0.3);
						Quake(5,5);
						sound_play(sndVore03);
						startBind( BindTarget,BIND_MEDIUM_ATTACKHIT,0,BindTarget.BINDED_SLIME_MEDIUM_ATTACKHIT,10,1 );
						MotionChange(MEDIUM_ATTACKHIT,7,1);
					}
					break;
			}
			/* 拘束解除処理 */
			if(BindTarget){
				if(!BindTarget.BINDED){
					Fluid(x,y,c_white,5,5,20,0,180,0.5);
					vspeed = -15;
					hspeed = -2.5+random(5);
					MotionChange(MEDIUM_STOP,0,5);
					with(BindTarget){ MotionChange(BINDED_SLIME_MEDIUM_ATTACKHIT,28,1); }
					endBind();
					break;
				}
			}
			break;

		/*-------- 攻撃ヒット死亡（前から） ---------*/
		case MEDIUM_ATTACKHIT_FINISH : 
			/* キャラより手前に */
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }

			switch(KeyFrmNum){
				case 13 : 
					if(KEYFRAME){
						Fluid(x,y,c_white,5,5,20,0,180,0.3);
						Quake(5,5);
						sound_play(sndVore03);
						startBind( BindTarget,BIND_MEDIUM_ATTACKHIT,0,-1,-1,-1 );
						MotionChange(MEDIUM_ATTACKHIT_FINISH,7,1);
					}
					break;
			}
			break;

		/*-------- 攻撃ヒット（後ろから） ---------*/
		case MEDIUM_ATTACKHIT2 : 

			/* キャラより手前に */
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }

			addDamage(0.1,-1, -1, -1, -1, -1, -1);
			if(isGameOver()){
				VoreVoiceRandom_Mid();
				Flash(c_red,1,0.05);
				Quake(5,5);
				if(global.config_Effect){
					for(i=0;i<40;i+=1){
						new = Bubble(objPlayerDoll.HEAD.x-random(16),objPlayerDoll.HEAD.y-8-random(8),30,20,20);
						new.gravity = -0.1*new.size;
					}
				}
				sound_play(sndVore04);
				startBind( BindTarget,BIND_MEDIUM_ATTACKHIT2,0,BindTarget.BINDED_SLIME_MEDIUM_ATTACKHIT2_FINISH,0,1 );
				MotionChange(MEDIUM_ATTACKHIT2_FINISH,7,1);
				break;
			}
			switch(KeyFrmNum){
				case 13 : 
					if(KEYFRAME){
						VoreVoiceRandom_Low();
						if(global.config_Effect){
							for(i=0;i<3;i+=1){
								new = Bubble(objPlayerDoll.HEAD.x-random(16),objPlayerDoll.HEAD.y-8-random(8),30,20,20);
								new.gravity = -0.1*new.size;
							}
						}
						addDamage(2,-1, -1, -1, -1, -1, -1);
						Fluid(x,y,c_white,5,5,20,0,180,0.3);
						Quake(5,5);
						sound_play(sndVore03);
						startBind( BindTarget,BIND_MEDIUM_ATTACKHIT2,0,BindTarget.BINDED_SLIME_MEDIUM_ATTACKHIT2,8,1 );
						MotionChange(MEDIUM_ATTACKHIT2,8,1);
					}
					break;
			}
			/* 拘束解除処理 */
			if(BindTarget){
				if(!BindTarget.BINDED){
					Fluid(x,y,c_white,5,5,20,0,180,0.5);
					vspeed = -15;
					hspeed = -2.5+random(5);
					MotionChange(MEDIUM_STOP,0,5);
					with(BindTarget){ MotionChange(BINDED_SLIME_MEDIUM_ATTACKHIT2,23,1); }
					endBind();
					break;
				}
			}
			break;
		/*-------- 攻撃ヒット死亡（後ろから） ---------*/
		case MEDIUM_ATTACKHIT2_FINISH : 
			/* キャラより手前に */
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }

			switch(KeyFrmNum){
				case 13 : 
					if(KEYFRAME){
						Fluid(x,y,c_white,5,5,20,0,180,0.3);
						Quake(5,5);
						sound_play(sndVore03);
						startBind( BindTarget,BIND_MEDIUM_ATTACKHIT2,0,-1,-1,-1 );
						MotionChange(MEDIUM_ATTACKHIT2_FINISH,7,1);
					}
					break;
			}
			break;

		case MEDIUM_GROUND :
			if(MOTIONEND) MotionChange(MEDIUM_STOP,0,1);
			break;
		case MEDIUM_CEILING : 
			switch(KeyFrmNum){
				/* 天井待機 */
				case 3 : 
					/* 待機モーションループ */
					if(KEYFRAME) MotionChange(MEDIUM_CEILING,0,1);
				case 0 : 
				case 1 : 
				case 2 : 
					var_hspd = 0;
					with(objPlayerDoll){ other.var_hspd = x - xprevious; }
					if(collision_line(x-var_hspd*10,y,x-var_hspd*10,view_yview+view_hview,objPlayerDoll,0,1)){
						atkCount=1;
						y += 1;
						MotionChange(MEDIUM_CEILING,4,3);
						break;
					}
					if(atkCount==0){
						move_contact_solid(90,-1);
						speed = 0;
					}
					break;

				/* 落下 */
				case 4 : 
				case 5 : 
				case 6 : 
				case 7 : 
					/* 着地 */
					if(!air){ MotionChange(MEDIUM_GROUND,0,1); break;}
					if(atkCount==1){
						with( col ){
							if(!INV){
								if(!BINDED){
									Fluid(x,y,c_white,15,5,20,0,180,0.5);
									if(Direction!=other.Direction){
										addDamage(15,-1, -1, -1, -1, -1, -1);
										with(other){
											Direction = other.Direction;
											startBind( col,BIND_MEDIUM_ATTACKHIT,0,other.BINDED_SLIME_MEDIUM_ATTACKHIT,0,1 );
											MotionChange(MEDIUM_ATTACKHIT,0,1);
											sound_play(sndVore02);
										}
									}else{
										addDamage(15,-1, -1, -1, -1, -1, -1);
										with(other){
											Direction = other.Direction;
											startBind( col,BIND_MEDIUM_ATTACKHIT2,0,other.BINDED_SLIME_MEDIUM_ATTACKHIT2,0,1 );
											MotionChange(MEDIUM_ATTACKHIT2,0,1);
											sound_play(sndVore02);
										}
									}
									other.hspeed *= 0.5;
									if(other.vspeed<0) other.vspeed *= 0.5;
									sound_play(sndHit00);
									Quake(15,15);
									with(other){ atkCount=2; }
								}
							}
						}
					}
					break;
			}
			if(MOTIONEND) MotionChange(MEDIUM_CEILING,4,1);
			break;

	/*======================== 大スライム =========================*/
		/*-------- 待機 ---------*/
		case LARGE_STOP :
			atkCount = 0;

			/* 相手の方を向く */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			/* 近づいたら飛ぶ */
			if(playerDirection<200 && random(100)<15 && !air) MotionChange(LARGE_ATTACK,0,5);

			/* 触れたら移動がゆっくりになる */
			with( col ){
				if(!BINDED){
					x -= (x - xprevious)*0.5;
					vspeed *= 0.5;
				}
			}
			break;
		/*-------- 移動兼攻撃 ---------*/
		case LARGE_ATTACK :
			switch(KeyFrmNum){
				case 3 : 
					vspeed = -5-random(15);
					hspeed = -5-random(15)*Direction;
					break;
				case 4 : 
				case 5 : 
				case 6 : 
				case 7 : 
					if(!air){ MotionChange(LARGE_GROUND,0,1); break; }
					if(atkCount==0){
						with( col ){
							if(!INV && !BINDED){
								VoreVoiceRandom_High();
								with(other){
									Fluid(x,y,c_white,5,5,20,0,180,0.5);
									Direction = other.Direction;
									startBind( col,BIND_LARGE_ATTACKHIT,0,other.BINDED_SLIME_LARGE_ATTACKHIT,0,1 );
									MotionChange(LARGE_ATTACKHIT,0,1);
									sound_play(sndVore02);
								}
								sound_play(sndHit00);
								Quake(15,15);
								with(other){ atkCount=1; }
							}

						}
					}
					break;
			}
			if(MOTIONEND) MotionChange(LARGE_ATTACK,3,1);
			break;

		/*-------- 攻撃ヒット ---------*/
		case LARGE_ATTACKHIT : 

			/* キャラより手前に */
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }

			addDamage(0.2,-1, -1, -1, -1, -1, -1);
			if(isGameOver()){
				VoreVoiceRandom_Mid();
				Quake(5,5);
				Flash(c_red,1,0.05);
				if(global.config_Effect){
					for(i=0;i<40;i+=1){
						new = Bubble(objPlayerDoll.HEAD.x-random(16),objPlayerDoll.HEAD.y-8-random(16),30,30,30);
						new.gravity = -0.1*new.size;
					}
				}
				sound_play(sndVore04);
				startBind( BindTarget,BIND_LARGE_ATTACKHIT,0,BindTarget.BINDED_SLIME_LARGE_ATTACKHIT_FINISH,0,1 );
				MotionChange(LARGE_ATTACKHIT_FINISH,0,1);
				break;
			}
			if(!air){
				if(global.config_Effect){
					for(i=0;i<1;i+=1){
						new = Bubble(x-32+random(64),y-random(64),60,20,20);
						new.gravity = -0.1*new.size;
					}
				}
			}
			switch(KeyFrmNum){
				case 12 : 
					VoreVoiceRandom_Low();
					if(global.config_Effect){
						for(i=0;i<10;i+=1){
							new = Bubble(objPlayerDoll.HEAD.x-random(16),objPlayerDoll.HEAD.y-8-random(8),30,20,20);
							new.gravity = -0.1*new.size;
						}
					}
					if(KEYFRAME){
						addDamage(1,-1, -1, -1, -1, -1, -1);
						Fluid(x,y,c_white,5,5,20,0,180,0.3);
						Quake(10,10);
						sound_play(sndVore04);
						startBind( BindTarget,BIND_LARGE_ATTACKHIT,0,BindTarget.BINDED_SLIME_LARGE_ATTACKHIT,6,1 );
						MotionChange(LARGE_ATTACKHIT,5,1);
					}
					break;
			}

			/* 拘束解除処理 */
			if(BindTarget){
				if(!BindTarget.BINDED){
					Fluid(x,y,c_white,5,5,20,0,180,0.5);
					vspeed = -15;
					hspeed = -2.5+random(5);
					MotionChange(LARGE_STOP,0,5);
					with(BindTarget){ MotionChange(FLYING_0,0,2); }
					endBind();
					break;
				}
			}
			break;

		/*-------- 攻撃ヒット死亡---------*/
		case LARGE_ATTACKHIT_FINISH : 
			/* キャラより手前に */
			depth = objPlayerDoll.depth - 1000;
			for(i=0;i<PARTS_MAX;i+=1) with(Draw[i]){ depth = other.depth - other.i*3; }

			switch(KeyFrmNum){
				case 12 : 
					if(KEYFRAME){
						addDamage(1,-1, -1, -1, -1, -1, -1);
						Fluid(x,y,c_white,5,5,20,0,180,0.3);
						Quake(10,10);
						sound_play(sndVore04);
						startBind( BindTarget,BIND_LARGE_ATTACKHIT,0,-1,-1,-1 );
						MotionChange(LARGE_ATTACKHIT_FINISH,5,1);
					}
					break;
			}
			break;

		case LARGE_GROUND :
			if(MOTIONEND) MotionChange(LARGE_STOP,0,1);
			break;
		/*-------- 全身のみ ---------*/

	/*======== 変形 =========*/
		case TRANSFORM : 
			if(ARGUMENT[0]!=null){
				size = ARGUMENT[0];
				ARGUMENT[0] = null;
			}
			Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
			Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
			Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
			switch(size){
				case 1 : 
					HP = 100;
					if(collision_line(x,y,x,y-96,objBlock,0,1)) MotionChange(SMALL_CEILING,0,1);
					else MotionChange(SMALL_STOP,0,1);
					break;
				case 2 : 
				case 3 : 
					HP = 200;
					if(collision_line(x,y,x,y-96,objBlock,0,1)) MotionChange(MEDIUM_CEILING,0,1);
					else MotionChange(MEDIUM_STOP,0,1);
					break;
				default : 
					MotionChange(LARGE_STOP,0,1);
					HP = 400;
					break;
			}
			break;
	/*======== 死亡モーション =========*/
		case DEAD_MOTION :
			switch(size){
				case 1 : 
					break;
				case 2 : 
				case 3 :
					new = instance_create(x,y,global.EnemyObject[index]);
					with(new){
						speed=10;
						direction=45;
						size=1;
						Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
						Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
						Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
						MotionChange(TRANSFORM,0,1);
					}
					new = instance_create(x,y,global.EnemyObject[index]);
					with(new){
						speed=10;
						direction=135;
						size=1;
						Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
						Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
						Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
						MotionChange(TRANSFORM,0,1);
					}
					break;
				default :
					new = instance_create(x,y,global.EnemyObject[index]);
					with(new){
						speed=10;
						direction=45;
						size=2;
						Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
						Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
						Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
						MotionChange(TRANSFORM,0,1);
					}
					new = instance_create(x,y,global.EnemyObject[index]);
					with(new){
						speed=10;
						direction=135;
						size=2;
						Process[ProcessNum[PARTS_LARGE]].image_alpha = 0;
						Process[ProcessNum[PARTS_MEDIUM]].image_alpha = 0;
						Process[ProcessNum[PARTS_SMALL]].image_alpha = 0;
						MotionChange(TRANSFORM,0,1);
					}
					break;
			}
			if(MOTIONEND){
				effect_create_above(ef_explosion,x,y,1,c_white);
				Flash(c_white,0.1,0.05);
				Fluid(x,y,c_white,5,5,20,0,180,0.5);
				Quake(5,5);
				sound_play(sndFluid);
				instance_destroy();
			}
			break;
	}
}