#東方弾幕風
#Title[No.128 水符「スプラッシュフラッド　-Normal-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

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

	let name    = "水符「スプラッシュフラッド　-Normal-」";
	let count   = 0;

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

	@Initialize{
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(1000);
	SetTimer(100);
	SetScore(10000000 + spellbonus * 0.5);
	SetDamageRate(15,0);

	LoadGraphic(imgboss73);
	SetTexture(imgboss73);
	SetGraphicRect(0,0,127,127);
	SetInvincibility(150);
	Shot(1);
	Move();
	LoadUserShotData(GetCurrentScriptDirectory~"11-221Shot_データ.txt");
	}

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

	//EX風ボムバリア
	if(OnBomb() == true){SetInvincibility(2);}
	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}


	@Finalize{
	DeleteGraphic(imgboss73);
	MasicPointAddSpellCard;
	loop(50 + scorebonus * 10){
	let x = rand(GetX-96,GetX+96);
	let y = rand(GetY-96,GetY+96);
	CreateItem(ITEM_SCORE,x,y);}
	CreateItem(ITEM_1UP,GetX,GetY);
	SetCommonData("ON_SPELL",0);
	}

	task Move(){
	loop{
	loop(180){yield;}
	if(GetX >= GetPlayerX){
	SetMovePositionRandom01(rand_int(-8,0)*8,rand(-16,16),1,GetClipMinX + 128,GetCenterY-40,GetClipMaxX - 128,GetCenterY);
	}
	if(GetX < GetPlayerX){
	SetMovePositionRandom01(rand_int(0,8)*8,rand(-16,16),1,GetClipMinX + 128,GetCenterY-40,GetClipMaxX - 128,GetCenterY);
	}
	}
	}


	task SplashShot(x,y,speed,angle,bullet,delay,level){

	function FloodShot(level){
	function Wait(frame){loop(frame){yield;}}
	let rate = [7,26,192,63,169,51,103,134,13,38,116,147,10,44,184,162,100,72,155,85,141,89,15,129,57,121,118,160,0,32,77,187,128,91,30,96,69,53,176,94,125,49,172,173,197,153,23,41,8,94,114,97,191,105,91,110,80,140,112,73,189,144,64,67,36,165,137,142,163,87,19,193,106,47,21,66,151,180,2,198,132,108,88,136,29,43,55,54,82,93,123,140,39,18,76,131,126,43,92,145,62,1,27,115,153,181,24,74,101,31,195,167,117,5,157,177,48,178,17,133,186,135,45,99,111,199,9,59,71,156,120,20,42,166,65,56,182,138,159,61,178,174,22,68,104,148,130,60,175,4,11,171,81,161,28,83,143,168,37,58,170,152,124,75,14,194,132,139,90,46,164,109,84,6,79,200,158,78,12,146,86,33,102,198,149,185,52,183,127,95,196,70,3,113,122,35,117,190,98,16,188,30,107,154,179,25,188,50,119];
	let a = 0;
	let b = 100;
	let c = 50;
	let d = 150;
	Wait(24);
	loop(10 + level * 15){
	CreateShotA(1,Obj_GetX(obj),Obj_GetY(obj),15);
	SetShotDataA(1,0,rate[a] / 200 * 2,rate[b] / 5 * 9,0.02,rand(0,0.03),3,25);
	a++;
	b++;
	CreateShotA(2,Obj_GetX(obj),Obj_GetY(obj),15);
	SetShotDataA(2,0,rate[c] / 200 * 2,rate[d] / 5 * 9,-0.02,rand(0,0.03),3,26);
	c--;
	d--;
	if(a >= length(rate)){a -= length(rate);}
	if(b >= length(rate)){b -= length(rate);}
	if(c < 0){c += length(rate);}
	if(d < 0){d += length(rate);}
	CreateShotA(3,Obj_GetX(obj),Obj_GetY(obj),15);
	SetShotDataA(3,0,3-rate[a] / 200 * 2,rate[b] / 5 * 9,0.02,rand(0,-0.01),1,25);
	a++;
	b++;
	CreateShotA(4,Obj_GetX(obj),Obj_GetY(obj),15);
	SetShotDataA(4,0,3-rate[c] / 200 * 2,rate[d] / 5 * 9,-0.02,rand(0,-0.01),1,26);
	c--;
	d--;
	if(a >= length(rate)){a -= length(rate);}
	if(b >= length(rate)){b -= length(rate);}
	if(c < 0){c += length(rate);}
	if(d < 0){d += length(rate);}
	if(level >= 2){
	CreateShotA(5,Obj_GetX(obj),Obj_GetY(obj),15);
	SetShotDataA(5,0,3-rate[a] / 200 * 2,rate[b] / 5 * 9,0.06,rand(0,-0.01),1,25);
	a++;
	b++;
	CreateShotA(6,Obj_GetX(obj),Obj_GetY(obj),15);
	SetShotDataA(6,0,3-rate[c] / 200 * 2,rate[d] / 5 * 9,-0.06,rand(0,-0.01),1,26);
	c--;
	d--;
	if(a >= length(rate)){a -= length(rate);}
	if(b >= length(rate)){b -= length(rate);}
	if(c < 0){c += length(rate);}
	if(d < 0){d += length(rate);}
	FireShot(5);
	FireShot(6);
	}
	FireShot(1);
	FireShot(2);
	FireShot(3);
	FireShot(4);
	}
	}

	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, delay);
	ObjShot_SetBombResist(obj,true);
			
	
	while(Obj_GetX(obj)<=GetClipMaxX&&Obj_GetX(obj)>=GetClipMinX&&Obj_GetY(obj)<=GetClipMaxY&&Obj_GetY(obj)>=GetClipMinY){yield;}
	FloodShot(level);
	Obj_Delete(obj);
	}

	task Shot(level){
	let angle;
	let angleadd;
	loop(90){yield;}

	angleadd = 15;
	loop{
	angle = GetAngleToPlayer + 180 - (angleadd * level);
	loop(1 + level * 2){
	SplashShot(GetX,GetY,2,angle,45,20,level);
	angle += angleadd;
	}
	angleadd += 6.19;
	loop(200){yield;}
	}
	}
}