#TouhouDanmakufu
#Title[Plain Fairy]
#Text[Its plain]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\mu\bgm.mp3]


script_enemy_main {

	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	#include_function ".\DATA\lib_anime_fairy.txt"
let randnum = rand(0, 359);
let pointnumber = 0;
let fairy = GetCurrentScriptDirectory~"sprites\Sprite.png";
let border = GetCurrentScriptDirectory~"sfx\border.wav";
let orb = GetCurrentScriptDirectory~"sfx\orb.wav";
let shot4 = GetCurrentScriptDirectory~"sfx\shot4.wav";
let shot2 = GetCurrentScriptDirectory~"sfx\shot2.wav";
let shot = GetCurrentScriptDirectory~"sfx\shot.wav";
let charge = GetCurrentScriptDirectory~"sfx\Charge.wav";
let wtf = GetCurrentScriptDirectory~"sfx\kira00.wav";
let time1 = GetCurrentScriptDirectory~"sfx\time1.wav";
let time2 = GetCurrentScriptDirectory~"sfx\time2.wav";
let warp = GetCurrentScriptDirectory~"sfx\warp.wav";
let caution = GetCurrentScriptDirectory~"sfx\caution.wav";
let shot3 = GetCurrentScriptDirectory~"sfx\shot3.wav";
let familiarspawn = GetCurrentScriptDirectory~"sfx\Shadow.wav";
let laser = GetCurrentScriptDirectory~"sfx\laser.wav";
let boom = GetCurrentScriptDirectory~"sfx\boom.wav";

let angle = 0;
let angle2 = 0;
let angle3 = 0;
let angle4 = 0;
let angle5 = 0;
let angle6 = 0;
let radius = 0;
let count = 0;
let speed = 0;




	
function wait(w){ loop(w){ yield;} }


function GetDistance(x1,y1,x2,y2){
return(((x2-x1)^2+(y2-y1)^2)^(1/2))
} 


function WithinPlayingField {
if(GetX>GetClipMinX-10 && GetX<GetClipMaxX+10 && GetY>GetClipMinY-50 && GetY<GetClipMaxY+10){ return true; }
else { return false;  }
}




	@Initialize{
	
	pointnumber = 1;
	LoadSE(shot3);
	LoadSE(boom);
	SetInvincibility(30);
	LoadGraphic(fairy);
	shotinit;
	Initialize_Fairy(0);
	attack1;
	attack2;
	SetLife(1);
	}

	
task attack1{
SetSpeed(2);
SetAngle(90);
loop{
if(GetArgument!=0){
SetAngle(90+(count*GetArgumentDefault(0)));
}
wait(1);
count+=0.3;
}
}

task attack2{
wait(rand_int(5, 25));
loop{
wait(30+rand_int(10, 30));
if(GetArgumentDefault(0)==0){
SetLife(50);
PlaySE(shot3);
loop(50){
CreateShot01(GetX, GetY, 2, randnum+angle, PURPLE31, 10);
angle+=360/50;
}
SetSpeed(0);
wait(60);
SetSpeed(0);
SetMovePosition02(GetX+rand(-20, 20), GetClipMinY-100, 90);
wait(180);
}
}
}

	@MainLoop{
	
	SetCollisionA(GetX, GetY, 6);
	SetCollisionB(GetX, GetY, 4);
	yield;

	if(WithinPlayingField==false){ VanishEnemy; }
	}


 @DrawLoop {

DrawFairy(fairy);

}





@Finalize{
if(!BeVanished){ PlaySE(boom); loop(pointnumber){ CreateItem(ITEM_SCORE, GetX+rand(-35, 35), GetY+rand(-5, 5)); }} }
}

}