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

let CLICK = 0;
let Value = 120;
let GRAPHIC = DS_BALL_BS_RED;
let M = 1.5;
let A2 = 90;
let angle3 = 270;
let TURNER = rand(0, 100);
@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5200*1.9)
	}
	
	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, 140, 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);
		//Wings;
		}
	
	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(shot==60){
			let angle = angle3;
			let obj = CreateShotA1(GetStgFrameWidth/2, 80, 6, angle-55, DS_ICE_SKY, 25);
			ObjMove_SetAcceleration(obj, -6/60);
			ObjMove_SetMaxSpeed(obj, 0);
			ObjMove_AddPatternA2(obj, 65, 5, 90-41, NO_CHANGE, 0, 4);
			let obj1 = CreateShotA1(GetStgFrameWidth/2, 80, 6, angle+55, DS_ICE_SKY, 25);
			ObjMove_SetAcceleration(obj1, -6/60);
			ObjMove_SetMaxSpeed(obj1, 0);
			ObjMove_AddPatternA2(obj1, 65, 5, 90+41, NO_CHANGE, 0, 4);
			
			let obj2 = CreateShotA1(GetStgFrameWidth/2, 80, 6, angle-85, DS_ICE_SKY, 25);
			ObjMove_SetAcceleration(obj2, -6/60);
			ObjMove_SetMaxSpeed(obj2, 0);
			ObjMove_AddPatternA2(obj2, 65, 5, 90-11, NO_CHANGE, 0, 4);
			let obj3 = CreateShotA1(GetStgFrameWidth/2, 80, 6, angle+85, DS_ICE_SKY, 25);
			ObjMove_SetAcceleration(obj3, -6/60);
			ObjMove_SetMaxSpeed(obj3, 0);
			ObjMove_AddPatternA2(obj3, 65, 5, 90+11, NO_CHANGE, 0, 4);
			
			let obj4 = CreateShotA1(GetStgFrameWidth/2, 80, 6, angle-125, DS_ICE_SKY, 25);
			ObjMove_SetAcceleration(obj4, -6/60);
			ObjMove_SetMaxSpeed(obj4, 0);
			ObjMove_AddPatternA2(obj4, 65, 5, 90-70, NO_CHANGE, 0, 4);
			let obj5 = CreateShotA1(GetStgFrameWidth/2, 80, 6, angle+125, DS_ICE_SKY, 25);
			ObjMove_SetAcceleration(obj5, -6/60);
			ObjMove_SetMaxSpeed(obj5, 0);
			ObjMove_AddPatternA2(obj5, 65, 5, 90+70, NO_CHANGE, 0, 4);
			
			angle3+=sin(A2)*3.5;
			A2+=5;
			shot-=7;
			}
			
		if(frame==30){
			Switch(1);
			}
			
		if(frame==120){
			let num = 7;
			let num1 = 6;
			PlaySoundA1(21, 100, 11);
			loop(num){
				let speed = 1.3;
				
				loop(num1){
					let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), speed, angle, DS_RICE_S_RED, 10);
					speed+=0.6;
					}
					
				angle+=360/num;
				}
				
			allow++;
			
			if(allow<=12){
				angle+=7*s;
				frame-=4;
				}
			
			else{
				allow=0;
				MoveBoss(objBoss, 40, 60);
				}
			}
			
		if(frame==185){
			Switch(2);
			}
			
		if(frame==200){
			let angle = rand(0, 360);
			let num = 20;
			PlaySoundA1(23, 100, 11);
			loop(num){
				let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 1, angle, DS_BALL_M_RED, 10);
				ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
				ObjMove_SetAcceleration(obj, 2/60);
				ObjMove_SetMaxSpeed(obj, 3);
				ObjMove_SetAngularVelocity(obj, 2*s);
				ObjMove_AddPatternA2(obj, 60, 3, NO_CHANGE, 0, 0, 3);
				
				angle+=360/num;
				}
			
			allow++;
			
			if(allow<=9){
				frame-=12;
				s*=-1;
				}
			
			else{
				allow=0;
				MoveBoss(objBoss, 40, 60);
				}
			}
			
		if(frame==265){
			Switch(1);
			frame=120-15;
			}
			
		}
	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 Hermit(x, y, x2, y2, angle, angle2, time, graphic, color){
	let vx=(x2-x)/time;
	let vy=(y2-y)/time;
	let r=0;
	let a=0;
	loop(time){
	angle+=2; angle2+=2;
	x+=vx; y+=vy;
	a+=360/time; r=120-120*cos(a);
	ShrinkShot(x+r*cos(angle), y+r*sin(angle2),graphic, color);
	yield;
	}
	
	}
task ShrinkShot(x, y, graphic,color){
	let obj=ObjShot_Create(OBJ_SHOT);
	ObjShot_Regist(obj);
	let sca=1;
	ObjShot_SetIntersectionEnable(obj, false);
	ObjShot_SetSpellResist(obj,true);
	ObjShot_SetGraphic(obj, graphic);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	if(color=="BLUE"){ObjRender_SetColor(obj,155,155,255);}
	if(color=="GREEN"){ObjRender_SetColor(obj, 155, 255, 155);}
	if(color=="RED"){ObjRender_SetColor(obj, 255, 155, 155);}
	if(color=="PURPLE"){ObjRender_SetColor(obj, 255, 155, 255);}
	if(color=="WHITE"){ObjRender_SetColor(obj, 255, 255, 255);}
	ObjRender_SetAlpha(obj, 100);
	ObjMove_SetPosition(obj, x, y);
	loop(10){
	sca-=1/15;
	ObjRender_SetScaleXYZ(obj, sca, sca, 1);
	yield;
	}
	Obj_Delete(obj);
	}
	
	
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);
	}