#東方弾幕風[Single]
#ScriptVersion[3]
#Title["SP2"]
#Text["Blep"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"

let objBoss;
let BossX;
let BossY;

@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	
	EnemyMarker(objBoss);
	HitSound(objBoss, 50, 450);
	RenderCharacter(objBoss);
	DamageReduction(objBoss, 320);
	
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-56, 10, 4);
	
	if(GetCommonData("IsStage", false)==false){
	LoadAssets;}
	
	Main;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(45);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),21);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),24);
	yield;
} 

@Finalize {
} 

task Main { 
	let path = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/cutin.png";
	SpellCard(210, "", [255, 60, 60], path, path, 20, 0.75, "Okina");
	
	let a = 0;
	Movement;
	Shoot;
	loop{
	ascent(j in 0..12){
	FireShotB2(BossX+75*cos(j*360/12+a), BossY+25*sin(j*360/12), 2*cos(j*360/12), -2+2*sin(j*360/12), 0, 0.05, 10, 10, SCALE_RED, 15);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	a+=3;
	wait(10);
	}
	
	task Shoot{
	loop{
	let random = rand(0,360);
		ascent(j in 0..24){
		FireShotA2(BossX, BossY,5, random+j*360/24, -0.1, 1, ORB_M_ORANGE, 20);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 90, 0);
	wait(90);
	}
	}
	
	task Movement{
	wait(60*4);
		loop{
		ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+100, GetStgFrameHeight/2-100, 10, 1);
		wait(60*4);
		ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2-100, GetStgFrameHeight/2-100, 10, 1);
		wait(60*4);
		ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-50, 10, 1);
		wait(60*6);
		}
	}
}

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 


