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

#include"script/default_system/Default_ShotConst.txt"
#include"./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;
//those Min and Max x y are taken from Shadow's Raimoo, Edited for full screen by Me(i am too honest :))
//if(ObjEnemy_GetInfo(Enemy, INFO_LIFE) == 0){break;}  my god "function"
let MinX = 0;
let MaxX = 640;
let MinY = 0;
let MaxY = GetStgFrameHeight*1.8;
@Event{
	alternative(GetEventType)
	case(EV_REQUEST_LIFE){SetScriptResult(2500);}
	case(EV_REQUEST_TIMER){SetScriptResult(50);}
case(EV_REQUEST_SPELL_SCORE){SetScriptResult(90000);}
}

@Initialize{
	Enemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(Enemy);
SetShotAutoDeleteClip(50,50,50,50);
ObjEnemyBossScene_StartSpell(GetEnemyBossSceneObjectID);
ObjEnemy_SetDamageRate(Enemy,40,10);
SetAutoDeleteObject(true);
name("Remilia Scarlet",0,30);
name("Yuyuko Saigyouki",0,40);
CutinSpell("Star Sign\"Star Trap\"",200,12);
InitializeAction(Enemy,GetCurrentScriptDirectory ~"img/dot_remilia.png");
DrawBoss_Task(Enemy);
spawnYuyuko;
SpellBGoverlay;
SpellBG1;
SpellBG2;
	ObjMove_SetDestAtFrame(Enemy, GetStgFrameWidth/2, 100, 60);
	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;
	}
	Obj_Delete(Enemy);
	loop(60){yield;}
	CloseScript(GetOwnScriptID);
}
function wait(t){loop(t){yield;}}

task ShootBullets{
wait(60);

}
function angleToPlayer{
let angle=atan2(GetPlayerY-EnemyY,GetPlayerX-EnemyX);
return angle;
}
task spawnYuyuko{
let yuyuko = ObjEnemy_Create(OBJ_ENEMY);
ObjEnemy_Regist(yuyuko);
ObjEnemy_SetLife(yuyuko,2500);
InitializeAction(yuyuko,GetCurrentScriptDirectory ~"img/dot_yuyuko.png");
DrawBoss_Task(yuyuko);
SetAction(yuyuko,YACT_STAND,999999999999999999999);
ObjMove_SetDestAtFrame(yuyuko, GetStgFrameWidth/2, 200, 60);
//yuyukoShot;
while(!Obj_IsDeleted(Enemy) && ObjEnemy_GetInfo(Enemy, INFO_LIFE) > 0 && ObjEnemy_GetInfo(yuyuko, INFO_LIFE) > 0){
yuyuX = ObjMove_GetX(yuyuko);
yuyuY = ObjMove_GetY(yuyuko);
ObjEnemy_SetIntersectionCircleToShot(Enemy, yuyuX, yuyuY, 40);
ObjEnemy_SetIntersectionCircleToPlayer(Enemy, yuyuX, yuyuY, 30);
                                  
		yield;
	}
Obj_Delete(yuyuko);
}
