let b ="script\DanMUku\Image\b.png";
let o ="script\DanMUku\Image\o.png";
let n ="script\DanMUku\Image\n.png";
let u ="script\DanMUku\Image\u.png";
let s="script\DanMUku\Image\s.png";
let bonus="script\DanMUku\Image\bonus.png";
let gotbonus=false;
let count=0;
let q = 0;
let boss=false;

let goombaM = "script\DanMUku\Stage1\ParagoombaM.txt";
let koopaV = "script\DanMUku\Stage3\ParaKoopaV.txt";
let koopaM = "script\DanMUku\Stage3\ParaKoopaM.txt";
let bomb = "script\DanMUku\Stage3\Bob-Bomb.txt";

#include_script "script\DanMUku\Wait.txt";

 function Ini3() {
	LoadGraphic("script\DanMUku\Stage3\Image\ville.png");
	PlayMusic("script\DanMuku\Stage3\Stage3.mp3");
	SetCommonData("StageFini", false);
	SetCommonData("B", false);
	SetCommonData("O", false);
	SetCommonData("N", false);
	SetCommonData("U", false);
	SetCommonData("S", false);
	SetCommonData("bombe", 0);
	SetCommonData("nobonus", false);
	LoadGraphic(b);
	LoadGraphic(o);
	LoadGraphic(n);
	LoadGraphic(u);
	LoadGraphic(s);
	LoadGraphic(bonus);
	stage3;
  }


 function BG3() {
            SetTexture("script\DanMUku\Stage3\Image\ville.png");
            SetRenderState(ALPHA);
            SetGraphicRect(0, q, 384, 50000+q);
            SetGraphicScale(1,1);
            SetGraphicAngle(0, 0, 0);
            DrawGraphic(GetCenterX, GetCenterY);
		if (boss==false) {
			q-=4;
		}

	if(GetCommonData("B")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(b);
            SetGraphicRect(0,0,14,21);
            DrawGraphic(GetClipMaxX-90,GetClipMaxY-10);
	}
	if(GetCommonData("O")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(o);
            SetGraphicRect(0,0,19,20);
            DrawGraphic(GetClipMaxX-70,GetClipMaxY-10);
	}
	if(GetCommonData("N")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(n);
            SetGraphicRect(0,0,15,20);
            DrawGraphic(GetClipMaxX-50,GetClipMaxY-10);
	}
	if(GetCommonData("U")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(u);
            SetGraphicRect(0,0,15,21);
            DrawGraphic(GetClipMaxX-30,GetClipMaxY-10);
	}
	if(GetCommonData("S")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(s);
            SetGraphicRect(0,0,16,23);
            DrawGraphic(GetClipMaxX-10,GetClipMaxY-10);
	}
	if(GetCommonData("nobonus")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(b);
            SetGraphicRect(0,0,14,21);
            DrawGraphic(GetCenterX-170,GetCenterY-100);
		DrawText("Finish 'Star system' in fewer than 25 seconds.",GetCenterX-150,GetCenterY-110,16,255);

		SetTexture(o);
            SetGraphicRect(0,0,19,20);
            DrawGraphic(GetCenterX-170,GetCenterY-60);
		DrawText("Kill the bonus Shy Guy.",GetCenterX-150,GetCenterY-70,16,255);

		SetTexture(n);
            SetGraphicRect(0,0,15,20);
            DrawGraphic(GetCenterX-170,GetCenterY-20);
		DrawText("Kill fewer than 5 Bob-bombs.",GetCenterX-150,GetCenterY-30,16,255);

		SetTexture(u);
            SetGraphicRect(0,0,15,21);
            DrawGraphic(GetCenterX-170,GetCenterY+20);
		DrawText("Finish Luidi's second non-spell",GetCenterX-150,GetCenterY,16,255);
		DrawText("without dying.",GetCenterX-150,GetCenterY+20,16,255);

		SetTexture(s);
            SetGraphicRect(0,0,16,23);
            DrawGraphic(GetCenterX-170,GetCenterY+60);
		DrawText("Capture Zigzaguing sign",GetCenterX-150,GetCenterY+40,16,255);
		DrawText("'Behind you !'.",GetCenterX-150,GetCenterY+60,16,255);
	}

		if(gotbonus&&count%60<40){
			SetTexture(bonus);
		    SetRenderState(ALPHA);
		    SetAlpha(255);
		    SetGraphicRect(0, 0, 150, 80);
			SetGraphicScale(1,1);
            		SetGraphicAngle(0, 0, 0);
			DrawGraphic(GetCenterX, GetCenterY-50);
	}
 }

 task stage3{
Wait(60);
CreateEnemyFromFile(goombaM, GetClipMinX, 100, 0.5, 0, 1);
CreateEnemyFromFile(goombaM, GetClipMaxX, 100, 0.5, 180, 0);
Wait(200);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-50, 1, 0, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY+50, 1, 180, 0);
Wait(50);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
Wait(200);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-150, 1, 30, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-150, 1, 150, 0);
Wait(50);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-200, 1, 30, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-200, 1, 150, 0);
Wait(50);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
Wait(100);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-150, 1, 30, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-150, 1, 150, 0);
Wait(50);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-100, 1, 30, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-100, 1, 150, 0);
Wait(50);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
Wait(100);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-150, 2, 30, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-150, 2, 150, 0);
Wait(100);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-100, 2, 30, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-100, 2, 150, 0);
Wait(100);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-200, 2, 80, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-200, 2, 100, 0);
Wait(100);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-100, 2, 50, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-100, 2, 130, 0);
Wait(200);
CreateEnemyBossFromFile("script\DanMUku\Stage3\Maritin.txt", GetCenterX, GetClipMinY, 0, 0, 0);
WaitForZeroEnemy;
CreateEnemyFromFile(goombaM, GetClipMinX, 100, 0.5, 0, 1);
CreateEnemyFromFile(goombaM, GetClipMaxX, 100, 0.5, 180, 0);
Wait(200);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-50, 1, 0, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY+50, 1, 180, 0);
Wait(50);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
Wait(200);
CreateEnemyFromFile(koopaM, GetClipMinX+100, GetClipMinY, 1, 90, 1);
CreateEnemyFromFile(koopaM, GetClipMaxX-100, GetClipMinY, 1, 90, 0);
Wait(200);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
Wait(100);
CreateEnemyFromFile("script\DanMUku\Stage5\1UPMaskass.txt", GetCenterX, GetClipMinY, 2, 90, "O");
Wait(100);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
CreateEnemyFromFile(bomb, rand(GetClipMinX+10, GetClipMaxX-10), GetClipMinY, 1, 90, 0);
Wait(100);
CreateEnemyFromFile(koopaV, GetClipMinX, GetCenterY-200, 2, 80, 1);
CreateEnemyFromFile(koopaV, GetClipMaxX, GetCenterY-200, 2, 100, 0);
Wait(500);
if(GetCommonData("bombe")<=5) {
	SetCommonData("N", true);
}

ForbidShot(true);
Wait(100);
 CreateEnemyBossFromFile("script\DanMUku\Stage3\Luidi.txt", GetCenterX, GetClipMinY, 0, 0, 0);
Wait(10);
ForbidShot(false);
WaitForZeroEnemy;
 CreateEnemyBossFromFile("script\DanMUku\Stage3\Dialogue 2.txt", GetCenterX, GetClipMinY, 0, 0, 0);
WaitForZeroEnemy;
AddScore(3000000);
Wait(100);
boss=false;

	SetCommonData("nobonus", true);
	Wait(300);
	SetCommonData("nobonus", false);

	let numberBonus = 0;
	ascent (i in 0..5) {
		if (GetCommonData(["B", "O", "N", "U", "S"][i])) {
			numberBonus++;
		}
	}

	if (numberBonus>=3) {
		gotbonus= true;
		count=0;
		PlayMusic("script\DanMUku\Musique\bonus.mp3");
		Wait(200);
		CreateEnemyBossFromFile("script\DanMUku\Stage3\Bonus3.txt", GetCenterX, GetClipMinY, 0, 0, numberBonus);
		gotbonus=false;
		WaitForZeroEnemy;
		Wait(100);
	}


SetCommonData("StageFini", true);
 }
