#TouhouDanmakufu
#Title[Card 1 Lunatic]
#Text [Missing - The Land the World Lost]
#Player[FREE]
#PlayLevel[Lunatic]
#ScriptVersion[2]
script_enemy_main {

//Example of FLAN library for boss sprite drawing...
	#include_function"lib\function_cutin.txt";
	#include_function"lib\SnowFunc.txt";

	#include_function ".\lib\lib_anime_yumemi.txt"; 		// including library
	let ImgBoss = GetCurrentScriptDirectory~"yumemid.png"; 	// declaring the boss image (sprited by Jhonny Walker);
	LoadGraphic(ImgBoss); 				// loading the boss sprite

	let frame = 0;
	let frame2 = 0;
	let i = 0;
	let ii = 0;
	let Name       = "Missing "\""The Land the World Lost"\";
	    let CSD        = GetCurrentScriptDirectory;
	    let ShotData   = CSD ~ "KIKISHOT.txt";
	    let cutinImg   = CSD ~ "Tanioka.png";
	    let var1 = 0;
	    let var2 = 0;
	    let var3 = 0;
	    let var4 = 0;
	let dir = 0;
	let count = 0;
	let dir2 = 0;
	let count2 = 0;
let SpellBG1 = CSD~"img/SpellBG1.png";
let SpellBG2 = CSD~"img/SpellBG2.png";
let bgalpha = 0;
let bgangle = 0;
    @Initialize {
LoadGraphic(SpellBG1);
LoadGraphic(SpellBG2);
/////////Setting Initial Position

	SetX(GetX);
	SetY(GetY);
	Concentration01(30);
	SetMovePosition02(GetCenterX, GetCenterY - 100, 10);
	SetInvincibility(180);
	PlayMusic("script\MUSIC\TH0X05.mp3");
	LoadGraphic(cutinImg);
        SetX(GetX);
        SetY(GetY);
	SetInvincibility(180);
	Concentration03(90);
        SetLife(600);
        SetDamageRate(20, 30);
        SetTimer(30);
        SetEnemyMarker(true);
        SetScore(40000);
	Concentration03(90);
        LoadGraphic("script\img\TANIOKA.png");
        SetTexture("script\img\TANIOKA.png");
        SetGraphicRect(0, 0, 63, 63);
        cutin("KANAKO", Name, cutinImg, 0, 0, 640, 825);
	SetMovePosition02(GetCenterX, GetCenterY, 40);
	spellcardtext(GetX,GetY,5);
	spellcardtext(GetX + 50,GetY,7);
	spellcardtext(GetX - 50,GetY,3);
        LoadUserShotData(ShotData);
	MotionBlur(SHOT,5000,50);		
////////

//////// You can use SetText when using the "Helepolis cutin script" to hide the danmakufu's
//////// default cutin drawings...
        	//the spellcard name...
        MagicCircle(false);		 	// I don' like the floating squares. Change to "true" if you want to see the circle
	SetMovePosition02(GetCenterX, GetCenterY, 40);

///////

////// This is the main function for the sprite control
        InitializeAction();
/////

}
    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	yield;
	frame++;
	if(frame==5){
	        SetAction(ACT_SPELL,60); 			// * For Spell Initialization
	}

	if(frame==80){
		loop(13){	
			CreateShotA(1,GetX,GetY,0);
			SetShotDataA(1,0,4.5,dir+count,0.4,0,0,1);
			SetShotDataA(1,10,2.5,dir+count,0.4,0,0,WHITE23);
			SetShotDataA(1,20,1,dir+count,0.4,0,0,1);
			SetShotDataA(1,25,2.5,dir+count,0.4,0,0,WHITE23);
			SetShotDataA(1,30,1,dir+count,0.4,0,0,1);
			SetShotDataA(1,35,2.5,dir+count,0.4,0,0,RED23);
			SetShotDataA(1,40,1,dir+count,0.4,0,0,1);
			SetShotDataA(1,43,2.5,dir+count,0.4,0,0,PURPLE23);
			SetShotDataA(1,46,1,dir+count,0.4,0,0,1);
			SetShotDataA(1,49,2.5,dir+count,0.4,0,0,PURPLE23);
			SetShotDataA(2,59,1,NULL,0.4,0,0,WHITE23);
			SetShotDataA(2,69,1,NULL,0.4,0,0,PURPLE23);
			FireShot(1);
			dir += 360/13;
			count+=13;

		}
loop(13){
			CreateShotA(2,GetX,GetY,0);
			SetShotDataA(2,0,4.5,dir2+count2,0.4,0,0,WHITE23);
			SetShotDataA(2,10,2.5,dir2+count2,0.4,0,0,1);
			SetShotDataA(2,20,1,dir2+count2,0.4,0,0,WHITE23);
			SetShotDataA(2,25,2.5,dir2+count2,0.4,0,0,1);
			SetShotDataA(2,30,1,dir2+count2,0.4,0,0,RED23);
			SetShotDataA(2,35,2.5,dir2+count2,0.4,0,0,1);
			SetShotDataA(2,40,1,dir2+count2,0.4,0,0,PURPLE23);
			SetShotDataA(2,43,2.5,dir2+count2,0.4,0,0,1);
			SetShotDataA(2,46,1,dir2+count2,0.4,0,0,PURPLE23);
			SetShotDataA(2,56,1,NULL,0.4,0,0,WHITE23);
			SetShotDataA(2,66,1,NULL,0.4,0,0,PURPLE23);

			FireShot(2);
			dir2 -= 360/13;
			count2 -=13;
}
		//SetAction(ACT_SHOT_A,60); 			// * Sieta 45: Shooting... (30 frames shot)
		}


	if(frame==80){frame=66} // * reset 
	if(frame2==80){

PlaySE("script\se\se_tan01.wav");
	frame2 = 66;
	}
frame2++;
var1++;
}



       @DrawLoop {


	if(GetSpeedX()>0){SetAction(ACT_MOVE,0)}		// * Init move for right - keep 0 for better usage    
	if(GetSpeedX()<0){SetAction(ACT_MOVE,0)}		// * Init move for left - keep 0 for better usage
	DrawBoss(ImgBoss);				// * call this to draw the boss
}

@BackGround	//This section is for drawing the background, and normally only works if the script is a spell card. Draws under everything else.
{
if (bgalpha < 255){bgalpha += 5;}
//bgangle += 0.9;

SetAlpha(bgalpha);
//SetGraphicScale(2.2,2.2);	//The background is scaled up so it can fill the whole screen.
SetColor(255,255,255);
SetGraphicRect(0,0,563,563);

SetTexture(SpellBG1);
DrawGraphic(GetCenterX,GetCenterY);

SetTexture(SpellBG2);
SetGraphicAngle(0,0,bgangle);
DrawGraphic(GetCenterX,GetCenterY);
//Remember to set everything back to default before drawing something else (spinning Reimu?!).
}

    @Finalize {

        DeleteGraphic(ImgBoss); 				// * Delete the image 
DeleteGraphic(SpellBG1);
DeleteGraphic(SpellBG2);
loop(15){
            CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));
        }

    }

}
