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

let CLICK = 0;
let Value = 1.5;
let GRAPHIC = DS_BALL_BS_RED;
let M = 1.5;
let A2 = 0;
let TURNER = rand(0, 100);
let angle3 = 90;
@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5200*1.9)
	}
	
	case(EV_REQUEST_TIMER) { SetScriptResult(50); }
}

@MainLoop{
	
	if(ObjMove_GetSpeed(objBoss)<=0){
		ObjSprite2D_SetSourceRect(objBoss, 0, 0, 128, 128);
		}
	
	if(animation==0){
		ObjMove_SetDestAtFrame(objBoss, GetStgFrameWidth/2, 110, 100);
		}
	animation++;
	
	
	if(animation==10){
		///BossCut(objBoss, "Traditionalism \"Drawing Reality By Hand\"", "./Okina_Stand.png");
		
		let Oki_Stand = GetCurrentScriptDirectory~"Okina_Stand.png";
		ObjCutin_SetSpellcardS4("Android Familiar \"Plasma Neurodiversion Field\"", Oki_Stand, AYA, 255, 100, 100);
		//ObjCutin_LaunchS3(KANAKO, Oki_Stand, "Normal");
		//ObjMove_SetDestAtFrame(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2, 70);
		}
	
	if(animation>=120){
		frame++;
		shot++;
		
		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(TURNER>=50){
				s=1;
				angle3-=45;
				}
				
			else{
				s=-1;
				angle3+=45;
				}
			}
			
		
		if(frame==90){
			let num = 2;
			let m = -1;
			let graphic = DS_BALL_S_BLUE;
			loop(num){
				if(m==1){
					graphic = DS_BALL_S_RED;
					}
				Wheel(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 0.5, angle, graphic, 0.3*m);
				angle+=360/num;
				m*=-1;
				}
				
			PlaySoundA1(21, 50, 1);
				
			angle+=21*s;
			
			allow++;
			
			if(allow<25){
				frame-=6;
				}
			
			else{
				s*=-1;
				allow=0;
				
				}
			}
			
		if(frame==95){
			Switch(1);
			}
			
		if(frame==100){
			MoveBoss(objBoss, 80, 120);
			}
			
		if(frame==110){
			let num = 3;
			let angle1 = angle + GetAngleToPlayer(objBoss);
			loop(num){
				let obj1 = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1.5, angle, DS_KUNAI_GREEN, 10);
				///let obj2 = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1.9, angle, DS_KUNAI_PURPLE, 10);
				let obj3 = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2.3, angle, DS_KUNAI_GREEN, 10);
				
				angle+=360/num;
				}
				
			angle+=6*s;
			
			allow++;
			
			if(allow<=40){
				frame-=3;
				}
				
			else{
				allow=0;
				angle = 0;
				
				}
				
			}
			
		if(frame==150){
			Switch(2);
			frame=0;
			}	
			
			
		}
	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 Wheel(X, Y, Speed, Angle, Graphic, M){
	let obj = CreateShotA1(X, Y, 4, Angle, Graphic, 0);
	ObjMove_SetAcceleration(obj, -(4-Speed)/20);
	ObjMove_SetMaxSpeed(obj, Speed);
	ObjRender_SetAlpha(obj, 0);
	ObjShot_SetIntersectionEnable(obj, false);
	ObjShot_SetAutoDelete(obj,false);
	let num = 7;
	let dist = 80;
	loop(num){
		let obj1 = CreateShotA1(ObjMove_GetX(obj)+dist*cos(Angle), ObjMove_GetY(obj)+dist*sin(Angle), 0, 0, Graphic, 0);
		Spinner(obj, obj1, M, dist, Angle);
		//ObjRender_SetBlendType(obj1, BLEND_ADD_ARGB);
		ObjShot_SetSpellResist(obj1, true);
		Angle+=360/num;
		}
		
	while(!Obj_IsDeleted(obj)){
		ObjShot_SetDeleteFrame(obj, 4000);
		yield;
		}
	
	
	task Spinner(Target, tobj, M, Dist, Angle){
		while(!Obj_IsDeleted(Target)){
			ObjMove_SetPosition(tobj, ObjMove_GetX(Target)+Dist*cos(Angle), ObjMove_GetY(Target)+Dist*sin(Angle));
			
			Angle+=M;
			
			yield;
			}
		
		Obj_Delete(tobj);
		}
		
	}
	
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);
	}