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

script_enemy_main {

	#include_function ".\Nueinclude.txt";

	@Initialize{
	shotinit;
	LoadGraphic(imglifebar); 
	LoadSE(time1);
	LoadGraphic(imageFile);
	LoadSE(time2);
	LoadSE(charge);
	LoadSE(familiarspawn);
	InitializeAction;
	SetLife(1500);
	LoadSE(shot);
	DelayedStart;
	LoadSE(shot2);
	SetTimer(99);
	SetEnemyMarker(true);
	SetInvincibility(780);
	SetDamageRate(17, 25);
	SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
	SetAction(ACT_MOVE, 60);
	SetShotAutoDeleteClip(50, 50, 50, 50);
	LoadGraphic(SP);
	LoadGraphic(MC);
	LoadGraphic(CBG1);
	LoadGraphic(CBG2);
	LoadGraphic(Cut);
	LoadSE(orb);
	LoadSE(warp);
	LoadSE(caution);
	LoadSE(border);
	SetAction(ACT_MOVE, 60);
	}


task DelayedStart {
wait(60);
SetScore(50000);
PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
cutin("Nue Sign "\""Red Room Mystery"\", Cut, 0, 0, 256, 512);
SetAction(ACT_SPELL, 90);
attack1;
attack2;
SetTimer(73);
}



	task attack2 { 
	wait(360);
	loop{
	ExMove;
	wait(60);
	SetAction(ACT_SHOT_B, 120);
	wait(240);
	}
}
	
	

	task attack1 {
	let variable = 0;
	wait(120);
	let g = 0;
	SetAction(ACT_SHOT_A, 120);
	Concentration01(120);
	PlaySE(charge);
	wait(120);
	PlaySE(laser);
	CreateLaserA(1, GetClipMinX-20, GetClipMaxY-10, 1000, 50, RED60, 60);
	SetLaserDataA(1, 0, 0, 0, 0, 0, 0);
	FireShot(1);
	wait(120);
	loop{
	PlaySE(charge);
	Concentration01(120);
	wait(120);
	//CreateShotFamiliar(GetCenterX, GetClipMaxY-10, 2.25, 270, RED02, 60, g);
	CreateShotFamiliar(GetCenterX+75, GetClipMaxY-10, 2, 270, RED02, 60, g);
	CreateShotFamiliar(GetCenterX-75, GetClipMaxY-10, 2, 270, RED02, 60, g);
	CreateShotFamiliar(GetCenterX+180, GetClipMaxY-10, 1.75, 270, RED02, 60, g);
	CreateShotFamiliar(GetCenterX-180, GetClipMaxY-10, 1.75, 270, RED02, 60, g);
	wait(240-variable);
	if(GetEnemyLife<1200 || GetTimer<=55){
	variable=60;
	}
	if(GetEnemyLife<650 || GetTimer<=40){
	variable=150;
	}
	g+=0.35;
	}
}

task CreateShotFamiliar(x, y, v, ang, graphic, delay, var) {
		let obj = Obj_Create(OBJ_SHOT);
		let increase = rand(13, 17);
	let time = 0;
	let angle = 0;
	let speed = v;
	let delay = delay;
	let waitnum = 5;
		let direction = rand_int(1, 2);
		Obj_SetPosition(obj, x, y);
		ObjShot_SetDelay(obj, delay);
		Obj_SetAngle(obj, ang);
		Obj_SetSpeed(obj, v);
		ObjShot_SetGraphic(obj, graphic);
		ObjShot_SetBombResist(obj, true);
		Obj_SetAutoDelete(obj, true);
		let r = 0;
		while(!Obj_BeDeleted(obj)) {
		time++;
		if(time>delay/5 && Obj_GetY(obj)<GetClipMaxY-25){
		angle+=4;
		CreateShotA(1, Obj_GetX(obj), Obj_GetY(obj), 10);
		SetShotDataA(1, 0, 0, 0, 0, 0, 0, RED04);
		SetShotDataA(1, 200-angle, 0, (angle*(speed*(1.14+var)))*2, 0, 0.007, 2, RED04);
		FireShot(1);
		PlaySE(shot3); 
		waitnum = 6;		
		}
		
		if(Obj_GetY(obj)<GetClipMinY-10){
		Obj_Delete(obj);
		}

		
		wait(waitnum); }
		
		
	}



@BackGround{
SetTexture(CBG1);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, anim2);
SetGraphicScale(1, 1);
SetGraphicRect(0, 0, 512, 512);
SetAlpha(200);
DrawGraphic(GetCenterX, GetCenterY);
SetTexture(CBG2);
SetRenderState(ALPHA);
SetGraphicAngle(0, 0, 0);
SetGraphicScale(1, 1);
SetGraphicRect(0, 0, 512, 512);
SetAlpha(100);
DrawGraphic(GetCenterX, GetCenterY);


anim2 += 1;
acc1 = 6;


}




	
}