#TouhouDanmakufu
#Title[Secant Spell 2]
#Text[SECANTCOSINE!]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\patchybackground.png, 0, 3)]
script_enemy_main {
    let ImgBoss = GetCurrentScriptDirectory~"sprite.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let cardcall = GetCurrentScriptDirectory~"cardcall.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let background = GetCurrentScriptDirectory~"patchybackground.png";
	let t = 0;
	let a = 0;
	let v = 1;
    let frame = -120;
	let frame2 = 1;
	let n = 0;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
        SetLife(600);
        SetTimer(50);
	DeleteSE("se\seUseSpellCard.wav");
        LoadSE(shot);
	LoadSE(cardcall);
	PlaySE(cardcall);
	LoadSE(bounce);
	LoadSE(shot2);
	SetShotAutoDeleteClip(200, 200, 200, 200);
	shotinit;
	SetScore(100000);
	
	SetEnemyMarker(true);
	LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        
	SetInvincibility(120);
	SetDamageRate(15, 40);
	LoadGraphic(background);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        CutIn(KOUMA, "Magnetism "\""Slingshot Maneuver"\", GetCurrentScriptDirectory~"cutin2.png", 0, 0, 240, 300);
        
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);

if(frame == 0 || frame == 80){
	let a   = 0;
        let num = 52; //Change this number here to specify the number of bullets in the ring.
	
	loop(num)
            {	
		PlaySE(shot);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, -3.1, a+GetAngleToPlayer, 0.3, 0.04, 2.2, RED57);
		a +=360/num;
FireShot(1);
}
        }

if(frame == 40 || frame == 120){
	let a   = rand_int(20, 0);
        let num = 52; //Change this number here to specify the number of bullets in the ring.
	
	loop(num)
            {	
		PlaySE(shot);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, -3.1, a+GetAngleToPlayer, 0.3, 0.04, 2.2, GREEN57);
		a +=360/num;
FireShot(1);
}
        }

if(frame == 20 || frame == 100){
	let a   = rand_int(20, 0);
        let num = 52; //Change this number here to specify the number of bullets in the ring.
	
	loop(num)
            {	
		PlaySE(shot2);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, -3.1, a+GetAngleToPlayer, -0.3, 0.04, 2.2, BLUE57);
		a +=360/num;
FireShot(1);
}
        }

if(frame == 60 || frame == 140){
	let a   =rand_int(20, 0);
        let num = 52; //Change this number here to specify the number of bullets in the ring.
	
	loop(num)
            {	
		PlaySE(shot2);
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, -3.1, a+GetAngleToPlayer, -0.3, 0.04, 2.2, YELLOW57);
		a +=360/num;
FireShot(1);
}
        }



if(frame == 141){
frame=-30;
}












if(frame2==1){
       v+=1.3;
	}
if(frame2==2){
	v+=-1.3;
	}
        frame++;
	t+=-0.05;
	
    }

   @DrawLoop {
		SetTexture(ImgBoss);
                SetRenderState(ALPHA);
		SetGraphicRect(1, 1, 128, 128);
                SetAlpha(255);  
                SetGraphicScale(1,1);
                SetGraphicAngle(0,0,0);
		DrawGraphic(GetEnemyX,GetEnemyY);
               
                      
 
               
    }
let y = 0;
@BackGround{
   SetTexture(background);
   SetGraphicRect(0, 0-y, 512, 512-y);
   DrawGraphic(GetCenterX, GetCenterY);
  y+=5;
}

let v = 0;
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}
