#東方弾幕風[Single]
#ScriptVersion[3]
#Title["SP1"]
#Text["I gotta do some research before[r]adding some spell names in."]
#System["./default_system/Default_System.txt"]
#Background["./default_System/Default_Background.txt"]
#include"./default_system/Default_ShotConst.txt"
#include"./default_system/Default_Index.txt"

let objBoss;
let BossX;
let BossY;

@Initialize {
	SetPlayerClip(126, 12, 510, 468);
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);

	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-100, 5, 4);

	Initialization;
	
	Main;
	end;
} 

task Initialization{
	RenderCharacter(objBoss);
	MagicRing(objBoss);
	WaveCircle(true, false, true, 156);
	HitSound(objBoss,60,500);
	TimerCountdown;
	SetArmor(objBoss, [90, 80], 180);
	EnemyMarker(objBoss);
}

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(3000);}
	case(EV_REQUEST_TIMER){SetScriptResult(60);}
	case(EV_REQUEST_SPELL_SCORE){SetScriptResult(10000);}
	//case(EV_REQUEST_IS_DURABLE_SPELL){SetScriptResult(true);}
	//case(EV_REQUEST_IS_LAST_SPELL){SetScriptResult(true);}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	SetCommonData("BossX", BossX);
	SetCommonData("BossY", BossY);
	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);
let path = GetCurrentScriptDirectory ~ "./default_system/img/Par.png";
let path2 = GetCurrentScriptDirectory ~ "./default_system/img/Par2.png";
SpellCard(180, "Jealousy &quot;As Prettiest as the White in the Snow&quot;", [12, 255, 12], path, path2, 50, 200, 0.5);

loop{
Attack(80*3);
ascent(i in 0..20){
	ascent(j in 0..3){
		let obj = CreateLooseLaserA1(BossX, BossY-25, 3, GetAngleToPlayer(objBoss)+45+(i*(16-i/8))+j*24, 100, 15, DS_RICE_M_BLUE, 10); 
		Snow(obj);
		
	}	
	ascent(j in 0..3){
		let obj = CreateLooseLaserA1(BossX, BossY-25, 3, GetAngleToPlayer(objBoss)-45-(i*(16-i/8))-j*24, 100, 15, DS_RICE_M_BLUE, 10); 
		Snow(obj);
	}	
	PlaySound("smbullet", 60, 10);
	wait(6);
}
wait(60*2);
ascent(i in 0..3){
ascent(j in 0..16){
FireShotA1(BossX, BossY, 3, j*360/16+GetAngleToPlayer(objBoss), DS_BALL_L_GREEN, 10);
}
PlaySound("labullet", 60, 10);
wait(30);
}
wait(60);
ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-75, 75), GetStgFrameHeight/2-100+rand(-75, 75), 5, 8);
wait(20);
}
}

task Snow(obj){
while(!Obj_IsDeleted(obj)){
if(GetX(obj) < GetStageLeft){
CreateShotA2(GetX(obj), GetY(obj), 6, 180 - ObjMove_GetAngle(obj), -0.1, 1, DS_BALL_SS_BLUE, 5);
PlaySound("spirit", 60, 5);
}
if(GetY(obj) < GetStageUp){
CreateShotA2(GetX(obj), GetY(obj), 6, 360 - ObjMove_GetAngle(obj), -0.1, 1, DS_BALL_SS_BLUE, 5);
PlaySound("spirit", 60, 5);
}
if(GetX(obj) > GetStageRight){
CreateShotA2(GetX(obj), GetY(obj), 6, 180 - ObjMove_GetAngle(obj), -0.1, 1, DS_BALL_SS_BLUE, 5);
PlaySound("spirit", 60, 5);
}
wait(15);
}
}


task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	NotifyEvent(GetStageID, EV_USER_STAGE, [true, true, true, false, false, false]); //smexplosion, smparticles, items, bigexplosion, bigparticles, shake+slow
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 