
#Title[enm1 Attack02 normal]
#Text[[VFp[h@ʏ02]
#Player[FREE]
#BackGround[Default]
#ScriptVersion[2]

script_enemy_main {
	let imgEffect = GetCurrentScriptDirectory~".\enm1eff\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,100,32);
	MagicCircle(false);
	SetRateScoreSystemEnable(false);
	hpb(2,1,0);
	SetTimer(60);
	Timer(2,0);
	VSname(0);
	EnemyTexture(true);
	RedMagicCircle(1,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~".\enm1spell\enm1_sn01_normal.png",0,0,300,30,255,255,255);
	BackGroundEffect;
	}
	if(S_count==50){
	}
	
	if(frame%120==60) {
		MoveToPlayerRand;
		}
	

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

}//MainLoop")"łB

	@DrawLoop {}

	@Finalize {
	}
	
	task Shot_Main{
		wait(60);
		loop {
			loop(2){
				PlaySE(kira);
				ascent( let a in 0..10) loop{
					CreateShotA(0,GetX,GetY,10);
					SetShotDataA(0,0,4,angle+a,0,0,0,195);
					SetShotDataA(0,25,2,angle+a,0,0,0,195);
					FireShot(0);
					CreateShotA(0,GetX,GetY,10);
					SetShotDataA(0,0,4,angle+a,0,0,0,194);
					SetShotDataA(0,25,2.5,angle+a,0,0,0,194);
					FireShot(0);
					angle+=35.7;
				}
				wait(4);
			}
			angle+=66.9;
			wait(25);
			}
		}
	
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+80,GetClipMaxX-32,GetClipMinY+140);
	}

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