#TouhouDanmakufu
#Title[YukaS1_H]
#Text[YukaS1_H]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
	let color = 0;
	#include_function ".\Yukainclude.txt";
	let i = 0;
	let onee = 1;
	let anim3 = 0;
	
	@Initialize{
	shotinit;
	hurtbox = false;
	LoadMusic(bgm);
	PlayMusic(bgm);
	LoadSE(time1);
	LoadGraphic(imageFile);
	LoadSE(time2);
	LoadSE(charge);
	LoadSE(familiarspawn);
	InitializeAction;
	SetLife(1500);
	LoadSE(ping);
	LoadSE(shot);
	LoadSE(capture);
	DelayedStart;
	LoadSE(shot2);
	SetX(GetCenterX);
	SetY(GetClipMinY+120);
	LoadSE(die);
	SetTimer(41);
	SetEnemyMarker(true);
	SetInvincibility(240);
	SetDamageRate(57.5, 25);
	SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
	SetAction(ACT_MOVE, 60);
	SetShotAutoDeleteClip(50, 50, 50, 50);
	LoadGraphic(SP);
	LoadGraphic(MC);
	LoadGraphic(CBG1);
	LoadGraphic(CBG2);
	LoadSE(shot4);
	alphaup;
	alpha = 0;
	LoadSE(die);
	LoadGraphic(Cut);
	SetAction(ACT_MOVE, 60);
	MagicCircle(false);
	}


task DelayedStart {
attack1;

wait(9*60 +50);
SetScore(275000);
PlaySE(GetCurrentScriptDirectory~"cardcall.wav");

cutin("Late Bloom "\""Moonlit Scattered Ipomoea"\", 0, 0, 0, 256, 512);
hurtbox = true;
SetInvincibility(60);
SetAction(ACT_SPELL, 60);
attack2;
makelaser;

}

	let backRED = 255;
	let backGREEN = 255;
	let backBLUE = 255;

task alphaup {
wait(6*60);
loop{
if(alpha<255){
alpha+=255/(5*60);
}
wait(1);
}
}


task CreateLaser(angle, turn, graphic, delay){
let obj = Obj_Create(OBJ_LASER);
		let width = 30;
		let count = 0;
		let length = 0;
		Obj_SetPosition(obj,GetX,GetY);
		ObjLaser_SetLength(obj,0);
		ObjLaser_SetWidth(obj,width);
		Obj_SetAngle(obj,angle);
		ObjShot_SetGraphic(obj,graphic);
		ObjShot_SetDelay(obj,delay);
		ObjLaser_SetSource(obj, false);
		while(!Obj_BeDeleted(obj)) {
		if(length<360){ length+=7.5; }
		ObjLaser_SetLength(obj,length);
		if(count==85){
		PlaySE(ping);
		}
		if(count>=170){
		width-=1.5
		}
		if(width<=7.5){
		Obj_SetCollisionToPlayer(obj, false);
		}
		
		if(count>=190){
		Obj_Delete(obj);
		}
		ObjLaser_SetWidth(obj,width);
		Obj_SetAngle(obj,angle);
		count++;
		angle+=turn;
		yield;
		}
	}

task attack1 {
//SetAction(ACT_SHOT_B, 1200000);
loop{


radiusx = rand(-115, 115);
radiusy = rand(-45, 45);
angle = rand(0, 360);
color++;
loop(20){
CreateShotA(1, GetCenterX+radiusx*cos(angle), GetClipMinY+120+radiusy*sin(angle), 20);

SetShotDataA(1, 0, 4, angle2+angle3, 0, 0, 3, [YELLOW54, ORANGE54][color%2]);
if(angle2%(360/80)==0){
SetShotDataA(1, 20, NULL, NULL, 0, -0.1, rand(1.45, 1.95), NULL);
}
FireShot(1);
angle2+=360/20;
}
angle3+=360/20/3+rand(-10, 10);
wait(12); 

}
}

task makelaser{
wait(30);
Concentration01(60);
wait(60);
SetAction(ACT_SHOT_B, 120910291);
loop{
PlaySE(laser2);
CreateLaser(GetAngleToPlayer, 0, BLUE60, 90);
CreateLaser(GetAngleToPlayer+12.5, 0, BLUE60, 90);
CreateLaser(GetAngleToPlayer-12.5, 0, BLUE60, 90);
wait(170);
}
}

	task attack2 {
		let w = 60;
		wait(w);
		loop(w){
			backGREEN-=255/w;
			backBLUE-=255/w;
			wait(1);
		}
		loop{
			loop(w){
				backGREEN+=128/w;
				wait(1);
			}
			loop(w){
				backGREEN+=127/w;
				wait(1);
			}
			loop(w){
				backRED-=255/w;
				wait(1);
			}
			loop(w){
				backBLUE+=255/w;
				wait(1);
			}
			loop(w){
				backGREEN-=255/w;
				wait(1);
			}
			loop(w){
				backRED+=255/w;
				wait(1);
			}
			loop(w){
				backBLUE-=255/w;
				wait(1);
			}
		}
	}




@BackGround{
SetTexture(CBG1);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, 0);
SetGraphicScale(1, 1);
SetColor(backRED/3, backGREEN/3, backBLUE/3);
SetGraphicRect(19, 0+(anim2*5), 474, 455+(anim2*5));
SetAlpha(255);
DrawGraphic(GetCenterX, GetCenterY);
SetTexture(CBG2);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, 0);
SetColor(255, 255, 255);
SetGraphicScale(1, 1);
SetGraphicRect(0, 0-(anim2*4), 493, 493-(anim2*4));
SetAlpha(60);
DrawGraphic(GetCenterX, GetCenterY);

i+=1; i%=360;
anim2 += 0.75;
acc1 = 6;


}




	
}