#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Spell 4"]
#Text["Woop"]

let objBoss;
let BossX;
let BossY;

#include "./Functions/Index.txt"


@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	renderorin(objBoss);
	BossShotSound(objBoss, 100, 500);
	ObjEnemy_SetDamageRate(objBoss,0,0);
	BottomEnemyMarker(objBoss, objBoss);
	
	ObjMove_SetDestAtWeight(objBoss,384/2-24,150,5,5);
	mainTask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(2500);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(90);
	}
	case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}
} 

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

@Finalize {

} 

task SpellCall {
	bspell = true;
	TCallBg;
}

let orin = GetCurrentScriptDirectory ~ "Functions/img/orin.png";

task mainTask { 
wait(40);
attack = true;
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/chargelong.wav", 90);
wait(130);
	ObjCutin_SetSpellcardS3("Cat Sign &quot;Cat's Spiritual Pounce&quot;", 200, 00, 00);
	ObjCutin_LaunchS3("KANAKO", orin, "Normal");
	SpellCall;
	let objScene = GetEnemyBossSceneObjectID();
	ObjEnemyBossScene_StartSpell(objScene);
	wait(160);
	SpellBurstA1(BossX, BossY,"Cherry",[100, 00, 00]);
cat = true;
SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/kitty.wav", 100);
wait(120);
attack = false;
ObjEnemy_SetDamageRate(objBoss,70,70);
	loop{
	let dist = 0;
	ObjMove_SetDestAtWeight(objBoss,GetPlayerX+rand(-25,25),150+rand(-25,25),15,9);
	wait(30);
	
		loop(3){
		CatSpread(12, ICE_RED, 1.2);
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 70);
		ObjMove_SetDestAtWeight(objBoss,GetPlayerX+rand(-25,25),150+rand(-25,25),15,5);
		wait(60);
		}
		
		loop(5){
		ObjMove_SetDestAtWeight(objBoss,25,dist,5,20);
		ObjEnemy_SetDamageRate(objBoss,125,125);
		wait(30);
		CatSpread(28, ICE_BLUE, 1.8);
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 70);
		dist+=30;
		
		ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth-25,dist,5,20);
		wait(30);
		CatSpread(28, ICE_BLUE, 1.8);
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 70);
		dist+=30;
		}
		ObjEnemy_SetDamageRate(objBoss,70,70);
		ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth/2,0,15,25);
		wait(30);
		CatSpread(48, ICE_BLUE, 1.8);
		SE_Play(GetCurrentScriptDirectory ~ "Functions/sfx/smbullet.wav", 70);
	}
}

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