task SunSpell(x, y, pos1, pos2, speed, rate, angle, num, dist, graphic, graphic1, delay, delay1) {

	let fire = CreateShotA1(x, y, 0, 0, graphic, delay);
	
	ObjMove_SetDestAtFrame(fire, pos1, pos2, speed);
	
	let burst=0;
	
	let endX=0;
	let endY=0;
	
	while(!Obj_IsDeleted(fire)){
	
		burst++;
		
		endX = ObjMove_GetX(fire);
		endY = ObjMove_GetY(fire);
		
		if(burst==delay1){
			Obj_Delete(fire);
			}
			
		yield;
		}
		
	let angle1 = angle;
	let angle2 = angle;
	
	loop(10){
	
		loop(num){
			angle1+=360/num;
		
			let obj20 = CreateShotA1(endX+dist*cos(angle1), endY+dist*sin(angle1), rate, angle2, graphic1, 0);
			let obj21 = CreateShotA1(endX+dist*cos(angle1), endY+dist*sin(angle1), rate, angle2+180, graphic1, 0);
				
			}
			
		angle2+=29.1;
		
		loop(10){
			yield;
			}
		}
	}
	
task WaterSpell(x, y, pos1, pos2, speed, width, angle, graphic, graphic1, delay, delay1, delay2) {

	let fire = CreateShotA1(x, y, 0, 0, graphic, delay);
	
	ObjMove_SetDestAtFrame(fire, pos1, pos2, speed);

	let burst=0;
	
	let endX=0;
	let endY=0;
	
	while(!Obj_IsDeleted(fire)){
	
		burst++;
		
		endX = ObjMove_GetX(fire);
		endY = ObjMove_GetY(fire);
		
		if(burst==delay1){
			Obj_Delete(fire);
			CHINK;
			}
			
		yield;
		}
		
	let angle1=angle;
	let angle2=angle;
	
	loop(10){
	
		let px = GetPlayerX();
		let py = GetPlayerY();
		
		let Player = atan2(py - endY, px - endX);
		
		CreateStraightLaserA1(endX, endY, Player, 460, width, 60, graphic1, delay2);
		CreateStraightLaserA1(endX, endY, Player-angle1, 460, width, 60, graphic1, delay2);
		CreateStraightLaserA1(endX, endY, Player+angle2, 460, width, 60, graphic1, delay2);
		
		angle1-=5.1;
		angle2-=5.1;
		
		
		loop(10){
			yield;
			}
		}
	}
	
task EarthSpell(x, y, pos1, pos2, speed, rate, angle, num, angvel, graphic, graphic1, delay, delay1) {

	let fire = CreateShotA1(x, y, 0, 0, graphic, delay);
	
	ObjMove_SetDestAtFrame(fire, pos1, pos2, speed);
	
	let burst=0;
	
	let endX=0;
	let endY=0;
	
	while(!Obj_IsDeleted(fire)){
	
		burst++;
		
		endX = ObjMove_GetX(fire);
		endY = ObjMove_GetY(fire);
		
		if(burst==delay1){
			Obj_Delete(fire);
			CHINK;
			}
			
		yield;
		}
		
	let angle1 = angle;
	let angle2 = angle;
	
	loop(num){
		let angle1 = rand(90+45, 45);
		loop(10){
			let angle1 = rand(90+45, 45);
		
			let obj = CreateShotA1(endX, endY, rate, angle1, graphic1, 0);
			ObjMove_SetAngularVelocity(obj, rand(-0.5, 0.5));
			}
		
		loop(15){
			yield;
			}
		}
	}
	
task WoodSpell(x, y, pos1, pos2, speed, rate, angle, num, graphic, graphic1, delay, delay1) {

	let fire = CreateShotA1(x, y, 0, 0, graphic, delay);
	
	ObjMove_SetDestAtFrame(fire, pos1, pos2, speed);
	
	let burst=0;
	
	let endX=0;
	let endY=0;
	
	while(!Obj_IsDeleted(fire)){
	
		burst++;
		
		endX = ObjMove_GetX(fire);
		endY = ObjMove_GetY(fire);
		
		if(burst==delay1){
			Obj_Delete(fire);
			CHINK;
			}
			
		yield;
		}
		
	let angle1 =0;
	let angle2 = angle;
	
	loop(num){
	
		let SP = rand(1,2);
	
		CreateShotA1(endX+angle1+rand(-5,5), endY+rand(-5, 5), SP, angle, graphic1, 5);
		CreateShotA1(endX-angle1+rand(-5,5), endY+rand(-5, 5), SP, angle, graphic1, 5);
		CreateShotA1(endX-angle1+rand(-5,5), endY+rand(-5, 5), SP-0.4, angle, graphic1, 5);
		CreateShotA1(endX-angle1+rand(-5,5), endY+rand(-5, 5), SP-0.2, angle, graphic1, 5);
		CreateShotA1(endX+angle1+rand(-5,5), endY+rand(-5, 5), SP-0.2, angle, graphic1, 5);
		CreateShotA1(endX+angle1+rand(-5,5), endY+rand(-5, 5), SP-0.4, angle, graphic1, 5);
		
		angle1-=18;

		
		loop(1){
			yield;
			}
		}
	}
	
task MoonSpell(x, y, pos1, pos2, speed, rate, angle, num, graphic, graphic1, delay, delay1) {

	let fire = CreateShotA1(x, y, 0, 0, graphic, delay);
	
	ObjMove_SetDestAtFrame(fire, pos1, pos2, speed);
	
	let burst=0;
	
	let endX=0;
	let endY=0;
	
	while(!Obj_IsDeleted(fire)){
	
		burst++;
		
		endX = ObjMove_GetX(fire);
		endY = ObjMove_GetY(fire);
		
		if(burst==delay1){
			Obj_Delete(fire);
			CHINK;
			}
			
		yield;
		}
		
	let angle1 = angle;
	
	loop(10){
	angle1=rand(0,360);
		
	loop(num){
		angle1+=360/num;
		
		CreateShotA1(endX, endY, rate, angle1, graphic1, 20);
		CreateShotA1(endX, endY, rate-0.15, angle1, graphic1, 20);
		CreateShotA1(endX, endY, rate-0.3, angle1, graphic1, 20);
		CreateShotA1(endX, endY, rate-0.45, angle1, graphic1, 20);
		CreateShotA1(endX, endY, rate-0.6, angle1, graphic1, 20);
		}
		
	loop(15){
		yield;
		}
		}
	}
	
task MetalSpell(x, y, pos1, pos2, speed, rate, angle, num, graphic, graphic1, delay, delay1) {

	let fire = CreateShotA1(x, y, 0, 0, graphic, delay);
	
	ObjMove_SetDestAtFrame(fire, pos1, pos2, speed);
	
	let burst=0;
	
	let endX=0;
	let endY=0;
	
	while(!Obj_IsDeleted(fire)){
	
		burst++;
		
		endX = ObjMove_GetX(fire);
		endY = ObjMove_GetY(fire);
		
		if(burst==delay1){
			Obj_Delete(fire);
			CHINK;
			}
			
		yield;
		}
		
	let angle1 = angle;
		
	loop(num){
		loop(5){
			angle1+=360/5;
			
			let obj10 = CreateShotA1(endX, endY, rate, angle1, graphic1, 10);
			
			let obj11 = CreateShotA1(endX, endY, rate-0.2, angle1, graphic1, 10);
			
			let obj12 = CreateShotA1(endX, endY, rate-0.4, angle1, graphic1, 10);
			
			ObjMove_AddPatternA1(obj10, 60, NO_CHANGE, 90);
			ObjMove_AddPatternA1(obj11, 60, NO_CHANGE, 90);
			ObjMove_AddPatternA1(obj12, 60, NO_CHANGE, 90);
			}
		angle1+=rand(0, 360);
		
		loop(20){
		yield;
		}
		}
	}
	
task FireSpell(x, y, pos1, pos2, speed, rate, angle, num, angvel, graphic, graphic1, delay, delay1) {

	let fire = CreateShotA1(x, y, 0, 0, graphic, delay);
	
	ObjMove_SetDestAtFrame(fire, pos1, pos2, speed);
	
	let burst=0;
	
	let endX=0;
	let endY=0;
	
	while(!Obj_IsDeleted(fire)){
	
		burst++;
		
		endX = ObjMove_GetX(fire);
		endY = ObjMove_GetY(fire);
		
		if(burst==delay1){
			Obj_Delete(fire);
			CHINK;
			}
			
		yield;
		}
		
	let angle1 = angle;
	
	loop(3){
		
	loop(num){
		angle1+=360/num;
		let obj60 = CreateShotA1(endX, endY, rate, angle1, graphic1, 10);
		ObjMove_SetAngularVelocity(obj60, angvel);
		
		if(ObjMove_GetX(obj60)<=0){
			Obj_Delete(obj60);
			}
		if(ObjMove_GetX(obj60)>=GetStgFrameWidth){
			Obj_Delete(obj60);
			}
		if(ObjMove_GetY(obj60)>=GetStgFrameHeight){
			Obj_Delete(obj60);
			}
		if(ObjMove_GetY(obj60)<=0){
			Obj_Delete(obj60);
			}
		}
		
	loop(60){
		yield
		}
		}
		
	}