
#Title[enm2 Attack01 normal]
#Text[REV[bg@ʏ01]
#Player[FREE]
#BackGround[Default]
#ScriptVersion[2]

script_enemy_main {
	let imgEffect = GetCurrentScriptDirectory~".\enm2eff\bossEfect.png";
	let t5		= GetCurrentScriptDirectory~"..\..\se\timer1.wav";
	let t10	   = GetCurrentScriptDirectory~"..\..\se\timer2.wav";
	let tan	   = GetCurrentScriptDirectory~"..\..\se\shot1.wav";
	let kira	  = GetCurrentScriptDirectory~"..\..\se\shot2.wav";
	let Gspel	 = GetCurrentScriptDirectory~"..\..\se\echo5.wav";
	let laser	 = GetCurrentScriptDirectory~"..\..\se\Laser2.wav";
	let power	 = GetCurrentScriptDirectory~"..\..\se\enemy_powereffect.wav";
	let powerl	= GetCurrentScriptDirectory~"..\..\se\power_logo.wav";
	let gekiha	= GetCurrentScriptDirectory~"..\..\se\BossEnd.wav";
	let powerla   = GetCurrentScriptDirectory~"..\..\se\power_logo.wav";
	let kaku	  = GetCurrentScriptDirectory~"..\..\se\j.wav";
	let frame	 = 0;
	let GetAngle  = 0;
	let angle	 = 0;
	let angle2	= 0;
	let angleBase = 0;
	let count	 = 0;
	let timer	 = 0;
	let shotdir   = GetCurrentScriptDirectory ~ "data_usershot.txt";
	let MinX	  = GetClipMinX;
	let MaxX	  = GetClipMaxX;
	let CenX	  = GetCenterX;
	let MinY	  = GetClipMinY;
	let MaxY	  = GetClipMaxY;
	let CenY	  = GetCenterY;
	let T_count   = 0;
	let Damage	= 0;
	let a		 = 0;
	let b		 = 0;
	let S_count   = 0;
	let w		 = 0;
	let lp		= 0;

	@Initialize {
		//SetX(MaxX+100);
		//SetY(MinY-100);

	SetLife(2500);
	SetDamageRate(0,0);

	SetInvincibility(120);

	/*e폜@(l64)*/
	SetShotAutoDeleteClip(30,30,30,30);

	LoadUserShotData(shotdir);
	SetMovePosition03(CenX,CenY-150,10,5);
	LoadGraphic(imgEffect);
	Aura(8,255,32,32);
	MagicCircle(false);
	SetRateScoreSystemEnable(false);
	hpb(2,1,0);
	SetTimer(60);
	Timer(2,0);
	VSname(1);
	VSname2(0,1);
	EnemyTexture(true);
	RedMagicCircle(0,0);
	Shot_Main;
	}

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

	/*ԏ*/
	if(GetTimer<=10 && GetTimer>=0){T_count++;}
	alternative(T_count)
	case(1,60,120,180,240){PlaySE(t10);}
	case(300,360,420,480,540){PlaySE(t5);}

	/*{Agp莞ԃ_[W*/
	if(OnBomb==true){SetDamageRate(120,100);Damage=0;}
	if(OnBomb==false){Damage++;}
	if(Damage>=100){SetDamageRate(120,100);}

	/*XyJ[hؐ錾*/
	if(S_count==1){
	CutinSP("TIREI",50,-50,4000000,60,0,0,0,0,0);
	CutinSP2(-120,-10,GetCurrentScriptDirectory~".\enm2spell\enm2_sn01_normal.png",0,0,300,30,255,255,255);
	BackGroundEffect;
	}
	if(S_count==50){
	}
	

	a++;	
	frame++;
	count++;
	//S_count++;
	timer++;

}//MainLoop")"łB

	@DrawLoop {}

	@Finalize {
	}
	
	task Shot_Main{
		loop(60){yield;}
		loop {
			SetCommonData("Attack",true);
			loop(3){
				loop(2){
					angle+=rand(1,9);
					PlaySE(kira);
					ascent( let a in 0..18) loop{
						CreateShotA(0,GetX-18,GetY-41,10);
						SetShotDataA(0,0,2.1,a*20+angle,0,0,0,73);
						FireShot(0);
					}
					wait(12);
				}
				wait(30);
			}
			MoveToPlayerRand;
			SetCommonData("Attack",false);
			wait(20);
			PlaySE(tan);
			ascent( let a in 0..16) loop{
				CreateShotA(0,GetX,GetY,10);
				SetShotDataA(0,0,rand(1.4,2.2),GetAngleToPlayer+rand(-20,20),0,0,0,17);
				FireShot(0);
			}
			ascent( let a in 0..8) loop{
				CreateShotA(0,GetX,GetY,10);
				SetShotDataA(0,0,rand(2.3,3.1),GetAngleToPlayer+rand(-10,10),0,0,0,41);
				FireShot(0);
			}
			CreateShotA(0,GetX,GetY,10);
			SetShotDataA(0,0,3.7,GetAngleToPlayer,0,0,0,49);
			FireShot(0);
		wait(35);
		}
	}
	
function MoveToPlayer_(xMove, yAdd, frame, left, top, right, bottom) {
	let x;
	let y;
	if(GetPlayerX < GetX) {
		x = GetX - xMove;
		if(x < left) {
			x = GetX + xMove;
		}
	} else {
		x = GetX + xMove;
		if(right < x) {
			x = GetX - xMove;
		}
	}
	y = GetY + yAdd;
	if(y < top) {
		y = top;
	} else if(bottom < y) {
		y = bottom;
	}
	SetMovePosition03(x, y, 20, 2);
}

function MoveToPlayerRand {
	MoveToPlayer_(rand(40, 80),rand(-40, 40),60,GetClipMinX+32,GetClipMinY+120,GetClipMaxX-32,GetClipMinY+160);
	}

	#include_function".\Obj_Control.txt"
	#include_function".\lib_kshot.txt"
}