#TouhouDanmakufu
#Title[Reimu Non Spellcard 2]
#Text []
#Player[FREE]
#ScriptVersion[2]			

script_enemy_main{         
	let CSD	= GetCurrentScriptDirectory;
let angul = 180;
let angull = 180;
 	let imgBoss = CSD ~ "system\raymoosprite.png";
	let cut = CSD ~ "system\GusanoCirnoCut.png";
	let bg = CSD ~ "system\lake.png";
        let bgm = CSD ~ "bgm\bgm.mp3";
                  #include_function ".\function_cutin.txt"
#include_function ".\blossom.txt"
#include_function ".\newsfx.txt";
#include_function ".\Obj_hpb.txt"
#include_function ".\let.txt"
	@Initialize{
                LoadUserShotData(CSD ~ "kshotData.txt");
		SetLife(4000);
		SetTimer(45);
SetDamageRate(100, 30);
hpb(0,1,0);
//Timer(2,0);
                SetInvincibility(180);
		SetMovePosition01(GetCenterX,GetCenterY,5);
		LoadGraphic(imgBoss);
		LoadGraphic(cut);
		LoadGraphic(bg);
                PlayMusic(bgm);
		SetCommonData("BGM", "BGM : A Tiny, Tiny, Clever Commander");
		SetCommonData("frame",0);
		SetCommonData("length",460);
	
		mainTask;
	}

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

	@DrawLoop{
DrawText("Reimu Hakurei", 40, 35, 12, 255);
		SetTexture(imgBoss);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,63,73);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetX,GetY);
	}

	@BackGround{
		SetTexture(bg);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,63,73);
		SetGraphicScale(2,2);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
	}

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

	// main task, activates stuff.
	task mainTask{
		yield;
		fire;
		movement;
	}

	task movement{
		loop{
			SetMovePositionRandom01(50,50,9,GetCenterX-80,GetCenterY-120,GetCenterX+80,GetCenterY-100);
			loop(240){yield;}
			yield;
		}
	}
	task fire{
SetColor(255,0,0);
Concentration01(60);
SetColor(255,255,255);
PlaySE(charge);
loop(60){yield;}
		        loop {
            loop(3) {
                angle2 = rand(0, 360);
                CreateShotA(0, GetX, GetY, 4);
                SetShotDataA(0, 0, 4, angle, 0, -0.1, 0, 92);

                CreateShotA(1, 0, 0, 5);
                SetShotDataA(1, 0, 1, angle - 30, 0, 0, 1, 91);
                AddShot(60, 0, 1, 0);
                CreateShotA(2, 0, 0, 5);
                SetShotDataA(2, 0, 1.4, angle - 15, 0, 0, 1.4,91);
                AddShot(60, 0, 2, 0);
                CreateShotA(3, 0, 0, 5);
                SetShotDataA(3, 0, 1.8, angle, 0, 0, 1.8, 91);
                AddShot(60, 0, 3, 0);
                CreateShotA(4, 0, 0, 5);
                SetShotDataA(4, 0, 2.2, angle + 15, 0, 0, 2.2, 91);
                AddShot(60, 0, 4, 0);
                CreateShotA(5, 0, 0, 5);
                SetShotDataA(5, 0, 2.6, angle + 30, 0, 0, 2.6, 91);
                AddShot(60, 0, 5, 0);

                SetShotKillTime(0, 61);

                FireShot(0);
                angle += 360 / 3;
            }
            angle += 7;
PlaySE(shot2);
			loop(3){yield;}
			yield;
		}

}
	}

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