#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Non1"]
#Text["The final take on Non Directional Laser!"]
//#BGM["script/practice/resources/area2_boss.wav"]
#Player["./Reimu/ReimuB.dnh"]


#include"./include.txt"

let Patch;
let Familiar;
let Familiar1;
let frame=0;
let animation=0;
let angle=0;
let Variance = 5;
let ANG= -0.5;
let NUMBER = 8;
let speed=2;
let angle1 = 0;
let angle3 = 0;
let shot=0;
let allow=0;
let move=0;

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4000)
	}
}

@Initialize
{	
	Patch = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(Patch);

	let imgExRumia = GetCurrentScriptDirectory ~ "/dot_patchouli.png"; //file path to enemy image

	ObjPrim_SetTexture(Patch, imgExRumia); //Setting the above image file as a texture to the enemy object(Patch)

	ObjSprite2D_SetSourceRect(Patch, 0, 0, 128, 128); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).

	ObjSprite2D_SetDestCenter(Patch); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).

	//Moving to the coordinate (cx, 60) in 60 frames

	let cx = GetStgFrameWidth() / 2;

	ObjMove_SetDestAtFrame(Patch, cx, 110, 30);
	
	//Crosshair(Patch, DS_BEAM_WHITE);
	
	

}

@MainLoop{
	animation++;
	
	let PatchX = ObjMove_GetX(Patch);
	let PatchY = ObjMove_GetY(Patch);
	
	if(animation>=90){
	
		ObjEnemy_SetIntersectionCircleToShot(Patch, PatchX, PatchY, 32);

		ObjEnemy_SetIntersectionCircleToPlayer(Patch, PatchX, PatchY, 24);

		if(ObjEnemy_GetInfo(Patch, INFO_LIFE) <= 0){

			death;
		}
		
		frame++;
		
		if(frame==30){
			WHOOOP;
			let ANG= 360/7;
			
			CreateStraightLaserA1(GetStgFrameWidth/2, 20, angle, 650, 50, 80, DS_NEEDLE_RED, 40); 
			CreateStraightLaserA1(GetStgFrameWidth/2, 20, angle+ANG, 650, 50, 80, DS_NEEDLE_GREEN, 40); 
			CreateStraightLaserA1(GetStgFrameWidth/2, 20, angle+ANG*2, 650, 50, 80, DS_NEEDLE_WHITE, 40); 
			CreateStraightLaserA1(GetStgFrameWidth/2, 20, angle+ANG*3, 650, 50, 80, DS_NEEDLE_BLUE, 40); 
			CreateStraightLaserA1(GetStgFrameWidth/2, 20, angle+ANG*4, 650, 50, 80, DS_NEEDLE_YELLOW, 40); 
			CreateStraightLaserA1(GetStgFrameWidth/2, 20, angle+ANG*5, 650, 50, 80, DS_NEEDLE_ORANGE, 40); 
			CreateStraightLaserA1(GetStgFrameWidth/2, 20, angle+ANG*6, 650, 50, 80, DS_NEEDLE_SKY, 40); 
			
			angle+=9.13;
			
			frame=0;
			}
		
		if(shot==2){
				
			let obj = CreateShotA1(PatchX, PatchY, 2, angle1, DS_LIGHT_PURPLE, 10);
			ObjMove_SetAngularVelocity(obj, 0.5);
			
			angle1+=10.112;
			shot=0;
			allow++;
			}
			
		if(allow>=100){
			angle3++;
			}
			
		if(angle3==2){
			//let obj1 = CreateShotA1(PatchX, PatchY, 1, angle1+180, DS_LIGHT_R_WHITE, 10);
			//ObjMove_SetAngularVelocity(obj1, -0.2);
			
			angle3=0;
			}
		shot++;
			
		}
	yield;
	}
	
task death {

	Obj_Delete(Patch);
	//Obj_Delete(Koa);
	//Obj_Delete(Koa1);
	
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	
	loop(100){	
		DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE);
		
		yield;
		}
		
	Obj_Delete(Patch);
		
	CloseScript(GetOwnScriptID());
	
	return;
	
	}