/* SPECTRAL NEXUS' CONCENTRATION EFFECTS!
By Spectral Nexus

Graphics made by Ozzy/ExPorygon
Please credit me if you use this, I'd appreciate it! Enjoy!
*/

task ConcentrateA3(enemyObj){
	loop(3){
		Star1(enemyObj);
		loop(20){yield;}
		Star2(enemyObj);
		loop(20){yield;}
	}
	task Star1(enemyObj){
		let spin = 0;
		let a = 3;
		let Path = GetCurrentScriptDirectory ~ "./img/Snow.png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		Obj_SetRenderPriorityI(obj,41);
		ObjPrim_SetTexture(obj,Path);
		ObjRender_SetAlpha(obj,0);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(Path),GetTextureHeight(Path));
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),0);
		
		spinstar;
		scalestar;
		alphastar;
		colorstar;
		
		task spinstar{
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetAngleZ(obj,spin);
				spin+=2;
				yield;
			}
		}
		task alphastar{
			let alp = 0;
			while(alp<255){
				ObjRender_SetAlpha(obj,alp);
				alp+=10;
				yield;
			}
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetAlpha(obj,alp);
				alp-=a;
				yield;
			}
			Obj_Delete(obj);
		}
		task scalestar{
			let scale = 2;
			while(scale>0){
				ObjRender_SetScaleXYZ(obj,scale,scale,scale);
				scale-=2/(255/a);
				yield;
			}
		}
		task colorstar{
				let color = 255;
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetColor(obj,color,color,255);
				color-=a;
				yield;
			}
		}
		
	}
	task Star2(enemyObj){
		let spin = 0;
		let a = 3;
		let Path = GetCurrentScriptDirectory ~ "./img/Snow.png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		Obj_SetRenderPriorityI(obj,41);
		ObjPrim_SetTexture(obj,Path);
		ObjRender_SetAlpha(obj,0);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(Path),GetTextureHeight(Path));
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),0);
		
		spinstar;
		scalestar;
		alphastar;
		colorstar;
		
		task spinstar{
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetAngleZ(obj,spin);
				spin-=2;
				yield;
			}
		}
		task alphastar{
			let alp = 0;
			while(alp<255){
				ObjRender_SetAlpha(obj,alp);
				alp+=10;
				yield;
			}
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetAlpha(obj,alp);
				alp-=a;
				yield;
			}
			Obj_Delete(obj);
		}
		task scalestar{
			let scale = 2;
			while(scale>0){
				ObjRender_SetScaleXYZ(obj,scale,scale,scale);
				scale-=2/(255/a);
				yield;
			}
		}
		task colorstar{
				let color = 255;
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetColor(obj,color,color,255);
				color-=a;
				yield;
			}
		}
		
	}
}

/* Notes
CONCENTRATE A4: SPIRAL CHARGE.
By Spectral Nexus

EnemyObj: What Object is Concentrating.
Type: What graphic is displayed. Choose from: "Cherry", "Maple", "Star", "Magic", "Magic", "Flower", "Heart", "Snow" and "Music".
Duration: How long the charge effect lasts. 9 is the typical "Long" Charge and 4 is "Short" Charge.
Number: Number of graphics per circle/spiral, Recommended: 7 for normal screen, 10 for fullscreen.
Radius: The maximum radius of the spiral. Recommended: 240 for normal screen, 480 for fullscreen.
Scale: Size of each graphic. Recommended 0.5 for 240 radius, 1 for 480 radius.
Intensity: How sharply the spiral twists. 1-3 is recommended, 0 is no spiral (lines) and 4+ is kinda crazy lol xD.
Speed: General Speed of Spiral. 3 Recommended: with increase, 6 without increase.
Increase: Speed in which spiral increases. Recommended 0-0.3. 0 is no increase (steady speed) and 0.3+ is also kinda crazy lol xD
Colour: Colour of graphics. Choose from: "RED", "ORANGE", "YELLOW", "LGREEN" (Light Green), "GREEN" (Dark Green), "AQUA", "BLUE", "PURPLE" and "PINK".
Sound: Sound that plays during charge. Choose from: "Long", "Short" or "" for nothing.

Example Code: ConcentrateA4(enemyObj,"Star",9,7,180,0.375,1,6,0,"RED","Long");

Please credit me if you use this, I'd appreciate it! Enjoy!
*/
task ConcentrateA4(enemyObj,type,duration,number,radius,scale,intensity,speed,increase,colour,sound){
	let dir = 0;
	let dir2 = 0;
	let soundtype = GetCurrentScriptDirectory ~ "./se/"~ sound ~".wav";
	LoadSound(soundtype);
	PlaySE(soundtype);
	loop(duration){
		loop(number){
			if(!Obj_IsDeleted(enemyObj)){
				Star1(enemyObj,dir,type,number,radius,scale,intensity,speed,increase,colour);
				dir+=360/number;
			}
		}
		wait(5);
		loop(number){
			if(!Obj_IsDeleted(enemyObj)){
				Star2(enemyObj,dir2,type,number,radius,scale,intensity,speed,increase,colour);
				dir2-=360/number;
			}
		}
		wait(5);
	}
	task Star1(enemyObj,ang,type,number,radius,scale,intensity,speed,increase,colour){
		let spin = 0;
		let a = speed;
		let Path = GetCurrentScriptDirectory ~ "./img/"~ type ~".png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		Obj_SetRenderPriorityI(obj,41);
		ObjPrim_SetTexture(obj,Path);
		ObjRender_SetAlpha(obj,0);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(Path),GetTextureHeight(Path));
		ObjSprite2D_SetDestCenter(obj);
		spinstar;
		scalestar;
		alphastar;
		colorstar;
		posistar;
		
		task posistar{
			let s = 0;
			let e = 0;
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetPosition(obj,ObjMove_GetX(enemyObj)+(radius-e*(radius/240))*cos(dir+s),ObjMove_GetY(enemyObj)+(radius-e*(radius/240))*sin(dir+s),0);
				dir+=360/number;
				a+=increase;
				s+=intensity;
				e+=a;
				yield;
			}
		}
		task spinstar{
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetAngleZ(obj,ang+spin);
				spin-=4;
				yield;
			}
		}
		task alphastar{
			let alp = 0;
			while(alp<255){
				ObjRender_SetAlpha(obj,alp);
				alp+=a*4;
				yield;
			}
			while(!Obj_IsDeleted(obj) && alp>0){
				ObjRender_SetAlpha(obj,alp);
				alp-=a;
				yield;
			}
			Obj_Delete(obj);
		}
		task scalestar{
			let s = scale;
			while(s>0){
				ObjRender_SetScaleXYZ(obj,s,s,s);
				s-=scale/(255/a);
				yield;
			}
		}
		task colorstar{
			let color = 255;
			let color2 = 255;
			alternative(colour)
			case("RED"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,255,color,color);
					color-=a;
					yield;
				}
			}
			case("ORANGE"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,255,color2,color);
					color-=a;
					color2-=a/2;
					yield;
				}
			}
			case("YELLOW"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,255,255,color);
					color-=a;
					yield;
				}
			}
			case("LGREEN"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color2,255,color);
					color-=a;
					color2-=a/2;
					yield;
				}
			}
			case("GREEN"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color,255,color);
					color-=a;
					yield;
				}
			}
			case("AQUA"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color,color2,255);
					color-=a;
					color2-=a/2;
					yield;
				}
			}
			case("BLUE"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color,color,255);
					color-=a;
					yield;
				}
			}
			case("PURPLE"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color2,color,255);
					color-=a;
					color2-=a/2;
					yield;
				}
			}
			case("PINK"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,255,color,255);
					color-=a;
					yield;
				}
			}
		}	
	}
	task Star2(enemyObj,ang,type,number,radius,scale,intensity,speed,increase,colour){
		let spin = 0;
		let a = speed;
		let Path = GetCurrentScriptDirectory ~ "./img/"~ type ~".png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		Obj_SetRenderPriorityI(obj,41);
		ObjPrim_SetTexture(obj,Path);
		ObjRender_SetAlpha(obj,0);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(Path),GetTextureHeight(Path));
		ObjSprite2D_SetDestCenter(obj);
		spinstar;
		scalestar;
		alphastar;
		colorstar;
		posistar;
		
		task posistar{
			let s = 0;
			let e = 0;
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetPosition(obj,ObjMove_GetX(enemyObj)+(radius-e*(radius/240))*cos(dir+s),ObjMove_GetY(enemyObj)+(radius-e*(radius/240))*sin(dir+s),0);
				dir+=360/number;
				a+=increase;
				s-=intensity;
				e+=a;
				yield;
			}
		}
		task spinstar{
			while(!Obj_IsDeleted(obj)){
				ObjRender_SetAngleZ(obj,ang+spin);
				spin-=4;
				yield;
			}
		}
		task alphastar{
			let alp = 0;
			while(alp<255){
				ObjRender_SetAlpha(obj,alp);
				alp+=a*4;
				yield;
			}
			while(!Obj_IsDeleted(obj) && alp>0){
				ObjRender_SetAlpha(obj,alp);
				alp-=a;
				yield;
			}
			Obj_Delete(obj);
		}
		task scalestar{
			let s = scale;
			while(s>0){
				ObjRender_SetScaleXYZ(obj,s,s,s);
				s-=scale/(255/a);
				yield;
			}
		}
		task colorstar{
			let color = 0;
			let color2 = 128;
			alternative(colour)
			case("RED"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,255,color,color);
					color+=a;
					yield;
				}
			}
			case("ORANGE"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,255,color2,color);
					color+=a;
					color2+=a/2;
					yield;
				}
			}
			case("YELLOW"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,255,255,color);
					color+=a;
					yield;
				}
			}
			case("LGREEN"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color2,255,color);
					color+=a;
					color2+=a/2;
					yield;
				}
			}
			case("GREEN"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color,255,color);
					color+=a;
					yield;
				}
			}
			case("AQUA"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color,color2,255);
					color+=a;
					color2+=a/2;
					yield;
				}
			}
			case("BLUE"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color,color,255);
					color+=a;
					yield;
				}
			}
			case("PURPLE"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,color2,color,255);
					color+=a;
					color2+=a/2;
					yield;
				}
			}
			case("PINK"){
				while(!Obj_IsDeleted(obj)){
					ObjRender_SetColor(obj,255,color,255);
					color+=a;
					yield;
				}
			}
		}	
	}
}

/* Notes
CONCENTRATE A4 RAINBOW: RAINBOW SPIRAL CHARGE.
By Spectral Nexus
This is a *slightly* modified version of my ConcentrateA4 Effect.

EnemyObj: What Object is Concentrating.
Type: What graphic is displayed. Choose from: "Cherry", "Maple", "Star", "Magic", "Magic", "Flower", "Heart", "Snow" and "Music".
Duration: How long the charge effect lasts. This is intended to be used as a "final charge" or important charge, so this does not have a short version. 1 is "Long", and anything above it restarts the sound effect. 
*DURATION NOTE* All other parameters' recommendations change according to the duration. The current recommendations are for 1 repetition.
Number: Number of graphics per circle/spiral, Recommended: 7 for normal screen, 10 for fullscreen.
Radius: The maximum radius of the spiral. Recommended: 120 for normal screen, 240 for fullscreen.
Scale: Size of each graphic. Recommended 0.125 for 120 radius, 0.25 for 240 radius.
Intensity: How sharply the spiral twists. 1-3 is recommended, 0 is no spiral (lines) and 4+ is kinda crazy lol xD.
Speed: General Speed of Spiral. 3 Recommended: with increase, 6 without increase.
Increase: Speed in which spiral increases. Recommended 0-0.3. 0 is no increase (steady speed) and 0.3+ is also kinda crazy lol xD.
Radius Increase: Speed in which radius expands/increases. Recommended 3-7 for 1 repetition. 0 is no radius increase (steady radius) and 7+ is also kinda crazy lol xD.

Example Code: ConcentrateA4_Rainbow(enemyObj,"Music",3,7,120,0.125,2,3,0.1,1.375);

Please credit me if you use this, I'd appreciate it! Enjoy!
*/
task ConcentrateA4_Rainbow(enemyObj,type,duration,number,radius,scale,intensity,speed,increase,radiusincrease){
	let t = 0;
	loop(duration){
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"RED","Long");
			wait(10);
			t+=radiusincrease;
		}
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"ORANGE","");
			wait(10);
			t+=radiusincrease;
		}
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"YELLOW","");
			wait(10);
			t+=radiusincrease;
		}
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"LGREEN","");
			wait(10);
			t+=radiusincrease;
		}
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"GREEN","");
			wait(10);
			t+=radiusincrease;
		}
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"AQUA","");
			wait(10);
			t+=radiusincrease;
		}
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"BLUE","");
			wait(10);
			t+=radiusincrease;
		}
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"PURPLE","");
			wait(10);
			t+=radiusincrease;
		}
		if(!Obj_IsDeleted(enemyObj)){
			ConcentrateA4(enemyObj,type,1,number,radius+t,scale+(t/120),intensity,speed,increase,"PINK","");
			wait(10);
			t+=radiusincrease;
		}
	}
}

/* Notes
CONCENTRATE A5: INVERT CHARGE.
By Spectral Nexus

EnemyObj: What Object is Concentrating.
Duration: How long the charge effect lasts. 20 or 10 (with 5 or 10 wait duration) is the typical "Long" Charge and 10 or 6(with 2 or 5 wait duration respectively) is "Short" Charge.
*DURATION NOTE* Must be an even number! If odd, the invert will flash onscreen, which won't look pretty at all lol xD.
Wait Duration: The amount of space between each invert circle. Recommended wait duration is 11.
Scale: Starting scale of the circles. Recommended: 1-2.
Decrease: Speed in which the circle decreases. Recommended: Approximately 0.7.
Sound: Sound that plays during charge. Choose from: "Long", "Short" or "" 
Please credit me if you use this, I'd appreciate it! Enjoy!
*/
task ConcentrateA5(enemyObj,duration,waitduration,scale,decrease,sound){
	let soundtype = GetCurrentScriptDirectory ~ "./se/"~ sound ~".wav";
	LoadSound(soundtype);
	PlaySE(soundtype);
		ascent(i in 0..duration){
			Circle(enemyObj,scale,decrease,sound,waitduration*i);
		}
	task Circle(enemyObj,scale,decrease,sound,delay){
		let spin = 0;
		let Path = GetCurrentScriptDirectory ~ "./img/Inverse.png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		Obj_SetRenderPriorityI(obj,42);
		ObjRender_SetBlendType(obj,BLEND_INV_DESTRGB);
		ObjPrim_SetTexture(obj,Path);
		ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(Path),GetTextureHeight(Path));
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj,ObjMove_GetX(enemyObj),ObjMove_GetY(enemyObj),0);
		ObjRender_SetScaleXYZ(obj,scale,scale,scale);
		
		scalestar;
		
		task scalestar{
			let sca = scale;
			let s = 0;
			wait(delay);
			while(sca>0){
				ObjRender_SetScaleXYZ(obj,sca,sca,sca);
				s+=decrease;
				sca-=sca/(255/s);
				yield;
			}
			Obj_Delete(obj);
		}
		
		
	}
}

task ConcObject(type,x,y,speed,dir,rotation,radius,opacity,color){

	let Path = GetCurrentScriptDirectory ~ "./img/"~ type ~".png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,41);
	ObjPrim_SetTexture(obj,Path);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(Path),GetTextureHeight(Path));
	ObjSprite2D_SetDestCenter(obj);
	
	if(radius>200){ scale = 1; }
	let Red = color[0];
	let Green = color[1];
	let Blue = color[2];
	let scale = 0.75*(radius/200);
	let spin = rand(0,180);
	let alpha = 0;
	
	while(!Obj_IsDeleted(obj)){
		ObjRender_SetPosition(obj,x+radius*cos(dir),y+radius*sin(dir),0);
		ObjRender_SetScaleXYZ(obj,scale,scale,scale);
		ObjRender_SetAngleZ(obj,spin);
		ObjRender_SetAlpha(obj,alpha);
		ObjRender_SetColor(obj,Red*(alpha/255),Green*(alpha/255),Blue*(alpha/255));
	
		if(alpha<opacity && radius>=10){ alpha+=opacity/90*speed; }
		if(radius<200){ scale-=0.75/200*speed; }
		if(radius<10){ alpha-=opacity/10*speed; }
		if(alpha<=0){ Obj_Delete(obj); }
		spin+=rand(3,4)*rotation;
		radius-=speed;
			
		yield;
	}

}

task ConcCircle(x,y,speed,radius,color){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	
	let RGB = color;
	
	let alpha = 0;
	let scale = 2.5*(radius/200);
	let Path = GetCurrentScriptDirectory ~ "./img/ConcentrationCircle.png";
	
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	Obj_SetRenderPriorityI(obj,41);
	ObjPrim_SetTexture(obj,Path);
	ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(Path),GetTextureHeight(Path));
	ObjSprite2D_SetDestCenter(obj);
	
	while(!Obj_IsDeleted(obj)){
		ObjRender_SetPosition(obj,x,y,0);
		ObjRender_SetScaleXYZ(obj,scale,scale,scale);
		ObjRender_SetColor(obj,RGB[0]*(alpha/255),RGB[1]*(alpha/255),RGB[2]*(alpha/255));
		if(alpha<255){ alpha+=255/(radius-90)*speed; }
		scale-=speed/100;
		if(scale<=0){ Obj_Delete(obj); }
		
		yield;
	}
}