
#Title[akyunon1]
#Text[akyunon1]
#Image[.\img\spellcard0103.jpg]
#PlayLevel[Hard]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\system\Effectsmore.txt";
#include_function ".\cutin.txt";
#include_function ".\drawall.txt";
#include_function ".\hitbox.txt";
#include_function ".\maple.txt" 
#include_function".\SnowFunc.txt";
let ImgBoss = GetCurrentScriptDirectory~"img\Akyu_Main.png";
let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
let CSD = GetCurrentScriptDirectory;
let ci = CSD ~ "system\NMM.png";
let bg1 = CSD ~ "system\bg8.png";
let bg2 = CSD ~ "system\bg3.png";
let cx=GetCenterX();
let frame = 0;
let framedelay = 0;
let angle = 0;
let angle2 = 0;
let anglemove = 20;
let anglestart = 0;
let x;
let switch = 1;
let switch2 = 1;
let gx;
let gy;
let Cut = GetCurrentScriptDirectory~"img\daiyousei11.png";
let ThisShot = GetCurrentScriptDirectory~"ZUN's shotdata.txt";

@Initialize
{
CreateHitbox;
SetLife(1000);
SetDamageRate(50,50);
SetTimer(40);
mainTask;

SetInvincibility(180);
SetMovePosition03(GetCenterX, GetCenterY-120, 10, 4);
LoadGraphic(ImgBoss);
LoadUserShotData(ThisShot);
LoadGraphic(Cut);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 64, 64);
MagicCircle(true);
Aura;
//Border2(255,0,0);

}

//---------------------------------------------------------------

@MainLoop 
{

SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);


frame++;

// Start Attack

yield;

// End Attack


// Start Boss Move


// End Boss Move



}

//---------------------------------------------------------------

@DrawLoop
{
SetTexture(ImgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicAngle(0, 0, 0);
SetGraphicScale(1.1, 1.1);
drawbossa;
DrawHitbox;
drawcirclea;


}
//---------------------------------------------------------------

@BackGround
{
	//drawbg;
}	

//---------------------------------------------------------------

@Finalize
{
DeleteGraphic(ImgBoss);
}

// main task
task mainTask{
	wait(90);
	LocateEnemy;
	StartMapleConcentrate;
	PlayDelaySE(CSD~"sound\charge2.wav",0);
	wait(60);
	fire;
	yield;
}

task fire{
	Bullet(GetX-50,GetY+100,2,240,78,0,0);
	wait(3);
	Bullet(GetX+50,GetY+100,2,300,79,0,1);
	wait(120);
	Bullet(GetX-30,GetY-10,2,210,75,0,2);
	wait(3);
	Bullet(GetX+30,GetY-10,2,330,73,0,3);
	wait(60);
	SetMovePositionRandom01(rand(20,50),0,2,GetClipMinX+100,rand(130,150),GetClipMaxX-100,rand(100,150));
	wait(60);
	fire;
	}


task Bullet(x, y, v, dir, graphic, delay,check) 
	{
    	 let obj = Obj_Create(OBJ_SHOT);
	 let c = 0;
    	 Obj_SetPosition   (obj, x, y);
    	 Obj_SetSpeed      (obj, v);
    	 Obj_SetAngle      (obj, dir);
    	 ObjShot_SetGraphic(obj, graphic);
    	 ObjShot_SetDelay  (obj, delay);
	 ObjShot_SetBombResist(obj, true);
	 Obj_SetAlpha(obj,0);
		 while(! Obj_BeDeleted(obj)) 
		{
		c++;
		if(check==0){Obj_SetAngle(obj,Obj_GetAngle(obj)+0.5);}
		if(check==1){Obj_SetAngle(obj,Obj_GetAngle(obj)-0.5);}
		if(check==2){Obj_SetAngle(obj,Obj_GetAngle(obj)-0.5);}
		if(check==3){Obj_SetAngle(obj,Obj_GetAngle(obj)+0.5);}
		if(c%6==0){
		 PlayDelaySE(CSD~"sound\shot1.wav",0);
		 ascent(i in 0..12){
		 CreateShotA(1,Obj_GetX(obj),Obj_GetY(obj),10);
 		 SetShotDataA(1,0,2.2,i*30+c/6*13,0,0,0,graphic);
		 FireShot(1);
		 }
		 }
		if(c>90){Obj_Delete(obj);}
		 yield;
		}
	}

task PlayDelaySE(se,delay){
        loop(delay){yield;}
        PlaySE(se);
}
	function wait(w){
		loop(w){yield;}
			}
}