
#Title[文３]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_aya.png"; 
    let imgBoss2 =csd ~ "..\lib/dot_aya2.png"; 
	let imgEffect=csd ~ "..\img/effect_tiny.png";
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let Step2=false;
	let wIni=60;
let TimeCounter=75*60;
let StandardTimeCounter=TimeCounter;
    @Initialize {
	SetX(GetCommonDataDefault("BossX",0));
	SetY(GetCommonDataDefault("BossY",0));
	if(GetCommonDataDefault("ExclusiveBoss",false)==true)
	{
		BossTimer(TimeCounter);
	}
	else
	{
		SetTimer(TimeCounter/60);
	}
	SetCommonData("BossLastAttackColor",[0,100,255]);
	SetCommonData("BossLastAttack",true);
        SetLife(5200);
	InitializeAction();
	SetEnemyMarker(true);
        TMainGrobal;
    }

    @MainLoop {
	SetCommonData("BossX",GetX);
	SetCommonData("BossY",GetY);
	SetCommonData("BossLife",GetLife);
	BulletNum=GetEnemyShotCount;
	TimeCounter-=1;
        yield;
    }
    @DrawLoop {
	DrawBoss( imgBoss );
    }

	let FinalX=0;
	let FinalY=0;
    @Finalize {
SetCommonData("DisableSearch",false);
	DeleteAllEnemyWithoutBoss;
	SetCommonData("BossX",FinalX);
	SetCommonData("BossY",FinalY);
	SetCommonData("BossLife",GetLife);
	DeleteEnemyShotToItem(ALL);
		SetCommonData("AyaFinalX",FinalX);
		SetCommonData("AyaFinalY",FinalY);
		if(!IsTimeOut)
		{
		SetCommonData("DeleteBulletNum",BulletNum);
		SetCommonData("DeleteBulletX",GetX);
		SetCommonData("DeleteBulletY",GetY);
		}

	SetCommonData("VanishSignal",false);
	SetCommonData("TimeBonus",TimeCounter/StandardTimeCounter);
	SetCommonData("BossRate",30000);
    }

let ExTargetX=GetCenterX;
let ExTargetY=GetCenterY;
    // メインタスク
task TMainGrobal
{
	yield;
	//Lissajous(0,100,255);
	BossShadowAnimation(imgBoss2,0,0,100,255);
	standBy;
	AyaGetDamege;
	AyaDamageRate;
	Collision;
	wait(30);
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
}

sub standBy//初期位置へ
{
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni, 20,5);
	wait(90);
	//summon;
	Concentration01(30);
}

task AyaGetDamege
{
MagicCircle(false);
AyaGetDamegeItem;
loop(375)
{
	if(GetHitCount!=0)
	{
		ZakoColor=[150,150,255];
		SetColor(150,150,255);
		wait(10);
	}
	else
	{
		ZakoColor=[255,255,255];
		SetColor(255,255,255);
	}
yield;
}
}

task AyaGetDamegeItem
{
loop(375)
{
		if(GetHitCount!=0 && GetDistanceToPlayer<=60)
		{
			if(GetCommonData("BURSTLEVEL")==0)
			{
				loop(2)
				{
				ItemSet(GetX,GetY,2);
				}
			}
			if(GetCommonData("BURSTLEVEL")==3)
			{
				loop(2)
				{
				ItemSet(GetX,GetY,8);
				}
			}
		}
yield;
}

alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Moderate")
{
	loop
	{
		if(GetHitCount!=0 && GetPlayerY<=160)
		{
			if(GetCommonData("BURSTLEVEL")==0)
			{
				loop(2)
				{
				ItemSet(GetPlayerX,GetPlayerY,2);
				}
			}
			if(GetCommonData("BURSTLEVEL")==3)
			{
				loop(2)
				{
				ItemSet(GetPlayerX,GetPlayerY,8);
				}
			}
		}
		yield;
	}
}

case("Extream")
{
	let dis=0;
	loop
	{
		dis=((GetPlayerX-ExTargetX)^2+(GetPlayerY-ExTargetY)^2)^0.5;
		if(GetHitCount!=0 && dis<=60)
		{
			if(GetCommonData("BURSTLEVEL")==0)
			{
				loop(2)
				{
				ItemSet(GetPlayerX,GetPlayerY,2);
				}
			}
			if(GetCommonData("BURSTLEVEL")==3)
			{
				loop(2)
				{
				ItemSet(GetPlayerX,GetPlayerY,8);
				}
			}
		}
		yield;
	}
}
case("Apocalypse")
{
	let dis=0;
	loop
	{
		dis=((GetPlayerX-GetCenterX)^2+(GetPlayerY-GetCenterY)^2)^0.5;
		if(GetHitCount!=0 && dis>=150)
		{
			if(GetCommonData("BURSTLEVEL")==0)
			{
				loop(2)
				{
				ItemSet(GetPlayerX,GetPlayerY,2);
				}
			}
			if(GetCommonData("BURSTLEVEL")==3)
			{
				loop(2)
				{
				ItemSet(GetPlayerX,GetPlayerY,8);
				}
			}
		}
		yield;
	}
}

}

task AyaDamageRate
{
let DamageRate=0;
//let SRange=GetCommonData("MagicAbsorbShortRange");
//let LRange=GetCommonData("MagicAbsorbLongRange");
let SRange=60;
let LRange=150;
loop(375)
{
		if(GetDistanceToPlayer<=SRange)
		{
			DamageRate=120;
		}
		else if(GetDistanceToPlayer<=LRange)
		{
			DamageRate=100+20*(GetDistanceToPlayer-LRange)/(SRange-LRange);
		}
		else
		{
			DamageRate=100;
		}
		SetDamageRate(DamageRate,100);
yield;
}
alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
case("Moderate")
{
	loop
	{
		SetX(GetCenterX);
		SetY(-1000);
		if(GetPlayerY<=160)
		{
			DamageRate=120;
		}
		else if(GetPlayerY<=250)
		{
			DamageRate=100+20*(GetPlayerY-160)/(160-250);
		}
		else
		{
			DamageRate=100;
		}
		SetDamageRate(DamageRate,100);
	yield;
	}
}
case("Extream")
{
	let dis=0;
	let DamegaRateCoefficient=1.00;
	loop
	{
		SetX(GetCenterX);
		SetY(-1000);
		dis=((GetPlayerX-ExTargetX)^2+(GetPlayerY-ExTargetY)^2)^0.5;
		if(dis<=60)
		{
			DamageRate=120;
		}
		else if(dis<=150)
		{
			DamageRate=100+20*(dis-60)/(60-150);
		}
		else
		{
			DamageRate=100;
		}
		SetDamageRate(DamageRate*DamegaRateCoefficient,100);
		DamegaRateCoefficient+=5/5000;
	yield;
	}
}
case("Apocalypse")
{
	let dis=0;
	let DamegaRateCoefficient=1.00;
	loop
	{
		SetX(GetCenterX);
		SetY(-1000);
		dis=((GetPlayerX-GetCenterX)^2+(GetPlayerY-GetCenterY)^2)^0.5;
		if(dis>=150)
		{
			DamageRate=120;
		}
		else if(dis>=60)
		{
			DamageRate=100-20*(dis-60)/(60-150);
		}
		else
		{
			DamageRate=100;
		}
		SetDamageRate(DamageRate*DamegaRateCoefficient,100);
		DamegaRateCoefficient+=5/4000;
	yield;
	}
}

}

task Collision
{
	loop
	{
        SetCollisionA(GetX, GetY, 48);
        MSDSetCollisionB(GetX, GetY, 16);
	yield;
	}
}

task shotM
{
SpellDraw(22,6000);
TMove;

task TMove
{
	let X=0;
	let Y=0;
	let time=60;
	let speed=0;
	let angle=-10;
	AppearEffect(360);
	SetAction(ACT_MOVE, 120);
	SetMovePosition02(GetClipMaxX+160,100,60);
	wait(65);
loop(3)
{
	X=GetClipMinX-140;
	Y=rand(64,160);
	SetAction(ACT_MOVE, time);
	SetMovePosition02(X, Y,time);
	Shot1(1,time);
	wait(time+5);
	X=GetClipMaxX+140;
	Y=rand(64,160);
	SetAction(ACT_MOVE, time-10);
	SetMovePosition02(X, Y,time-10);
	Shot1(-1,time-10);
	wait(time-5);
	time-=20;
}
time=10;
loop(1)
{
	X=GetClipMinX-140;
	Y=rand(64,128);
	SetAction(ACT_MOVE, time);
	SetMovePosition02(X, Y,time);
	wait(time+5);
}
time=8;
SetCommonData("DisableSearch",true);
	loop
	{
		MoveLaser(1,time);
		wait(time);
		MoveLaser(-1,time);
		wait(time);
		
		}

	task Shot1(dir,frame)
	{
		loop(frame)
		{
			CreateShot12(GetX+rand(-50,50),GetY+rand(-50,50),rand(-0.1,-1)*dir,-rand(0.2, 0.5),0,0.02,0,2.5,45,10);
			wait(1);
		}	
	}

	task MoveLaser(dir, let frame) {
	
		let SX=GetCenterX+(GetCenterX-32)*dir;
		let PX=GetCenterX-(GetCenterX-32)*dir;
		let SY=rand(GetClipMinY+32,160);
		let PY=rand(GetClipMinY+32,160);
		
		let dis=((PX-SX)^2+(PY - SY)^2)^0.5;
		let angle=atan2(PY-SY,PX-SX);
		
		//SetShotColor(0,100,255);
		//CreateLaser01(SX,SY,50,angle,2*dis,20,2481,0);
		AyaLaser(SX,SY,50,angle,2*dis,20,241,0);
		//SetShotColor(255,255,255);	

		ascent(i in 0..frame)
		{
			let x=SX+(PX-SX)*i/frame;
			let y=SY+(PY-SY)*i/frame;
			LaserCol(x,y);
			MomijiEffect(x,y);
			FinalX=PX;
			FinalY=PY;
			CreateShot12(x+rand(-50,50),y+rand(-50,50),rand(-0.1,-1)*dir,-rand(0.2, 0.5),0,0.02,0,2.5,45,10);
			if(i==trunc(frame/2) && dir==1){
			shotL(rand(GetClipMinX,GetClipMaxX),y,rand(3,4),rand(240,300));}
		wait(1);
		}

		task LaserCol(x,y)
		{
			descent(i in 1..6)
			{
				SetCollisionA(x, y, 48/i);
				yield;
			}
		}

		task AyaLaser(SX,SY,speed,angle,leng,width,gra,delay)
		{
		let L=0;
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,SX,SY);
	//	Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);
		ObjShot_SetGraphic(obj,gra);
		ObjLaser_SetLength(obj,L);
		ObjLaser_SetWidth(obj,width);
		ObjLaser_SetSource(obj,false);
		Obj_SetCollisionToPlayer(obj,false);
		ObjShot_SetBombResist(obj,true);
		ObjShot_ToItem(obj,false);
		Obj_SetAutoDelete(obj,false);
		while(L<leng)
		{
			ObjLaser_SetLength(obj,L);
			L+=speed;
			yield;
		}
		loop(30)
		{
			Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(angle),Obj_GetY(obj)+speed*sin(angle));
			yield;
		}
		Obj_Delete(obj);
		}
	}

   task shotL(x,y,speed,angle) {
	if(rand_int(0,2)==0){return;}
	SetShotColor(0, 180, 255);

        let objE = Obj_Create(OBJ_SHOT);
        ObjShot_SetGraphic(objE, 245);
        Obj_SetAngle(objE, angle);
        Obj_SetSpeed(objE, speed);
        Obj_SetPosition(objE, x, y);
	Obj_SetAutoDelete(objE,false);
	ObjShot_SetBombResist(objE,true);
	ObjShot_ToItem(objE,false);

	SetShotColor(0, 0, 255);

        let objE2 = Obj_Create(OBJ_SHOT);
        ObjShot_SetGraphic(objE2, 246);
        Obj_SetAngle(objE2, angle);
        Obj_SetSpeed(objE2, speed);
        Obj_SetPosition(objE2, x, y);
	Obj_SetAutoDelete(objE2,false);
	ObjShot_SetBombResist(objE2,true);
	ObjShot_ToItem(objE2,false);

	SetShotColor(255, 255, 255);

        let frame = 0;
        while(Obj_BeDeleted(objE) == false)
	{
		if(frame%12==0)
		{
			ObjShot_SetDelay(objE, 13);
		}
		else if(frame%12==6)
		{
                	ObjShot_SetDelay(objE2, 13);
		}
		Obj_SetPosition(objE,Obj_GetX(objE)+speed*cos(angle),Obj_GetY(objE)+speed*sin(angle));
		Obj_SetPosition(objE2,Obj_GetX(objE)+speed*cos(angle),Obj_GetY(objE)+speed*sin(angle));
		frame++;
		if(frame>=60){break;}
		yield;
        }

	LightningShot(Obj_GetX(objE),Obj_GetY(objE),rand(70,110));
	descent(i in 0..13)
	{
                ObjShot_SetDelay(objE, i);
                ObjShot_SetDelay(objE2, i);
		yield;
	}
        ObjShot_SetDelay(objE, 0);
        Obj_SetSpeed(objE, speed);
        Obj_SetAngle(objE, angle);
        ObjShot_SetDelay(objE2, 0);
        Obj_SetSpeed(objE2, speed);
        Obj_SetAngle(objE2, angle);
        Obj_Delete(objE);
        Obj_Delete(objE2);
    }

}

task LightningShot(X,Y,Angle)
{
		let StandardAngle=Angle;

		let SX=X;
		let SY=Y;
		let PX=SX;
		let PY=SY;
		let RandumWide=0;
		while (SX>GetClipMinX-32 && SX<GetClipMaxX+32 && SY<GetClipMaxY+32)
		{
			loop (1)
			{
				if(StandardAngle>Angle)
				{
					Angle+=rand(0,RandumWide);
				}
				else
				{
					Angle-=rand(0,RandumWide);
				}
				SX+=14*cos(Angle);
				SY+=14*sin(Angle);
				Lightning(PX,PY,SX,SY);
				PX=SX;
				PY=SY;
				if(RandumWide<60)
				{
				RandumWide+=10;
				}
			}
			wait(1);
		}
}

	task Lightning(PX,PY,SX,SY)
	{
		let width=3;
		let leng=((SX-PX)^2+(SY-PY)^2)^(1/2)*1.5;
		let angle=atan2(SY-PY,SX-PX);

	//SetShotColor(200, 100, 200);

		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,PX,PY);
		Obj_SetAngle(obj,angle);
		ObjShot_SetGraphic(obj,159);
		ObjLaser_SetLength(obj,leng);
		ObjLaser_SetWidth(obj,width);
		ObjLaser_SetSource(obj,false);
		Obj_SetCollisionToPlayer(obj,false);
		ObjShot_SetBombResist(obj,true);
		ObjShot_ToItem(obj,false);

	SetShotColor(255, 255, 255);

		wait(60);
		ascent(i in 0..2)
		{
			thunderEffect(Obj_GetX(obj)+leng*cos(angle)*i/2,Obj_GetY(obj)+leng*sin(angle)*i/2);
			yield;
		}
		loop(10)
		{
			width += 0.9;
			ObjLaser_SetWidth(obj, width);
			yield;
		}
		Obj_SetCollisionToPlayer(obj,true);
		wait(60);
		ascent(i in 0..2)
		{
			thunderEffect(Obj_GetX(obj)+leng*cos(angle)*i/2,Obj_GetY(obj)+leng*sin(angle)*i/2);
			yield;
		}
		Obj_SetCollisionToPlayer(obj,false);
		loop(10)
		{
			width -= 1.2;
			ObjLaser_SetWidth(obj, width);
			yield;
		}
		Obj_Delete(obj);
	}

task thunderEffect(x,y)
{
	SetShotColor(100, 0, 100);
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,x,y);
	ObjShot_ToItem(obj,false);
	ObjShot_SetBombResist(obj,true);
	Obj_SetCollisionToPlayer(obj,false);
	ObjShot_SetDelay(obj,10);
	ObjShot_SetGraphic(obj,238);
	Obj_SetSpeed(obj,200);
	Obj_SetAngle(obj,rand(0,360));
	Obj_SetAlpha(obj,0);

	SetShotColor(255, 255, 255);
}

}
/////////////////////////////////////////////////////////////////////////////
task shotE
{
SpellDraw(25,6000);
	TMove;

	task TMove
	{
		let TargetX=GetCenterX;
		let TargetY=GetCenterY;
		let TargetSpeed=0.5;
		let TargetAngle=90;
		let X=0;
		let Y=0;
		let time=60;
		let speed=0;
		let angle=15;
		AppearEffect(360);
		SetAction(ACT_MOVE, 120);
		SetMovePosition02(GetClipMaxX+160, 160,60);
		wait(65);
		loop(3)
		{
			let MoveY=GetCenterY;
			X=GetClipMinX-140;
			Y=(MoveY-GetY)+MoveY+rand(-30,30);
			SetAction(ACT_MOVE, time);
			SetMovePosition02(X, Y,time);
			Shot1(1,time);
			wait(time+5);
			X=GetClipMaxX+140;
			let MoveY=GetCenterY;
			Y=(MoveY-GetY)+MoveY+rand(-30,30);
			SetAction(ACT_MOVE, time-10);
			SetMovePosition02(X, Y,time-10);
			Shot1(-1,time-10);
			wait(time-5);
			time-=20;
		}
		time=10;
		loop(1)
		{
			X=GetClipMinX-140;
			let MoveY=GetCenterY;
			Y=(MoveY-GetY)+MoveY+rand(-30,30);
			SetAction(ACT_MOVE, time);
			SetMovePosition02(X, Y,time);
			wait(time+5);
		}
		time=7;
SetCommonData("DisableSearch",true);
		TargetMove;
		loop
		{
			MoveLaser(TargetX+rand(-50,50),TargetY+rand(-30,30),angle,0,time);
			wait(time);
			angle+=3;
			MoveLaser(TargetX+rand(-50,50),TargetY+rand(-30,30),angle,1,time);
			wait(time);
			angle+=3;
		}

		task TargetMove
		{
			loop
			{
				TargetAngle=atan2(GetPlayerY-TargetY,GetPlayerX-TargetX);
				TargetX+=TargetSpeed*cos(TargetAngle);
				TargetY+=TargetSpeed*sin(TargetAngle);
				ExTargetX=TargetX;
				ExTargetY=TargetY;
				yield;
			}
		}
	}

	task Shot1(dir,frame)
	{
		loop(frame)
		{
			CreateShot12(GetX+rand(-50,50),GetY+rand(-50,50),rand(-0.1,-1)*dir,-rand(0.2, 0.5),0,0.02,0,2.5,45,10);
			wait(1);
		}	
	}

	task MoveLaser(CX,CY,angle,dir,frame)
	{
		let StartX=[GetClipMinX,GetClipMaxX][dir];
		let EndX=[GetClipMaxX,GetClipMinX][dir];
		let StartY=[GetClipMinY,GetClipMaxY][dir];
		let EndY=[GetClipMaxY,GetClipMinY][dir];

		let SX=CX;
		let PX=CX;
		let SY=CY;
		let PY=CY;
		if(dir==0){dir=-1;}
		while(PX>=GetClipMinX && PX<=GetClipMaxX && PY>=GetClipMinY && PY<=GetClipMaxY)
		{
			PX+=10*cos(angle)*dir;
			PY+=10*sin(angle)*dir;
		}

		while(SX<=GetClipMaxX && SX>=GetClipMinX && SY<=GetClipMaxY && SY>=GetClipMinY)
		{
			SX-=10*cos(angle)*dir;
			SY-=10*sin(angle)*dir;
		}
		
		let dis=((PX-SX)^2+(PY - SY)^2)^0.5;
		let angle=atan2(PY-SY,PX-SX);
		
		//SetShotColor(0,100,255);
		//CreateLaser01(SX,SY,50,angle,2*dis,20,248,0);
		AyaLaser(SX,SY,50,angle,2*dis,20,241,0);
		SetShotColor(255,255,255);	
		let ParaAngle=angle+90;
		if(dir==0){ParaAngle-=180;}
		let speedx=rand(-0.1,-1)*dir*cos(ParaAngle);
		let speedy=-rand(0.2, 0.5)*sin(ParaAngle);
		let ax=0.02*cos(ParaAngle);
		let ay=0.02*sin(ParaAngle);
		let maxx=2.5*cos(ParaAngle);
		let maxy=2.5*sin(ParaAngle);
		let scount=rand_int(0,4);
		ascent(i in 0..frame)
		{
			let x=SX+(PX-SX)*i/frame;
			let y=SY+(PY-SY)*i/frame;
			LaserCol(x,y);
			MomijiEffect(x,y);
			FinalX=PX;
			FinalY=PY;
			if(scount%4!=3)
			{
			CreateShot12(x+rand(-50,50),y+rand(-50,50),speedx,speedy,ax,ay,maxx,maxy,45,10);
			CreateShot12(x+rand(-50,50),y+rand(-50,50),speedx,speedy,ax,ay,maxx,maxy,45,10);
			}
			if(i==trunc(frame/2) && dir==1){
			}
		scount+=1;
		wait(1);
		}

		task LaserCol(x,y)
		{
			descent(i in 1..7)
			{
				SetCollisionA(x, y, 48/i);
				yield;
			}
		}

		task AyaLaser(SX,SY,speed,angle,leng,width,gra,delay)
		{
		let L=0;
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,SX,SY);
	//	Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);
		ObjShot_SetGraphic(obj,gra);
		ObjLaser_SetLength(obj,L);
		ObjLaser_SetWidth(obj,width);
		ObjLaser_SetSource(obj,false);
		Obj_SetCollisionToPlayer(obj,false);
		ObjShot_SetBombResist(obj,true);
		ObjShot_ToItem(obj,false);
		Obj_SetAutoDelete(obj,false);
		while(L<leng)
		{
			ObjLaser_SetLength(obj,L);
			L+=speed;
			yield;
		}
		loop(30)
		{
			Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(angle),Obj_GetY(obj)+speed*sin(angle));
			yield;
		}
		Obj_Delete(obj);
		}

	}
}
//////////////////////////////////////////////////////////////////////
task shotA
{
SpellDraw(29,6000);
	TMove;

	task TMove
	{
		let X=0;
		let Y=0;
		let time=60;
		let speed=0;
		let angle=-10;
		AppearEffect(360);
		SetAction(ACT_MOVE, 120);
		SetMovePosition02(GetClipMaxX+160, 100,60);
		wait(65);
		loop(1)
		{
			X=GetCenterX;
			Y=GetClipMaxY+140;
			SetAction(ACT_MOVE, time);
			SetMovePosition02(X, Y,time);
			Shot1(X,Y,0,1,time);
			wait(time+5);
			X=GetClipMinX-140;
			Y=GetCenterY-100;
			SetMovePosition02(X, Y,time-10);
			SetAction(ACT_MOVE, time-10);
			Shot1(X,Y,3,1,time-10);
			wait(time-5);
			time-=20;

			X=GetCenterX+150;
			Y=GetClipMinY-140;
			SetAction(ACT_MOVE, time);
			SetMovePosition02(X, Y,time);
			Shot1(X,Y,2,1,time);
			wait(time+5);
			X=GetClipMaxX-40;
			Y=GetClipMaxY+140;
			SetAction(ACT_MOVE, time-10);
			SetMovePosition02(X, Y,time-10);
			Shot1(X,Y,1,1,time-10);
			wait(time-5);
			time-=20;

			X=GetClipMinX-140;
			Y=GetCenterY-100;
			SetAction(ACT_MOVE, time);
			SetMovePosition02(X, Y,time);
			Shot1(X,Y,0,1,time);
			wait(time+5);
			X=GetClipMaxX+140;
			Y=GetCenterY-100;
			SetAction(ACT_MOVE, time-10);
			SetMovePosition02(X, Y,time-10);
			Shot1(X,Y,3,1,time-10);
			wait(time-5);
			time-=20;
		}
		time=10;
		loop(1)
		{
			X=GetCenterX;
			Y=GetClipMaxY+140;
			SetAction(ACT_MOVE, time);
			SetMovePosition02(X, Y,time);
			Shot1(X,Y,2,3,time);
			wait(time+5);
		}
		time=8;
SetCommonData("DisableSearch",true);
		loop
		{
			MoveLaser(3,rand_int(0,1),time);
			wait(time);
			MoveLaser(0,rand_int(0,1),time);
			wait(time);
			MoveLaser(1,rand_int(0,1),time);
			wait(time);
			MoveLaser(2,rand_int(0,1),time);
			wait(time);		
		}
	}

	task Shot1(PX,PY,dir,rotdir,frame)
	{
		let SX=GetX;
		let SY=GetY;

		let dis=((PX-SX)^2+(PY - SY)^2)^0.5;
		let angle=atan2(PY-SY,PX-SX);
			
		let ParaAngle=angle+90;
		if(rotdir==0){ParaAngle-=180;}
		let speedx=rand(-0.1,-1)*dir*cos(ParaAngle);
		let speedy=-rand(0.2, 0.5)*sin(ParaAngle);
		let ax=0.02*cos(ParaAngle);
		let ay=0.02*sin(ParaAngle);
		let maxx=2.5*cos(ParaAngle);
		let maxy=2.5*sin(ParaAngle);
		ascent(i in 0..frame)
		{
			CreateShot12(GetX+rand(-50,50),GetY+rand(-50,50),speedx,speedy,ax,ay,maxx,maxy,45,10);
			wait(1);
		}	
	}

	task MoveLaser(dir,rotdir,frame)
	{
		let SX=GetCenterX+(GetCenterX-32)*dir;
		let PX=GetCenterX-(GetCenterX-32)*dir;
		let SY=rand(GetClipMinY+32,160);
		let PY=rand(GetClipMinY+32,160);
		let ram=rand_int(0,1);
		let IntialX=[GetClipMinX,GetClipMaxX];
		let IntialY=[GetClipMinY,GetClipMaxY];
		alternative(dir)
		case(0)
		{
			if(ram==0)
			{
				SY=rand(GetClipMinY,GetCenterY);
			}
			else
			{
				SY=rand(GetClipMaxY,GetCenterY);
			}

			SX=GetClipMaxX;

			if(rotdir==1)
			{
				PY=GetClipMaxY;
			}
			else
			{
				PY=GetClipMinY;
			}
			if(ram==0)
			{
				if(rotdir==1)
				{
					PX=rand(GetClipMaxX,GetCenterX);
				}
				else
				{
					PX=rand(GetClipMinX,GetCenterX);
				}
			}
			else
			{
				if(rotdir==1)
				{
					PX=rand(GetClipMinX,GetCenterX);
				}
				else
				{
					PX=rand(GetClipMaxX,GetCenterX);
				}
			}
		}
		case(1)
		{
			if(ram==0)
			{
				SX=rand(GetClipMinX,GetCenterX);
			}
			else
			{
				SX=rand(GetClipMaxX,GetCenterX);
			}
			SY=GetClipMinY;

			if(rotdir==1)
			{
				PX=GetClipMaxX;
			}
			else
			{
				PX=GetClipMinX;
			}
			if(ram==0)
			{
				if(rotdir==1)
				{
					PY=rand(GetClipMinY,GetCenterY);
				}
				else
				{
					PY=rand(GetClipMaxY,GetCenterY);
				}
			}
			else
			{
				if(rotdir==1)
				{
					PY=rand(GetClipMaxY,GetCenterY);
				}
				else
				{
					PY=rand(GetClipMinY,GetCenterY);
				}
			}			
		}
		case(2)
		{
			if(ram==0)
			{
				SY=rand(GetClipMinY,GetCenterY);
			}
			else
			{
				SY=rand(GetClipMaxY,GetCenterY);
			}
			SX=GetClipMinX;

			if(rotdir==1)
			{
				PY=GetClipMinY;
			}
			else
			{
				PY=GetClipMaxY;
			}
			if(ram==0)
			{
				if(rotdir==1)
				{
					PX=rand(GetClipMaxX,GetCenterX);
				}
				else
				{
					PX=rand(GetClipMinX,GetCenterX);
				}
			}
			else
			{
				if(rotdir==1)
				{
					PX=rand(GetClipMinX,GetCenterX);
				}
				else
				{
					PX=rand(GetClipMaxX,GetCenterX);
				}
			}	
		}
		case(3)
		{
			if(ram==0)
			{
				SX=rand(GetClipMinX,GetCenterX);
			}
			else
			{
				SX=rand(GetClipMaxX,GetCenterX);
			}
			SY=GetClipMaxY;

			if(rotdir==1)
			{
				PX=GetClipMinX;
			}
			else
			{
				PX=GetClipMaxX;
			}
			if(ram==0)
			{
				if(rotdir==1)
				{
					PY=rand(GetClipMinY,GetCenterY);
				}
				else
				{
					PY=rand(GetClipMaxY,GetCenterY);
				}
			}
			else
			{
				if(rotdir==1)
				{
					PY=rand(GetClipMaxY,GetCenterY);
				}
				else
				{
					PY=rand(GetClipMinY,GetCenterY);
				}
			}
		}
		
		let dis=((PX-SX)^2+(PY - SY)^2)^0.5;
		let angle=atan2(PY-SY,PX-SX);
		
		//SetShotColor(0,100,255);
		//CreateLaser01(SX,SY,50,angle,2*dis,20,248,0);
		AyaLaser(SX,SY,50,angle,2*dis,20,241,0);
		SetShotColor(255,255,255);	
		let ParaAngle=angle+90;
		if(rotdir==0){ParaAngle-=180;}
		let speedx=rand(-0.1,-1)*dir*cos(ParaAngle);
		let speedy=rand(0.2, 0.5)*sin(ParaAngle);
		let ax=0.02*cos(ParaAngle);
		let ay=0.02*sin(ParaAngle);
		let maxx=2.0*cos(ParaAngle);
		let maxy=2.0*sin(ParaAngle);
		let scount=rand_int(0,1);
		ascent(i in 0..frame)
		{
			let x=SX+(PX-SX)*i/frame;
			let y=SY+(PY-SY)*i/frame;
			LaserCol(x,y);
			MomijiEffect(x,y);
			FinalX=PX;
			FinalY=PY;
			if(scount%3!=2)
			{
			CreateShot12(x+rand(-50,50),y+rand(-50,50),speedx,speedy,ax,ay,maxx,maxy,45,10);
			}
			if(i==trunc(frame/2) && dir==1){
			}
		scount+=1;
		wait(1);
		}

		task LaserCol(x,y)
		{
			descent(i in 1..8)
			{
				SetCollisionA(x, y, 48/i);
				yield;
			}
		}

		task AyaLaser(SX,SY,speed,angle,leng,width,gra,delay)
		{
		let L=0;
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,SX,SY);
	//	Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);
		ObjShot_SetGraphic(obj,gra);
		ObjLaser_SetLength(obj,L);
		ObjLaser_SetWidth(obj,width);
		ObjLaser_SetSource(obj,false);
		Obj_SetCollisionToPlayer(obj,false);
		ObjShot_SetBombResist(obj,true);
		ObjShot_ToItem(obj,false);
		Obj_SetAutoDelete(obj,false);
		while(L<leng)
		{
			ObjLaser_SetLength(obj,L);
			L+=speed;
			yield;
		}
		loop(30)
		{
			Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(angle),Obj_GetY(obj)+speed*sin(angle));
			yield;
		}
		Obj_Delete(obj);
		}
	}
}

task AppearEffect(w)
{
loop(w/2)
{
	AMomijiEffect;
	yield;
	yield;
}
}

task AMomijiEffect//紅葉の設定
{
		let R=255;let G=rand(0,165); let B=0;
		let Angle=rand(0,360);
		let Speed=rand(0.2,0.4);
		let RotateAngle=rand(2,10);
		let Zangle=rand(0,360);
		let dir=rand_int(0,1)*2-1;
		let Scale=1.0;
		let Alpha=150;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgEffect);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -16, -16);
		ObjEffect_SetVertexXY(obj, 1, 16,  -16);
		ObjEffect_SetVertexXY(obj, 2, 16, 16);
		ObjEffect_SetVertexXY(obj, 3,  -16,  16);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  32, 0);
		ObjEffect_SetVertexUV(obj, 2, 32,  32);
		ObjEffect_SetVertexUV(obj, 3, 0, 32);
		ObjEffect_SetLayer(obj,4);
		ObjEffect_SetScale(obj, Scale,Scale);
		
		ObjEffect_SetVertexColor(obj,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,3,Alpha,R,G,B);

		Obj_SetPosition(obj,GetX+10*cos(Angle),GetY+10*sin(Angle));
		Obj_SetAngle(obj,Angle);
		Obj_SetSpeed(obj,Speed);

		if(GetCommonDataDefault("LightMode_SpecialEffect",0)==1){Obj_Delete(obj);return;}

		loop(30)
		{
			ObjEffect_SetAngle(obj,0,0,Zangle);
			ObjEffect_SetScale(obj, Scale,Scale);
			Zangle+=RotateAngle*dir;
			Scale-=1.0/30;
			yield;
		}
		Obj_Delete(obj);
}

task MomijiEffect(X,Y)//紅葉の設定
{
		let R=255;let G=rand(0,165); let B=0;
		let Angle=rand(70,110);
		let Speed=rand(0.5,1.0);
		let RotateAngle=rand(2,10);
		let Zangle=rand(0,360);
		let dir=rand_int(0,1)*2-1;
		let Scale=rand(0.5,1.0);
		let Sscale=Scale;
		let time=rand_int(20,40);
		let Alpha=150;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgEffect);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -16, -16);
		ObjEffect_SetVertexXY(obj, 1, 16,  -16);
		ObjEffect_SetVertexXY(obj, 2, 16, 16);
		ObjEffect_SetVertexXY(obj, 3,  -16,  16);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  32, 0);
		ObjEffect_SetVertexUV(obj, 2, 32,  32);
		ObjEffect_SetVertexUV(obj, 3, 0, 32);
		ObjEffect_SetLayer(obj,4);
		ObjEffect_SetScale(obj, Scale,Scale);
		
		ObjEffect_SetVertexColor(obj,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj,3,Alpha,R,G,B);

		Obj_SetPosition(obj,X+10*cos(Angle),Y+10*sin(Angle));
		Obj_SetAngle(obj,Angle);
		Obj_SetSpeed(obj,Speed);

		if(GetCommonDataDefault("LightMode_SpecialEffect",0)==1){Obj_Delete(obj);return;}

		loop(time)
		{
			ObjEffect_SetAngle(obj,0,0,Zangle);
			ObjEffect_SetScale(obj, Scale,Scale);
			Zangle+=RotateAngle*dir;
			Scale-=Sscale/time;
			yield;
		}
		Obj_Delete(obj);
}

#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Aya.txt"
}