#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["spellcard3"]
#Text["light sign~ light piercing through rock[r]"]
#include "script/default_system/Default_ShotConst.txt"

let bossObj;
let bossX = 0;
let bossY = 0;
let objScene = GetEnemyBossSceneObjectID();
let imgBoss = GetCurrentScriptDirectory ~ "sprite/lightgirlsheet.png";
let animFrame = 0; 
let animFrame2 = 0;
let spellcardSFX = GetCurrentScriptDirectory ~ "SFX/SPELLCARD.wav";
let bossdeathSFX = GetCurrentScriptDirectory ~ "SFX/ATTACK3.wav";
let burstSFX = GetCurrentScriptDirectory ~ "SFX/ATTACK2.wav";
let burst2SFX = GetCurrentScriptDirectory ~ "SFX/ATTACK.wav";
let objText = ObjText_Create();
let sky = GetCurrentScriptDirectory ~ "sprite/starbg.jpg";
let overlay = GetCurrentScriptDirectory ~ "sprite/swirl.png";
let circleObj = ObjPrim_Create(OBJ_SPRITE_2D);

let textoverlay = GetCurrentScriptDirectory ~ "sprite/spelltext.png";

let CSD = GetCurrentScriptDirectory;

//textures

let texFog = CSD ~ "sprite/fog.png";

let texTree = CSD ~ "sprite/tree.png"; 

let texFloor = CSD ~ "sprite/floor.png";

//--------------------------------------------
//function to spawn a floor piece
function makeFloor(locX,locY,locZ) {
        let obj = ObjPrim_Create(OBJ_SPRITE_3D);
        ObjPrim_SetTexture(obj,texFloor);
        Obj_SetRenderPriorityI(obj,20);
        ObjSprite3D_SetSourceDestRect(obj,0,0,512,512);
        ObjRender_SetScaleXYZ(obj,1,1,0);
        ObjRender_SetZWrite (obj, true); 

       ObjRender_SetAngleXYZ(obj,90,0,0);
       ObjRender_SetPosition(obj,locX,locY,locZ);
}
//function to spawn wall
function makeWall(locX,locY,locZ) {
        let obj = ObjPrim_Create(OBJ_SPRITE_3D);
        ObjPrim_SetTexture(obj,texFloor);
        Obj_SetRenderPriorityI(obj,20);
        ObjSprite3D_SetSourceDestRect(obj,0,0,512,512);
        ObjRender_SetScaleXYZ(obj,1,1,0);
        ObjRender_SetZWrite (obj, true); 

       ObjRender_SetAngleXYZ(obj,0,90,0);
       ObjRender_SetPosition(obj,locX,locY,locZ);
}


function makeTree(locX,locY,locZ) {
        let obj = ObjPrim_Create(OBJ_SPRITE_3D);
        ObjPrim_SetTexture(obj,texTree);
        Obj_SetRenderPriorityI(obj,20);
        ObjSprite3D_SetSourceDestRect(obj,0,0,300,300);
        ObjRender_SetScaleXYZ(obj,0.5,0.5,0);
        ObjRender_SetZWrite (obj, true); 

       ObjRender_SetAngleXYZ(obj,0,180,180);
       ObjRender_SetPosition(obj,locX,locY,locZ);
}
function makeFog(locX,locY,locZ,red,green,blue) {
        let obj = ObjPrim_Create(OBJ_SPRITE_3D);
        ObjPrim_SetTexture(obj,texFog);
        Obj_SetRenderPriorityI(obj,20);
        ObjSprite3D_SetSourceDestRect(obj,0,0,4096,4096);
        ObjRender_SetScaleXYZ(obj,1,1,0);
        ObjRender_SetZWrite (obj, true); 

      
       ObjRender_SetPosition(obj,locX,locY,locZ);


    ObjSprite3D_SetBillboard(obj, true); //makes this object face camera no matter where the camera is facing 
}

function makeWall2(locX,locY,locZ) {
        let obj = ObjPrim_Create(OBJ_SPRITE_3D);
        ObjPrim_SetTexture(obj,texFloor);
        Obj_SetRenderPriorityI(obj,20);
        ObjSprite3D_SetSourceDestRect(obj,0,0,512,512);
        ObjRender_SetScaleXYZ(obj,1,1,0);
        ObjRender_SetZWrite (obj, true); 

       ObjRender_SetAngleXYZ(obj,0,90,90);
       ObjRender_SetPosition(obj,locX,locY,locZ);
}
//--------------------------------


@Initialize {
    renderStage;
    scrollStage;
	SpellImage;
	SpellText;

   SetAutoDeleteObject(true); //automatically deletes object when THIS script ends

        bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
        ObjEnemy_Regist(bossObj); 

        ObjMove_SetPosition(bossObj,182,200); //warps the boss

        ObjMove_SetDestAtSpeed(bossObj,180,120,10); //movement function

   
              LoadSound (spellcardSFX);
        LoadSound(bossdeathSFX);
     PlaySE(spellcardSFX);
	 LoadSound(burstSFX);
	 LoadSound(burst2SFX);
 ObjText_SetText(objText, "light magic ~ solid light and gaseous rock");
    ObjText_SetFontSize(objText, 14);
    ObjText_SetFontType(objText, "Russell Square Regular");
    ObjText_SetFontBold(objText, true);
    ObjText_SetFontColorTop(objText, 255, 255, 255);
    ObjText_SetFontColorBottom(objText, 255, 255, 255);
    ObjText_SetFontBorderType(objText, BORDER_FULL);
    ObjText_SetFontBorderColor(objText, 224, 64, 192);
    ObjText_SetFontBorderWidth(objText, 1);
   ObjText_SetHorizontalAlignment(objText, ALIGNMENT_RIGHT);
    ObjText_SetMaxWidth(objText, 450);
    ObjRender_SetX(objText, 5 - 80);
	ObjRender_SetY(objText, 20);

     mainTask;
	 

}




@MainLoop {
     bossX = ObjMove_GetX(bossObj);
     bossY = ObjMove_GetY(bossObj);
     
//enemy collision
    ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
    ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
   

    yield;
}


task mainTask { 
	renderBoss;
    renderBG;
	MagicCircle;
	movement;
        TEnd;


} 

task MagicCircle
{    let alpha = 0;
      let spin = 0;
	  let path = GetCurrentScriptDirectory ~ "sprite/lightcircle.png";
	  

     ObjPrim_SetTexture(circleObj,path);
     ObjRender_SetBlendType(circleObj,BLEND_ADD_ARGB);
     Obj_SetRenderPriorityI(circleObj,100);
     ObjRender_SetAlpha(circleObj,120);
     ObjRender_SetScaleXYZ(circleObj,0.8,0.8,0);
     ObjSprite2D_SetSourceRect(circleObj,0,0,182,182);
     ObjSprite2D_SetDestCenter(circleObj);
     
   while(!Obj_IsDeleted(bossObj)){

       ObjRender_SetPosition(circleObj,bossX+32,bossY+12,0);
       ObjRender_SetAngleZ(circleObj,spin);
       ObjRender_SetAlpha(circleObj,alpha);

         alpha = 120;
		 spin+=1.8;
		yield;
        }
    
       yield;
  
 }

@Event {
//boss health and timer
       alternative(GetEventType())
       case(EV_REQUEST_LIFE) {
          SetScriptResult(1200);
       }
       case(EV_REQUEST_TIMER) {
          SetScriptResult(30);
     }

}

@Finalize {

}
task renderBG {

 
        let scrollTex = 0;

        //background
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,20); 
	ObjPrim_SetTexture(obj,sky); 
	ObjSprite2D_SetSourceRect(obj,0,0,1024,768);
	ObjSprite2D_SetDestRect(obj,0,0,GetStgFrameWidth,GetStgFrameHeight);

        //spell card overlay
        let overlayObj = ObjPrim_Create(OBJ_SPRITE_2D);
        Obj_SetRenderPriorityI(overlayObj,21); 
	ObjPrim_SetTexture(overlayObj,overlay); 
        ObjRender_SetBlendType(overlayObj,BLEND_ADD_ARGB); //blend type (effect)
        ObjRender_SetAlpha(overlayObj,100); //set opacity, 200 is maximum
	ObjSprite2D_SetSourceRect(overlayObj,0,0,1024,768);
	ObjSprite2D_SetDestRect(overlayObj,0,0,GetStgFrameWidth,GetStgFrameHeight);
 
        while(!Obj_IsDeleted(bossObj)) {
          ObjSprite2D_SetSourceRect(overlayObj,0-scrollTex,0-scrollTex,1024-scrollTex,768-scrollTex);
		
          scrollTex += 2; //controll how fast its scrolling
          yield;
      }
        Obj_Delete(overlayObj);
} 


task renderStage {

//enable the fog

SetFogEnable(true);

//set begining and end of fog and color
SetFogParam(1024,1563,0,0,0);

makeFog(0,0,2048,344,255,255);

makeFloor(0,0,1024);
makeFloor(0,0,512);
makeFloor(0,0,0);

makeWall(-256,256,1024);
makeWall(-256,256,512);
makeWall(-256,256,0);

makeWall2(256,256,1024);
makeWall2(256,256,512);
makeWall2(256,256,0);

makeTree (0,100,1024);
makeTree (0,100,512);
makeTree (0,100,0);

}

task scrollStage {


 let i = 0;
 let f = 0;
 let scroll = 0;


  //set the minimum and maximum render distance for your camera
    SetCameraPerspectiveClip(16,4096);


 //azimuth camera
    SetCameraAzimuthAngle (-90);
    SetCameraElevationAngle (0);
    SetCameraRadius(64);

 //focus camera
     SetCameraFocusX(0);                //left or right
    SetCameraFocusY(256);               //up or down
    SetCameraFocusZ(-512+scroll);         //depth forward and back 

 // ? camera    
     SetCameraYaw(0);
     SetCameraPitch(0);
     SetCameraRoll(0);   



    loop {

       i = sin(f)*25;
       f+=0.5;
       scroll+=4;
      
       SetCameraRoll(0+i);
       SetCameraYaw(0+i/2);


       SetCameraFocusZ(-512+scroll); 
       if(scroll > 512) {
          scroll = 0;

        }
        scroll+=2; //speed of the counting

        yield; 
   }



}



function wait(w) { loop(w) { yield; } }


task renderBoss {
	let dir;
        let speed;

        //texture the boss and set the center
        ObjPrim_SetTexture(bossObj,imgBoss);
        ObjSprite2D_SetSourceRect(bossObj,0,0,77,100);
        ObjSprite2D_SetDestCenter(bossObj);
        ObjRender_SetScaleXYZ(bossObj,0.5,0.5,0);
    
	while(!Obj_IsDeleted(bossObj)) {
		//when the boss is NOT deleted

		
		dir = ObjMove_GetAngle(bossObj);
		speed = ObjMove_GetSpeed(bossObj);
		
 //animation handling
		if(speed == 0){ 
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame < 5) { ObjSprite2D_SetSourceRect(bossObj,0,0,75,95); }
			if(animFrame >= 5 && animFrame < 10) { ObjSprite2D_SetSourceRect(bossObj,75,0,150,95); }
			if(animFrame >= 15) { ObjSprite2D_SetSourceRect(bossObj,150,0,220,95); }
			
			animFrame2 = 0;
		}
		else if(cos(dir) < 0){ 
			ObjRender_SetAngleXYZ(bossObj,0,180,0);	// flip vertical
			if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,0,102,75,192); }
			if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,75,0,150,95); }
			if(animFrame2 >= 30) { ObjSprite2D_SetSourceRect(bossObj,155,0,222,95); }
		}
		else if(cos(dir) > 0){ 
			ObjRender_SetAngleXYZ(bossObj,0,180,0);	// flip vertical
			if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,0,102,75,192); }
			if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,75,0,150,95); }
			if(animFrame2 >= 30) { ObjSprite2D_SetSourceRect(bossObj,155,0,222,95); }
		}
		animFrame++;		// count animFrame. (++ is +1)
		animFrame2+=2;		// count animFrame2.
		if(animFrame > 20) { animFrame = 0; }	// reset animFrame when it is higher than 60.
		yield;
	}
}


task movement {

let angleT = 0;
        let angle=0;
	wait(100);
	loop { 
	
		ObjMove_SetDestAtSpeed(bossObj,100,120,5);		// move to the left
		wait(45);
		fire;
		fire2;
		wait(30);
		ObjMove_SetDestAtSpeed(bossObj,280,120,5);		// move to the right
		wait(45);
		fire;
		fire2;
		wait(30);
}
}

 task SpellImage{
        let obj = ObjPrim_Create(OBJ_SPRITE_2D);
        let imgpath = GetCurrentScriptDirectory() ~ "sprite/baby.png";
        ObjPrim_SetTexture(obj, imgpath);
		Obj_SetRenderPriorityI(obj,60);
        ObjSprite2D_SetSourceRect(obj, 0, 1, 512, 522); 
        ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetScaleXYZ(obj,0.8,0.8,0);
	
		// Moves the object's coordinates 
	        	let a = 0;
             ascent(i in 0..20){
             ObjRender_SetPosition(obj, a, a, 0);
              a+= 10;
			  
yield;
           
		}
		wait(30);
		ObjRender_SetAlpha(obj,200);
		wait(5);
		ObjRender_SetAlpha(obj,100);
		wait(5);
		ObjRender_SetAlpha(obj,50);
		wait(5);
		Obj_Delete(obj);
		
		

    
	}
	
		task SpellText{
 let scrollTex = 0;
      
	  let overlayObj = ObjPrim_Create(OBJ_SPRITE_2D);
        Obj_SetRenderPriorityI(overlayObj,21); 
	ObjPrim_SetTexture(overlayObj,textoverlay); 
        ObjRender_SetBlendType(overlayObj,BLEND_ADD_ARGB); //blend type (effect)
        ObjRender_SetAlpha(overlayObj,100); //set opacity, 200 is maximum
	ObjSprite2D_SetSourceRect(overlayObj,0,0,400,504);
	ObjRender_SetScaleXYZ(overlayObj,1,1,0);
	ObjSprite2D_SetDestRect(overlayObj,0,0,GetStgFrameWidth,GetStgFrameHeight);
 
        loop(70) {
          ObjSprite2D_SetSourceRect(overlayObj,400-scrollTex,504-scrollTex,0-scrollTex,0-scrollTex);
		
          scrollTex += 5; //controll how fast its scrolling
          yield;
		 
		 
      }
	  
		ObjRender_SetAlpha(overlayObj,200);
		wait(5);
		ObjRender_SetAlpha(overlayObj,100);
		wait(5);
		ObjRender_SetAlpha(overlayObj,50);
		wait(5);
		Obj_Delete(overlayObj);
        
	
}

function angleToPlayer {
	let dir = atan2(GetPlayerY-bossY,GetPlayerX-bossX);
	return dir;
}


task fire{
      if (GetCommonData("Difficulty", 3) == 3){
	
	loop(10){
	PlaySE(burstSFX);

                CreateShotOA1(bossObj, 3, 80,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 100, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 120,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 140, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 160,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 180, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 200,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 220, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 240,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 260, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 280,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 300, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 320,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 340, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 360,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 20, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 40,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 60, DS_BALL_M_SKY, 0);
				
				CreateShotOA1(bossObj, 3, 80,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 100, DS_BALL_M_SKY, 40);
				CreateShotOA1(bossObj, 3, 120,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 140, DS_BALL_M_SKY, 40);
				CreateShotOA1(bossObj, 3, 160,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 180, DS_BALL_M_SKY, 40);
				CreateShotOA1(bossObj, 3, 200,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 220, DS_BALL_M_SKY, 40);
				CreateShotOA1(bossObj, 3, 240,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 260, DS_BALL_M_SKY, 40);
				CreateShotOA1(bossObj, 3, 280,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 300, DS_BALL_M_SKY, 40);
				CreateShotOA1(bossObj, 3, 320,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 340, DS_BALL_M_SKY, 40);
				CreateShotOA1(bossObj, 3, 360,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 20, DS_BALL_M_SKY, 40);
				CreateShotOA1(bossObj, 3, 40,DS_BALL_M_SKY, 60);
                CreateShotOA1(bossObj, 3, 60, DS_BALL_M_SKY, 40);
				
				
		yield;
	}
}

      if (GetCommonData("Difficulty", 2) == 2){
	
	loop(10){
	PlaySE(burstSFX);

                CreateShotOA1(bossObj, 3, 80,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 100, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 120,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 140, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 160,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 180, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 200,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 220, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 240,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 260, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 280,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 300, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 320,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 340, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 360,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 20, DS_BALL_M_SKY, 0);
				CreateShotOA1(bossObj, 3, 40,DS_BALL_M_SKY, 20);
                CreateShotOA1(bossObj, 3, 60, DS_BALL_M_SKY, 0);
				
				
                CreateShotOA1(bossObj, 3, 100, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 140, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 180, DS_BALL_M_SKY, 40);
			
                CreateShotOA1(bossObj, 3, 220, DS_BALL_M_SKY, 40);
			
                CreateShotOA1(bossObj, 3, 260, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 300, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 340, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 20, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 60, DS_BALL_M_SKY, 40);
				
				
		yield;
	}
}

if (GetCommonData("Difficulty", 1) == 1){
	
	loop(10){
	PlaySE(burstSFX);

                CreateShotOA1(bossObj, 3, 80,DS_BALL_M_SKY, 20);
              
				CreateShotOA1(bossObj, 3, 120,DS_BALL_M_SKY, 20);
              
				CreateShotOA1(bossObj, 3, 160,DS_BALL_M_SKY, 20);
              
				CreateShotOA1(bossObj, 3, 200,DS_BALL_M_SKY, 20);
               
				CreateShotOA1(bossObj, 3, 240,DS_BALL_M_SKY, 20);
            
				CreateShotOA1(bossObj, 3, 280,DS_BALL_M_SKY, 20);
            
				CreateShotOA1(bossObj, 3, 320,DS_BALL_M_SKY, 20);
         
				CreateShotOA1(bossObj, 3, 360,DS_BALL_M_SKY, 20);
           
				CreateShotOA1(bossObj, 3, 40,DS_BALL_M_SKY, 20);
          
				
				
                CreateShotOA1(bossObj, 3, 100, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 140, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 180, DS_BALL_M_SKY, 40);
			
                CreateShotOA1(bossObj, 3, 220, DS_BALL_M_SKY, 40);
			
                CreateShotOA1(bossObj, 3, 260, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 300, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 340, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 20, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 60, DS_BALL_M_SKY, 40);
				
				
		yield;
	}
}

if (GetCommonData("Difficulty", 0) == 0){
	
	loop(10){
	PlaySE(burstSFX);

               
          
				
				
                CreateShotOA1(bossObj, 3, 100, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 140, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 180, DS_BALL_M_SKY, 40);
			
                CreateShotOA1(bossObj, 3, 220, DS_BALL_M_SKY, 40);
			
                CreateShotOA1(bossObj, 3, 260, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 300, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 340, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 20, DS_BALL_M_SKY, 40);
				
                CreateShotOA1(bossObj, 3, 60, DS_BALL_M_SKY, 40);
				
				
		yield;
	}
}

}
task fire2 {

if (GetCommonData("Difficulty", 3) == 3){
let angleT = 0;
        let angle=0;

ascent(i in 0..50){
            let obj2 = CreateShotA2(bossX, bossY, 5, angle, -0.10, 1, DS_RICE_M_WHITE, 20);
			CreateShotA2(bossX, bossY, 5, angle, -0.10, 1, DS_RICE_M_WHITE, 40);
			
		angle += 10;	
		 PlaySE(burst2SFX);
           ObjMove_AddPatternA4(obj2, 50, 4, 0, 2, 0, 3,GetPlayerObjectID,DS_SCALE_A_WHITE);
                        
		}
		
		yield;
		
		
		}
		
		if (GetCommonData("Difficulty", 2) == 2){
let angleT = 0;
        let angle=0;

ascent(i in 0..50){
            let obj2 = CreateShotA2(bossX, bossY, 5, angle, -0.10, 1, DS_RICE_M_WHITE, 20);
			
			
		angle += 10;	
		 PlaySE(burst2SFX);
           ObjMove_AddPatternA4(obj2, 50, 4, 0, 2, 0, 3,GetPlayerObjectID,DS_SCALE_A_WHITE);
                        
		}
		
		yield;
		
		
		}
		
		if (GetCommonData("Difficulty", 1) == 1){
let angleT = 0;
        let angle=0;

ascent(i in 0..50){
            let obj2 = CreateShotA2(bossX, bossY, 5, angle, -0.10, 1, DS_RICE_M_WHITE, 20);
			
			
		angle += 10;	
		 PlaySE(burst2SFX);
           ObjMove_AddPatternA4(obj2, 50, 4, 0, 2, 0, 3,GetPlayerObjectID,DS_SCALE_A_WHITE);
                        
		}
		
		yield;
		
		
		}
		
		if (GetCommonData("Difficulty", 0) == 0){
let angleT = 0;
        let angle=0;

ascent(i in 0..50){
            let obj2 = CreateShotA2(bossX, bossY, 5, angle, -0.10, 1, DS_RICE_M_WHITE, 20);
			
			
		angle += 10;	
		 PlaySE(burst2SFX);
           ObjMove_AddPatternA4(obj2, 50, 4, 0, 2, 0, 3,GetPlayerObjectID,DS_SCALE_A_WHITE);
                        
		}
		
		yield;
		
		
		}
		
		}




task TDrawLoop {
    let imgBoss = GetCurrentScriptDirectory() ~ "sprite/testsheet.png";
    ObjPrim_SetTexture(bossObj, imgBoss);
    ObjSprite2D_SetSourceRect(bossObj, 64, 1, 127, 64);
    ObjSprite2D_SetDestCenter(bossObj);
}

task TEnd 
{
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {
		yield;
	}
     PlaySE(bossdeathSFX);   
	Obj_Delete(bossObj);
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);	
	wait(20);	
	CloseScript(GetOwnScriptID());

}