TouhouDanmakufu
#Title[Non Spellcard 3]
#Text[Normal]
#Image[]
#PlayLevel[Normal]
#Player[FREE]
#ScriptVersion[2]
#BGM[]

script_enemy_main{

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

        let hit = 1;

	@Initialize{
                SetInvincibility(200);
		SetLife(3200);
		SetTimer(44);
                SetEnemyMarker(true);
                SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
                LoadUserShotData(shot);
                InitializeAction();

		mainTask;
	}

	@MainLoop{
if(GetPlayerType == USER_PLAYER && GetPlayerScriptName =="Mamizou.txt"){
	if(((|GetX-GetPlayerX|)^2+(|GetY-GetPlayerY|)^2)^0.5 < 20){
                SetCommonData("gafas",true);
DeleteMusic(GetCurrentScriptDirectory ~ "se\(UNL) Love-coloured Magic.mp3");
PlayMusic(GetCurrentScriptDirectory ~ "se\(TD) Futatsuiwa from Sado.mp3");
ForbidBomb(true);
	}
}


if (hit==1){
		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{

	}

	@Finalize{
        DeleteSE(onmyway);
	}

	task mainTask{
                wait(130);
		yield;
		fire;
	}

	task movement{

		wait(100);
                SetMovePosition02(GetClipMinX-170, rand(GetPlayerY,GetCenterY - 100), 60);
		wait(60);
                hit=0;
	        SetY(GetPlayerY);
		wait(30);
                SetMovePosition02(GetClipMaxX+150, GetPlayerY, 30);
                PlaySE(onmyway);
		wait(40);
                SetX(GetClipMinX-150);
                wait(10);
                SetMovePosition02(GetClipMaxX+150, GetPlayerY, 30);
                PlaySE(onmyway);
		wait(50);
                SetMovePosition02(GetClipMinX-150, GetPlayerY, 30);
                PlaySE(onmyway);
		wait(50);
	        SetY(rand(GetPlayerY,GetCenterY - 100));
	        SetX(GetClipMinX-150);
                hit=1;
                SetMovePosition02(GetCenterX, GetCenterY - 100, 60);
		wait(180);
	}

	task fire{

	let count=0;
	let color=[134,135,136,137,138,139,140,141,142,143,144,145,146,147,148];

	while(true) {
                PlaySE(imachargingup);
		loop(2){
			ConcentrationEx( 60, 243 );
			ConcentrationEx( 60, 243 );
		}
                wait(70);
		movement;
		ascent(cnt in 0..370) {
                PlaySE(dis);
		    let ang=count*40+cnt*743.056458*p1m0(count);
      		    let x=GetCenterX()+cos(ang)*cnt;
		    let y=GetCenterY()+sin(ang)*cnt;
		    CreateShotA(0,x,y-100,30);
	            SetShotDataA(0,0,0,ang-180-cnt*p1m0(cnt),0,0,0,color[rand_int(0,14)]);
		    SetShotDataA(0,100,0,NULL,p1m0(cnt),0.005,2,NULL);
	            SetShotDataA(0,330,NULL,NULL,0,0.005,2,NULL);
		    FireShot(0);
		    wait(1);
		}
		count++;
		wait(60);
	}
}


}