#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["SP3"]
#Text["Baaaaaaaaaap"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"


let BossX;
let BossY;
let objBoss;



@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	HitSound(objBoss, 75, 450);
	RenderCharacter(objBoss);
	ObjEnemy_SetDamageRate(objBoss, 0, 0);
	
	if(GetCommonData("IsStage", false)==true){
	MagicRing(objBoss,false);
	}
	else{
	MagicRing(objBoss,true);
	SetCommonData("BossAlpha", 255);
	StageBackground;
	}
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/3, 10, 4);
	mainTask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(105);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
}

let appear = false; 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);

	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),21);
	yield;
} 

@Finalize {
} 

task mainTask { 
	SpellCard("Marsh March &quot;Slimy Slug's Army&quot;", [198, 132, 39], GetCurrentScriptDirectory ~ "./default_system/img/Ingame/Shou.png", 0);
	
	ObjEnemy_SetDamageRate(objBoss, 60, 70);
	
	loop{
	let scale = 60;
	let scale2 = 60;
	ascent(i in 0..64){
	let random = rand(0,360);
	let obj = CreateShotA1(GetPlayerX+scale*cos(random), GetPlayerY+scale*sin(random), 0, 0, BALL_S_YELLOW, 25);
	let random3 = rand(0,360);
	let obj2 = CreateShotA1(GetPlayerX+scale2*cos(random3), GetPlayerY+scale2*sin(random3), 0, 0, VORTEX_YELLOW, 25);
	Dissapear(obj);
	Dissapear(obj2);
	scale+=8;
	scale2+=8;
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 90);
	}
	
	let random = rand(0,200);
	ascent(i in 0..6){
	Slug(-100+random+i*124, 0);
	}
	wait(30);
	random = rand(0,200);
	ascent(i in 0..6){
	SlugReverse(-100+random+i*124, 0);
	}
	wait(30);
	random = rand(0,200);
	ascent(i in 0..6){
	Slug(-100+random+i*124, 0);
	}
	wait(30);
	}
	
	task Slug(x, y){
		ascent(j in 0..15){
		let obj2 = CreateShotA1(x, y, 4, 180, RICE_S_YELLOW, 35);
		Curve(obj2, 1);
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90);
		wait(3);
		}
	}
	task SlugReverse(x, y){
		ascent(j in 0..15){
		let obj3 = CreateShotA1(x, y, 4, 0, RICE_S_YELLOW, 35);
		CurveReversed(obj3, 1);
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90);
		wait(3);
		}
	}
	
	task Curve(obj, mult){
	wait(10);
	while(!Obj_IsDeleted(obj)){
	ObjMove_SetAngularVelocity(obj, 360/40*mult);
	wait(20);
	ObjMove_SetAngularVelocity(obj, 0);
	wait(10);
	ObjMove_SetAngularVelocity(obj, -360/40*mult);
	wait(20);
	ObjMove_SetAngularVelocity(obj, 0);
	wait(10);
	}
	}
	task CurveReversed(obj, mult){
	wait(10);
	while(!Obj_IsDeleted(obj)){
	ObjMove_SetAngularVelocity(obj, -360/40*mult);
	wait(20);
	ObjMove_SetAngularVelocity(obj, 0);
	wait(10);
	ObjMove_SetAngularVelocity(obj, 360/40*mult);
	wait(20);
	ObjMove_SetAngularVelocity(obj, 0);
	wait(10);
	}
	}	
	task Dissapear(obj){
	wait(60*5);
	ObjShot_FadeDelete(obj);
	}
}


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