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

let CLICK = 0;
let Value = 0.7;
let GRAPHIC = DS_BALL_BS_RED;
let M = -1;
let A2 = 1.5;
let TURNER = 61;
let angle3 = 45;
@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){ 
		SetScriptResult(5200*1.2)
	}
	
	case(EV_REQUEST_TIMER) { SetScriptResult(80); }
}

@MainLoop{
	
	if(ObjMove_GetSpeed(objBoss)<=0){
		ObjSprite2D_SetSourceRect(objBoss, 0, 0, 128, 128);
		}
	
	if(animation==0){
		//ObjMove_SetPosition(objBoss, GetStgFrameWidth/2-90, GetStgFrameHeight/2);
		ObjMove_SetDestAtFrame(objBoss, GetStgFrameWidth/2, 110, 100);
		ObjSprite2D_SetSourceRect(objBoss, 128*2, 128*3, 128*3, 128*4);
		///ObjRender_SetAlpha(objBoss, 0);
		///Entrance;
		}
	animation++;
	
	
	if(animation==10){
		///BossCut(objBoss, "Traditionalism \"Drawing Reality By Hand\"", "./Okina_Stand.png");
		
		let Oki_Stand = GetCurrentScriptDirectory~"SatoriDeclare.png";
		ObjCutin_SetSpellcardS4("Recollection \"Liquid Shots of Sunshine\"", Oki_Stand, AYA, 255, 100, 100);
		ObjCutin_SetSpellcardS4("Mindblow \"The Satori Looking Glass\"", Oki_Stand, AYA, 255, 100, 100);
		ObjCutin_LaunchS3(YABUSAME, 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==15&&frame<=30){
			//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, 3, 5, -4, 30, 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, 5, 6, 4, 30, objBoss);
			PlaySoundA1(4, 100, 1);
			//HandleBoundary;
			}
			
		if(shot==-100){
			CLICK=0;
			}
			
		if(shot==-100+240){
			PlaySoundA1(5, 100, 1);
			CLICK=1;
			}
			
		if(shot==-100+240+60){
			CLICK=2;
			}
			
		if(shot==-100+240+60+240){
			PlaySoundA1(5, 100, 1);
			CLICK=1;
			}
			
		if(shot==-100+240+60+240+60){
			shot=-101;
			}
			
		
		if(frame==50){
			let num = 9;
			let graphic = DS_BALL_L_SKY;
			let graphic1 = DS_RICE_M_SKY;
			
			if(s==-1){
				PlaySoundA1(21, 40, 30);
				}
			loop(num){
				if(s==-1){
					graphic = DS_RICE_M_YELLOW;
					graphic1 = DS_BALL_L_YELLOW;
					}
				let obj = CreateShotA1(GetStgFrameWidth/2, 30, 8, angle*s, graphic, 30);
				Vision(obj, graphic, graphic1);
				//let obj1 = CreateShotA1(GetStgFrameWidth/2, 30, 8, -angle, DS_RICE_S_YELLOW, 30);
				ObjMove_SetAcceleration(obj, -(8-2.5)/60);
				//ObjMove_SetAcceleration(obj1, -(8-2)/60);
				ObjMove_SetMaxSpeed(obj, 2.5);
				//ObjMove_SetMaxSpeed(obj1, 3);
				ObjMove_SetAngularVelocity(obj, 2.4*s);
				///ObjMove_SetAngularVelocity(obj1, 2.4);
				
				ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
				
				ObjMove_AddPatternA2(obj, 60, NO_CHANGE, NO_CHANGE, 0, -0.6*s, 2.5);
				//ObjMove_AddPatternA2(obj1, 60, NO_CHANGE, NO_CHANGE, 0, -0.2, 2);
				
				angle+=360/num;
				}
			
			allow++;
			
			if(allow==40){
				let angle = GetAngleToPlayer(objBoss)-90;
				let num1 = 9;
				
				let m = -1;
				
				loop(num1){
					let speed = 3.6;
					
					if(m==1){
						speed=1.2/2;
						}
					let obj1 = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), speed, angle+rand(-5, 5), DS_BUTTERFLY_BLUE, 10);
					//let obj2 = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2.4, angle+rand(-5, 5), DS_BUTTERFLY_BLUE, 10);
					Bouncer(obj1);
					//Bouncer(obj2);
					
					m*=-1;
					angle-=180/num1;
					}
					
				MoveBoss(objBoss, 50, 4*40-10);
				allow=0;
				}
			s*=-1;
				
			angle+=10.71;
			
			frame-=4;
			}
					
		}
	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, 60);
	ObjMove_SetPosition(obj, x, y);
	loop(10){
	sca-=1/15;
	///ObjRender_SetScaleXYZ(obj, sca, sca, 1);
	yield;
	}
	Obj_Delete(obj);
	}
	
task Vision(tobj, graphic, graphic1){
	let count = 0;
	while(!Obj_IsDeleted(tobj)){
		if(CLICK==0){
			ObjRender_SetAlpha(tobj, 256);
			ObjShot_SetIntersectionEnable(tobj, true);
			ObjShot_SetSpellResist(tobj, false);
			ObjShot_SetGraphic(tobj, graphic);
			
			count=0;
			}
			
		if(CLICK==1&&count==0){
			ObjRender_SetAlpha(tobj, 60);
			ObjShot_SetIntersectionEnable(tobj, false);
			ObjShot_SetSpellResist(tobj, true);
			ObjShot_SetGraphic(tobj, graphic1);
			}
			
		if(CLICK==2){
			count=1;
			ObjRender_SetAlpha(tobj, 256);
			ObjShot_SetIntersectionEnable(tobj, true);
			ObjShot_SetSpellResist(tobj, false);
			ObjShot_SetGraphic(tobj, graphic1);
			}
			
		if(CLICK==1&&count==1){
			ObjRender_SetAlpha(tobj, 60);
			ObjShot_SetIntersectionEnable(tobj, false);
			ObjShot_SetSpellResist(tobj, true);
			ObjShot_SetGraphic(tobj, graphic);
			}
			
		yield;
		}
		
	}
	
task Bouncer(tobj){
	
	let A = 0;
	
	while(!Obj_IsDeleted(tobj)){
		if(ObjMove_GetX(tobj)>=GetStgFrameWidth&&A==0){
			A=1;
			ObjMove_SetX(tobj, GetStgFrameWidth-1);
			let obj = CreateShotA1(GetStgFrameWidth-1, ObjMove_GetY(tobj), 0, 0, 1, 0);
			ObjRender_SetAlpha(obj, 0);
			let angle = GetAngleToPlayer(obj);
			Obj_Delete(obj);
			
			ObjMove_SetAngle(tobj, angle);
			ObjMove_SetSpeed(tobj, 0);
			ObjMove_SetAcceleration(tobj, 3/80);
			ObjMove_SetMaxSpeed(tobj, 3);
			PlaySoundA1(23, 80, 1);
			}
			
		if(ObjMove_GetX(tobj)<=0&&A==0){
			A=1;
			ObjMove_SetX(tobj, 1);
			let obj = CreateShotA1(1, ObjMove_GetY(tobj), 0, 0, 1, 0);
			ObjRender_SetAlpha(obj, 0);
			let angle = GetAngleToPlayer(obj);
			Obj_Delete(obj);
			
			ObjMove_SetAngle(tobj, angle);
			ObjMove_SetSpeed(tobj, 0);
			ObjMove_SetAcceleration(tobj, 3/80);
			ObjMove_SetMaxSpeed(tobj, 3);
			PlaySoundA1(23, 80, 1);
			}
			
		if(ObjMove_GetY(tobj)<=0&&A==0){
			A=1;
			ObjMove_SetY(tobj, 1);
			let obj = CreateShotA1(ObjMove_GetX(tobj), 1, 0, 0, 1, 0);
			ObjRender_SetAlpha(obj, 0);
			let angle = GetAngleToPlayer(obj);
			Obj_Delete(obj);
			
			ObjMove_SetAngle(tobj, angle);
			ObjMove_SetSpeed(tobj, 0);
			ObjMove_SetAcceleration(tobj, 3/80);
			ObjMove_SetMaxSpeed(tobj, 3);
			PlaySoundA1(23, 80, 1);
			}
			
		yield;
		}
		
	}