#TouhouDanmakufu
#Title[Maid Secret Skill "Knife Cage"]
#Text[]
#Image[]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let type=0;
	let frame=-100;
	let move_count=0;
    	let BossCutIn = GetCurrentScriptDirectory~"img\sakuya_TS.png";
	#include_function ".\sakuyaanim.txt";
	#include_function ".\spellcard.txt";
task cage
{
	loop(20)
	{
	PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
	ascent(i in -1..3)
	{
	CreateShotA(1, GetPlayerX+i*70-35, GetPlayerY-150, 20);
	SetShotDataA(1, 0, 2, 90, 0, 0, 0, 218);
	SetShotKillTime(1, 150);
	FireShot(1);
	CreateShotA(1, GetPlayerX-150, GetPlayerY+i*70-35, 20);
	SetShotDataA(1, 0, 2, 0, 0, 0, 0, 218);
	SetShotKillTime(1, 150);
	FireShot(1);
	}
	loop(8){yield;}
	}
	PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
	TimeStop(100, 1, 1, 0);
	type=1;
	loop(20){yield;}
	wave;
	loop(80){yield;}
	type=0;
	PlaySE(GetCurrentScriptDirectory~"sound\BulletWave.wav");
	loop(200){yield;}
	loop(20)
	{
	PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
	ascent(i in -1..3)
	{
	CreateShotA(1, GetPlayerX+i*70-35, GetPlayerY-150, 20);
	SetShotDataA(1, 0, 2, 90, 0, 0, 0, 218);
	SetShotKillTime(1, 150);
	FireShot(1);
	CreateShotA(1, GetPlayerX-150, GetPlayerY+i*70-35, 20);
	SetShotDataA(1, 0, 2, 0, 0, 0, 0, 218);
	SetShotKillTime(1, 150);
	FireShot(1);
	}
	loop(8){yield;}
	}
	PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
	TimeStop(100, 1, 1, 0);
	type=1;
	loop(20){yield;}
	waveb;
	loop(80){yield;}
	type=0;
	PlaySE(GetCurrentScriptDirectory~"sound\BulletWave.wav");
	loop(200){yield;}
	cage;
}
task wave
{
	ascent(j in 3..10)
	{
	PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
	ascent(i in 0..20)
	{
	CreateShot01(GetPlayerX+j*30*cos(i*18), GetPlayerY+j*30*sin(i*18), 0.3, rand(0, 359), 216, rand_int(10, 30));
	}
	loop(3){yield;}
	}
}
task waveb
{
	ascent(j in 3..10)
	{
	PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
	ascent(i in 0..20)
	{
	CreateShot01(GetPlayerX+j*30*cos(i*18), GetPlayerY+j*30*sin(i*18), 0.7, i*30+180+j*45, 216, rand_int(10, 30));
	}
	loop(3){yield;}
	}
}
	@Initialize
	{
		SetInvincibility(200);
		SetLife(500);
		SetDamageRate(10,10);
		LoadGraphic(BossCutIn);

		SetMovePosition02(GetCenterX,120,20);
		Concentration01(150);
		CutIn(YOUMU, "Maid Secret Skill ''Knife Cage'' ",BossCutIn,0,0,256,512);
		LoadUserShotData(GetCurrentScriptDirectory~"supershot.txt");

		SetCommonData("ONSPELL", "TRUE");
		spellbonus(3000000);
		timer;
		SetCommonData("timercount", 5400);
	}
	
	@MainLoop
	{
		SetDamageRate(10+floor(30-30*GetCommonData("timercount")/5400),5);
		SetCollisionA(GetX(),GetY(),24);
		SetCollisionB(GetX(),GetY(),24);
		frame++;
		yield;
	if(frame==0)
	{
		cage;
	}
}
	
	@Finalize
	{
		AddScore(spellbonustotal);
		if(spellbonustotal>0)
		{
		PlaySE(GetCurrentScriptDirectory~"sound\se_cardget.wav");
		loop(50)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY+rand(20,100));
		}
		}else{
		loop(15)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY+rand(20,100));
		}
		}
		DeleteGraphic(BossCutIn);
		SetCommonData("ONSPELL", "FALSE");
	}
	
	@DrawLoop
	{
	spellbg;
	if(type==0)
	{
	anim2;
	}
	if(type==1)
	{
	animation2;
	}
	}
}