#東方弾幕風
#Title[No.019　紅符「赤毛の和蘭人形改　-Normal-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\弾幕集.txt"

	let name    = "紅符「赤毛の和蘭人形改　-Normal-」";

	//初期位置
	let xini    =GetCenterX;
	let yini    =GetCenterY;

	@Initialize{
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(1750);
	SetTimer(49);
	SetScore(2500000 + spellbonus);
	SetDamageRate(50,10);
	SetInvincibility(120);

	LoadGraphic(imgboss2);
	SetTexture(imgboss2);
	SetGraphicRect(0,0,127,127);
	ShotA(1);
	Move();
	}

	@MainLoop{
	ChackBonus;
	SetCollisionA(GetX,GetY,24);
	SetCollisionB(GetX,GetY,24);

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss2);
	MasicPointAddSpellCard;
	loop(18 + scorebonus){
	let x = rand(GetX-32,GetX+32);
	let y = rand(GetY-32,GetY+32);
	CreateItem(ITEM_SCORE,x,y);}

	}

	task Move(){
	loop{
	yield;
	}
	}

	task ShotA(level){
	function Wait(time){loop(time){yield;}}
	let x;	let y;	let m = rand(-10,10);
	Wait(60);
	loop{
	x = 374;y = 128;m = rand(-4,4);
	loop(4){
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x -= 47; y += 75+m;
	Wait(12);m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x -= 47; y -= 45+m;
	Wait(12);m = rand(-4,4);
	}
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x -= 47; y += 75+m;
	if(level >= 2){
	loop(6){
	x +=40+m; y -= 23;m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	Wait(12);
	x -=20+m; y -= 23;m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	Wait(12);
	}
	}
	Wait(100);m = rand(-4,4);
	x = 65;	y = 128+m;
	loop(4){
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x += 47; y += 75+m;
	Wait(12);m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x += 47; y -= 45+m;
	Wait(12);m = rand(-4,4);
	}
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x += 47; y += 75+m;m = rand(-4,4);
	if(level >= 2){
	loop(6){
	x -=40+m; y -= 23;m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	Wait(12);
	x +=20+m; y -= 23;m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	Wait(12);
	}
	}
	Wait(100);
	}
	}

	task ShotB(level){
	function Wait(time){loop(time){yield;}}
	let x;	let y;	let m = rand(-4,4);
	Wait(60);
	loop{
	m = rand(-4,4);
	x = 65;	y = 128+m;
	loop(4){
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x += 47; y += 75+m;
	Wait(12);m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x += 47; y -= 45+m;
	Wait(12);m = rand(-4,4);
	}
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x += 47; y += 75+m;m = rand(-4,4);
	if(level >= 2){
	loop(6){
	x -=40+m; y -= 23;m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	Wait(12);
	x +=20+m; y -= 23;m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	Wait(12);
	}
	}
	Wait(100);
	x = 374;y = 128;m = rand(-4,4);
	loop(4){
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x -= 47; y += 75+m;
	Wait(12);m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x -= 47; y -= 45+m;
	Wait(12);m = rand(-4,4);
	}
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	x -= 47; y += 75+m;
	if(level >= 2){
	loop(6){
	x +=40+m; y -= 23;m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	Wait(12);
	x -=20+m; y -= 23;m = rand(-4,4);
	CreateEnemyFromScript("DOLL",x,y,0,0,level);
	Wait(12);
	}
	}
	Wait(100);
	}
	}
}

script_enemy DOLL
{
#include_function ".\弾幕集.txt"

	@Initialize{
	SetX(GetX);
	SetY(GetY);
	SetLife(30);
	SetScore(10);
	SetDamageRate(0,0);

	SetTexture(imgboss2);
	SetGraphicRect(766,0,798,32);
	Shot(GetArgument);
	Move();
	}

	@MainLoop{
	ChackBonus;

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	loop(scorebonus-7){
	let x = rand(GetX-32,GetX+32);
	let y = rand(GetY-32,GetY+32);
	CreateItem(ITEM_SCORE,x,y);}
	}

	task Move(){
	loop{
	yield;
	}
	}

	task Shot(level){
	function Wait(time){loop(time){yield;}}
	task CreateDifShot(x,y,speed,angle,angledif,bullet,deley){
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetX(obj, x);
	Obj_SetY(obj, y);
	Obj_SetSpeed(obj, speed);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, bullet);
	ObjShot_SetDelay(obj, deley);
	loop(20){yield;}
	Obj_SetAngle(obj, angle+angledif*4);	
	while( !Obj_BeDeleted(obj) ){
	yield;}
	}

	let angle = rand(0,360);
	let way = 4;
	let dif = rand(-6,6);
	if(level > 0){way = 6;}
	Wait(30);

	loop(way){
	loop(level + 5){
	dif = rand(-8,8);
	CreateDifShot(GetX+dif,GetY+dif,1,angle,dif,RED23,0);
	angle += 360 / way;
	}
	Wait(50);
	VanishEnemy;
	}
	}
}