#TouhouDanmakufu
#Title[YuyukoS1_H]
#Text[YuyukoS1_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;
	@Initialize{
	shotinit;
	LoadSE(time1);
	LoadGraphic(imageFile);
	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(270);
	SetDamageRate(25, 25);
	SetMovePosition02((GetCenterX+GetClipMaxX)/2, GetClipMinY + 120, 60);
	SetAction(ACT_MOVE, 60);
	SetShotAutoDeleteClip(30, 30, 30, 40);
	LoadGraphic(SP);
	LoadGraphic(MC);
	LoadGraphic(CBG1);
	LoadGraphic(CBG2);
	LoadSE(shot4);
	LoadSE(dream);
	LoadSE(die);
	LoadGraphic(Cut);
	SetAction(ACT_MOVE, 60);
	SetCommonData("lastattack", false);
	
	}

task DelayedStart {
let radius = 30;

wait(90);
SetScore(1000000);
PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
cutin("Dual Spell "\""A Wicked Soul's Ghastly Dream"\", Cut, 0, 0, 256, 512);
SetAction(ACT_SPELL, 90);
attack1;
//Shiny;
SetTimer(62);
}


task attack1 {
wait(240);
loop{
wait(120);
SetAction(ACT_MOVE, 120);
SetMovePosition03(rand(GetClipMinX+60, GetClipMaxX-60), GetClipMinY+rand(90, 160), 6, 2);
wait(120);
Concentration01(120);
SetAction(ACT_SHOT_B, 300);
PlaySE(charge);
wait(120);
loop(4){
color++;
PlaySE(dream);
ascent(i in 0..5){
	
	loop(10){
		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 1, angle, 0, -0.02+(i/350), 0, [PURPLE22, YELLOW22][color%2]);
		SetShotDataA(1, 60, NULL, NULL, -0.35-(i/2), 0, 0, NULL);
		SetShotDataA(1, 90, NULL, NULL, 0, 0.02, 1.5+(i/4), NULL);
		FireShot(1);
		CreateShotA(1, GetX, GetY, 5);
		SetShotDataA(1, 0, 1, angle, 0, -0.02+(i/350), 0, [YELLOW22, PURPLE22][color%2]);
		SetShotDataA(1, 60, NULL, NULL, 0.35+(i/2), 0, 0, NULL);
		SetShotDataA(1, 90, NULL, NULL, 0, 0.02, 1.5+(i/4), NULL);
		FireShot(1);
		angle+=360/10;
		}
	
	 }
wait(40);
angle+=360/10/2;
}
wait(60);
}

}


@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;


}




	
}


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(90);
	SetAction(ACT_SPELL, 90);
	wait(120);
	Concentration01(120);
	PlaySE(charge);
	wait(130);
	PlaySE(familiarspawn);
	CreateMyon;
	loop{
	ExMove;
	wait(160);
	}
}

	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 Fan{
	
	let imageFile = GetCurrentScriptDirectory~"sprites\fan.png";

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

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

	@DrawLoop{
	
	}
	@Finalize{
	}


}








