#TouhouDanmakufu
#Title[Star Color Sign - Supernova]
#Text[Pero que!? Muchas estrellas? y sin bombas? o_O!]
#Image[.\image.jpg]
#PlayLevel[Extra Survival]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\yuugi.mp3]

script_enemy_main{

	let CSD	= GetCurrentScriptDirectory;
        #include_function "script\Yui\SHOT_REPLACE\shot_replace.dnh"
	#include_function "script\Yui\MCircle.txt";
	#include_function"script\Yui\CharacterRect.txt"
	#include_function"script\Yui\functions.txt"
        //#include_function "script\Yui\CutIn\function_cutin.txt"
        let cut = "script\Yui\Img\yui2.png";
        LoadGraphic(cut);
let disparo = "script\Yui\SE\Shot3.wav";
//let ss ="script\Yui\SE\spell.wav";
let vida = "script\Yui\SE\vida.wav";
	let to1 = "script\Yui\SE\se_timeout1.wav";
	let to2 = "script\Yui\SE\se_timeout2.wav";


	let imgBoss = "script\Yui\Img\yui.png";
	let bg = "script\Yui\Img\back.png";
let img_bg= "script\Yui\Img\yuibacka.png";
let img_bgb= "script\Yui\Img\yuibackc.png";
let black= "script\Yui\Img\black.png";
let anim=0;
let type=0;
let bgdist=0;
let rot=0;
let alpha=255;
let drawangle=0;

	@Initialize{
		SetLife(3000);
		SetTimer(50);
                SetDurableSpellCard;
		SetScore(900000);

                ExtendPlayer(4);
                SetInvincibility(70);
                SetEnemyMarker(false);
                MagicCircle(false);
                SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
		LoadGraphic(imgBoss);
                LoadGraphic(bg);
                LoadSE(disparo);
                //LoadSE(ss);
                shotinit;
LoadGraphic(black);
LoadGraphic(img_bg);
LoadGraphic(img_bgb);
LoadSE(vida);
LoadSE(to1);
LoadSE(to2);	
LoadGraphic(imgForbidEffect);


		//cutin("NAZRIN","Star Color Sign "\""Supernova"\",cut, 0, 0, 210, 470);
	CutIn(KOUMA,"Star Color Sign "\""Supernova"\",cut,0,0,1,1);
	        //PlaySE(ss);
                PlaySE(vida);
		mainTask;
	}

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

	@DrawLoop{
  
	if(GetSpeedX()<0){SetGraphicRect(GraphicRectLeft[0],GraphicRectLeft[1],GraphicRectLeft[2],GraphicRectLeft[3]);}
	else if(GetSpeedX()>0){SetGraphicRect(GraphicRectRight[0],GraphicRectRight[1],GraphicRectRight[2],GraphicRectRight[3]);}
	else {SetGraphicRect(GraphicRectCenter[0],GraphicRectCenter[1],GraphicRectCenter[2],GraphicRectCenter[3]);}
	SetAlpha(255);
	SetGraphicExpansion(GraphicScale,GraphicScale);
	SetColor(255,255,255);
	SetGraphicAngle(0,0,0);
	SetTexture(imgBoss);	
	DrawGraphic(GetX(),GetY());	
	
        DrawText("Yui-chan", 40, 35, 12, 255);
        DrawGraphic(GetX, GetY);

Circle;
	}

	@BackGround{
	SetTexture(black);
	SetGraphicRect(-1024, -1024, 1024, 1024);
	SetGraphicAngle(0, 0, 0);
    SetRenderState(ALPHA);
	SetAlpha(255);
	DrawGraphic(GetCenterX, GetCenterY);
	SetTexture(img_bg);
	SetGraphicRect(0, 0, 256, 256);
	SetGraphicAngle(0, 0, rot);
	SetGraphicScale(3, 3);
	SetAlpha(175);
	DrawGraphic(GetCenterX, GetCenterY);
	SetTexture(img_bgb);
	SetGraphicRect(0, 0, 256, 256);
	SetGraphicAngle(0, 0, -rot);
	SetGraphicScale(3, 3);
	SetAlpha(100);
	DrawGraphic(GetCenterX, GetCenterY);
	rot+=0.5;
	}

	@Finalize{
		DeleteGraphic(imgBoss);
		DeleteGraphic(cut);
		DeleteGraphic(bg);
	}

	// main task, activates stuff.
	task mainTask{
Forbid;
		//wait(120);
                ForbidBomb(true);
                ForbidShot(true);
		PlaySE("script\Yui\SE\se_charge01.wav");
		SetColor(100,100,100);
		Concentration01(80);
		SetColor(255,255,255);
		wait(120);

                timeout;
		yield;
		fire;
		movement;

	}
	task timeout(){
		loop{
			if (GetTimer > 4 && GetTimer <= 10){
				PlaySE(to1);
				wait(60);
			}
			else if (GetTimer <= 4){
				PlaySE(to2);
				wait(60);
			}
			
			yield;
		
		}
	}

	task movement{
		loop{
	                
	                SetMovePositionRandom01(GetCenterX,GetCenterY,3,60,100,408,200);
			wait(250);
			yield;
		}
	}

	task fire{
		let x = 0;
		let dir = 0;

		loop{
			//while loop, executes while x<36
			while(x<36){
				//CreateShotA(id,x,y,delay);
			        CreateShotA(4,GetX,GetY,2);
                                CreateShotA(3,GetX,GetY,2);
                                CreateShotA(2,GetX,GetY,2);
                                CreateShotA(1,GetX,GetY,2);
			        CreateShotA(5,GetX,GetY,2);
                                CreateShotA(6,GetX,GetY,2);
                                CreateShotA(7,GetX,GetY,2);
                                CreateShotA(8,GetX,GetY,2);
                                CreateShotA(9,GetX,GetY,2);
			        CreateShotA(0,GetX,GetY,2);
                                CreateShotA(12,GetX,GetY,2);
                                CreateShotA(11,GetX,GetY,2);

				//SetShotDataA(id,time,speed,dir,dir-velocity,acceleration,maxspeed,graphic);

				//Holds bullet still

				//Moves Bullet
                                SetShotDataA(4,0,5,rand(0,360),rand(1,5),-1/10,2,BLUE59);
			        SetShotDataA(4,60,NULL,NULL,0,0,2,BLUE58);
                                SetShotDataA(3,0,5,rand(0,360),rand(1,5),-1/10,2,RED59);
			        SetShotDataA(3,60,NULL,NULL,0,0,2,RED58);
                                SetShotDataA(2,0,5,rand(0,360),rand(1,5),-1/10,2,YELLOW59);
			        SetShotDataA(2,60,NULL,NULL,0,0,2,YELLOW58);
                                SetShotDataA(1,0,5,rand(0,360),rand(1,5),-1/10,2,AQUA59);
			        SetShotDataA(1,60,NULL,NULL,0,0,2,AQUA58);
                                SetShotDataA(5,0,5,rand(0,360),rand(1,5),-1/10,2,WHITE59);
			        SetShotDataA(5,60,NULL,NULL,0,0,2,WHITE58);
                                SetShotDataA(6,0,5,rand(0,360),rand(1,5),-1/10,2,GREEN59);
			        SetShotDataA(6,60,NULL,NULL,0,0,2,GREEN58);
                                SetShotDataA(7,0,5,rand(0,360),rand(1,5),-1/10,2,PURPLE59);
			        SetShotDataA(7,60,NULL,NULL,0,0,2,PURPLE58);
                                SetShotDataA(8,0,5,rand(0,360),rand(1,5),-1/10,2,ORANGE59);
			        SetShotDataA(8,60,NULL,NULL,0,0,2,ORANGE58);
                                SetShotDataA(9,0,5,rand(0,360),rand(1,5),-1/10,2,WHITEI59);
			        SetShotDataA(9,60,NULL,NULL,0,0,2,WHITEI58);
                                SetShotDataA(0,0,5,rand(0,360),rand(1,5),-1/10,2,BLUEI59);
			        SetShotDataA(0,60,NULL,NULL,0,0,2,BLUEI58);
                                SetShotDataA(12,0,5,rand(0,360),rand(1,5),-1/10,2,REDI59);
			        SetShotDataA(12,60,NULL,NULL,0,0,2,REDI58);
                                SetShotDataA(11,0,5,rand(0,360),rand(1,5),-1/10,2,PURPLEI59);
			        SetShotDataA(11,60,NULL,NULL,0,0,2,PURPLEI58);
                                PlaySE(disparo);

				//SetShotKillTime(id,value) optional
                                //SetShotKillTime(4,30);

			      //FireShot(id) fires bullets
                              FireShot(4);
                              FireShot(3);
                              FireShot(2);
                              FireShot(1);
                              FireShot(5);
                              FireShot(6);
                              FireShot(7);
                              FireShot(8);
                              FireShot(9);
                              FireShot(0);
                              FireShot(12);
                              FireShot(11);
				//adjust the angle of the next bullet to complete a circle
				dir+=360/36;
				x++;
			}
			x = 0;
			dir = 0;
			wait(60);

		}
	}

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

