//#include"script/default_system/Default_ShotConst.txt"
#include".\Resources.txt"
#include".\GizmoSpriteLibrary.txt"
#include".\shot\AllStarShot_Const.txt"
let shou;
let kaguya;
let TIME = 99;
let shouX = 0;
let shouY = 0;
let kaguyaX = 0;
let kaguyaY = 0;

@Event
{
	SetTimer(TIME);
    SetLife(471);
    SetScore(10000000);	
}

@Initialize
{
	DeleteShotAll(TYPE_ALL, TYPE_ITEM); 
	SetAutoDeleteObject(true);
	let objScene = GetEnemyBossSceneObjectID();
	ObjEnemyBossScene_StartSpell(objScene);
	
	shou = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	kaguya = ObjEnemy_Create(OBJ_ENEMY);
	
	ObjEnemy_Regist(shou);
	ObjEnemy_Regist(kaguya);
	
	ObjMove_SetPosition(shou,GetCommonData("ShouX",0),GetCommonData("ShouY",0));
	ObjMove_SetPosition(kaguya,GetCommonData("KaguyaX",0),GetCommonData("KaguyaY",0));
	let cx = GetStgFrameWidth() / 3;
	
	renderShouUFO(shou);
	renderKaguyaIN(kaguya);
	
	
	//ObjMove_SetDestAtFrame(shou, cx, 100, 60);
	//ObjMove_SetDestAtFrame(kaguya, GetStgFrameWidth()-cx, 100, 60);
	
	
	ObjEnemy_SetLife(kaguya, 471);
	BossManage;
	TMain();
	
	wait(60);
	
	Obj_SetValue(kaguya,"cast",1);
	if(GetCommonData("Difficulty",1) == 1){FireE; spellCast("Sacred Mirror: \"Reflection Of Yata no Kagami\"");}
	else if(GetCommonData("Difficulty",1) == 2){FireN; spellCast("wait... \"Isn't That Watatsuki no Yorihime's Mirror?\"");}
	else if(GetCommonData("Difficulty",1) == 3){FireH; spellCast("Mirroring Mirror: \"Mirrored Mirror Mirrors Mirrors\"");}
	else if(GetCommonData("Difficulty",1) == 4){FireL; spellCast("I'm Sorry: \"This Spell Isn't Refined And Is A              
	Clusterfuck Of Bullets And Ideas Cause I                   
	Procrastinated. Also Sorry For The Long Spell Name\"");}
	wait(60);
	Border();
}

@MainLoop
{

	yield;
}

task TMain(){
	ObjEnemy_SetDamageRate(shou,0,0);
	ObjEnemy_SetDamageRate(kaguya,0,0);
	let bossHP = 471*2;
	loop(120){
		bossHP-=471*2/120;
		SetCommonData("BossHealth",bossHP);
		yield;
	}
	ObjEnemy_SetDamageRate(shou,4,100);
	ObjEnemy_SetDamageRate(kaguya,4,100);
	loop{
		if(ObjEnemy_GetInfo(kaguya, INFO_LIFE) < ObjEnemy_GetInfo(shou, INFO_LIFE)){ObjEnemy_SetLife(shou, ObjEnemy_GetInfo(kaguya, INFO_LIFE));}
		else if(ObjEnemy_GetInfo(kaguya, INFO_LIFE) > ObjEnemy_GetInfo(shou, INFO_LIFE)){ObjEnemy_SetLife(kaguya, ObjEnemy_GetInfo(shou, INFO_LIFE));}
		SetCommonData("BossHealth",471-ObjEnemy_GetInfo(shou,INFO_LIFE));
	yield;}	
}

task BossManage{

	while(ObjEnemy_GetInfo(shou,INFO_LIFE)>0){
        shouX = ObjMove_GetX(shou);
        shouY = ObjMove_GetY(shou);
		kaguyaX = ObjMove_GetX(kaguya);
		kaguyaY = ObjMove_GetY(kaguya);
		
		ObjEnemy_SetIntersectionCircleToShot(shou, shouX, shouY, 40);
        ObjEnemy_SetIntersectionCircleToPlayer(shou, shouX, shouY, 30);
		ObjEnemy_SetIntersectionCircleToShot(kaguya, kaguyaX, kaguyaY, 40);
        ObjEnemy_SetIntersectionCircleToPlayer(kaguya, kaguyaX, kaguyaY, 30);
		yield;
	}
	SetCommonData("ShouX",ObjMove_GetX(shou));
	SetCommonData("ShouY",ObjMove_GetY(shou));
	
	SetCommonData("KaguyaX",ObjMove_GetX(kaguya));
	SetCommonData("KaguyaY",ObjMove_GetY(kaguya));
	
	Obj_Delete(shou);
	Obj_Delete(kaguya);
	
	DeleteShotAll(TYPE_ALL, TYPE_FADE);
	SetCommonData("LifebarsRemaining",GetCommonData("LifebarsRemaining",0)-1);
	SetCommonData("SpellsRemaining", GetCommonData("SpellsRemaining", 0)-1);
    CloseScript(GetOwnScriptID()); 
}

task spellCast(name){
	let objText = ObjText_Create();
			Obj_SetRenderPriorityI(objText, 80);
			ObjText_SetFontType(objText, "8bitoperator JVE");
			ObjText_SetFontSize(objText, 16);
			ObjText_SetFontBorderType(objText, BORDER_FULL);
			ObjText_SetFontBorderWidth(objText, 3);
			ObjText_SetFontBorderColor(objText, 0,0,0);
			ObjText_SetFontColorTop(objText, 255,255,255);
			ObjText_SetFontColorBottom(objText, 255,255,255);
			ObjText_SetMaxWidth(objText, 500);
			ObjRender_SetPosition(objText,GetStgFrameWidth/2-237,300,0);
			ObjText_SetText(objText, name);
			wait(60);
			let y = 300;
			let dist = 260/60;
			loop(60){
				ObjRender_SetPosition(objText,GetStgFrameWidth/2-237,y,0);
				y-= dist;
				yield;
			}
			ObjRender_SetPosition(objText,GetStgFrameWidth/2-237,40,0);
}

task Border(){
	let path1 = GetCurrentScriptDirectory() ~ "img/SpecGradiant.png";
	let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj1, BLEND_ADD_ARGB);
	Obj_SetRenderPriority(obj1, 0.61);
	ObjPrim_SetTexture(obj1, path1);
	ObjSprite2D_SetDestRect(obj1, 0, 0, 640, 480);
	//ObjSprite2D_SetDestCenter(obj1);
	ObjRender_SetScaleXYZ(obj1, 1, 1, 0);

	ObjSprite2D_SetSourceRect(obj1, 0, 0, 640, 480);
}
//Lunatic
task FireL(){
	wait(60);
	wait(60);
			wait(60);
	let random1 = rand(1,4);
	random1 -= random1%1;
	
	let random2 = rand(1,4);
	random2 -= random2%1;
	while(random2 == random1){random2 = rand(1,4); random2 -= random2%1; yield;}
	
	let random3 = 3;
	while(random3 == random1 || random3 == random2){random3--; }
	let pat1 = random1;
	let pat2 = random2;
	let pat3 = random3;
	
	random1 = rand(1,4);
	random1 -= random1%1;
	random2 = rand(1,4);
	random2 -= random2%1;
	while(random2 == random1){random2 = rand(1,4); random2 -= random2%1; yield;}
	random3 = 3;
	while(random3 == random1 || random3 == random2){random3--; }
	let delay = 60*10;
	KFireL(1);
		
	loop{
		SFireL(pat1);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*8;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*6;
		}
		
		SFireL(pat2);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*8;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*6;
		}

		SFireL(pat3);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*8;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*6;
		}

	}

	
}

//Hard
task FireH(){
	wait(60);
			wait(60);
	let random1 = rand(1,4);
	random1 -= random1%1;
	
	let random2 = rand(1,4);
	random2 -= random2%1;
	while(random2 == random1){random2 = rand(1,4); random2 -= random2%1; yield;}
	
	let random3 = 3;
	while(random3 == random1 || random3 == random2){random3--; }
	let pat1 = random1;
	let pat2 = random2;
	let pat3 = random3;
	
	random1 = rand(1,4);
	random1 -= random1%1;
	random2 = rand(1,4);
	random2 -= random2%1;
	while(random2 == random1){random2 = rand(1,4); random2 -= random2%1; yield;}
	random3 = 3;
	while(random3 == random1 || random3 == random2){random3--; }
	let delay = 60*5;
	loop{
		SFireH(pat1);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireH(random1);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		SFireH(pat2);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireH(random2);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		SFireH(pat3);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireH(random3);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		
	}
}

//Normal
task FireN(){
		wait(60);
	let random1 = rand(1,4);
	random1 -= random1%1;
	
	let random2 = rand(1,4);
	random2 -= random2%1;
	while(random2 == random1){random2 = rand(1,4); random2 -= random2%1; yield;}
	
	let random3 = 3;
	while(random3 == random1 || random3 == random2){random3--; }
	let pat1 = random1;
	let pat2 = random2;
	let pat3 = random3;
	
	random1 = rand(1,4);
	random1 -= random1%1;
	random2 = rand(1,4);
	random2 -= random2%1;
	while(random2 == random1){random2 = rand(1,4); random2 -= random2%1; yield;}
	random3 = 3;
	while(random3 == random1 || random3 == random2){random3--; }

	let delay = 60*5;
	loop{
		SFireN(pat1);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireN(random1);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		SFireN(pat2);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireN(random2);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		SFireN(pat3);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireN(random3);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		
	}

}

//Easy
task FireE(){
	wait(60);
	let random1 = rand(1,4);
	random1 -= random1%1;
	
	let random2 = rand(1,4);
	random2 -= random2%1;
	while(random2 == random1){random2 = rand(1,4); random2 -= random2%1; yield;}
	
	let random3 = 3;
	while(random3 == random1 || random3 == random2){random3--; }
	let pat1 = random1;
	let pat2 = random2;
	let pat3 = random3;
	
	random1 = rand(1,4);
	random1 -= random1%1;
	random2 = rand(1,4);
	random2 -= random2%1;
	while(random2 == random1){random2 = rand(1,4); random2 -= random2%1; yield;}
	random3 = 3;
	while(random3 == random1 || random3 == random2){random3--; }
	let delay = 60*5;
	loop{
		SFireE(pat1);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireE(random1);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		SFireE(pat2);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireE(random2);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		SFireE(pat3);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		KFireE(random3);
		wait(delay);
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)*2){
			delay = 60*4;
		}
		if(ObjEnemy_GetInfo(shou,INFO_LIFE) < (471/3)){
			delay = 60*3;
		}
		
	}

}

task KFireL(num){
	wait(60);
	ObjMove_SetDestAtFrame(kaguya, GetStgFrameWidth/2, GetStgFrameHeight/2, 60);
	wait(60);
	num = 1;
	if(num ==1){
		
		loop(4){
			let angle = rand(0, 360);
			loop(9){
				let shot = CreateShotOA1(kaguya, 3, angle, rand(35, 48), 5);
				let shot2 = CreateShotOA1(kaguya, 3, angle, rand(35, 48), 5);
				ObjMove_SetAcceleration(shot, -0.1);
				ObjMove_SetMaxSpeed(shot, 0);
				ObjMove_SetAcceleration(shot2, -0.1);
				ObjMove_SetMaxSpeed(shot2, 0);
				moveShot(shot, 1);
				moveShot(shot2, -1);
				Reflect(shot, num);
				Reflect(shot2, num);
				angle += 360/9;
			}
			angle += rand(-2, 2);
			wait(10);
		}
	}
	task moveShot(shot, n){
		while(!Obj_IsDeleted(shot)){
			if(ObjMove_GetSpeed(shot) <= 0){
				ObjMove_SetAngularVelocity(shot, 1*n);
				ObjMove_SetAcceleration(shot, 0.01);
				ObjMove_SetMaxSpeed(shot, 2);
				wait(90);
				ObjMove_SetAngularVelocity(shot, 0);
				break;
			}
			yield;
		}
		
	}

	task Reflect(obj, Id){
    let GetClipMaxX = GetStgFrameWidth();
    let GetClipMaxY = GetStgFrameHeight();
    let value = 1;
    while(!Obj_IsDeleted(obj))
    {
        if(value>0){
            if(ObjMove_GetX(obj)<0||ObjMove_GetX(obj)>GetClipMaxX)
            {
				if(Id ==1){
					if(ObjMove_GetX(obj)>GetClipMaxX){
					ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, -0.02, NO_CHANGE, -1.5, 0);
					}else{
						ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, 0.02, NO_CHANGE, 1.5, 0);
					}
					ObjMove_SetAngle(obj,180-ObjMove_GetAngle(obj));
				}
            }
            if(ObjMove_GetY(obj)<0|| ObjMove_GetY(obj)>484)
            {
				if(Id ==1){
					if(ObjMove_GetY(obj)>484){
					ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, NO_CHANGE, -0.02, 0, -1.5);
					} else{
						ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, NO_CHANGE, 0.02, 0, 1.5);
					}
					ObjMove_SetAngle(obj,-ObjMove_GetAngle(obj));
				}
            }
        }
        if(value==0){break;}
        yield;
	}
}
	
	
	
}

task KFireH(num){
wait(60);
	ObjMove_SetDestAtFrame(kaguya, rand(GetStgFrameWidth/5, GetStgFrameWidth - GetStgFrameWidth/5), rand(100, 250), 60);
	wait(60);
	num = 1;
	if(num ==1){
		
		loop(4){
			let angle = rand(0, 360);
			loop(9){
				let shot = CreateShotOA1(kaguya, 3, angle, rand(35, 48), 5);
				let shot2 = CreateShotOA1(kaguya, 3, angle, rand(35, 48), 5);
				ObjMove_SetAcceleration(shot, -0.1);
				ObjMove_SetMaxSpeed(shot, 0);
				ObjMove_SetAcceleration(shot2, -0.1);
				ObjMove_SetMaxSpeed(shot2, 0);
				moveShot(shot, 1);
				moveShot(shot2, -1);
				Reflect(shot, num);
				Reflect(shot2, num);
				angle += 360/9;
			}
			angle += rand(-2, 2);
			wait(10);
		}
	}
	task moveShot(shot, n){
		while(!Obj_IsDeleted(shot)){
			if(ObjMove_GetSpeed(shot) <= 0){
				ObjMove_SetAngularVelocity(shot, 1*n);
				ObjMove_SetAcceleration(shot, 0.01);
				ObjMove_SetMaxSpeed(shot, 2);
				wait(90);
				ObjMove_SetAngularVelocity(shot, 0);
				break;
			}
			yield;
		}
		
	}

	task Reflect(obj, Id){
    let GetClipMaxX = GetStgFrameWidth();
    let GetClipMaxY = GetStgFrameHeight();
    let value = 1;
    while(!Obj_IsDeleted(obj))
    {
        if(value>0){
            if(ObjMove_GetX(obj)<0||ObjMove_GetX(obj)>GetClipMaxX)
            {
				if(Id ==1){
					if(ObjMove_GetX(obj)>GetClipMaxX){
					ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, -0.02, NO_CHANGE, -1, 0);
					}else{
						ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, 0.02, NO_CHANGE, 1, 0);
					}
					ObjMove_SetAngle(obj,180-ObjMove_GetAngle(obj));
					value--;
				}
            }
            if(ObjMove_GetY(obj)<0|| ObjMove_GetY(obj)>484)
            {
				if(Id ==1){
					if(ObjMove_GetY(obj)>484){
					ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, NO_CHANGE, -0.02, 0, -1);
					} else{
						ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, NO_CHANGE, 0.02, 0, 1);
					}
					ObjMove_SetAngle(obj,-ObjMove_GetAngle(obj));
					value--;
				}
            }
        }
        if(value==0){break;}
        yield;
	}
}
	
	
	
}

task KFireN(num){
wait(60);
	ObjMove_SetDestAtFrame(kaguya, rand(GetStgFrameWidth/5, GetStgFrameWidth - GetStgFrameWidth/5), rand(100, 250), 60);
	wait(60);
	num = 1;
	if(num ==1){
		
		loop(3){
			let angle = rand(0, 360);
			loop(9){
				let shot = CreateShotOA1(kaguya, 3, angle, rand(35, 48), 5);
				let shot2 = CreateShotOA1(kaguya, 3, angle, rand(35, 48), 5);
				ObjMove_SetAcceleration(shot, -0.1);
				ObjMove_SetMaxSpeed(shot, 0);
				ObjMove_SetAcceleration(shot2, -0.1);
				ObjMove_SetMaxSpeed(shot2, 0);
				moveShot(shot, 1);
				moveShot(shot2, -1);
				Reflect(shot, num);
				Reflect(shot2, num);
				angle += 360/9;
			}
			angle += rand(-2, 2);
			wait(10);
		}
	}
	task moveShot(shot, n){
		while(!Obj_IsDeleted(shot)){
			if(ObjMove_GetSpeed(shot) <= 0){
				ObjMove_SetAngularVelocity(shot, 1*n);
				ObjMove_SetAcceleration(shot, 0.01);
				ObjMove_SetMaxSpeed(shot, 2);
				wait(90);
				ObjMove_SetAngularVelocity(shot, 0);
				break;
			}
			yield;
		}
		
	}

	task Reflect(obj, Id){
    let GetClipMaxX = GetStgFrameWidth();
    let GetClipMaxY = GetStgFrameHeight();
    let value = 1;
    while(!Obj_IsDeleted(obj))
    {
        if(value>0){
            if(ObjMove_GetX(obj)<0||ObjMove_GetX(obj)>GetClipMaxX)
            {
				if(Id ==1){
					if(ObjMove_GetX(obj)>GetClipMaxX){
					ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, -0.02, NO_CHANGE, -1, 0);
					}else{
						ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, 0.02, NO_CHANGE, 1, 0);
					}
					ObjMove_SetAngle(obj,180-ObjMove_GetAngle(obj));
					value--;
				}
            }
            if(ObjMove_GetY(obj)<0|| ObjMove_GetY(obj)>484)
            {
				if(Id ==1){
					if(ObjMove_GetY(obj)>484){
					ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, NO_CHANGE, -0.02, 0, -1);
					} else{
						ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, NO_CHANGE, 0.02, 0, 1);
					}
					ObjMove_SetAngle(obj,-ObjMove_GetAngle(obj));
					value--;
				}
            }
        }
        if(value==0){break;}
        yield;
	}
}
	
	
	
}

task KFireE(num){
wait(60);
	ObjMove_SetDestAtFrame(kaguya, rand(GetStgFrameWidth/5, GetStgFrameWidth - GetStgFrameWidth/5), rand(100, 250), 60);
	wait(60);
	num = 1;
	if(num ==1){
		let angle = rand(0, 360);
		loop(3){
			
			loop(9){
				let shot = CreateShotOA1(kaguya, 3, angle, rand(35, 48), 5);
				let shot2 = CreateShotOA1(kaguya, 3, angle, rand(35, 48), 5);
				ObjMove_SetAcceleration(shot, -0.1);
				ObjMove_SetMaxSpeed(shot, 0);
				ObjMove_SetAcceleration(shot2, -0.1);
				ObjMove_SetMaxSpeed(shot2, 0);
				moveShot(shot, 1);
				moveShot(shot2, -1);
				Reflect(shot, num);
				Reflect(shot2, num);
				angle += 360/9;
			}
			angle += rand(-2, 2);
			wait(10);
		}
	}
	task moveShot(shot, n){
		while(!Obj_IsDeleted(shot)){
			if(ObjMove_GetSpeed(shot) <= 0){
				ObjMove_SetAngularVelocity(shot, 1*n);
				ObjMove_SetAcceleration(shot, 0.01);
				ObjMove_SetMaxSpeed(shot, 2);
				wait(90);
				ObjMove_SetAngularVelocity(shot, 0);
				break;
			}
			yield;
		}
		
	}

	task Reflect(obj, Id){
    let GetClipMaxX = GetStgFrameWidth();
    let GetClipMaxY = GetStgFrameHeight();
    let value = 1;
    while(!Obj_IsDeleted(obj))
    {
        if(value>0){
            if(ObjMove_GetX(obj)<0||ObjMove_GetX(obj)>GetClipMaxX)
            {
				if(Id ==1){
					if(ObjMove_GetX(obj)>GetClipMaxX){
					ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, -0.02, NO_CHANGE, -1, 0);
					}else{
						ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, 0.02, NO_CHANGE, 1, 0);
					}
					ObjMove_SetAngle(obj,180-ObjMove_GetAngle(obj));
					value--;
				}
            }
            if(ObjMove_GetY(obj)<0|| ObjMove_GetY(obj)>484)
            {
				if(Id ==1){
					if(ObjMove_GetY(obj)>484){
					ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, NO_CHANGE, -0.02, 0, -1);
					} else{
						ObjMove_AddPatternB2(obj, 3, NO_CHANGE, NO_CHANGE, NO_CHANGE, 0.02, 0, 1);
					}
					ObjMove_SetAngle(obj,-ObjMove_GetAngle(obj));
					value--;
				}
            }
        }
        if(value==0){break;}
        yield;
	}
}
	
	
	
}

task SFireL(num){
		wait(60);
	if(num ==1){
	ObjMove_SetDestAtFrame(shou, GetStgFrameWidth/2, GetStgFrameHeight/2, 60);
	} else{
		ObjMove_SetDestAtFrame(shou, rand(GetStgFrameWidth/5, GetStgFrameWidth - GetStgFrameWidth/5), rand(100, 250), 60);
	}
	wait(60);
	if(num == 1){
		let angle = -35;
		loop(2){
			loop(4){
				loop(2){
					let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_RED, 30);
					Reflect(shot, 1);
					angle += 180;
				}
				angle += 70/3;
			}
			angle = -35 + 90;
			wait(120);
		}
	}
	if(num == 2){
		let angle = rand(0, 360);
		loop(4){
			loop(4){
			let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_GREEN, 30);
			Reflect(shot, num);
			angle += 90;
			}
			angle += 20/4;
		}
	}
	if(num == 3){
		let angle = rand(0, 360);
		loop(10){
			let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_YELLOW, 30);
			Reflect(shot, num);
			angle += 360/10;
		}
	}
	
	task moveShot(shot){
		while(!Obj_IsDeleted(shot)){
			if(ObjMove_GetSpeed(shot) <= 0.5){
				ObjMove_SetAngularVelocity(shot, 0);
				ObjMove_SetAcceleration(shot, 0.15);
				ObjMove_SetMaxSpeed(shot, 20);
				break;
			}
			yield;
		}
		
	}
	
	task Reflect(obj, Id){
    let GetClipMaxX = GetStgFrameWidth();
    let GetClipMaxY = GetStgFrameHeight();
    let value = 1;
    while(!Obj_IsDeleted(obj))
    {
        if(value>0){
            if(ObjMove_GetX(obj)<0||ObjMove_GetX(obj)>GetClipMaxX)
            {
				if(Id ==1){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 0, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 180, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id ==2){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 0, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 180, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id == 3){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 0, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 180, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot , FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					
				}
                value--;
            }
            if(ObjMove_GetY(obj)<0|| ObjMove_GetY(obj)>484)
            {
				if(Id == 1){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 25, 90, 200, 30, L_LASER_RED, 60);
						FireShot(shot , FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 270, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id ==2){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 25, 90, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 270, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id == 3){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 25, 90, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),25, 270, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					
				}
                value--
            }
        }
        if(value==0){break;}
        yield;
		
		task FireShot(shot, shot2){
			wait(60);
			let angle = ObjMove_GetAngle(shot);
			while(!Obj_IsDeleted(shot)){
				let fire = CreateShotOA1(shot, 0, angle, shot2, 10);
				ObjRender_SetBlendType(fire, BLEND_ADD_ARGB);
				ObjMove_SetAcceleration(fire, 0.01);
				ObjMove_SetMaxSpeed(fire, 2);
				angle += 15.7;
				wait(1);
			}
		}
		
    }
}

	
}

task SFireH(num){
		wait(60);
	if(num ==1){
	ObjMove_SetDestAtFrame(shou, GetStgFrameWidth/2, GetStgFrameHeight/2, 60);
	} else{
		ObjMove_SetDestAtFrame(shou, rand(GetStgFrameWidth/5, GetStgFrameWidth - GetStgFrameWidth/5), rand(100, 250), 60);
	}
	wait(60);
	if(num == 1){
		let angle = -35;
		loop(8){
			loop(2){
				let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_RED, 30);
				Reflect(shot, 1);
				angle += 180;
			}
			angle += 70/7;
		}
	}
	if(num == 2){
		let angle = rand(0, 360);
		loop(4){
			loop(4){
			let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_GREEN, 30);
			Reflect(shot, num);
			angle += 90;
			}
			angle += 20/4;
		}
	}
	if(num == 3){
		let angle = rand(0, 360);
		loop(10){
			let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_YELLOW, 30);
			Reflect(shot, num);
			angle += 360/10;
		}
	}
	
	task moveShot(shot){
		while(!Obj_IsDeleted(shot)){
			if(ObjMove_GetSpeed(shot) <= 0.5){
				ObjMove_SetAngularVelocity(shot, 0);
				ObjMove_SetAcceleration(shot, 0.15);
				ObjMove_SetMaxSpeed(shot, 20);
				break;
			}
			yield;
		}
		
	}
	
	task Reflect(obj, Id){
    let GetClipMaxX = GetStgFrameWidth();
    let GetClipMaxY = GetStgFrameHeight();
    let value = 1;
    while(!Obj_IsDeleted(obj))
    {
        if(value>0){
            if(ObjMove_GetX(obj)<0||ObjMove_GetX(obj)>GetClipMaxX)
            {
				if(Id ==1){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id ==2){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id == 3){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot , FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					
				}
                value--;
            }
            if(ObjMove_GetY(obj)<0|| ObjMove_GetY(obj)>484)
            {
				if(Id == 1){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_RED, 60);
						FireShot(shot , FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id ==2){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id == 3){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					
				}
                value--
            }
        }
        if(value==0){break;}
        yield;
		
		task FireShot(shot, shot2){
			wait(60);
			let angle = ObjMove_GetAngle(shot);
			while(!Obj_IsDeleted(shot)){
				let fire = CreateShotOA1(shot, 0, angle, shot2, 10);
				ObjRender_SetBlendType(fire, BLEND_ADD_ARGB);
				ObjMove_SetAcceleration(fire, 0.01);
				ObjMove_SetMaxSpeed(fire, 2);
				angle += 15.7;
				wait(1);
			}
		}
		
    }
}
	
}

task SFireN(num){
		wait(60);
	if(num ==1){
	ObjMove_SetDestAtFrame(shou, GetStgFrameWidth/2, GetStgFrameHeight/2, 60);
	} else{
		ObjMove_SetDestAtFrame(shou, rand(GetStgFrameWidth/5, GetStgFrameWidth - GetStgFrameWidth/5), rand(100, 250), 60);
	}
	wait(60);
	if(num == 1){
		let angle = -35;
		loop(6){
			loop(2){
				let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_RED, 30);
				Reflect(shot, 1);
				angle += 180;
			}
			angle += 80/6;
		}
	}
	if(num == 2){
		let angle = rand(0, 360);
		loop(3){
			loop(4){
			let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_GREEN, 30);
			Reflect(shot, num);
			angle += 90;
			}
			angle += 20/3;
		}
	}
	if(num == 3){
		let angle = rand(0, 360);
		loop(8){
			let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_YELLOW, 30);
			Reflect(shot, num);
			angle += 360/8;
		}
	}
	
	task moveShot(shot){
		while(!Obj_IsDeleted(shot)){
			if(ObjMove_GetSpeed(shot) <= 0.5){
				ObjMove_SetAngularVelocity(shot, 0);
				ObjMove_SetAcceleration(shot, 0.15);
				ObjMove_SetMaxSpeed(shot, 20);
				break;
			}
			yield;
		}
		
	}
	
	task Reflect(obj, Id){
    let GetClipMaxX = GetStgFrameWidth();
    let GetClipMaxY = GetStgFrameHeight();
    let value = 1;
    while(!Obj_IsDeleted(obj))
    {
        if(value>0){
            if(ObjMove_GetX(obj)<0||ObjMove_GetX(obj)>GetClipMaxX)
            {
				if(Id ==1){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id ==2){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id == 3){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot , FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					
				}
                value--;
            }
            if(ObjMove_GetY(obj)<0|| ObjMove_GetY(obj)>484)
            {
				if(Id == 1){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_RED, 60);
						FireShot(shot , FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id ==2){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id == 3){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					
				}
                value--
            }
        }
        if(value==0){break;}
        yield;
		
		task FireShot(shot, shot2){
			wait(60);
			let angle = ObjMove_GetAngle(shot);
			while(!Obj_IsDeleted(shot)){
				let fire = CreateShotOA1(shot, 0, angle, shot2, 10);
				ObjRender_SetBlendType(fire, BLEND_ADD_ARGB);
				ObjMove_SetAcceleration(fire, 0.01);
				ObjMove_SetMaxSpeed(fire, 2);
				angle += 15.7;
				wait(1);
			}
		}
		
    }
}
	
}

task SFireE(num){
	wait(60);
	if(num ==1){
	ObjMove_SetDestAtFrame(shou, GetStgFrameWidth/2, GetStgFrameHeight/2, 60);
	} else{
		ObjMove_SetDestAtFrame(shou, rand(GetStgFrameWidth/5, GetStgFrameWidth - GetStgFrameWidth/5), rand(100, 250), 60);
	}
	wait(60);
	if(num == 1){
		let angle = -35;
		loop(5){
			loop(2){
				let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_RED, 30);
				Reflect(shot, 1);
				angle += 180;
			}
			angle += 80/5;
		}
	}
	if(num == 2){
		let angle = rand(0, 360);
		loop(2){
			loop(4){
			let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_GREEN, 30);
			Reflect(shot, 2);
			angle += 90;
			}
			angle += 10;
		}
	}
	if(num == 3){
		let angle = rand(0, 360);
		loop(6){
			let shot = CreateShotA2(shouX, shouY, 2.5, angle, 0.05, 10, LARGE_YELLOW, 30);
			Reflect(shot, num);
			angle += 360/6;
		}
	}
	
	task moveShot(shot){
		while(!Obj_IsDeleted(shot)){
			if(ObjMove_GetSpeed(shot) <= 0.5){
				ObjMove_SetAngularVelocity(shot, 0);
				ObjMove_SetAcceleration(shot, 0.15);
				ObjMove_SetMaxSpeed(shot, 20);
				break;
			}
			yield;
		}
		
	}
	
	task Reflect(obj, Id){
    let GetClipMaxX = GetStgFrameWidth();
    let GetClipMaxY = GetStgFrameHeight();
    let value = 1;
    while(!Obj_IsDeleted(obj))
    {
        if(value>0){
            if(ObjMove_GetX(obj)<0||ObjMove_GetX(obj)>GetClipMaxX)
            {
				if(Id ==1){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id ==2){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id == 3){
					if(ObjMove_GetX(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 0, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 180, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 180, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot , FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					
				}
                value--;
            }
            if(ObjMove_GetY(obj)<0|| ObjMove_GetY(obj)>484)
            {
				if(Id == 1){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_RED, 60);
						FireShot(shot , FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_RED, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_RED, 60);
						FireShot(shot, FIRE_RED);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id ==2){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_GREEN, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_GREEN, 60);
						FireShot(shot, FIRE_GREEN);
						wait(60);
						Obj_Delete(temp);
					}
				}
				if(Id == 3){
					if(ObjMove_GetY(obj)<0){
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 90, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 30, 90, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					else{
						let temp = CreateStraightLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 270, GetStgFrameWidth+10, 30, 60, ST_LASER_YELLOW, 60);
						let shot = CreateLooseLaserA1(ObjMove_GetX(obj), ObjMove_GetY(obj),30, 270, 200, 30, L_LASER_YELLOW, 60);
						FireShot(shot, FIRE_YELLOW);
						wait(60);
						Obj_Delete(temp);
					}
					
				}
                value--
            }
        }
        if(value==0){break;}
        yield;
		
		task FireShot(shot, shot2){
			wait(60);
			let angle = ObjMove_GetAngle(shot);
			while(!Obj_IsDeleted(shot)){
				let fire = CreateShotOA1(shot, 0, angle, shot2, 10);
				ObjRender_SetBlendType(fire, BLEND_ADD_ARGB);
				ObjMove_SetAcceleration(fire, 0.01);
				ObjMove_SetMaxSpeed(fire, 2);
				angle += 15.7*2;
				wait(1);
			}
		}
		
    }
}
	
}



