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


#include"./lib/WormShot_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,160);
ObjRender_SetPosition(Enemy,GetStgFrameWidth/2, 100,0);
SetAutoDeleteObject(true);
InitializeAction(Enemy,MichaelDot);
DrawBoss_Task(Enemy);
name("Michael Derpy",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,5);
TAura(Enemy,5);
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,0,0,255);
wait(90);
let rad = 80;
let angul = 0;
let angul2 = 0;
let b_count = [0,5,8,11,14];
//let bullets = [0,3,3,3,3];
loop{
angul += 0;
if(Obj_IsDeleted(Enemy)){break;}
PlaySFX(tan00);
ascent(i in 0..8){
 let dd =CreateShotA1(EnemyX+130*cos(90+i*360/8),EnemyY+130*sin(90+i*360/8) ,0 ,90+i*360/8 ,289+i ,30 );
 //ObjRender_SetScaleXYZ(dd,3 ,3 ,2 );
 }
 ascent(i in 0..8){
 	let ces = CreateCurveLaserA1(EnemyX,EnemyY ,5 ,90+i*360/8 ,50 ,20 ,297+i ,0 );
 	ObjCrLaser_SetTipDecrement(ces, 0);
 	ObjMove_SetAngularVelocity(ces,1 );
 let dd =CreateShotA1(EnemyX+100*cos(90+i*360/8),EnemyY+100*sin(90+i*360/8) ,0 ,90+i*360/8 ,288 ,30 );
 //ObjRender_SetScaleXYZ(dd,2 ,2 ,2 );
 }
 //ObjMove_SetDestAtWeight(Enemy, GetStgFrameWidth/2+rand(50,-50), 100+rand(50,-50), 10,3);
 //MoveCheck(Enemy);
wait(600);

}
}

