#TouhouDanmakufu
#Title[spell too]
#Text[reimu reveng u wit cunfuzing danmacku]
#Player[REIMU]
#ScriptVersion[2]
#PlayLevel[loonatik]

script_enemy_main{

	let D	= GetCurrentScriptDirectory;

	let imgBoss = D ~ ".\ReIMu.png";
	let cut = D ~ ".\Raimu.png";
	let shot = D ~ "supershot.txt";
	let s1 = D ~ "Shot.wav";


	CutIn(YOUMU,"raymoooo - reimu revenj -",cut,0,0,360,290);


	@Initialize{
		SetLife(2500);
		SetTimer(60);
		SetScore(250000);
		LoadGraphic(imgBoss);
		LoadGraphic(cut);
    		LoadUserShotData(shot);
		LoadSE(s1);
		fire;
		movement;
	}

	@MainLoop{
		SetCollisionA(GetX,GetY,150);
		SetCollisionB(GetX,GetY,150);
		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{
		DeleteGraphic(imgBoss);
		loop(40){CreateItem(ITEM_SCORE,GetX+rand(-150,150),GetY+rand(50,200));}
		CollectItems;
	}
	task movement{
		loop{
			SetMovePosition01(rand(GetClipMaxX,GetClipMinX),GetCenterY,5);
			wait(30);
			yield;
		}
	}

	task fire{
	loop{
		loop(100){
			bullet(GetX, GetY, 5, GetAngleToPlayer, rand_int(95,108), 20);
			PlaySE(s1);
		wait(1);
		}
		loop(100){
			loop(4){CreateShot01(GetX, GetY, 5, rand(0,356), rand_int(1,250), 20);}
			PlaySE(s1);
		wait(1);
		}
	}
       }
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)){
wait(1);
Obj_SetAngle(obj,GetAngleToPlayer);
		}
		yield;
		}
	function wait(w){loop(w){yield;}}
}