#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Non Spellcard 3"]
#Text["..."]
#System[".\system\Default_System.txt"]

#include"./lib/AllStarShot_Const.dnh"
#include"./lib/Functions.txt"
#include"./BGTask.txt"
#include"./Animation_lib.txt"
let Enemy = ID_INVALID;
let EnemyX = 0;
let EnemyY = 0;
let yuyuX = 0;
let yuyuY = 0;

@Event{
	alternative(GetEventType)
	case(EV_REQUEST_LIFE){SetScriptResult(900);}
	case(EV_REQUEST_TIMER){SetScriptResult(50);}
//case(EV_REQUEST_SPELL_SCORE){SetScriptResult(90000);}
}

@Initialize{
	Enemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(Enemy);
ObjEnemy_SetDamageRate(Enemy,0,0);
//ObjMove_SetPosition(Enemy,-120,0);
ObjMove_SetPosition(Enemy,GetStgFrameWidth/2,100);
DrawTimer03(2);//0=transition Spell-NonSpell,1=Transition NS-S,2= Spawn NS
InitializeAction(Enemy,GetCurrentScriptDirectory ~"img/dot_edorev.png");
DrawBoss_Task(Enemy);
SetAutoDeleteObject(true);
name("Edorev Milton",0,30);
	BossActions;
}



@MainLoop{
	yield;
}

task BossActions{
ObjMove_SetDestAtWeight(Enemy, GetStgFrameWidth/2, 100, 20,6);
SetAction(Enemy,ACT_MOVE_R,100);
wait(120);
	ShootBullets;
//Texto;
	while(ObjEnemy_GetInfo(Enemy, INFO_LIFE) > 0){
		EnemyX = ObjMove_GetX(Enemy);
		EnemyY = ObjMove_GetY(Enemy);
		ObjEnemy_SetIntersectionCircleToShot(Enemy, EnemyX, EnemyY, 20);
		ObjEnemy_SetIntersectionCircleToPlayer(Enemy, EnemyX, EnemyY, 20);
                                          
		yield;
	}
DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	Obj_Delete(Enemy);
	//loop(60){yield;}
	CloseScript(GetOwnScriptID);
}
function wait(t){loop(t){yield;}}

task ShootBullets{
//Preparation
MagicCircleEx2(Enemy,true); //Magic Circle, true means opening enabled
LifeCircleBar_A(Enemy,0.5,0.5,true);//Active Lifebar part(enemy,usable part,unusable part(empity),opening)
LifeCircleBar_B(Enemy,0.5,0.0,true);//Inactive LB part
LifeCircleBar_Marker(Enemy,0.5);//Marker
Aura1(Enemy,8,128,128,0);	//Aura(enemy,spawn rate,r,g,b)			
wait(60);		
SE(CSD~"sfx/charge00.wav");
//Concentration06(Enemy,60,255,255,255);  (enemy,time,r,g,b);
nTestCharge(EnemyX,EnemyY,90,255,255,0);
//All shot things here
let angle = 0;
let angle2 = 0;
wait(60);
let radius = 80;
ObjEnemy_SetDamageRate(Enemy,40,10);
Shot2;
loop{
//SE(CSD~"sfx/tan00.wav");
if(ObjEnemy_GetInfo(Enemy, INFO_LIFE) == 0){break;}
angle = getAtanAngle(Enemy,Player);
SE(CSD~"sfx/Laser.wav");

ascent(i in 0..6){
let a=CreateCurveLaserA1(EnemyX,EnemyY,2,angle+i*360/6,50,10,LIGHTNING,0);
ObjMove_AddPatternA2(a,30,5,(angle+i*360/6)+45,-0.1,0,0);
ObjMove_AddPatternA2(a,60,5,(angle+i*360/6)-45,-0.1,0,0);
ObjMove_AddPatternA2(a,90,5,(angle+i*360/6)+45,0,0,0);
//ObjMove_AddPatternA2(a,120,5,(angle+i*360/6)-45,-0.1,0,0);
//ObjMove_AddPatternA2(a,150,5,(angle+i*360/6)+45,-0.1,0,0);
//ObjMove_AddPatternA2(a,180,5,(angle+i*360/6)-45,-0.1,0,0);
ObjCrLaser_SetTipDecrement(a,0);
}
ascent(i in 0..6){
let a=CreateCurveLaserA1(EnemyX,EnemyY,2,angle+i*360/6,50,10,LIGHTNING,0);
ObjMove_AddPatternA2(a,30,5,(angle+i*360/6)-45,-0.1,0,0);
ObjMove_AddPatternA2(a,60,5,(angle+i*360/6)+45,-0.1,0,0);
ObjMove_AddPatternA2(a,90,5,(angle+i*360/6)-45,0,0,0);
//ObjMove_AddPatternA2(a,120,5,(angle+i*360/6)+45,-0.1,0,0);
//ObjMove_AddPatternA2(a,150,5,(angle+i*360/6)-45,-0.1,0,0);
//ObjMove_AddPatternA2(a,180,5,(angle+i*360/6)+45,-0.1,0,0);
ObjCrLaser_SetTipDecrement(a,0);
}

wait(60);
}
}

task Shot2{
loop{
 ascent(a in 0..3){
  ascent(b in 0..30){
   CreateShotFA2(EnemyX,EnemyY,1+a,getAtanAngle(Enemy,Player)+b*360/30,0.05,5,ORB_YELLOW+500,1,true);
   }
  }
 wait(60);
 }
}