TouhouDanmakufu
#Title[Wild Love "Prism Powered Master Spark"]
#Text[Lunatic]
#Image[]
#PlayLevel[Lunatic]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{

	#include_function ".\lib\lib_anime_marisa.txt"
        #include_function ".\lib\Func.txt"

let color = [1,2,3,4,5,6,7,8];

	@Initialize{
		SetLife(4500);
		SetTimer(85);
                SetInvincibility(260);
                SetDamageRate(100,0);
		SetScore(15000000);
                SetEnemyMarker(true);
                MagicCircle(true);
                SetX(GetCenterX);
	        SetY(GetClipMinY + 120);
                SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
                LoadUserShotData(estreshitas);
                InitializeAction();
	CutIn(YOUMU,"Wild Love "\""Prism Powered Master Spark"\",cut,0,0,203,360);
	
		mainTask;
	}

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

	}

	@DrawLoop{

	if(GetSpeedX()>0){SetAction(ACT_MOVE,0)}
	if(GetSpeedX()<0){SetAction(ACT_MOVE,0)}		
	DrawBoss(imgBoss);
        DrawText("Marisa Kirisame", 40, 30, 11, 255);

	}

	@BackGround{
        fondue;
	}

	@Finalize{
	}

	// main task, activates stuff.
	task mainTask{
		yield;
                wait(60);
                MagicC;
                wait(120);
                fire;
		fire2;
                
             
	}

	task movement{
	SetMovePositionRandom01(rand(90,120),rand(90,120),7,GetCenterX-120,GetCenterY-120,GetCenterX+120,GetCenterY-90);
	}

task disse{
wait(30);
loop(100){
PlaySE(dis);
wait(1);}
}

	task	fire
	{
	let count=0;
loop{
		wstar(0);
		wstar(1);
		wait(460);
		wstar(2);
		wstar(3);
		wait(460);
	}

	}

task wstar(let flg) {

	let x=0;
	let y=0;
        let angle=0;
	let color=0;
	ascent(cnt in 0..60) {
		if(flg==0) {
			x=GetClipMaxX();
			y=rand(GetClipMinY(),GetClipMaxY());
                        angle=180;
                        color=22;
		}

		if(flg==1) {
			x=GetClipMinX();
			y=rand(GetClipMinY(),GetClipMaxY());
                        angle=0+rand(-20,20);
                        color=12;
		}

		if(flg==2) {
			x=GetClipMaxX();
			y=rand(GetClipMinY(),GetClipMaxY());
                        angle=180+rand(-20,20);;
                        color=12;
		}

		if(flg==3) {
			x=GetClipMinX();
			y=rand(GetClipMinY(),GetClipMaxY());
                        angle=0;
                        color=22;
		}


                CreateShot01(x,y,rand(0.1,3),angle+rand(-5,5),color,0);
		wait(1+(cnt%2==0)*3);
	}
}


task fire2{

let angle = 0;

loop{
wait(60);
movement;
wait(60);
		loop(2){
			ConcentrationEx( 60, 7 );
			ConcentrationEx( 60, 7 );
		}
	        PlaySE(imachargingup);
wait(80);
angle = GetAngleToPlayer();
colorspark(GetX(),GetY(),angle,80,260);
PlaySE(sparkze);
wait(200);
}
}



	function colorspark(x,y,angle,wid,frame){
		let rand = 0;
		ascent(i in 0..8){
			spark(x,y,angle,i * 360 / 8,wid,i,frame);
		}
	}
	
	task spark(x,y,bangle,sangle,wid,graph,frame){
		let angle = sangle;
		let nrad = wid;
		let nangle = bangle + sin(angle) * wid;
		
	        let obj = Obj_Create(OBJ_LASER);
	        Obj_SetPosition(obj,x,y);
	        Obj_SetSpeed(obj,0);
	        Obj_SetAngle(obj,nangle);
	        ObjShot_SetGraphic(obj,color[graph]);
	        ObjShot_SetDelay(obj,60);
	
	        ObjLaser_SetLength(obj,550);
	        ObjLaser_SetWidth(obj,100);
	        ObjLaser_SetSource(obj,false);

		ObjShot_SetBombResist(obj,true);
		Obj_SetCollisionToPlayer(obj,true);
		
		SetColor(255,255,255);
		
		loop(frame){
			nrad -= wid / frame;
			angle += 3;
			nangle = bangle + sin(angle) * nrad;
			Obj_SetAngle(obj,nangle);
			yield;


		}
		
		if( !Obj_BeDeleted(obj) ){
			Obj_Delete(obj);

		}
	}



}


