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

script_enemy_main {

	#include_function ".\Yuyukoinclude.txt";
	let i = 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);
	CreateEnemyFromScript("Youmu", GetCommonDataDefault("YoumuX", GetX), GetCommonDataDefault("YoumuY", GetY), 0, 0, 0);
	SetTimer(99);
	SetEnemyMarker(true);
	SetInvincibility(360);
	SetDamageRate(30, 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);
	immediatefan;
	
	}

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

SetScore(1500000);
PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
cutin("Nether Sign "\""Higan River's Late Glow"\", Cut, 0, 0, 256, 512);
SetAction(ACT_SPELL, 90);

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


task attack1 {
wait(60);

wait(60);
YuyukoSensu_Close;
ExMove;
wait(60);
let YuyukoSensu_SizeX = 0;
 let YuyukoSensu_SizeY = 1/20;
Concentration01(120);
SetAction(ACT_SHOT_B, 60000000);
PlaySE(charge);
imageFile2 = GetCurrentScriptDirectory~"sprites\ougi.png";
LoadGraphic(imageFile2);
wait(120);
fan;

CreateEnemyFromScript("Fan", GetX+100, GetY, 0, 0, 1);
CreateEnemyFromScript("Fan", GetX-100, GetY, 0, 0, 0);
wait(30);
Butterflies;
//drift=true;
loop{
PlaySE(laser);
CreateEnemyFromScript("LASER", GetX, GetY, 2, angle, 0);
CreateRotatingLaser(angle, BLUE60);
CreateEnemyFromScript("LASER2", GetX, GetY, 2, -angle-180, 0);
CreateRotatingLaser(-angle-180, PURPLE60);
wait(35);
angle-=22;
}
}

task Butterflies{
wait(150);
loop{
loop(4){
i++;
PlaySE(dream);
loop(25){
	CreateShotA(1, GetX, GetY, 10);
	SetShotDataA(1, 0, 2, angle2, 2, -0.05, 1, [PURPLE22, YELLOW22][i%2]);
	SetShotDataA(1, 60, NULL, NULL, 0, -0.05, 1, NULL);
	FireShot(1);
	CreateShotA(1, GetX, GetY, 10);
	SetShotDataA(1, 0, 2, angle2, -2, -0.05, 1, [PURPLE22, YELLOW22][i%2]);
	SetShotDataA(1, 60, NULL, NULL, 0, -0.05, 1, NULL);
	FireShot(1);
	angle2+=360/25;
	}
wait(60);
angle2+=rand(-400, 293409);
}
wait(210);
}
}
@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;
}


task CreateRotatingLaser(ang, graphic){
let obj = Obj_Create(OBJ_LASER);
		let angle = ang;
		let count = 0;
		let width = 300;
		Obj_SetPosition(obj,GetEnemyX,GetEnemyY);
		ObjLaser_SetLength(obj,500);
		ObjLaser_SetWidth(obj,300);
		Obj_SetAngle(obj,ang);
		ObjShot_SetGraphic(obj,graphic);
		ObjShot_SetDelay(obj,10000);
		Obj_SetAlpha(obj, 150);
		ObjLaser_SetSource(obj, false);
		
		while(!Obj_BeDeleted(obj)) {
		ObjLaser_SetWidth(obj,width);
		count++;
		if(count>60){
		width-=10;
		if(width<=0){
		Obj_Delete(obj);
		}
		}
		yield;
		}
	}




	
}


script_enemy Youmu{
	
	
	
	#include_function ".\Youmuinclude.txt"


	@Initialize {
	InitializeAction;
	SetAction(ACT_MOVE, 120);
	SetMovePosition02((GetCenterX+GetClipMinX)/2, GetClipMinY + 120, 60);
	LoadSE(shot);
	LoadSE(shot2);
	LoadSE(familiarspawn);
	LoadSE(slash);
	LoadSE(shot3);
	LoadGraphic(imageFile);
	LoadGraphic(Cut);
	SetLife(150000);
	SetInvincibility(240);
	SetDamageRateEx(100, 25, 90, 10);
	attack1;
	}

	task attack1 {
	wait(180);
	SetAction(ACT_MOVE, 120);
	SetMovePosition02(GetClipMinX-100, GetClipMinY-100, 120); 
	
}

	task CreateMyon {
	let obj = Obj_Create(OBJ_SHOT);
	let angle = 0;
	let time = 0;
	
		Obj_SetPosition(obj, GetX, GetY);
		ObjShot_SetDelay(obj, 0);
		Obj_SetAngle(obj, GetAngleToPlayer);
		Obj_SetSpeed(obj, 0);
		ObjShot_SetGraphic(obj, SP02);
		ObjShot_SetBombResist(obj, true);
		Obj_SetAutoDelete(obj, false);
		Obj_SetCollisionToPlayer(obj, false);
		while(!Obj_BeDeleted(obj)) {
		
loop(2){
		CreateShotA(1, Obj_GetX(obj)+rand(-10, 10), Obj_GetY(obj)+rand(-30, 5), 10);
		SetShotDataA(1, 0, rand(0, 0.5), rand(260, 270), 0, 0, 0, RED01);
		SetShotKillTime(1, 0); 
		FireShot(1);
		}

		if(time == 120){
		Obj_SetSpeed(obj, GetDistance(Obj_GetX(obj), Obj_GetY(obj), GetPlayerX, GetPlayerY)/120);
		Obj_SetAngle(obj, atan2(Obj_GetY(obj) - GetPlayerY, Obj_GetX(obj) - GetPlayerX)-180);
		wait(120);
		Obj_SetSpeed(obj, 0);
		loop(4){
	PlaySE(shot3);
		 loop(90){
			CreateShotA(1, Obj_GetX(obj), Obj_GetY(obj), 20);
			SetShotDataA(1, 0, 2, angle, 0, -0.02, 0, PURPLE50);
			SetShotKillTime(1, 180);
			angle+=360/90;
			FireShot(1);
			}
		wait(90);
		}
	time=60;
		}
		time++;
		yield;
		
		 }
		

}

}





script_enemy LASER2{
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	let shot = false;
	@Initialize {
	
	shotinit;
	SetLife(10000000000000);
	}

	@MainLoop {
	yield;
	
	if(GetY>=GetClipMaxY){ if(shot==false){CreateLaser(270, PURPLE60);}  SetSpeed(0); shot=true;}
	if(GetY<=GetClipMinY){ if(shot==false){CreateLaser(90, PURPLE60);  }SetSpeed(0);shot=true;}
	if(GetX>=GetClipMaxX){ if(shot==false){CreateLaser(180, PURPLE60);  }SetSpeed(0); shot=true;}
	if(GetX<=GetClipMinX){ if(shot==false){ CreateLaser(0, PURPLE60);  }SetSpeed(0); shot=true;}
	}

	
task CreateLaser(ang, graphic){
let obj = Obj_Create(OBJ_LASER);
		let angle = ang;
		let count = 0;
		let width = 35;
		let length = 0;
		Obj_SetPosition(obj,GetX,GetY);
		ObjLaser_SetLength(obj,1);
		if(Obj_GetAngle(obj)==90){
		count=-1800;
		}
		ObjLaser_SetWidth(obj,30);
		Obj_SetAngle(obj,ang);
		ObjShot_SetGraphic(obj,graphic);
		Obj_SetAlpha(obj, 255);
		ObjLaser_SetSource(obj, true);
		
		while(!Obj_BeDeleted(obj)) {
		ObjLaser_SetWidth(obj,width);
		if(Obj_GetAngle(obj)==90){ count-=0.5;
		}
		count++;
		if(count>60){
		ObjLaser_SetLength(obj,length);
		if(length<500){
		
		length+=25;
		if(Obj_GetAngle(obj)==90){ length-=15;
		}
		}
		}
		if(count>90){
		width-=1;
		if(width<30){
		Obj_SetCollisionToPlayer(obj, false);
		}
		if(width<=0){
		Obj_Delete(obj);
		VanishEnemy;
		}
		}
		yield;
		}
	}


	@DrawLoop{
	
	}
	@Finalize{
	}


}


script_enemy LASER{
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	let shot = false;
	@Initialize {
	
	shotinit;
	SetLife(10000000000000);
	}

	@MainLoop {
	yield;
	
	if(GetY>=GetClipMaxY){ if(shot==false){ CreateLaser(270, BLUE60); }  SetSpeed(0); shot=true;}
	if(GetY<=GetClipMinY){ if(shot==false){ CreateLaser(90, BLUE60); }  SetSpeed(0); shot=true;}
	if(GetX>=GetClipMaxX){ if(shot==false){ CreateLaser(180, BLUE60);}  SetSpeed(0); shot=true;}
	if(GetX<=GetClipMinX){ if(shot==false){ CreateLaser(0, BLUE60);  }SetSpeed(0); shot=true;}
	}

	

task CreateLaser(ang, graphic){
let obj = Obj_Create(OBJ_LASER);
		let angle = ang;
		let count = 0;
		let width = 35;
		let length = 0;
		Obj_SetPosition(obj,GetX,GetY);
		ObjLaser_SetLength(obj,1);
		if(Obj_GetAngle(obj)==90){
		count=-1800;
		}
		ObjLaser_SetWidth(obj,30);
		Obj_SetAngle(obj,ang);
		ObjShot_SetGraphic(obj,graphic);
		Obj_SetAlpha(obj, 255);
		ObjLaser_SetSource(obj, true);
		
		while(!Obj_BeDeleted(obj)) {
		ObjLaser_SetWidth(obj,width);
		if(Obj_GetAngle(obj)==90){ count-=0.5;
		}
		count++;
		if(count>60){
		ObjLaser_SetLength(obj,length);
		if(length<500){
		
		length+=25;
		if(Obj_GetAngle(obj)==90){ length-=15;
		}
		}
		}
		if(count>90){
		if(width<30){
		Obj_SetCollisionToPlayer(obj, false);
		}
		width-=1;
		if(width<=0){
		Obj_Delete(obj);
		VanishEnemy;
		}
		}
		yield;
		}
	}




	
}

	@DrawLoop{
	
	}
	@Finalize{
	}


}










script_enemy Fan{
	
	let imageFile = GetCurrentScriptDirectory~"sprites\fan.png";

	@Initialize {
	
	LoadGraphic(imageFile);
	SetLife(1500000000);
	SetInvincibility(120);
	SetDamageRateEx(35, 25, 70, 10);
	}

	@MainLoop {
	yield;
	SetCollisionA(GetX, GetY, 80);
	if(GetArgument==0){ SetX(GetEnemyX+100); SetY(GetEnemyY); }
	if(GetArgument==1){ SetX(GetEnemyX-100); SetY(GetEnemyY); }
	}

	@DrawLoop{
	
	}
	@Finalize{
	}


}













