#東方弾幕風[Single]
#ScriptVersion[3]
#Title["Mid2"]
#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);
	
	HitSound(objBoss, 50, 450);
	RenderNue(objBoss);
	DamageReduction(objBoss, 120);
	EnemyMarker(objBoss);
	
	
	SetCommonData("ForceLifebar", 0);
	
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-100, 5, 4);
	
	if(GetCommonData("IsStage", false)==false){
	LoadAssets;}
	
	Main;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4000);
     	}
	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 { 
wait(90);
SetCommonData("MidBossAlpha", 0);
ascent(i in 0..45){
let random = rand(0,360);
let randomrad = rand(0, 25);
MamiSmoke(BossX+randomrad*cos(random), BossY+randomrad*sin(random), rand(1, 2), rand(0,360), 0.5, 0, 5, 60);
}
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/barrage.wav", 60, 0);
RenderKogasa(objBoss);
wait(120);

let path = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/kog1.png";
let path2 = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/kog2.png";
SpellCard(160, "Umbrella Sign &quot;Midsummer Sprinkle&quot;", [122, 122, 255], path, path2, 5, 150, 0.4, "Kogasa");

Lazor;
loop{
Rain(1);
wait(180);
Rain(-1);
wait(180);
}

}

task Lazor{
loop{
ascent(i in 0..12){
CreateStraightLaserA1(BossX, BossY, GetAngleToPlayer(objBoss)+i*360/12, 500, 25, 120, LASER_C_BLUE, 60);
}
PlaySound(GetCurrentScriptDirectory ~ "default_system/se/laser1.wav", 70, 60);
wait(60*3);
}
}

task Rain(mult){
let a = 270;
let b = 0;
let graph = DROPLET_BLUE;
	ascent(j in 0..60*3){
		ascent(i in 0..5){
		FireShotA2(BossX+(180-j)*cos(a-22.5+11.25*i), BossY+(180-j)*sin(a-22.5+11.25*i), 0.5, a-22.5+11.25*i, 0.03, 10, graph, 10);
		}
	if(j > 60*3/2){graph = DROPLET_SKY;}
	if(mult == 1){	
	if(b < 10){b+=0.1;}}
	if(mult == -1){	
	if(b > -10){b-=0.1;}}
	a+=b;
	PlaySound(GetCurrentScriptDirectory ~ "default_system/se/smbullet.wav", 60, 0);
	wait(3);
	}
}

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

    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	SetCommonData("BossAlpha",255);
	SetCommonData("ForceLifebar", 0);
	StartSlow(TARGET_ALL, 15);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/death.ogg", 90, 0);
	loop(45){
	ParticleT(BossX, BossY, rand(1, 20), rand(0,360), 1, rand(0,360), "Cherry", [255, 10, 10], 10);
	ParticleT(BossX, BossY, rand(1, 20), rand(0,360), 1, rand(0,360), "Cherry", [155, 10, 155], 10);
	yield;
	}
	SetCommonData("bossx", BossX);
	SetCommonData("bossy", BossY);
	SetCommonData("RipMami", 1);
	StopSlow(TARGET_ALL);
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
	
} 


