#TouhouDanmakufu
#Title[Witch Girl "Double Spark in a Milky Way"]
#Text[She copies double spark, but the lasers are a bit skinny... In any case, I wanted to use LASERS.]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let ImgBoss = "script\img\ExRumia.png";
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    let frame = -120;
	let a = 1;
	let b = 0;
	let d = 0;
	
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let laser = GetCurrentScriptDirectory~"laser.wav";
	let background = GetCurrentScriptDirectory~"patchybackground.png";
	let spark = GetCurrentScriptDirectory~"spark.wav";
	let rumia = GetCurrentScriptDirectory~"rumia.png";
    @Initialize {
        SetLife(3400);
        SetTimer(75);
        SetScore(1000000);
	SetInvincibility(180);
	shotinit;
	LoadSE(shot);
	LoadSE(shot);
	LoadSE(laser);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        CutIn(KOUMA, "Witch Girl "\""Double Spark in a Milky Way"\", GetCurrentScriptDirectory~"rumia.png", 0, 0, 128, 256);
	LoadGraphic(background);
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(0, 0, 64, 64);
	SetDamageRate(60, 0);
	SetShotAutoDeleteClip(10, 10, 10, 10);
    }

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


if(GetPlayerX > GetCenterX){
	let a = 0.015;
	}

	if(GetPlayerX < GetCenterX){
	let a = -0.015;
	}
	
	
	if(frame == 120){

	




		let angle = rand(12, 13);
            CreateLaserA(1, GetX, GetY, 4, 90, YELLOW60, 60);
	    SetLaserDataA(1, 0, -angle+GetAngleToPlayer, 0.012, 8, 0, 0); 
	    SetShotKillTime(1, 320);
	    FireShot(1);
            PlaySE(laser);

	CreateLaserA(2, GetX, GetY, 4, 90, YELLOW60, 60);
	    SetLaserDataA(2, 0, angle+GetAngleToPlayer, -0.012, 8, 0, 0); 
	    SetShotKillTime(2, 320);
	    FireShot(2);
            PlaySE(laser);
        }

	if(frame == 180) {
	PlaySE(spark);
		}

	if(frame == 20){

	let c   = 0;
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);

}
}

if(frame == 40){

	let c   = rand(0, 200);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 60){

	let c   = rand(0, 40);
        let num = 50; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 80){

	let c   = rand(0, 600);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 100){

	let c   = rand(0, 80);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 120){

	let c   = rand(0, 100);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 140){

	let c   = rand(0, 120);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 160){

	let c   = rand(0, 140);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 180){

	let c   = rand(0, 160);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 200){

	let c   = rand(0, -200);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 220){

	let c   = rand(0, -400);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 240){

	let c   = rand(0, -600);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 260){

	let c   = rand(0, -80);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 280){

	let c   = rand(0, -120);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 300){

	let c   = rand(0, -140);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 320){

	let c   = rand(0, -160);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 340){

	let c   = rand(0, -180);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 360){

	let c   = rand(0, -200);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 380){

	let c   = rand(0, -100);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, RED59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 400){

	let c   = rand(0, -1000);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, BLUE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}

if(frame == 420){

	let c   = rand(0, -1000);
        let num = 40; //Change this number here to specify the number of bullets in the ring.
        
        loop(num)
        {
            CreateShot01(GetX, GetY, 1, c+90, PURPLE59, 5);
            c += 360/num;
	PlaySE(shot);
}

}
        if(frame == 421) {

	frame=0;

	}
        frame++;
	

    }

   @DrawLoop {
	SetTexture(ImgBoss);
                SetRenderState(ALPHA);
                SetAlpha(255);  
                SetGraphicScale(1,1);
                SetGraphicAngle(0,0,0);

                if(GetSpeedX==0){
                         SetGraphicRect(0,0,64,64); }
                        
 
                if(GetSpeedX>0){
                        SetGraphicRect(190, 126, 256, 64);
			}
 
                if(GetSpeedX<0){
                        
                        SetGraphicRect(128,128,186,64); }
                      
 
                DrawGraphic(GetX,GetY);
    }

let y = 0;

@BackGround{
   SetTexture(background);
   SetGraphicRect(0, 0 - y, 512, 512 - y);
   DrawGraphic(GetCenterX, GetCenterY);
   y+=4;
}

    @Finalize {
        DeleteGraphic(ImgBoss);

	if(GotSpellCardBonus){SetCommonData("SpellCardsCaptured", GetCommonDataDefault("SpellCardsCaptured", 0)+1);}

    }




}



