#e
#Title[z剃W]
#Text[]
#BackGround[User(.\img\Sky.png,0,0)]
#BGM[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
	let csd		=GetCurrentScriptDirectory;
	let shotData	=csd ~ "img\shot_All.txt";
	let imgBoss	=csd ~ "img\Boss\.png";
	let Back	=csd ~ "img\Sky.png";

	@Initialize {
        SetLife(1);
	SetScore(45000);
	SetDamageRate(0, 0);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	LoadGraphic(Back);
	Load;
	Expert;
        CutIn(YOUMU,"u20΂v", NULL, 0, 0, 0, 0);
        Main;
	}

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
        yield;
    }

	@DrawLoop {
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	SetAlpha(255);
	DrawBoss(imgBoss);
	}

	@BackGround {
	SetTexture(Back);
	SetGraphicRect(0, 0, 384, 457);
	SetGraphicAngle(0, 0, 0);
	DrawGraphic(224, 240);
	}

    task Main {
	yield;
	Att;
}

task Att{
	CreateEnemyFromScript("MOKOU", 448, 120, 0, 0, 0);
	CreateEnemyFromScript("KEINE", 0, 60, 0, 0, 0);
	CreateEnemyFromScript("ALICE", 224, -20, 0, 0, 0);
	CreateEnemyFromScript("NITORI", 448, 90, 0, 0, 0);
	CreateEnemyFromScript("HINA", 0, 180, 0, 0, 0);
	CreateEnemyFromScript("AYA", 448, 180, 0, 0, 0);
	wait(530);
	AddLife(-1);	
}

	@Finalize{
	DeleteGraphic(imgBoss);
	Delete;
	}

	#include_function ".\lib\lib_anime_Sakuya.txt"
	#include_function ".\lib_Functions.txt"
}


script_enemy MOKOU{
	let csd     = GetCurrentScriptDirectory;
	let shotData	=csd ~ "img\shot_All.txt";
	let imgBoss  = csd ~ "img\Boss\dot_mokou.png";

	@Initialize{
        SetLife(1);
	SetDamageRate(0, 0);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	Load;
	Main;
	}

	@MainLoop{
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	yield;
	}

	@DrawLoop{
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	SetAlpha(255);
	DrawBoss(imgBoss);
	}

task	Main{
	yield;
	standBy;
	Att;	
}

	sub standBy{
		SetMovePosition03(224, 60, 10, 7);
		SetAction(ACT_MOVE, 60);
		wait(60);
}

task Att{
	SetAction(ACT_SHOT_B, 120);
	shot;
	wait(120);
	SetAngle(0);
	SetSpeed(7);
	SetAction(ACT_MOVE_R, 600);
}

task shot{
	wait(15);
	let r=0;
	while(r<3){
	CreateBardShot(GetAngleToPlayer, 1, r);
	r++;
	}
	wait(60);
	let r=0;
	while(r<3){
	CreateBardShot(GetAngleToPlayer, 1, r);
	r++;
	}
}

task CreateBardShot(let base, let color, let type){
	let ba=-40;
	let bb=20;
	let bba=0;
	let bc=20;
	let bbc=0;
	let bd=30;
	let bbd=15;
	let be=30;
	let bbe=15;
	let bf=50;
	let bbf=41;
	let bg=50;
	let bbg=41;
	let ang= [ 0, 60, -60];
	loop(4){
	let g=color+240;
	if(ba==0){
	g=color+224;
	}
	CreateShot02(GetX-ba*cos(base+ang[type]), GetY-ba*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, g, 0);
	ba+=20;
	}
	loop(4){
	CreateShot02(GetX+bb*sin(base+ang[type])-bba*cos(base+ang[type]), GetY-bb*cos(base+ang[type])-bba*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bb+=10;
	bba+=5;
	}
	loop(4){
	CreateShot02(GetX-bc*sin(base+ang[type])-bbc*cos(base+ang[type]), GetY+bc*cos(base+ang[type])-bbc*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bc+=10;
	bbc+=5;
	}
	loop(4){
	CreateShot02(GetX+bd*sin(base+ang[type])-bbd*cos(base+ang[type]), GetY-bd*cos(base+ang[type])-bbd*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bd+=10;
	bbd+=8;
	}
	loop(4){
	CreateShot02(GetX-be*sin(base+ang[type])-bbe*cos(base+ang[type]), GetY+be*cos(base+ang[type])-bbe*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	be+=10;
	bbe+=8;
	}
	loop(2){
	CreateShot02(GetX+bf*sin(base+ang[type])-bbf*cos(base+ang[type]), GetY-bf*cos(base+ang[type])-bbf*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bf+=10;
	bbf+=10;
	}
	loop(2){
	CreateShot02(GetX-bg*sin(base+ang[type])-bbg*cos(base+ang[type]), GetY+bg*cos(base+ang[type])-bbg*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bg+=10;
	bbg+=10;
	}	
}

	@Finalize{
	DeleteGraphic(imgBoss);
	Delete;
	}

	#include_function ".\lib\lib_anime_Mokou.txt"
	#include_function ".\lib_Functions.txt"
}


script_enemy KEINE{
	let csd     = GetCurrentScriptDirectory;
	let shotData	=csd ~ "img\shot_All.txt";
	let imgBoss  = csd ~ "img\Boss\dot_keine.png";

	@Initialize{
        SetLife(1);
	SetDamageRate(0, 0);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	Load;
	Main;
	}

	@MainLoop{
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	yield;
	}

	@DrawLoop{
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	SetAlpha(255);
	DrawBoss(imgBoss);
	}

task	Main{
	yield;
	standBy;
	Att;	
}

	sub standBy{
		SetMovePosition03(404, 60, 10, 7);
		SetAction(ACT_MOVE, 60);
		wait(60);
}

task Att{
	SetAction(ACT_SHOT_B, 60);
	CreateBardShot(320, 60, 90, 6, 0);
	wait(30);
	CreateBardShot(224, 60, 90, 6, 0);
	wait(30);
	CreateBardShot(96, 60, 90, 6, 0);
	wait(60);
	SetAngle(180);
	SetSpeed(7);
	SetAction(ACT_MOVE_L, 600);
}

task CreateBardShot(let x, let y, let base, let color, let type){
	let ba=-40;
	let bb=20;
	let bba=0;
	let bc=20;
	let bbc=0;
	let bd=30;
	let bbd=15;
	let be=30;
	let bbe=15;
	let bf=50;
	let bbf=41;
	let bg=50;
	let bbg=41;
	let ang= [ 0, 30, -30, 60, -60, 90, -90];
	loop(4){
	let g=color+240;
	if(ba==0){
	g=color+224;
	}
	CreateShot02(x-ba*cos(base+ang[type]), y-ba*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, g, 0);
	ba+=20;
	}
	loop(4){
	CreateShot02(x+bb*sin(base+ang[type])-bba*cos(base+ang[type]), y-bb*cos(base+ang[type])-bba*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bb+=10;
	bba+=5;
	}
	loop(4){
	CreateShot02(x-bc*sin(base+ang[type])-bbc*cos(base+ang[type]), y+bc*cos(base+ang[type])-bbc*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bc+=10;
	bbc+=5;
	}
	loop(4){
	CreateShot02(x+bd*sin(base+ang[type])-bbd*cos(base+ang[type]), y-bd*cos(base+ang[type])-bbd*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bd+=10;
	bbd+=8;
	}
	loop(4){
	CreateShot02(x-be*sin(base+ang[type])-bbe*cos(base+ang[type]), y+be*cos(base+ang[type])-bbe*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	be+=10;
	bbe+=8;
	}
	loop(2){
	CreateShot02(x+bf*sin(base+ang[type])-bbf*cos(base+ang[type]), y-bf*cos(base+ang[type])-bbf*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bf+=10;
	bbf+=10;
	}
	loop(2){
	CreateShot02(x-bg*sin(base+ang[type])-bbg*cos(base+ang[type]), y+bg*cos(base+ang[type])-bbg*sin(base+ang[type]), 0.5, base+ang[type], 0.1, 4, color+240, 0);
	bg+=10;
	bbg+=10;
	}	
}

	@Finalize{
	DeleteGraphic(imgBoss);
	Delete;
	}

	#include_function ".\lib\lib_anime_Yuyuko.txt"
	#include_function ".\lib_Functions.txt"
}


script_enemy ALICE{
	let csd     = GetCurrentScriptDirectory;
	let shotData	=csd ~ "img\shot_All.txt";
	let imgBoss  = csd ~ "img\Boss\dot_alice.png";

	@Initialize{
        SetLife(1);
	SetDamageRate(0, 0);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	Load;
	Main;
	}

	@MainLoop{
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	yield;
	}

	@DrawLoop{
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	SetAlpha(255);
	DrawBoss(imgBoss);
	}

task	Main{
	yield;
	wait(150);
	standBy;
	Att;	
}

	sub standBy{
		SetMovePosition03(224, 240, 10, 7);
		SetAction(ACT_MOVE, 60);
		wait(60);
}

task Att{
	SetAction(ACT_SHOT_A, 30);
	shot;
	wait(60);
	SetAngle(-135);
	SetSpeed(7);
	SetAction(ACT_MOVE_L, 600);
}

task shot{
	let angle=0;
	while(angle<360){
	CreateShotA(1, GetX, GetY, 0);
	SetShotDataA(1, 0, 4, angle, 0, 0, 4, 11);
	SetShotKillTime(1, 30);
	CreateShotA(2, 0, 0, 0);
	SetShotDataA(2, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(2, 30, 1.5, angle-30, 0, 0, 2, 9);
	AddShot(0, 1, 2, 0);
	CreateShotA(11, 0, 0, 0);
	SetShotDataA(11, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(11, 30, 1.5, angle+30, 0, 0, 2, 9);
	AddShot(0, 1, 11, 0);
	CreateShotA(3, 0, 0, 0);
	SetShotDataA(3, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(3, 30, 1, angle+60, 0, 0, 2, 12);
	AddShot(0, 1, 3, 0);
	CreateShotA(4, 0, 0, 0);
	SetShotDataA(4, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(4, 30, 1, angle-60, 0, 0, 2, 12);
	AddShot(0, 1, 4, 0);
	CreateShotA(5, 0, 0, 0);
	SetShotDataA(5, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(5, 30, 2, angle+90, 0, 0, 2, 14);
	AddShot(0, 1, 5, 0);
	CreateShotA(6, 0, 0, 0);
	SetShotDataA(6, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(6, 30, 2, angle-90, 0, 0, 2, 14);
	AddShot(0, 1, 6, 0);
	CreateShotA(7, 0, 0, 0);
	SetShotDataA(7, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(7, 30, 1, angle+120, 0, 0, 2, 11);
	AddShot(0, 1, 7, 0);
	CreateShotA(8, 0, 0, 0);
	SetShotDataA(8, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(8, 30, 1, angle-120, 0, 0, 2, 11);
	AddShot(0, 1, 8, 0);
	CreateShotA(9, 0, 0, 0);
	SetShotDataA(9, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(9, 30, 2, angle+150, 0, 0, 2, 15);
	AddShot(0, 1, 9, 0);
	CreateShotA(10, 0, 0, 0);
	SetShotDataA(10, 0, 4, angle, 0, 0, 4, 11);
	SetShotDataA(10, 30, 2, angle-150, 0, 0, 2, 15);
	AddShot(0, 1, 10, 0);
	FireShot(1);
	angle+=10;
	}
}

	@Finalize{
	DeleteGraphic(imgBoss);
	Delete;
	}

	#include_function ".\lib\lib_anime_Alice.txt"
	#include_function ".\lib_Functions.txt"
}


script_enemy NITORI{
	let csd     = GetCurrentScriptDirectory;
	let shotData	=csd ~ "img\shot_All.txt";
	let imgBoss  = csd ~ "img\Boss\dot_nitori.png";

	@Initialize{
        SetLife(1);
	SetDamageRate(0, 0);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	Load;
	Main;
	}

	@MainLoop{
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	yield;
	}

	@DrawLoop{
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	SetAlpha(255);
	DrawBoss(imgBoss);
	}

task Main{
	yield;
	wait(240);
	Att;	
}

task Att{
	SetAngle(180);
	SetSpeed(2);
	SetAction(ACT_MOVE_L, 600);
	shot;
}

task shot{
	loop{
	shotA(GetX, GetY);
	wait(30);
	yield;
	}
}

task shotA(let x, let y){
	loop(6){
	CreateShotA(1, x, y, 0);
	SetShotDataA(1, 0, 3, 90, 0.5, 0, 3, 230);
	SetShotDataA(1, 60, 3, NULL, -1, 0, 3, 230);
	SetShotDataA(1, 120, 3, NULL, 1, 0, 3, 230);
	SetShotDataA(1, 180, 3, NULL, -1, 0, 3, 230);
	SetShotDataA(1, 240, 3, NULL, 1, 0, 3, 230);
	SetShotDataA(1, 300, 3, NULL, -1, 0, 3, 230);
	SetShotDataA(1, 360, 3, NULL, 1, 0, 3, 230);
	FireShot(1);
	wait(10);
	}
}

	@Finalize{
	DeleteGraphic(imgBoss);
	Delete;
	}

	#include_function ".\lib\lib_anime_Sangetusei.txt"
	#include_function ".\lib_Functions.txt"
}


script_enemy HINA{
	let csd     = GetCurrentScriptDirectory;
	let shotData	=csd ~ "img\shot_All.txt";
	let imgBoss  = csd ~ "img\Boss\dot_hina.png";

	@Initialize{
        SetLife(1);
	SetDamageRate(0, 0);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	Load;
	Main;
	}

	@MainLoop{
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	yield;
	}

	@DrawLoop{
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	SetAlpha(255);
	DrawBoss(imgBoss);
	}

task	Main{
	yield;
	wait(300);
	Att;	
}

task Att{
	SetAngle(0);
	SetSpeed(4);
	SetAction(ACT_MOVE, 600);
	shotA;
	shotB;
	shotC;
}

task shotA{
	loop{
	let time=0;
	while(time<360){
	let angle=0;
	while(angle<360){
	CreateShot01(GetX+60*sin(time), GetY+60*cos(time), 3, angle+time, 89, 0);
	angle+=180;
	}
	time+=9;
	wait(2);
	}
	yield;
	}	
}

task shotB{
	loop{
	let time=0;
	while(time<360){
	let angle=0;
	while(angle<360){
	CreateShot01(GetX+30*sin(time+120), GetY+30*cos(time+120), 2, angle+time, 94, 0);
	angle+=180;
	}
	time+=9;
	wait(2);
	}
	yield;
	}	
}

task shotC{
	loop{
	let time=0;
	while(time<360){
	let angle=0;
	while(angle<360){
	CreateShot01(GetX+30*sin(time+240), GetY+30*cos(time+240), 1, angle+time, 95, 0);
	angle+=180;
	}
	time+=9;
	wait(2);
	}
	yield;
	}	
}


	@Finalize{
	DeleteGraphic(imgBoss);
	Delete;
	}

	#include_function ".\lib\lib_anime_Hina.txt"
	#include_function ".\lib_Functions.txt"
}


script_enemy AYA{
	let csd     = GetCurrentScriptDirectory;
	let shotData	=csd ~ "img\shot_All.txt";
	let imgBoss  = csd ~ "img\Boss\dot_aya.png";

	@Initialize{
        SetLife(1);
	SetDamageRate(0, 0);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	Load;
	Main;
	}

	@MainLoop{
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	yield;
	}

	@DrawLoop{
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	SetAlpha(255);
	DrawBoss(imgBoss);
	}

task	Main{
	yield;
	wait(300);
	Att;	
}

task Att{
	SetAngle(200);
	SetSpeed(7);
	SetAction(ACT_MOVE_L, 600);
	shot;
}

task shot{
	loop{
	CreateGravityShot( GetX+rand(-30, 30), GetY+rand(-30, 30), rand(0, 2), rand(-30,-90), 46, 1, 3);
	yield;
	}
}

task CreateGravityShot( x, y, speed, angle, color, gravity, limit) {
	let Obj = Obj_Create(OBJ_SHOT);
	let g   = gravity;

	Obj_SetPosition(Obj, x, y);
	Obj_SetAngle(Obj, angle);
	ObjShot_SetGraphic(Obj, color);
	ObjShot_SetDelay(Obj, 10);

	let vX = speed * cos(angle);
	let vY = speed * sin(angle);

	wait(10);

	while(Obj_BeDeleted(Obj)==false) {
		Obj_SetPosition(Obj, Obj_GetX(Obj) + vX, Obj_GetY(Obj) + vY);
		Obj_SetAngle(Obj, atan2(vY, vX));

		if(vY < limit) { vY = vY + g;
		} else { vY = limit;
		}

		yield;
	}
}

	@Finalize{
	DeleteGraphic(imgBoss);
	Delete;
	}

	#include_function ".\lib\lib_anime_Aya.txt"
	#include_function ".\lib_Functions.txt"
}