let bg = GetCurrentScriptDirectory ~ "img\eff04_b.png";
let over = GetCurrentScriptDirectory ~ "img\eff04_a.png";
let black = GetCurrentScriptDirectory ~ "img\black.png";
let circa = GetCurrentScriptDirectory ~ "lib\circulo.png";


        let shot = GetCurrentScriptDirectory ~ "lib\supershot.txt";
        let estreshitas = GetCurrentScriptDirectory ~ "lib\last.txt";

	let imgBoss = GetCurrentScriptDirectory ~ "img\Marisa.png";
        let imachargingup = GetCurrentScriptDirectory ~ "se\se_ch02.wav";
        let cut = GetCurrentScriptDirectory ~ "img\cutman.png";
        let throw = GetCurrentScriptDirectory ~ "se\007.wav";
        let dis = GetCurrentScriptDirectory ~ "se\se_tan01.wav";
        let diss = GetCurrentScriptDirectory ~ "se\shoot13.wav";
        let onmyway = GetCurrentScriptDirectory ~ "se\006.wav";
        let kira = GetCurrentScriptDirectory ~ "se\se_kira00.wav";
        let saldraaaan = GetCurrentScriptDirectory ~ "se\se_power1.wav";
        let op = GetCurrentScriptDirectory ~ "se\se_option.wav";
        let sparkze = GetCurrentScriptDirectory ~ "se\se_nep00.wav";

	        LoadSE(imachargingup);
	        LoadGraphic(cut);
	        LoadGraphic(imgBoss);
	        LoadSE(throw);
	        LoadSE(dis);
	        LoadSE(diss);
	        LoadSE(onmyway);
	        LoadSE(kira);
	        LoadSE(saldraaaan);
	        LoadSE(op);
	        LoadSE(sparkze);

let op1 = 0;
let op2 = 0;
let offs1 = 0; 
let offs2 = 0; 

	LoadGraphic(bg);
	LoadGraphic(over);
	LoadGraphic(black);
        LoadGraphic(circa);

/////////////////////////////////////////////////////////////////////////////////////

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

        function p1m0(let a) {
	a=absolute(trunc(a))%2*2-1;
	return a;
}

	function fondue{
		SetTexture(black); 
		SetRenderState(ALPHA);
		SetAlpha(op1); 
		SetGraphicRect(0,0,256,256);
		SetGraphicScale(2,2); 
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);

		SetTexture(bg); 
		SetRenderState(ALPHA);
		SetAlpha(op1); 
		SetGraphicRect(0,0,256,256);
		SetGraphicScale(1.5,2); 
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);

		BgScrollExAdd(over, 0, 0.7, 3,op2,op2,op2);//1-1

		if(op1<255){
			op1+=3;
		}
		if(op2<60){
			op2+=3;
		}
	}

function BgScrollExAdd(bg, hdir, vdir, scale,r1,g1,b1){
   SetTexture(bg);
   SetRenderState(ADD);
   SetGraphicAngle(0, 0, 0);
   SetGraphicScale(scale, scale);
   SetColor(r1,g1,b1);
   SetGraphicRect(0+offs1, 0+offs2, 512+offs1, 512+offs2);
   DrawGraphic(GetCenterX, GetCenterY);
   offs1+=hdir;
   offs2+=vdir;

   SetGraphicScale(1, 1);
   SetAlpha(255)
   }

//////////////////////////////////////////////////////////////////////////


task MagicC{
if(OnEnemySpell || OnEnemyLastSpell){ 
circulo;
circulo2;
}else{
}
}
	task circulo{
		let rad = 0;
		let r = 0;
		let spellcount = 0;
		let objstar = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(objstar, circa);
		ObjEffect_SetPrimitiveType(objstar, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_CreateVertex(objstar, 4);
                ObjEffect_SetRenderState(objstar,ADD);
		ObjEffect_SetVertexUV(objstar, 0, 0, 0);//51 arriba
		ObjEffect_SetVertexUV(objstar, 1, 256, 0);//0 iz
		ObjEffect_SetVertexUV(objstar, 2, 256, 256);//128 der
		ObjEffect_SetVertexUV(objstar, 3, 0, 256);//180 abajo
		ObjEffect_SetLayer(objstar, 2);

		while(!Obj_BeDeleted(objstar)){
			Obj_SetPosition(objstar, GetX, GetY);
			ObjEffect_SetAngle(objstar, 0, 0, r);
			r+=3;
			ObjEffect_SetVertexXY(objstar, 0, -rad,-rad);
			ObjEffect_SetVertexXY(objstar, 1, rad, -rad);
			ObjEffect_SetVertexXY(objstar, 2, rad, rad);
			ObjEffect_SetVertexXY(objstar, 3, -rad,rad);

			if (rad==90 && spellcount <= 90){
				spellcount++;
				yield;
			}
			else if (spellcount > 90){
				//rad--;
				yield;
			}


			else{
				rad+=1;
				yield;
			}
		}
	}

	task circulo2{
		let rad = 0;
		let r = 0;
		let spellcount = 0;
		let objstar = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(objstar, circa);
		ObjEffect_SetPrimitiveType(objstar, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_CreateVertex(objstar, 4);
                ObjEffect_SetRenderState(objstar,ADD);
		ObjEffect_SetVertexUV(objstar, 0, 0, 0);//51 arriba
		ObjEffect_SetVertexUV(objstar, 1, 256, 0);//0 iz
		ObjEffect_SetVertexUV(objstar, 2, 256, 256);//128 der
		ObjEffect_SetVertexUV(objstar, 3, 0, 256);//180 abajo
		ObjEffect_SetLayer(objstar, 2);

		while(!Obj_BeDeleted(objstar)){
			Obj_SetPosition(objstar, GetX, GetY);
			ObjEffect_SetAngle(objstar, 0, 0, r);
			r+=-3;
			ObjEffect_SetVertexXY(objstar, 0, -rad,-rad);
			ObjEffect_SetVertexXY(objstar, 1, rad, -rad);
			ObjEffect_SetVertexXY(objstar, 2, rad, rad);
			ObjEffect_SetVertexXY(objstar, 3, -rad,rad);

			if (rad==90 && spellcount <= 90){
				spellcount++;
				yield;
			}
			else if (spellcount > 90){
				//rad--;
				yield;
			}
			else{
				rad+=1;
				yield;
			}
		}
	}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Another Concentration Lines Effect (Created by Johnny Walker) ////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
task ConcentrationEx( framec, grbul ){

	loop((framec-30)/3){
		lines(rand(180,200), rand(0,360),grbul);
		loop(3){yield;}
	}
	descent(let i in 3..30){
		lines(12*i, rand(0,360),grbul);
		yield;
	}

	
	
	
	task lines(let leng, let angl, let grbul){
		let del = leng/20;
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetAngle(obj, angl);
		Obj_SetAlpha(obj, 100);
		ObjShot_SetGraphic(obj, grbul);
		Obj_SetCollisionToPlayer(obj, false);
		ObjLaser_SetSource(obj, false);
		ascent(let t in 0..16){
			Obj_SetPosition(obj, GetX-30*cos(angl),GetY-30*sin(angl));
			ObjLaser_SetLength(obj, leng);
			ObjLaser_SetWidth(obj,t*del/30+4);
			leng-=del;
			yield;
		}

		ObjShot_FadeDelete(obj);
	}

}