#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*1.2)
	}
	
	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("Eislanze \"Gae Bulg Cast from Silver\"", 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==80){
			loop(1){
				Lance(GetStgFrameWidth/2+200*cos(angle), -10+10*sin(angle), 15, angle, DS_RICE_M_WHITE, 40);
				Lance(GetStgFrameWidth/2+150*cos(0-angle), -10+10*sin(0-angle), 15, 0-angle, DS_RICE_M_WHITE, 40);
				angle+=360/3;
				}
			
			PlaySoundA1(25, 70, 0);
			
			angle+=3;
			
			frame-=3;
			
				
			}
			
		if(shot==120-5){
			PlaySoundA1(22, 100, 14);
			}
			
		if(shot==120){
			let num = 8;
			let num1 = 3;
			
			loop(num){
				let mod = 0;
				loop(num1){
					if(s==1){
						let obj1 = CreateShotA1(ObjMove_GetX(objBoss)+60*cos(0+angle1+mod), ObjMove_GetY(objBoss)+60*sin(0+angle1+mod), 4, 0+angle1+mod-110, DS_RICE_S_SKY, 10);
						ObjMove_SetAcceleration(obj1, -(4-1.2)/60);
						ObjMove_SetMaxSpeed(obj1, 1.2);
						}
						
					if(s==-1){
						let obj1 = CreateShotA1(ObjMove_GetX(objBoss)+60*cos(0-angle1-mod), ObjMove_GetY(objBoss)+60*sin(0-angle1-mod), 4, 0-angle1-mod+110, DS_RICE_S_GREEN, 10);
						ObjMove_SetAcceleration(obj1, -(4-1.2)/60);
						ObjMove_SetMaxSpeed(obj1, 1.2);
						}
						
					mod+=2*s;
					}
					
				angle1+=360/num;
				}
				
			allow++;
			
			if(allow<=2){
				shot-=7;
				angle1+=2;
				}
				
			else{
				allow=0;
				shot-=12;
				s*=-1;
				angle1+=14;
				
				A2++;
				
				if(A2==4){
					MoveFreu(GetPlayerX, rand(80, 160), 60);
					A2=0;
					}
				}
				
			}
			
		}
	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 Lance(X, Y, Speed, Angle, Graphic1, Time){
	let obj10 = CreateStraightLaserA1(X, Y, Angle, 0, 2, Time+15, DS_BEAM_WHITE, 0);
	ObjStLaser_SetSource(obj10, false);
	ObjShot_SetIntersectionEnable(obj10, false);
	let L = 0;
	loop(Time){
		ObjLaser_SetLength(obj10, L);
		L+=640/Time;
		
		yield;
		}
		
	//Obj_Delete(obj10);
	let obj = CreateShotA1(X, Y, Speed, Angle, Graphic1, 0);
	
	ObjShot_SetSpellResist(obj, true);
	ObjShot_SetIntersectionEnable(obj, false);
	ObjRender_SetAlpha(obj, 0);
	ObjRender_SetBlendType(obj, BLEND_SUBTRACT);
	
	//ObjShot_SetAutoDelete(obj, false);
	//ObjRender_SetScaleXYZ(obj, 2, 2, NULL);
	
	let count = 0;
	while(!Obj_IsDeleted(obj)){
		Frost(ObjMove_GetX(obj), ObjMove_GetY(obj), 100, 20, Angle, Graphic1, 20);
		
		yield;
		}
		
	task Frost(X, Y, Length, Width, Angle, Graphic, Delay){
		let obj10 = CreateStraightLaserA1(X, Y, Angle, 0, 0, 60, Graphic, 0);
		ObjStLaser_SetSource(obj10, false);
		let L = Length;
		let W = Width;
		loop(Delay){
			yield;
			ObjLaser_SetLength(obj10, L);
			//ObjLaser_SetWidth(obj10, W);
			ObjLaser_SetRenderWidth(obj10, W);
			ObjLaser_SetIntersectionWidth(obj10, W/2);
			L-=Length/Delay;
			W-=Width/Delay;
			if(W<=6){
				ObjShot_SetIntersectionEnable(obj10, false);
				}
			
			yield;
			}
		
		}
		
	}
	
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);
	}