#TouhouDanmakufu
#Title[Aya ShaMEEMaru ns1]
#Text []
#Player[FREE]
#ScriptVersion[2]			

script_enemy_main{  
#include_function ".\1Config.txt"       
	let CSD	= GetCurrentScriptDirectory;
let angul = 180;
let angull = 180;
    let MinX	  = GetClipMinX;
    let MaxX	  = GetClipMaxX;
    let CenX	  = GetCenterX;
    let MinY	  = GetClipMinY;
    let MaxY	  = GetClipMaxY;
    let CenY	  = GetCenterY;
let powerl    = GetCurrentScriptDirectory~".\enm4se\power_logo.wav";
 	let imgBoss = CSD ~ "system\Aya_Main.png";
	let cut = CSD ~ "system\GusanoCirnoCut.png";
	let bg = CSD ~ "system\lake.png";
        let bgm = CSD ~ "bgm.mp3";
#include_function ".\newsfx.txt";
#include_function ".\Obj_hpb.txt"
#include_function ".\Cutin_Eff.txt"
#include_function ".\system\Aura_Effects.dnh"
#include_function ".\lib_anime_Aya.txt"
	@Initialize{
                LoadUserShotData(CSD ~ "kshotData.txt");
		SetLife(2500);
		SetTimer(45);
SetDamageRate(140, 30);
if(lifebar_activate ==1){
hpb(0,1,0);
}
if(Cutin_Activate ==1){
Timer(2,0);
}
                SetInvincibility(180);
		SetMovePosition01(GetCenterX,GetCenterY,5);
		LoadGraphic(imgBoss);
		LoadGraphic(cut);
		LoadGraphic(bg);
                PlayMusic(bgm);
InitializeAction;
if(Aura_Activate==1){
	Aura5;
}
		mainTask;
	}

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

	@DrawLoop{
DrawText("Aya Shameimaru", 40, 35, 12, 255);
	if(GetSpeedX()>0){SetAction(ACT_MOVE,0)}
	if(GetSpeedX()<0){SetAction(ACT_MOVE,0)}		
	DrawBoss(imgBoss);
	}

	@BackGround{
		SetTexture(bg);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,63,73);
		SetGraphicScale(2,2);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
	}

	@Finalize{
		DeleteGraphic(imgBoss);
		DeleteGraphic(cut);
		DeleteGraphic(bg);
	}

	// main task, activates stuff.
	task mainTask{
		yield;
		fire;
		movement;
	}

	task movement{
		loop{
			SetMovePositionRandom01(50,50,9,GetCenterX-80,GetCenterY-120,GetCenterX+80,GetCenterY-100);
			wait(240);
			yield;
		}
	}
	task fire{
//StartMapleConcentrate;
SetColor(255,0,0);
Concentration01(60);
SetColor(255,255,255);
PlaySE(charge);
wait(60);
let dispoot =0;
let duspo =0;
		loop{
PlaySE(shot2);
	CircleShot(GetX+100,GetY,30,120,15,90+sin(dispoot)*60,4,1,20);
CircleShot(GetX-100,GetY,30,120,15,90-sin(dispoot)*60,4,3,20);
if(GetPlayerY<=GetEnemyY){	
PlaySE(shot3);
CircleShot(GetX,GetY,10,1,15,GetAngleToPlayer,5,3,0);
}	
dispoot += 18;
duspo += 5;
wait(5);
yield;
}
	}

	// wait function
	function wait(w){
		loop(w){yield;}
	}
 function CircleShot(x,y,radius,angle,bullets,shotangle,speed,graphic,delay){
loop( bullets )
{
CreateShot01(x+radius*cos(angle),y+radius*sin(angle),speed,shotangle,graphic,delay);
angle+=360/bullets;
}
}

}