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

let CLICK = 0;
let Value = 18;
let GRAPHIC = DS_ICE_BLUE;
let M = -3;
let A2 = 0;
let angle3 = rand(0, 360);
@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5600)
	}
	
	case(EV_REQUEST_TIMER) { SetScriptResult(60); }
}

@MainLoop{
	if(animation==0){
		MoveFreu(GetStgFrameWidth/2, 110, 100);
		}
		
	animation++;
	
	
	if(animation==10){
		///BossCut(objBoss, "Traditionalism \"Drawing Reality By Hand\"", "./Okina_Stand.png");
		
		let Oki_Stand = GetCurrentScriptDirectory~"Ch-Freudiaf.png";
		ObjCutin_SetSpellcardS4("Eisschwert \"Cage of the World Eater\"", 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), 3, 60, 1, 5, -4, 30, objBoss);
			PlaySoundA1(4, 100, 1);
			}
			
		if(frame==-20){
			//Concentration_True(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), rand(0, 360), 3, 60, 1, 5, -4, 30, objBoss);
			PlaySoundA1(4, 100, 1);
			}
		
		if(frame==80){
			let num = 4*14;
			///let angle = rand(0, 360);
			let SA = 1;
			PlaySoundA1(22, 100, 0);
			PlaySoundA1(23, 100, 60+80);
			loop(num){
				
				if(s==-1){
					if(SA==4){
						Slash(ObjMove_GetX(objBoss)+100*cos(angle), ObjMove_GetY(objBoss), Value, angle, DS_LIGHT_BLUE, M, 60, 0);
						SA = 0;
						}
						
					else{
						Slash(ObjMove_GetX(objBoss)+100*cos(angle), ObjMove_GetY(objBoss), Value, angle, DS_LIGHT_SKY, M, 60, SA);
						}
					}
					
				else{
					if(SA==4){
						Slash(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss)+100*sin(angle), Value, angle, DS_LIGHT_BLUE, M, 60, 0);
						SA=0;
						}
						
					else{
						Slash(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss)+100*sin(angle), Value, angle, DS_LIGHT_SKY, M, 60, SA);
						}
					}
					
				SA*=-1;
					
				angle+=360/num;
				}
				
			allow++;
			
			if(allow<12){
				s*=-1;
				frame-=10;
				M*=s;
				Value-=17/12;
				}
				
			else{
				
				frame-=600;
				allow=0;
				Value = 18;
				A2++;
				
				if(A2==1){
					GRAPHIC = DS_ICE_BLUE;
					MoveFreu(rand(100, GetStgFrameWidth-100), rand(80, 140), 200);
					}
					
				if(A2==2){
					A2=0;
					GRAPHIC = DS_ICE_PURPLE;
					MoveFreu(GetPlayerX, rand(80, 140), 200);
					}
				}
				
			}
			
		}
	yield;
	}
	
task Die1(tobj){
	loop(10){
		DeleteShotAll(TYPE_ALL, TYPE_FADE);
		}
	Obj_Delete(tobj);
	
	loop(100){
		yield;
		}
	
	CloseScript(GetOwnScriptID());
	}	
	
task MoveFreu(X, Y, Time){
	ObjMove_SetDestAtFrame(objBoss, X, Y, Time);
	ObjRender_SetScaleXYZ(objBoss, 0, 0, NULL);
	
	loop(Time){
		FreuMove = true;
		FreuTrail;
		yield;
		}
		
	let scale = 0;
	
	FreuMove = false;
	
	loop(6){
		ObjRender_SetScaleXYZ(objBoss,scale, 1, NULL);
		scale+=1/5;
		}
		
	}
	
task FreuTrail{
	let obj = CreateShotA1(ObjMove_GetX(objBoss)+rand(-15, 15), ObjMove_GetY(objBoss)+rand(-15, 15), 0, 0, DS_BILL_WHITE, 40);
	ObjShot_SetDeleteFrame(obj, 0);
	ObjShot_SetSpellResist(obj, true);
	
	}
	
task Slash(X, Y, Speed, Angle, Graphic1, S, Time, Shot){
	let obj = CreateShotA1(X, Y, Speed, Angle, Graphic1, 0);
	
	ObjShot_SetSpellResist(obj, true);
	ObjShot_SetIntersectionEnable(obj, false);
	ObjRender_SetAlpha(obj, 60);
	ObjRender_SetBlendType(obj, BLEND_SUBTRACT);
	
	ObjMove_SetAngularVelocity(obj, S);
	ObjMove_SetAcceleration(obj, -Speed/Time);
	ObjMove_SetMaxSpeed(obj, 0);
	
	ObjShot_SetAutoDelete(obj, false);
	//ObjRender_SetScaleXYZ(obj, 2, 2, NULL);
	
	let count = 0;
	while(!Obj_IsDeleted(obj)){
		
		if(ObjMove_GetSpeed(obj)<=0&&count==0){
			//ObjMove_SetAngularVelocity(obj, 0);
			count=1;
			}
			
		if(count==1){
			count=2;
			loop(80){
				yield;
				}
				
			
				Frost(ObjMove_GetX(obj), ObjMove_GetY(obj), 1.2, Angle+110*Shot, GRAPHIC, 10);
				//Frost(ObjMove_GetX(obj), ObjMove_GetY(obj), 0.2, Angle-110, GRAPHIC, 10);
				
				
			Obj_Delete(obj);
			}
		yield;
		}
		
	task Frost(X, Y, Speed, Angle, Graphic, Delay){
		let obj = CreateShotA1(X, Y, 0, Angle, Graphic, Delay);
		ObjShot_SetAutoDelete(obj, false);
		loop(60){
			yield;
			}
			
		ObjMove_SetAcceleration(obj, Speed/200);
		ObjMove_SetMaxSpeed(obj, Speed);
		
		}
		
	}
	
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);
	}