#TouhouDanmakufu[Single}
#Title[spll FOUR.]
#Text[4st speell !!!11!]
#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";

	CutIn(YOUMU," Ying-yag epik tiem! ~ raemu kil u",cut,0,0,360,290);

	@Initialize{
		SetLife(3000);
		SetTimer(99);
		SetScore(100000);
		LoadGraphic(imgBoss);
		LoadSE(s1);
		SetInvincibility(120);
		SetEffectForZeroLife(100, 180, 1);
    		LoadUserShotData(D ~ "ZUN's shotdata.txt");
		fire;
		movement;
	}

	@MainLoop{
		SetCollisionA(GetX,GetY,32);
		SetCollisionB(GetX,GetY,16);
		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{
		loop(20){CreateItem(ITEM_SCORE,GetX+rand(-150,150),GetY+rand(50,200));}
		DeleteGraphic(imgBoss);
		DeleteSE(s1);
	}
	task movement{ loop{
		SetMovePosition01(GetCenterX-30,GetCenterY-90,5);
		wait(120);
		SetMovePosition01(GetCenterX+30,GetCenterY-90,5);
		wait(120); } }
	task fire{
let dir = 0;
let dir2 = 0;
loop{
		loop(100){
			loop(3){bullet(GetX,GetY,rand(2,5),rand(0,356),250,0);}
		wait(1);
		PlaySE(s1);
		}
	wait(120);
loop(90){
	bullet2(GetPlayerX+200*cos(dir),GetPlayerY+200*sin(dir),0,dir-180,BLUE05,0); 
	bullet2(GetPlayerX+250*cos(dir2),GetPlayerY+250*sin(dir2),0,dir2-180,BLUE05,0);
	bullet2(GetPlayerX+50*cos(dir2),GetPlayerY+50*sin(dir2),0,dir2-180,BLUE05,0);
	bullet2(GetPlayerX+100*cos(dir),GetPlayerY+100*sin(dir),0,dir-180,BLUE05,0); 
	bullet2(GetPlayerX+150*cos(dir2),GetPlayerY+150*sin(dir2),0,dir2-180,BLUE05,0);
	bullet2(GetPlayerX+300*cos(dir),GetPlayerY+300*sin(dir),0,dir-180,BLUE05,0); 
	bullet2(GetPlayerX+350*cos(dir2),GetPlayerY+350*sin(dir2),0,dir2-180,BLUE05,0);
	bullet2(GetPlayerX+400*cos(dir),GetPlayerY+400*sin(dir),0,dir-180,BLUE05,0); 
	bullet2(GetPlayerX+450*cos(dir2),GetPlayerY+450*sin(dir2),0,dir2-180,BLUE05,0);
	bullet2(GetPlayerX+500*cos(dir),GetPlayerY+500*sin(dir),0,dir-180,BLUE05,0); 
	bullet2(GetPlayerX+450*cos(dir2),GetPlayerY+550*sin(dir2),0,dir2-180,BLUE05,0);
dir+=4; dir2-=4; wait(1); PlaySE(s1);}
	wait(240);
		}
	}
task bullet(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){Obj_SetAngle(obj,GetAngleToPlayer); Obj_SetSpeed(obj,v+2);}
	if(Obj_GetX(obj) > GetClipMaxX){Obj_SetAngle(obj,GetAngleToPlayer); Obj_SetSpeed(obj,v+2);}
	if(Obj_GetY(obj) < GetClipMinY){Obj_SetAngle(obj,GetAngleToPlayer); Obj_SetSpeed(obj,v+2);}
	if(Obj_GetX(obj) < GetClipMinX){Obj_SetAngle(obj,GetAngleToPlayer); Obj_SetSpeed(obj,v+2);}
		yield;}
	}
task bullet2(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)){
	wait(100);
	ObjShot_SetGraphic(obj,250);


	wait(100);
	Obj_SetSpeed(obj,4);


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