#TouhouDanmakufu
#Title[YuyukoS3_H]
#Text[YuyukoS3_H]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\mu\bgm.mp3]

script_enemy_main {

	#include_function ".\Yuyukoinclude.txt";
	let i = 0;
	let dx = 0;
	let onee = 1;
	let anim3 = 0;
	let color = 0;
	let x = 0;
let y = 0;
let one = 1;
let angle2 = 0;
	@Initialize{
	shotinit;
	LoadSE(time1);
	LoadGraphic(imageFile);
	LoadGraphic(imageFile2);
	LoadSE(time2);
	LoadSE(charge);
	LoadSE(familiarspawn);
	InitializeAction;
	SetLife(1500);
	LoadSE(ping);
	LoadSE(shot);
	DelayedStart;
	LoadSE(shot2);
	LoadSE(die);
	LoadSE(wisps);
	LoadSE(wispspawner);
	SetTimer(99);
	SetEnemyMarker(true);
	SetInvincibility(600);
	SetDamageRate(40, 25);
	SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
	SetAction(ACT_MOVE, 60);
	SetShotAutoDeleteClip(30, 30, 30, 40);
	LoadGraphic(SP);
	LoadGraphic(MC);
	LoadGraphic(CBG1);
	LoadGraphic(CBG2);
	LoadSE(shot4);
	LoadSE(ping);
	LoadSE(dream);
	LoadSE(die);
	LoadGraphic(Cut);
	SetAction(ACT_MOVE, 60);
	SetCommonData("lastattack", false);
	SetShotColor(246, 166, 201);
	}

task DelayedStart {
let i = 0;
let radius = 30;
angle = 180;
wait(90);

SetScore(1500000);
PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
cutin("Reawakening "\""Rise of Earthbound Spirits"\", Cut, 0, 0, 256, 512);
SetAction(ACT_SPELL, 90);

attack1;
//Shiny;
SetTimer(62);
}


task attack1 {

wait(150);
loop{
SetAction(ACT_SHOT_A, 450);
PlaySE(wispspawner);
wait(15);
loop(4){

Spirits(GetPlayerX);;
wait(20);
}
ExMove;
wait(120);

SetAction(ACT_SHOT_A, 300);
wait(30);
PlaySE(wispspawner);
Spirits2;
wait(300);
ExMove;
wait(90);
SetAction(ACT_SHOT_A, 450);
PlaySE(wispspawner);
wait(15);
dx = GetClipMinX+30;

loop(4){

Spirits(dx);
dx+=5+(GetClipMaxX-20)/4;
wait(20);
}
ExMove;
wait(120);

SetAction(ACT_SHOT_A, 300);
wait(30);
PlaySE(wispspawner);
Spirits2;
wait(300);
ExMove;
wait(90);
}
}

task Spirits(x){	let i = 0;
		let obj = Obj_Create(OBJ_SHOT); 
		let  counter = 0;
		Obj_SetPosition(obj, x, GetClipMaxY-5);
		ObjShot_SetGraphic(obj, WHITE03);
		Obj_SetSpeed(obj, 0); 
		Obj_SetAngle(obj, 0);
		Obj_SetAutoDelete(obj, false);
		ObjShot_SetDelay(obj, 181);
		while(!Obj_BeDeleted(obj)) {
			wait(60);
			PlaySE(wisps);
			loop(30){
			CreateShot12(Obj_GetX(obj), Obj_GetY(obj), rand(-i, i), rand(-3, -5), 0, 0.02, 0, rand(2, 3), SP01, 5); 
			wait(4);
			i+=0.03;
			}
			Obj_Delete(obj);
		}
	}


task Spirits2{	let i = 0.25;
		let obj = Obj_Create(OBJ_SHOT); 
		let  counter = 0;
		Obj_SetPosition(obj, GetX, GetClipMaxY-5);
		ObjShot_SetGraphic(obj, WHITE03);
		Obj_SetSpeed(obj, 0); 
		Obj_SetAngle(obj, 0);
		ObjShot_SetDelay(obj, 221);
		Obj_SetAutoDelete(obj, false);
		while(!Obj_BeDeleted(obj)) {
			wait(60);
			PlaySE(wisps);
			loop(40){
			loop(1){
			CreateShot12(Obj_GetX(obj), Obj_GetY(obj), rand(-i, i), rand(-3, -5), 0, 0.02, 0, rand(2, 3), SP01, 5); 
			}
			wait(4);
			i+=0.04;
			}
			Obj_Delete(obj);
		}
	}



@BackGround{

SetTexture(CBG2);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, 0);
SetColor(255, 255, 255);
SetGraphicScale(1, 1);
SetGraphicRect(0, 0-(anim2*4), 512, 512-(anim2*4));
SetAlpha(255);
DrawGraphic(GetCenterX, GetCenterY);
SetTexture(CBG1);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, 0);
SetGraphicScale(1, 1);
SetGraphicRect(0, 0, 512, 512);
SetAlpha(150);
DrawGraphic(GetCenterX, GetCenterY);

SetGraphicScale(1, 1);
anim2 += 1.5;
acc1 = 6;
}


}