#TouhouDanmakufu[Single}
#Title[faynl kard!!! !OIhj pouihr two other 2!]
#Text[lazter!]
#Player[REIMU]
#ScriptVersion[2]
#PlayLevel[Normal]

script_enemy_main{

	let D = GetCurrentScriptDirectory;

	let imgBoss = D ~ ".\ReIMu.png";
	let cut = D ~ ".\Raimu.png";
	let s1 = D ~ "Shot.wav";
	let s2 = D ~ "ekspload.wav";
	let poo = D ~ "bufil.wav";
	let ha = D ~ "ha.png";
	CutIn(YOUMU,"kiutƒA65631guyhoi7utyl7uth ~ 78uitbkliuyg&*^%SSSfbutyfyfk",cut,0,0,360,290);
	@Initialize{
		SetLife(2000);
		SetTimer(25);
		SetScore(100000);
		LoadGraphic(imgBoss);
		LoadGraphic(ha);
		LoadSE(s1);
		LoadSE(s2);
		LoadMusic(poo);
		SetInvincibility(120);
		SetMovePosition01(GetCenterX,GetCenterY,5);
		SetEffectForZeroLife(100, 255, 5);
    		LoadUserShotData(D ~ "supershot.txt");
		ForbidShot(true);
		ForbidBomb(true);
		fire;
		death;
		hi;
		explodzhion;
	}

	@MainLoop{yield;}
	@DrawLoop{
		SetTexture(imgBoss);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetGraphicRect(0,0,110,110);
		SetGraphicScale(0.7,0.7);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetX,GetY);
	}
	@BackGround{}
	@Finalize{
		DeleteMusic(poo);
		loop(30000){CreateItem(ITEM_SCORE,GetX+rand(-200,200),GetY+rand(200,-200));}
		CollectItems;
		DeleteGraphic(ha);
		DeleteGraphic(imgBoss);
		DeleteSE(s1);
		DeleteSE(s2);
	}
task hi{

wait(1);
	let obj=Obj_Create(OBJ_EFFECT);



	let counter = 0;


	ObjEffect_SetRenderState(obj, ALPHA);

	ObjEffect_SetTexture(obj, ha);


	Obj_SetPosition(obj, GetCenterX+100, GetCenterY);


	ObjEffect_SetScale(obj, 1, 1);

	ObjEffect_SetLayer(obj, 8);


	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);

	ObjEffect_CreateVertex(obj, 4);


	ObjEffect_SetVertexXY(obj, 0, -320, -240);

	ObjEffect_SetVertexXY(obj, 1, 320, -240);

	ObjEffect_SetVertexXY(obj, 2, -320, 240);

	ObjEffect_SetVertexXY(obj, 3, 320, 240);


	ObjEffect_SetVertexUV(obj, 0, 0, 0);

	ObjEffect_SetVertexUV(obj, 1, 640, 0);

	ObjEffect_SetVertexUV(obj, 2, 0, 480);

	ObjEffect_SetVertexUV(obj, 3, 640, 480);


	while(!Obj_BeDeleted(obj)) {
	
	if(counter==370){Obj_Delete(obj);}

		counter++;

		yield;

	}

}

task death{
wait(240);
let dir = 0;
wait(620);
	loop(15){
	loop(90){CreateShot01(GetEnemyX+250*cos(dir),GetEnemyY+280*sin(dir),0.5,dir-180,BLUE03,0); dir+=4; PlaySE(s1);}
	wait(15);}
wait(200);
wait(30);
	loop(1500){b2(rand(GetClipMaxX,GetClipMinX),rand(GetClipMinY,GetClipMaxY),0,0,BLUE03,60);}
SetPlayerInvincibility(600);
}
task explodzhion{wait(240); wait(1048); PlaySE(s2);}
task fire{
wait(240);
	wait(120);
PlayMusic(poo);
		CreateShot01(GetX,GetY,1,GetAngleToPlayer,rand_int(95,110),0); PlaySE(s1);
	wait(340);
	loop(640){
	loop(180){b(GetX,GetY,15,rand(0,359),rand_int(95,110),0);} PlaySE(s1);
	wait(1);}}
	task b(x,y,v,dir,graphic,delay){
	
		 let obj=Obj_Create(OBJ_SHOT);


		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);

		while(!Obj_BeDeleted(obj)){
	if(Obj_GetY(obj) > GetClipMaxY-70){Obj_Delete(obj);}
	if(Obj_GetX(obj) > GetClipMaxX-50){Obj_Delete(obj);}
	if(Obj_GetY(obj) < GetClipMinY+70){Obj_Delete(obj);}
	if(Obj_GetX(obj) < GetClipMinX+50){Obj_Delete(obj);}
		yield;}
	}


	task b2(x,y,v,dir,graphic,delay){
	
		 let obj=Obj_Create(OBJ_SHOT);


		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);

		while(!Obj_BeDeleted(obj)){yield;}
	}


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