#ScriptVersion[3]
#Title["YukariSkeleton - Do Not Play"]
#Text["Don't actually play this, you idiot."]
#BGM["./bgm1.mp3"]
//#Player["./Ultima's DDC Reimu B/ReimuH.dnh"]
#System["./default_system/Default_System.txt"]

#include"./resources/include.txt"
//#include"./StageBG.txt"
#include"./default_system/Default_ShotConst.txt"
#include"./default_system/UsShotC.txt"
#include"./default_system/UsShotRD.txt"


let objBoss;
let frame=0;
let animation=0;
let angle=0;
let angle1=0;
let mod=0;
let mod1 = 0;
let mod2=0;
let move=0;
let s = 1;
let allow=0;
let allow1=0;
let shot=0;
let shot2 = 0;
let Death = false;

let TURNL = false;
let TURNR = false;

let FreuMove = false;



@Initialize
{	
	objBoss= ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	
	
	let imgExRumia = GetCurrentScriptDirectory ~ "dot_satori.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);
	
		
	ObjRender_SetScaleXYZ(objBoss, 1, 1, NULL);
	
	//ObjMove_SetDestAtFrame(objBoss, GetStgFrameWidth/2, 110, 30);
	
	
	if(GetStgFrameWidth/2>=ObjMove_GetX(objBoss)){
		AuraMoveRight=true;
		//ObjSprite2D_SetSourceRect(objBoss, 128*2, 128*3, 128*3, 128*4);
		}
		
	else{
		AuraMoveLeft=true;
					//MoveLeft = true;
		//ObjSprite2D_SetSourceRect(objBoss, 128*2, 128, 128*3, 128*2);	
		}
		
	
		
	MCircle(objBoss, "NORMAL");
	//BattleAnim;
	//Halo(objBoss);
	///SoundDeclare;
	
//	StageBG(objBoss);
	
	//Line(objBoss);
	
	if(Declare==true){
		MariBG(objBoss);
		}
	}
	
task MariBG(tobj){
	let graphic = GetCurrentScriptDirectory~ "SatoriSpellBG1.png";
	let graphic1 = GetCurrentScriptDirectory~ "SatoriSpellBG2.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, graphic);
	Obj_SetRenderPriorityI(obj,27);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjSprite2D_SetSourceRect(obj, 0, 0, 1000, 708);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj, GetStgFrameWidth-90, GetStgFrameHeight/2+70, 0);
	ObjRender_SetColor(obj, 200, 200, 200);
	ObjRender_SetScaleXYZ(obj, 0.86, 0.86, NULL);
	ObjRender_SetAngleZ(obj, 30);
	ObjRender_SetAlpha(obj, 150);
	
	let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj1, graphic1);
	Obj_SetRenderPriorityI(obj1,28);
	ObjRender_SetBlendType(obj1,BLEND_SUBTRACT);
	ObjSprite2D_SetSourceRect(obj1, 0, 0, 512, 512);
	ObjSprite2D_SetDestCenter(obj1);
	ObjRender_SetAlpha(obj1, 100);
	ObjRender_SetPosition(obj1, GetStgFrameWidth/2, GetStgFrameHeight/2, 0);
	///ObjRender_SetColor(obj1, 255, 0, 255-50);
	ObjRender_SetScaleXYZ(obj1, 1, 1, NULL);
	
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj2, graphic1);
	Obj_SetRenderPriorityI(obj2,26);
	ObjRender_SetBlendType(obj2,BLEND_ALPHA);
	ObjSprite2D_SetSourceRect(obj2, 0, 0, 512, 512);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetAlpha(obj2, 255);
	ObjRender_SetPosition(obj2, GetStgFrameWidth/2, GetStgFrameHeight/2, 0);
	//ObjRender_SetColor(obj2, 255, 0, 255-50);
	ObjRender_SetScaleXYZ(obj2, 1, 1, NULL);
	
	ObjRender_SetAngleZ(obj1, 10);
	ObjRender_SetAngleZ(obj2, -10);
	//ObjRender_SetAngleZ(obj, 180);
	
	let mod = 0;
	let mod1 = 0;
	
	while(!Obj_IsDeleted(tobj)){
		ObjSprite2D_SetSourceRect(obj1, 0+mod, 0+mod, 512+mod, 512+mod);
		ObjSprite2D_SetSourceRect(obj2, 0-mod1, 0+mod1, 512-mod1, 512+mod1);
		///ObjSprite2D_SetSourceRect(obj, 0, 0+mod, 512, 512+mod);
		///ObjSprite2D_SetSourceRect(obj2, 0-mod, 0-mod, 500*2-mod, 500*2-mod);
		ObjSprite2D_SetDestCenter(obj1);
		ObjSprite2D_SetDestCenter(obj2);
		//ObjSprite2D_SetDestCenter(obj2);
		//ObjSprite2D_SetDestCenter(obj2);
		//ObjSprite2D_SetSourceRect(obj2, 0, 0, 1255, 1254);
		//ObjSprite2D_SetDestCenter(obj2);
		
		if(CLICK==1){
			ObjRender_SetColor(obj, 205, 50, 50);
			}
			
		else{
			ObjRender_SetColor(obj, 200, 200, 200);
			}
		mod+=1.7/4;
		mod1+=1.7/(1.7*2);
		
		
		yield;
		}
	Obj_Delete(obj);	
	Obj_Delete(obj1);	
	Obj_Delete(obj2);	
	}
	
task BattleAnim{
	let mod = 0;
	
	while(!Obj_IsDeleted(objBoss)){
		
		///ObjSprite2D_SetSourceRect(objBoss, 512/6*mod, 0, 512/6*(mod+1), 1024/11);
		
		//mod++;
		
		if(mod>=4){
			mod=1;
			}
		
		yield;
		}
		
	}
	
task Halo(tobj){
	loop(40){yield;}
	while(!Obj_IsDeleted(tobj)){
		
		HGraphic(tobj);
		
		loop(90){
			yield;
			}
			
		}
	
	
	task HGraphic(tobj){
		let graphic = GetCurrentScriptDirectory~ "Halo.png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(obj, graphic);
		Obj_SetRenderPriorityI(obj,28);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj, 0, 0, 256, 256);
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj, ObjMove_GetX(tobj), ObjMove_GetY(tobj), 0);
		ObjRender_SetColor(obj, 200, 200, 200);
		ObjRender_SetScaleXYZ(obj, 0.5, 0.5, NULL);
		
		let scale = 0;
		let alpha =150;
		while(!Obj_IsDeleted(tobj)){
			ObjRender_SetScaleXYZ(obj, scale, scale, NULL);
			ObjRender_SetAlpha(obj, alpha);
			
			if(scale<=1){
				scale+=1/100;
				alpha-=150/100;
				}
				
			else{
				Obj_Delete(obj);
				}
				
			yield;
			}
			
		Obj_Delete(obj);
		}
	
	}
	
	
task PlaySoundA1(index, volume, delay){
	loop(delay){
		yield;
		}
	NotifyEvent(GetCommonData("SoundScript", GetOwnScriptID), EV_USER, [index, volume]);
}