#뱦뺴뭙뼀븮
#Title[Sell Outs Until Death]
#Text[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
	#include_function ".\lib\lib_anime_Reisen.txt"
	#include_function ".\lib\function.txt"
	#include_function ".\boss.txt"
	let csd		=GetCurrentScriptDirectory;
	let shotData	=csd ~ ".\shot.txt";
	let imgBoss	=csd ~ "img\dot_reisen.png";
	let imgBG1	=csd ~ "img\maho1.png";
	let imgBG2	=csd ~ "img\maho2.png";
	let BGn		=0;
	let xIni	=GetCenterX;
	let yIni	=GetClipMinY + 100;
	let count	=0;
	@Initialize {
        CutIn(YOUMU,"Sell Outs Until Death", "", 0, 0, 0, 0);
        SetLife(2800);
	SetTimer(60);
	SetScore(100000);
	SetDamageRate(5, 5);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBG1);
	LoadGraphic(imgBG2);
        TMain;
	}

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

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

	@Finalize{
	}

    task TMain {
	yield;
	SetDamageRate(80,100);
	loop{
	loop(2){
	moveA;
	wait(60);
	put_bit_B(1,-90);
	put_bit_B(-1,90);
	wait(80);
	put_bit_A(1);
	wait(60);
	}
	moveA;
	wait(60);
	put_bit_C;
	wait(300);
	moveA;
	wait(60);
	loop(2){
	moveA;
	wait(60);
	put_bit_B(1,-90);
	put_bit_B(-1,90);
	wait(80);
	put_bit_A(1);
	wait(60);
	}
	put_bit_D;
	loop(3){
	moveA;
	wait(60);
	}
	}
	}

	task put_bit_A(Ang){
	let A=180;
	let B=GetAngleToPlayer-90;
	let C=20;
	let D=GetAngleToPlayer;
	loop(5){
		loop(360/A){
			CreateEnemyFromScript("bit", GetX+cos(B)*C, GetY+sin(B)*C, 2, D, 0);
		B+=A;
		}
	wait(12);
	}
	}

	task put_bit_B(Ang,Ang2){
	let A=180;
	let B=GetAngleToPlayer+Ang2;
	let C=20;
		loop(9){
			CreateEnemyFromScript("bit", GetX+cos(B)*C, GetY+sin(B)*C, 2, B, 0);
		B+=9*Ang;
	wait(8);
		}
	}

	task put_bit_C{
	let A=30;
	let B=GetAngleToPlayer;
	let C=40;
	loop(15){
		loop(360/A){
			CreateEnemyFromScript("bit", GetX+cos(B)*C, GetY+sin(B)*C, 2, B, 0);
		B+=A;
		}
	B+=A/2;
	wait(20);
	}
	}

	task put_bit_D{
	let C=40;
	loop(60){
	let B=GetAngleToPlayer+rand(120,-120);
			CreateEnemyFromScript("bit", GetX+cos(B)*C, GetY+sin(B)*C, 2, B, 0);
	wait(3);
	}
	}

   task moveA {
	let wMove =60;	
	SetAction(ACT_MOVE,wMove);
	moveToPlayer(rand(40, 120), rand(-40, 40), wMove,
		GetClipMinX + 48, GetClipMinY +  80,
		GetClipMaxX - 48, GetClipMinY + 120);
	wait(wMove);
	}

function GetGapAngle(
	let x1,
	let y1,
	let x2,
	let y2
){
	return atan2(y2-y1,x2-x1);
}

}

script_enemy bit {

	#include_function ".\lib\function.txt"

	let csd		= GetCurrentScriptDirectory;
	let imgEy	= csd ~ ".\shot_all.png";
	let imgmaho3	= csd ~ ".\img\maho3.png";
	let imgmaho4	= csd ~ ".\img\maho4.png";
	let Angle	= GetAngle;
	let Arg		= GetArgument;
	let Alp		= 255;
	let SX		= 0;
	let tama	=csd ~ "img\tama.wav";

	@Initialize {
	SetLife(10);
	SetDamageRateEx(100, 0, 0, 0);
	SetScore(2000000);
	LoadGraphic(imgEy);
	LoadGraphic(imgmaho3);
	LoadGraphic(imgmaho4);
	LoadSE(tama);
	TMain;
	}

	@MainLoop {
	if(GetX <= 0 || GetX >= 448){VanishEnemy;}
	if(GetY <= - 72 || GetY >= 640){VanishEnemy;}
	SetCollisionB(GetX, GetY, 6);
	SetCollisionA(GetX, GetY, 16);
	yield;
	}

	@DrawLoop{

	SetGraphicRect(0, 0, 48, 48);
	SetGraphicAngle(0,0,GetAngle+90);
	SetGraphicScale(1,1);
	SetColor(255,255,255);
	SetAlpha(255);
	SetTexture(imgmaho3);
	DrawGraphic(GetX,GetY);

	SetGraphicRect(0, 0, 64, 64);
	SetGraphicAngle(0,0,GetAngle+90);
	SetGraphicScale(SX,1);
	SetColor(255,255,255);
	SetAlpha(255);
	SetTexture(imgmaho4);
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	attributeB();
	if(BeVanished==false){
	let S=1;
		loop(26){
			CreateShot01(GetX,GetY,S,GetAngle,46,0);
		S+=0.12;
		}
	}
	}

	task TMain {
		yield;
		let Ang=0;
		SetSpeed(0);
		shotA;
		loop(10){
			SX+=0.05;
			yield;
		}
		SetSpeed(5.5);
		SetAngle(GetAngle);
		}


//way뭙귩띿맶
	task shotA{
		wait(10);
		loop{
			CreateShot01(GetX,GetY,rand(1,3),GetAngle+rand(-10,10),62,0);
		wait(2);
		}
	}
#include_function ".\zako.txt"
}