#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Dross NS1"]
#Text["Numero 7 -Ataque Normal-"]
#System[".\system\Default_System.txt"]


#include"./lib/AllStarShot_Const.dnh"
#include"./lib/TheFunctions.txt"
#include"./BGTask.txt"
#include"./Animation_lib_satori.txt"

let Enemy = ID_INVALID;
let EnemyX = 0;
let EnemyY = 0;

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

@Initialize{
	Enemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(Enemy);
SetDamageRateAtFrame(Enemy,60,10,120);
ObjRender_SetPosition(Enemy,GetStgFrameWidth/2, 100,0);
SetAutoDeleteObject(true);
InitializeAction(Enemy,DrossDot);
DrawBoss_Task(Enemy);
name("Dross Rotzank",0,10);
//LifeCircleBar_A(Enemy,0.8,0.2,true);
//LifeCircleBar_B(Enemy,0.2,0.0,true);
//LifeCircleBar_Marker(Enemy,0.8);
//LifeStock(2,1);
EnemyMarker(Enemy,Enemy);
TWaveCircle_Shadertask(Enemy,0);
TAura(Enemy,0);
LoadSounds;

	//ObjMove_SetDestAtWeight(Enemy, GetStgFrameWidth/2, 100, 10,5);
	BossActions;
}

@MainLoop{

	yield;
}

task BossActions{
	ShootBullets;
//Texto;
	while(ObjEnemy_GetInfo(Enemy, INFO_LIFE) > 0){
		EnemyX = ObjMove_GetX(Enemy);
		EnemyY = ObjMove_GetY(Enemy);
		ObjEnemy_SetIntersectionCircleToShot(Enemy, EnemyX, EnemyY, 40);
		ObjEnemy_SetIntersectionCircleToPlayer(Enemy, EnemyX, EnemyY, 30);
                                          
		yield;
	}
DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	Obj_Delete(Enemy);
			if(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(), INFO_PLAYER_SHOOTDOWN_COUNT) == 0 && ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID(), INFO_PLAYER_SPELL_COUNT) == 0 ){
	SetCommonData("Perfects_Bombs",GetCommonData("Perfects_Bombs",perfectsB)+1);
	}
	if(GetCommonData("Perfects_Bombs",perfectsB) == 5){SetPlayerSpell(GetPlayerSpell+1); SetCommonData("Perfects_Bombs",0);NotifyEventAll(EV_USER+998,0)}
	loop(60){yield;}

	CloseScript(GetOwnScriptID);
}
function wait(t){loop(t){yield;}}

task ShootBullets{
wait(60);
PlaySFX(charge00);
nTestCharge(EnemyX,EnemyY,90,255,0,0);
wait(90);
PlaySFX(D7);
let rad = 80;
let angul = 0;
let angul2 = 0;
let spd = 0;
Attack2;
let C1 = [0,4,4,4];
let C2 = [0,3,4,5];
loop{

if(Obj_IsDeleted(Enemy)){break;}
let angul2 = 0.2;
loop(15){
if(Obj_IsDeleted(Enemy)){break;}
PlaySFX(tan00);
 MShot01(EnemyX,EnemyY,0-angul,5-spd,C2[GetDifficulty],C1[GetDifficulty],2,SMALL_RED,SMALL_RED);
 //MShot01(EnemyX,EnemyY,180+angul,5-spd,4,4,2,SMALL_RED,SMALL_RED);
 angul+= 20;
 spd+= angul2;
 wait(2);
 }
wait(120);
ObjMove_SetDestAtWeight(Enemy,GetStgFrameWidth/2+rand(80,-80),rand(20,140),10,4);
wait(120);
spd = 0;


}
}

task MShot01(x,y,angle,speed,count,shape,shapespeed,graphic,graphic2){
let a=CreateShotA2(x,y,speed,angle,-0.1,0,graphic,0);
wait(60);
if(!Obj_IsDeleted(a)){
PlaySFX(kira00);
 ShootShapeB(ObjMove_GetX(a),ObjMove_GetY(a),shapespeed,angle,shape,count,graphic2,0);
 }
 Obj_Delete(a);
}

task Attack2{
wait(260);
let C3 = [0,5,6,7];
loop{
if(Obj_IsDeleted(Enemy)){break;}
PlaySFX(tan01);
ShootShapeB(EnemyX,EnemyY,3,rand(0,360),7,C3[GetDifficulty],AMULET_BLUE,0);
 wait(40);
 }
}