#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Nonspell 1"]
#Text[""]
#Background["./../BG.txt"]
#Player["./../player/DT_PLAYERS/Reimu/TypeB/Reimu.txt", "./../player/DT_PLAYERS/Marisa/TypeA/Marisa.txt", "./../player/DT_PLAYERS/Sakuya/TypeB/Sakuya.txt", "./../player/gt_medicine/PracticeP.txt"]
#System["./../system/Default_System.dnh"]

#include "./../LibRefs.dnh"
#include "./task_folder/N01.dnh"

let objBoss;
let count = 0;

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

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

	//if(!GetCommonData("music", false)){BGM_Play("Harvest the Tres", 68, [0, 60*2 + 38.25]); SetCommonData("music", true);}

	setpos(objBoss, gx, -400); 
  ObjMove_SetDestAtFrameWeight(objBoss, gx(), gy-110, 90);
	TDrawLoop;
  TFinalize;
}

@MainLoop{
  ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32); 
  ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 18);

  if(count == 0){
		phases;
    count = 0;
  } 
    
  count++;
  yield;
}

task TDrawLoop{
	renderHinaMoF(objBoss); renderHinaAura(objBoss);
  EnMarikin(objBoss);
  ObjRender_SetScaleXYZ(objBoss, 1.15, 1.1, 0);
}

task phases{
	ObjEnemy_SetDamageRate(objBoss, 0, 0);
	wait(90);
	wait(10); DrawName(objBoss, "Hina Kagiyama", [240, 117, 166], [170, 9, 9], [104, 30]);
  wait(30);
	ObjEnemy_SetDamageRate(objBoss, 85, 45); 

	missiles();
}

task Delete(){ 
  Obj_Delete(objBoss);
}

task TFinalize {
  while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
  NotifyEventAll(EV_USER_SYSTEM + 2, NULL);
	
  Delete(); SetAutoDeleteObject(true);
  CloseScript(GetOwnScriptID());
  return;
}