#TouhouDanmakufu#TouhouDanmakufu
#Title[Second Spell]
#Text[SECANTCOSINE!]
#Player[FREE]
#BGM[.\BGM.mp3]
#ScriptVersion[2]
#BackGround[User(.\BG.png, 0, 0)]


script_enemy_main {
	let lolol = 0;
	let s = -0.01;
    let ImgBoss = GetCurrentScriptDirectory~"nimono.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let time1 = GetCurrentScriptDirectory~"time1.wav";
	let time2 = GetCurrentScriptDirectory~"time2.wav";
	let timer = GetTimer;
	let initialscore = GetScore;
	let background = GetCurrentScriptDirectory~"BG2.png";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let angle = 0;
	let charge = GetCurrentScriptDirectory~"charge.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let explode = GetCurrentScriptDirectory~"explode.wav";
	let familiarspawn = GetCurrentScriptDirectory~"familiarspawn.wav";
	let tilt = 0;
	let alive = 1;
	let moo = 867;
	let xs = GetCommonData("secx");
	let ys = GetCommonData("secy");
	let xy = 0;
	let nyan = 1;
	let v = 90;
    let frame = 0;
	let frame2 = 0;
	let n = 0;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
		PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
	DeleteSE("se\seUseSpellCard.wav");
        SetLife(1000);
	LoadGraphic(background);
	SetCommonData("alive", true);
	CutIn(KOUMA, ""\""The Opposite of An Abundance of Personal Space"\", GetCurrentScriptDirectory~"cutin2.png", 150, 40, 450, 300);
	SetScore(200000);
        SetTimer(60);
	LoadSE(time1);
	LoadSE(time2);
	MagicCircle(false);
        LoadSE(shot);
	LoadSE(bounce);
	LoadSE(shot2);
	LoadSE(charge);
	LoadSE(familiarspawn);
	SetShotAutoDeleteClip(100, 200, 100, 100);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(120);
	SetDamageRate(25, 40);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
     
    }



    @MainLoop {
	frame++;
	s+=0.0002;
	if(GetTimer!=timer && (GetTimer < 10 && GetTimer>3)){
	PlaySE(time1);
	}

	if(GetTimer!=timer && GetTimer < 4){
	PlaySE(time2);
	}

	timer = GetTimer;
	





	if(frame==130){
	PlaySE(shot2);
	let angle = rand(0, 360);
	let a = 0;
	let num = 10;
	loop(num){
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 2+s, angle+a, -5, 0, 5, YELLOW22);
		SetShotDataA(1, 40, NULL, NULL, -0.9, 0, 5, YELLOW22);
		SetShotDataA(1, 70, NULL, NULL, 0, 0, 5, YELLOW22);
		a+=360/num;
		FireShot(1);
		if(GetEnemyLife<500){
		CreateShotA(2, GetX, GetY, 0);
		SetShotDataA(2, 0, 2+s, -angle+a, 5, 0, 5, YELLOW22);
		SetShotDataA(2, 40, NULL, NULL, -0.5, 0, 5, YELLOW22);
		SetShotDataA(2, 70, NULL, NULL, 0, 0, 5, YELLOW22);
		SetShotDataA(2, 100, 2, NULL, 0, 0, 5, YELLOW22);
		a+=360/num;
	}
		FireShot(1);
		FireShot(2);

}
}


	if(frame==150){
	PlaySE(shot2);
	let angle = rand(0, 360);
	let a = 0;
	let num = 10;
	loop(num){
		CreateShotA(1, GetX, GetY, 0);
		SetShotDataA(1, 0, 2+s, angle+a, 5, 0, 5, WHITE22);
		SetShotDataA(1, 40, NULL, NULL, 0.5, 0, 5, WHITE22);
		SetShotDataA(1, 70, NULL, NULL, 0, 0, 5, WHITE22);
		a+=360/num;
		FireShot(1);
	if(GetEnemyLife<500){
	CreateShotA(2, GetX, GetY, 0);
		SetShotDataA(2, 0, 2+s, -angle+a, -5, 0, 5, WHITE22);
		SetShotDataA(2, 40, NULL, NULL, 0.5, 0, 5, WHITE22);
		SetShotDataA(2, 70, NULL, NULL, 0, 0, 5, WHITE22);
		SetShotDataA(2, 100, 2, NULL, 0, 0, 5, WHITE22);
		a+=360/num;
	}
		FireShot(1);
		FireShot(2);

		
frame=110;
}
}
	
	frame2++;
	yield;
	
	
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	



if(frame2==1){
CreateEnemyFromFile(GetCurrentScriptDirectory~"Secant2B.txt", GetCommonData("secx"), GetCommonData("secy"), 0, 0, 0);
}



    }



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

task LifeGet{ AddLife(1); }


    @BackGround{
   SetTexture(background);
	
   SetGraphicRect(0, 0, 512, 512);
	SetGraphicScale(1.2, 1.2);
   DrawGraphic(GetCenterX, GetCenterY);
	
  
}



    @DrawLoop {
		SetTexture(ImgBoss);
		if(tilt == 0){
		SetGraphicAngle(0, 0, 0);
		SetGraphicRect(1, 1, 128, 128);
                DrawGraphic(GetX,GetY);
		}

    }
let v = 0;
    @Finalize {
	if(GetMissCountInThisSpell == 0 && GetBombCountInThisSpell == 0){ AddScore(initialscore); PlaySE(GetCurrentScriptDirectory~"capture.wav"); }
	if(GetMissCountInThisSpell >0 || GetBombCountInThisSpell > 0){ PlaySE(GetCurrentScriptDirectory~"fail.wav"); }

        DeleteGraphic(ImgBoss);
    }
}
