#東方弾幕風[Single]
#ScriptVersion[3]
#Title["SP3"]
#Text["Whoopsies"]
#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 {
} 

let aim;

task Main { 
wait(45);
let path = GetCurrentScriptDirectory ~ "./default_system/img/Par.png";
let path2 = GetCurrentScriptDirectory ~ "./default_system/img/Par2.png";
SpellCard(180, "Jealousy &quot;Murderer to Rule the Rocks&quot;", [12, 255, 12], path, path2, 50, 200, 0.5);

Reticle;

loop{
let a = 0;
let b = 0;
	ascent(x in 0..20){
		ascent(i in 0..6){
		FireShotB2(BossX, BossY, (2+1*sin(b*10))*cos(i*360/6+a), (2+1*sin(b*10))*sin(i*360/6+a), 0, 0.03, (2+1*sin(b*10))*cos(i*360/6+a), 3, DS_KNIFE_KOUMA_GREEN, 10);
		FireShotB2(BossX, BossY, (2+1*sin(b*10))*cos(i*360/6-a), (2+1*sin(b*10))*sin(i*360/6-a), 0, 0.03, (2+1*sin(b*10))*cos(i*360/6-a), 3, DS_KNIFE_KOUMA_SKY, 10);
		}
	b++;
	a+=6;
	PlaySound("smbullet", 60, 5);
	wait(12);
	}
wait(60);
ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-75, 75), GetStgFrameHeight/2-100+rand(-75, 75), 5, 2);
}
}

task Reticle{
aim = CreateShotA1(GetPlayerX, GetPlayerY, 0, 0, 0, 0);
ObjShot_SetIntersectionEnable(aim, 0);
let las = CreateStraightLaserA1(GetPlayerX, -10, 90, 0, 25, 0, DS_BEAM_BLUE, 99999999999999);
Length(las, 500, 60);
Shoot(las);
	while(!Obj_IsDeleted(las)){
	ObjMove_SetPosition(las, GetX(aim), -10);
	ObjMove_SetDestAtWeight(aim, GetPlayerX, GetPlayerY, 50, 5);
	yield;
	}
	
	task Shoot(las){
	loop{
	let obj = FireShotA1(GetX(las), GetY(las), 0, 90, DS_BALL_L_ORANGE, 20);
	Pos(obj);
	PlaySound("labullet", 70, 5);
	wait(40);
	}
	task Pos(obj){
	let i = 0;
	loop{
	ObjMove_SetPosition(obj, GetX(las), -10+i*2);
	i++;
	yield;
	}
	}
	}
}

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