#e
#Title[T]
#Text[]
#BGM[]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
                        
script_enemy_main{
        #include_function ".\lib_anime_Murasa.txt"
	let imgBoss=GetCurrentScriptDirectory~"dot_murasa.png";
	LoadUserShotData(GetCurrentScriptDirectory ~ "shot_waterl.txt");
        let cx=GetCenterX;
        let cy=GetCenterY;
    	@Initialize
        {
          InitializeAction();
          LoadGraphic(imgBoss);
          SetMovePosition03(cx,cy-140,10,5);
          SetInvincibility(90);
          SetLife(4000);

          Tmain;
	}

	@MainLoop
	{  
                SetCollisionA(GetX(),GetY(),48);
		SetCollisionB(GetX(),GetY(),24);
                yield;
        } 
	
	@Finalize
	{       
		DeleteGraphic(imgBoss);
	}
	
	@DrawLoop
	{//`
                SetColor(255,255,255);
		SetRenderState(ALPHA);
		DrawBoss( imgBoss );

	}
        
        task Tmain
        {
              loop(90){yield}
              loop{
		 SetAction(ACT_SHOT_A, 60);
		 shot1(-120,70,130,30, 80/30,3,6);
		 shot2(-120,70,160,30,140/30,2,5);
		 shot2(-120,70,130,30, 80/3 ,2,6);
		 shot2(-120,70,130,30, 80/5 ,rand(1.4,3),5);
		 loop(28){yield}
		 SetGraphicAngle(180,0,0);
		 SetAction(ACT_SHOT_A, 60);
		 shot3(120,40,50,30, 80/30,3,5);
		 shot4(120,40,20,30,140/30,2,7);
		 shot4(120,40,50,30, 80/3 ,2,5);
		 shot4(120,40,50,30, 80/5 ,rand(1.4,3),7);
		 loop(28){yield}
		 SetGraphicAngle(0,0,0);
		 SetAction(ACT_SHOT_A, 60);
		 shot1(-120,10,130,30, 80/30,3,5);
		 shot2(-120,10,160,30,140/30,2,3);
		 shot2(-120,10,130,30, 80/3 ,2,5);
		 shot2(-120,10,130,30, 80/5 ,rand(1.4,3),3);
		 loop(60){yield}
		 Tmove();
		 loop(90){yield}
              }
        }

        task Tmove(){
                 if(GetX>=cx+100){SetMovePositionRandom01(70,20,2,GetX-40,cy-160,GetX-41,cy-90);}
                 else if(GetX<=cx-100){SetMovePositionRandom01(70,20,2,GetX+40,cy-160,GetX+41,cy-90);}
                 else if(GetX>=GetPlayerX){SetMovePositionRandom01(70,20,2,GetX-40,cy-160,GetX-41,cy-90);}
                 else if(GetX<=GetPlayerX){SetMovePositionRandom01(70,20,2,GetX+40,cy-160,GetX+41,cy-90);}
                 SetAction( ACT_MOVE, 60 );
        }

	task shot1(X,Y,angle,loops,Pangle,speed,col){
		loop(loops){
			CreateShot01(GetX+X,GetY+Y,speed,angle,col,14);
			X+=240/loops;
			Y-=30/loops;
			angle-=Pangle;
			yield;
		}
		
	}

	task shot2(X,Y,angle,loops,Pangle,speed,col){
		loop(loops){
			CreateShot01(GetX+X,GetY+Y,speed,angle,col,14);
			X+=240/loops/2;
			Y-=30/loops/2;
			angle-=Pangle;
			CreateShot01(GetX+X,GetY+Y,speed,angle,col,14);
			X+=240/loops/2;
			Y-=30/loops/2;
			angle-=Pangle;
			yield;
		}
	}

	task shot3(X,Y,angle,loops,Pangle,speed,col){
		loop(loops){
			CreateShot01(GetX+X,GetY+Y,speed,angle,col,14);
			X-=240/loops;
			Y-=30/loops;
			angle+=Pangle;
			yield;
		}
		
	}

	task shot4(X,Y,angle,loops,Pangle,speed,col){
		loop(loops){
			CreateShot01(GetX+X,GetY+Y,speed,angle,col,14);
			X-=240/loops/2;
			Y-=30/loops/2;
			angle+=Pangle;
			CreateShot01(GetX+X,GetY+Y,speed,angle,col,14);
			X-=240/loops/2;
			Y-=30/loops/2;
			angle+=Pangle;
			yield;
		}
	}

}

                       
