#include"./JunkoSkeleton.txt"
let Declare = true;
let Type = "PURE";

let CLICK = 0;
let Value = 1.2;
let GRAPHIC = DS_BALL_BS_RED;
let M = 1.5;
let A2 = 0;
let angle3 = 0;
@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5200*2.1)
	}
	
	case(EV_REQUEST_TIMER) { SetScriptResult(70); }
}

@MainLoop{
	
	if(ObjMove_GetSpeed(objBoss)<=0){
		ObjSprite2D_SetSourceRect(objBoss, 0, 0, 128, 128);
		}
	
	if(animation==0){
		ObjMove_SetDestAtFrame(objBoss, GetStgFrameWidth/2, 110, 100);
		///Wings;
		}
	animation++;
	
	
	if(animation==10){
		///BossCut(objBoss, "Land Cleaving Fire Sword \"Teraflare\"", "./Okina_Stand.png");
		
		let Oki_Stand = GetCurrentScriptDirectory~"Yukari_Stand.png";
		let Oki_Stand2 = GetCurrentScriptDirectory~"Junko_Stand.png";
		ObjCutin_SetSpellcardS4("Babylonia Duality \"Wildflowers of Kur\"", Oki_Stand, AYA, 255, 100, 100);
		ObjCutin_LaunchS3(BYAKUREN, Oki_Stand2, "NAZRIN");
		
		
		//ObjMove_SetDestAtFrame(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2, 70);
		angle = 270;
		}
		
	if(animation==60){
		let Oki_Stand = GetCurrentScriptDirectory~"Yukari_Stand.png";
		///ObjCutin_LaunchS3(NAZRIN, Oki_Stand, "NAZRIN");
		}
	
	if(animation>=120){
		frame++;
		shot++;
		shot2++;
		
		if(FreuMove==false){
			ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32);
			}
		
		if(ObjEnemy_GetInfo(objBoss, INFO_LIFE)<=0){
			Die(objBoss);
			}
			
		if(shot==1){
			//Concentration_True(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), rand(0, 360), 5, 60, 5, 1, -4, 40, objBoss);
			Concentration_True(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), rand(0, 360), 5, 60, 2, 3, -4, 40, objBoss);
			//Concentration_True(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), rand(0, 360), 5, 120, 2, 5, 4, 40, objBoss);
			Concentration_True(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), rand(0, 360), 5, 120, 4, 2, 4, 40, objBoss);
			PlaySoundA1(4, 100, 1);
			
			}
		
		if(frame==90){
			let num = 6;
			let angle = rand(0, 360);
			PlaySoundA1(23, 100, 1);
			loop(num){
				JunFlower(angle, 2*s, DS_BALL_L_BLUE);
				angle+=360/num;
				}
				
			allow++;
			s*=-1;
			
			if(allow<=3){
				frame-=20;
				}
				
			else{
				allow=0;
				}
			}
			
		if(frame==160){
			Switch(1);
			MoveBoss(objBoss, 40, 100);
			}
			
		if(frame==200){
			let num = 5;
			let angle = GetAngleToPlayer(objBoss);
			PlaySoundA1(21, 100, 1);
			loop(num){
				YuFlower(angle, 0.9*s, DS_BALL_L_RED);
				angle+=360/num;
				}
			
			allow++;
			
			if(allow<=1){
				s*=-1;
				frame-=29;
				}
				
			else{
				allow=0;
				}
			}
			
		if(frame==280){
			Switch(2);
			MoveBoss(objBoss, 60, 80);
			frame=-60;
			}
			
				
		
			
		}
	yield;
	}
	
task Die1(tobj){
	loop(1){
		DeleteShotAll(TYPE_ALL, TYPE_FADE);
		}
	Obj_Delete(tobj);
	
	loop(100){
		yield;
		}
	
	CloseScript(GetOwnScriptID());
	}	
	
	
task MoveBoss(tobj, mod, time){
	let posX = GetPlayerX+rand(-20, 20);
	let posY = rand(80, 120);
			
	if(posX<=GetStgFrameWidth/6){
		posX=(GetStgFrameWidth/6)+20;
		}
			
	if(posX>=GetStgFrameWidth/6*5){
		posX=(GetStgFrameWidth/6*5)-20;
		}
				
	if(posY>=110){
		posY-=mod*2.1;
		}
				
	if(posY<=80){
		posY+=mod*2.1;
		}
		
	if(posX>ObjMove_GetX(objBoss)){
		ObjSprite2D_SetSourceRect(objBoss, 128*2, 128*3, 128*3, 128*4);
		//AuraMoveRight=true;
		}
		
	if(posX<ObjMove_GetX(objBoss)){
		ObjSprite2D_SetSourceRect(objBoss, 128*2, 128, 128*3, 128*2);
		//AuraMoveLeft=true;
		}
			
	ObjMove_SetDestAtFrame(tobj, posX, posY, time);
	
	}
	
task Switch(id){
	if(id==1){
		let imgExRumia = GetCurrentScriptDirectory ~ "dot_yukari.png"; //file path to enemy image

		ObjPrim_SetTexture(objBoss, imgExRumia); //Setting the above image file as a texture to the enemy object(objBoss)

		ObjSprite2D_SetSourceRect(objBoss, 0, 0, 128, 128); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

		ObjSprite2D_SetDestCenter(objBoss);
		}
		
	if(id==2){
		let imgExRumia = GetCurrentScriptDirectory ~ "dot_junko.png"; //file path to enemy image

		ObjPrim_SetTexture(objBoss, imgExRumia); //Setting the above image file as a texture to the enemy object(objBoss)

		ObjSprite2D_SetSourceRect(objBoss, 0, 0, 128, 128); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

		ObjSprite2D_SetDestCenter(objBoss);
		}
	
	PlaySoundA1(31, 100, 1);
	}
	
task JunFlower(Angle, Turn, Graphic){
	let obj = CreateShotA1(GetPlayerX(), GetPlayerY(), 6, Angle, Graphic, 0);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj, 0);
	let Alpha = 0;
	ObjShot_SetIntersectionEnable(obj, false);
	ObjMove_SetAngularVelocity(obj, Turn);
	ObjMove_SetAcceleration(obj, -6/60);
	ObjMove_SetMaxSpeed(obj, 0);
	let V=  0;
	while(!Obj_IsDeleted(obj)){
		
		if(Alpha<=150){
			Alpha+=150/60;
			ObjRender_SetAlpha(obj, Alpha);
			}
		if(ObjMove_GetSpeed(obj)<=0&&V==0){
			V=1;
			
			let num = 6;
			let num1 = 1;
			let angle = Angle;
			loop(num){
				let mod = 0;
				
				loop(num1){
					let obj1 = CreateShotA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, angle+mod, DS_BALL_S_BLUE, 30);
					ObjMove_SetAcceleration(obj1, 0.5/30);
					ObjMove_SetMaxSpeed(obj1, 0.5);
					mod+=3;
					}
					
				angle+=360/num;
				}
				
			loop(15){
				yield;
				}
				
			Obj_Delete(obj);
			}
		yield;
		}
	}
	
task YuFlower(Angle, Turn, Graphic){
	let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 6, Angle, Graphic, 0);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj, 0);
	let Alpha = 0;
	ObjShot_SetIntersectionEnable(obj, false);
	ObjMove_SetAngularVelocity(obj, Turn);
	ObjMove_SetAcceleration(obj, -6/30);
	ObjMove_SetMaxSpeed(obj, 0);
	
	loop(30){
		Alpha+=150/30;
			ObjRender_SetAlpha(obj, Alpha);
	yield;}
	
	ObjMove_SetAcceleration(obj, 6/80);
	ObjMove_SetMaxSpeed(obj, 6);
	let frame = 0;
	let angle = Angle+180;
	while(!Obj_IsDeleted(obj)){
		frame++;
		if(frame==2){
			let num = 2;
			
			loop(num){
				let obj1 = CreateShotA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 0, angle, DS_ICE_RED, 10);
				ObjMove_SetAcceleration(obj1, 0.9/120);
				ObjMove_SetMaxSpeed(obj1, 0.9);
				angle+=360/num;
				}
			angle-=Turn*3;
			frame-=5;
			}
			
		yield;
		}
		
	}
	
	