//#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["FirstNon"]
#include "./../../ZUNShot/ZUNShot_Const.txt"
#include "./../sharedFuncDave.dnh"



let objBoss;
let width = 384;
let height = 448;
let life = 4500;
let scene = GetEnemyBossSceneObjectID();


@Event{
    alternative(GetEventType())
    case(EV_REQUEST_LIFE){
        SetScriptResult(life);
    }
    case(EV_REQUEST_TIMER){
        SetScriptResult(45);
    }
}


@Initialize{
    objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
    ObjEnemy_Regist(objBoss);
	SetCommonData("non1", "yes");
	
	animNon(objBoss);
	TFinalizeNon(scene, objBoss);
	
	
    ObjMove_SetDestAtFrame(objBoss, width/2, 2*height/5, 60);
	Main;
}

@MainLoop{
    ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32); 
    ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 28);
    yield;
}


task Main{
    Name(1, objBoss);
    SetForbidPlayerShot(false);
	NotifyEventAll(EV_USER_STAGE, 0);
    Indicator(objBoss, 1);
    takeDamage(objBoss, scene, life);
    ObjEnemy_SetDamageRate(objBoss, 0, 0);
	wait(116);
	ObjEnemy_SetDamageRate(objBoss, 20, 0);
    wait(60); 
	let shot2 = LoadEffect(GetCurrentScriptDirectory~ "./../../SFX/ATTACK5.WAV", 60);
	ObjSound_Play(LoadEffect(GetCurrentScriptDirectory~ "./../../SFX/Charge.WAV", 80));
	wait(60);
	ObjEnemy_SetDamageRate(objBoss, 100, 50);
	let ang = GetAngleToPlayer(objBoss);
	move(width/4, 3*width/4, height/5, height/2, 120, 180, 200, objBoss, 0);
	while(ObjEnemy_GetInfo(objBoss, INFO_LIFE)>0){
	    let t=0;
		shotSound(shot2, 300, 50, 10, objBoss, false, 0);
		while(t<300){
			ascent(i in 0..4){
			    ascent(j in 0..2){if(ObjEnemy_GetInfo(objBoss, INFO_LIFE)<=0){return;}
				let obj =CreateShotA2(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), rand(2.5,3.5), ang +rand(-3,3)+90*i, rand(-0.05, -0.02), rand(1, 1.2), rand(90,105), 0);}
			}
			ascent(i in 0..4){
				ascent(j in 0..2){if(ObjEnemy_GetInfo(objBoss, INFO_LIFE)<=0){return;}
				let obj =CreateShotA2(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), rand(2.5,3.5), -ang+rand(-3,3) +90*i, rand(-0.05, -0.02), rand(1, 1.2), rand(90,105), 0);}
			}
			wait(10); ang+=12; t+=10;
		}
		wait(60);
	}
}



	
	
	