#TouhouDanmakufu
#Title[Puppeteer "Grand Doll Performance"]
#Text[]
#Image[]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let frame=-100;
	let move_count=0;
    	let BossCutIn = GetCurrentScriptDirectory~"img\alice.png";
	#include_function ".\aliceanim.txt";
	#include_function ".\spellcard.txt";
task Dolls
{
	loop
	{
	ascent(i in 0..4)
	{
	CreateEnemyFromScript("Doll", GetX, GetY, 0, 0, [i*90, 1, i*90+180]);
	CreateEnemyFromScript("Doll", GetX, GetY, 0, 0, [i*90, -1, i*90+180]);
	}
	loop(300){yield;}
	ascent(i in 0..4)
	{
	CreateEnemyFromScript("Doll", GetX, GetY, 0, 0, [i*90, 1, i*90+90]);
	CreateEnemyFromScript("Doll", GetX, GetY, 0, 0, [i*90, -1, i*90+90]);
	}
	loop(300){yield;}
	}
}
	@Initialize
	{
		SetInvincibility(200);
		SetLife(500);
		SetDamageRate(10,10);
		LoadGraphic(BossCutIn);

		SetMovePosition02(GetCenterX,120,20);
		Concentration01(150);
		CutIn(YOUMU, " Puppeteer ''Grand Doll Performance'' ",BossCutIn,0,0,128,512);
		LoadUserShotData(GetCurrentScriptDirectory~"supershot.txt");

		SetCommonData("ONSPELL", "TRUE");
		spellbonus(3000000);
		timer;
		SetCommonData("timercount", 3600);
	}
	
	@MainLoop
	{
		SetDamageRate(10+floor(30-30*GetCommonData("timercount")/3600),5);
		SetCollisionA(GetX(),GetY(),24);
		SetCollisionB(GetX(),GetY(),24);
		frame++;
		yield;
		if(frame==0)
		{
		Dolls;
		}
}
	
	@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;
	animation;
	}
}

script_enemy Doll {
	#include_function ".\dollanim.txt";
	let frame=0;
	let angle=GetArgument[0];
	let angleb=GetArgument[2];
	let dist=0;
task bullets
{
	loop
	{
	PlaySE(GetCurrentScriptDirectory~"sound/Shot1.wav");
	CreateShot01(GetX, GetY, 1, angleb, 2, 30);
	loop(12){yield;}
	}
}

	@Initialize
	{
	SetLife(200);
	SetDamageRateEx(70, 30, 30, 0);
}
	@MainLoop
	{
	yield;
	angle+=GetArgument[1];
	angleb+=GetArgument[1]*7;
	SetX(GetEnemyX+dist*cos(angle));
	SetY(GetEnemyY+dist*sin(angle));
	if(frame==0)
	{
	bullets;
	frame=50;
	}
	frame++;
	if(frame<100){dist+=2;}
	if(frame>=100){dist-=2;}
	if(frame>200){frame=50;}
	if(dist>400){VanishEnemy;}
}
	@DrawLoop
	{
	anim2;
}
	@Finalize
	{
	}

}