#TouhouDanmakufu
#Title[Youmu s1]
#Text[A strange spell where blood-stained cherry blossoms float in the air...and a ghost tries to hug you.Strange... ]
#BackGround[]
#PlayLevel[Normal]
#Player[FREE]
#BGM[]
#ScriptVersion[2]


script_enemy_main{

#include_function ".\shots\MS_Shot_Name.txt"

let csd = GetCurrentScriptDirectory;	//This is just so I don't have to type this every single time.

 let  Enemy = csd~"img\sprites\youmu.png";
 let  EnemyCutin = csd~"img\cut\youmu.png";


let SpellBG1 = csd~"img/sprites/BG1.png";
let SpellBG2 = csd~"img/sprites/BG2.png";
let bgangle=0;

let shot6 = GetCurrentScriptDirectory~"se\shot6.wav";
let time1 = GetCurrentScriptDirectory~"se\timeout0.wav";
let time2 = GetCurrentScriptDirectory~"se\timeout1.wav";

let angle=0;
let turn=0;
let s=0;
@Initialize{

LoadSE(shot6);
LoadGraphic(Enemy);
LoadGraphic(SpellBG1);
LoadGraphic(SpellBG2);

SetTimer(90);
SetMovePosition02(GetCenterX,GetCenterY-60,60);

LoadUserShotData(GetCurrentScriptDirectory~".\shots\newshots9c.txt");	//Loads the shot definition file, allowing us to use many more types of bullets.


SetLife(1000);		
SetDamageRate(10,5);
SetScore(100000);
CutIn(YOUMU,"Spirits "\""Bloody Cherry Blossoms of Hakugyokurou"\",EnemyCutin,0,0,256,512);
SetEffectForZeroLife(60,0,0);

Move;
MainTask;
Timer;
Vulnerable;
CallMyon;
}


function Wait(t){loop(t){yield;}}


task CallMyon{
Wait(180);

CreateEnemyFromScript("Myon", GetX, GetY, 0,  0, 0); 
}



task Vulnerable
 {
Wait(1200);
SetDamageRate(50,50);	//Becomes more vulnerable after 20 seconds.
}



task Move{
Wait(360);
SetMovePosition02(GetCenterX+rand(-50,50),GetCenterY-rand(80,130),60);
	
}



task Timer{
loop{
	if (GetTimer > 5 && GetTimer <= 11){PlaySE(time1);}
	if (GetTimer >= 1 && GetTimer <= 5){PlaySE(time2);}
	Wait(60);
	}
}


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


task MainTask{

SetInvincibility(180);  //Can't be hit during her charge effect.

Wait(60);
SetColor(64,255,255);	//Sets color to a greenish tone.
Concentration01(120);	//Charges for 2 seconds.
SetColor(255,255,255);	//Sets color back to normal.
Wait(120);

loop{

let num=9;
loop(num){
ascent(i in 0..9){
CreateShot01(GetX,GetY,1+i/5,angle+i*5,RICE_S_RED,10);
CreateShot01(GetX,GetY,1+i/5,angle-i*5,RICE_S_RED,10);

CreateShot01(GetX,GetY,1+i/5,angle+i*5,DOT_RED,20);
CreateShot01(GetX,GetY,1+i/5,angle-i*5,DOT_RED,20);

}
angle+=360/num;}
angle+=40.7;
PlaySE(shot6);
Wait(240);

let num=10;
loop(num){
ascent(s in 0..10){
CreateShot01(GetX+60*cos(angle+180),GetY+60*sin(angle+180),1+s/5,angle+s*4,RICE_S_RED,10);
CreateShot01(GetX+60*cos(angle+180),GetY+60*sin(angle+180),1+s/5,angle-s*4,RICE_S_RED,10);

CreateShot01(GetX+60*cos(angle+180),GetY+60*sin(angle+180),1+s/5,angle+s*4,DOT_RED,20);
CreateShot01(GetX+60*cos(angle+180),GetY+60*sin(angle+180),1+s/5,angle-s*4,DOT_RED,20);}
angle+=360/num;}
PlaySE(shot6);
Wait(240);


let num=18;
loop(num){
ascent(s in 0..6){
CreateShot01(GetX+80*cos(angle+180),GetY+60*sin(angle+180),1+s/5,angle+s*12,RICE_S_RED,s*4);
CreateShot01(GetX+60*cos(angle+180),GetY+80*sin(angle+180),1+s/5,angle-s*12,RICE_S_RED,s*4);

CreateShot01(GetX+80*cos(angle+180),GetY+60*sin(angle+180),1+s/5,angle+s*12,DOT_RED,s*5);
CreateShot01(GetX+60*cos(angle+180),GetY+80*sin(angle+180),1+s/5,angle-s*12,DOT_RED,s*5);}
angle+=360/num;}
PlaySE(shot6);
Wait(240);


		}


}//end of maintask



@DrawLoop{
SetGraphicRect(44,34,87,95);
SetAlpha(255);
SetGraphicScale(1,1);
SetColor(255,255,255);
SetGraphicAngle(0,0,0);
SetTexture(Enemy);
DrawGraphic(GetX,GetY);

}



let bgalpha1 = 0;
let bgalpha2 = 0;

@BackGround{
bgangle-=0.4;
if (bgalpha1 < 255){bgalpha1 += 5;}
if (bgalpha2 < 255){bgalpha2 += 5;}



SetAlpha(bgalpha1);
SetGraphicScale(2.2,2.2);	//The background is scaled up so it can fill the whole screen.
SetColor(255,255,255);
SetGraphicRect(0,0,256,256);
SetTexture(SpellBG1);
DrawGraphic(GetCenterX,GetCenterY);

SetAlpha(bgalpha2);
SetGraphicScale(2.2,2.2);	//The background is scaled up so it can fill the whole screen.
SetColor(255,255,255);
SetGraphicRect(0,0,256,256);
SetGraphicAngle(0,0,bgangle);
SetTexture(SpellBG2);
DrawGraphic(GetCenterX,GetCenterY);


//Remember to set everything back to default before drawing something else 
}




@Finalize{
DeleteGraphic(Enemy);
}

//end of boss script
}





///////////MYON//////////////////
script_enemy Myon {

#include_function ".\shots\MS_Shot_Name.txt"

let shot5 = GetCurrentScriptDirectory~"se\shot5.wav";
let csd = GetCurrentScriptDirectory;	//This is just so I don't have to type this every single time.

function Wait(t){loop(t){yield;}}

let angle =0;
let moveangle=0;
let acc=0;
let rx=0;
let ry=0;

@Initialize
{
SetLife(1);
LoadUserShotData(GetCurrentScriptDirectory~".\shots\newshots9c.txt");	
MyonMove;
MyonAura;
LoadSE(shot5);
}


 @MainLoop {

SetCollisionB(GetX,GetY,32);
yield;

 }


task MyonMove{
loop{

loop(240){

if(rx<120){rx+=0.4;}
if(ry<70){ry+=0.2;}
SetMovePosition02(GetEnemyX+rx*cos(moveangle),GetEnemyY+ry*sin(moveangle),1);
moveangle+=2;
Wait(1);}


PlaySE(shot5);
SetMovePosition02(GetPlayerX,GetPlayerY,60);
Wait(60);

SetMovePosition02(GetEnemyX+rx*cos(moveangle),GetEnemyY+ry*sin(moveangle),60);
Wait(60);
}

}



task MyonAura{


loop{

		CreateShotA(1,GetX+rand(-10,10),GetY+rand(-10,10),rand(20,40));	
		SetShotDataA(1,0,0,rand(0,360),0,0,0,DOT_SKY);			
		SetShotKillTime(1,0);
		FireShot(1);

Wait(1);
	}

} //end of maintask



@DrawLoop
{


}



@Finalize
{
}


}