//#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["BGMFade"]
#include "./sharedfuncJames.dnh"

let objBoss;
let width = 384;
let height = 448;
let life = 1;


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


@Initialize{                                  
    objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);   
    ObjEnemy_Regist(objBoss);
	animNon(objBoss);
	TFinalizeFade;
	
    MainTask;
}



@MainLoop{     
    ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32);            // boss hurtbox (what the player must shoot)
    ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 28);          // boss hitbox (what the player must avoid)
	yield;
}

task MainTask{
    Indicator(objBoss);
    ObjEnemy_SetDamageRate(objBoss, 0, 0);
	NotifyEventAll(EV_USER_STAGE + 1, 0);
	wait(30);
	text("That does it![r]Now you've angered me.", 360);
	wait(360);
	ObjEnemy_SetLife(objBoss, 0);
}	



task TFinalizeFade {
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	Obj_Delete(objBoss);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
    return;
}
	