
#Title[大妖精通常]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_daiyousei.png"; 
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let Step2=false;
	let wIni=60;
let TimeCounter=42*60;
let StandardTimeCounter=TimeCounter;
    @Initialize {
	SetCommonData("STAGE1BOSS",true);
	SetShotAutoDeleteClip(16,32,16,32);
        SetTimer(TimeCounter/60);
        SetLife(2700);
	InitializeAction();
	SetEnemyMarker(true);
	SetX(GetClipMaxX+16);
	SetY(GetCenterY-0);
        TMainGrobal;
    }

    @MainLoop {
	BulletNum=GetEnemyShotCount;
	TimeCounter-=1;
        yield;
    }

    @DrawLoop {
//DrawText(GetLife,120,382,12,255);//起動時間の表示
	DrawBoss( imgBoss );
    }

    @Finalize {
		if(!IsTimeOut)
		{
		SetCommonData("DeleteBulletNum",BulletNum);
		SetCommonData("DeleteBulletX",GetX);
		SetCommonData("DeleteBulletY",GetY);
		}

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

    // メインタスク
task TMainGrobal
{
	yield;
	GetDamege;
	OutDamageRateZero;
	Collision;
	//Lissajous(0,250,154);
	BossShadowAnimation(imgBoss,0,0,250,154);
	standBy;
	DamageRateChange;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}

}

sub standBy//初期位置へ
{
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni-96, yIni+48,30,8);
	wait(60);
	SetAction(ACT_MOVE, 60);
	SetMovePosition03(xIni, yIni, 20,5);
	wait(60);
	summon;
	Concentration01(30);
	//Concentration03(GetX,GetY,60,0,64,255);
}

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

	loop
	{
        SetCollisionA(GetX, GetY, 48);
        MSDSetCollisionB(GetX, GetY, 8);
	yield;
	}
}

task DamageRateChange
{
loop
{
	if(GetEnemyNum==3){DamageRate=100;}
	else if(GetEnemyNum==2){DamageRate=110;}
	else if(GetEnemyNum==1){DamageRate=120;}
yield;
}
}

task summon
{
        CreateEnemyFromScript("Familiar", GetX, GetY,
                              0, 0, 1);
        CreateEnemyFromScript("Familiar", GetX, GetY,
                              0, 0, -1);
}

task TMove
{
loop
{
//	SetMovePosition03(GetX+rand(-10,10), GetY+rand(-10,10), 20,5);
	wait(60);
}
}


task shotM
{
let looptime=0;
wait(30);
loop
{
	SetAction(ACT_SHOT_A,225);
	loop(5)
	{
	kunaishot(GetAngleToPlayer,73,looptime);
	wait(45);
	}
	wait(95);
	MoveToPlayer03(rand(50, 70), rand(-30, 30), 10,2,
                     GetClipMinX + 100, GetClipMinY +  32,
                     GetClipMaxX - 100, GetClipMinY + 128);
	ascent(let i in 0..15)
	{
		CreateShot01(GetX,GetY,3+0.3*i,90,73,5);
		wait(3);
	}
	wait(30);
	wait(60);
	summon;
	Concentration01(30);
	wait(30);
	looptime+=1;
}

task kunaishot(let angle,let color,looptime)
{
	loop(8)
	{
		ascent(let i in -(looptime+1)..looptime+2)
		{
			CreateShot01(GetX,GetY,3.5,angle+(30-5*looptime)*i,73,5);
		}
	wait(3);
	}
}

}
/////////////////////////////////////////////////////////////////////////////
task shotE
{
let looptime=0;
wait(30);
loop
{
	SetAction(ACT_SHOT_A,225);
	loop(5)
	{
	let angle=rand(0,360);
	ascent(let j in 0..8+looptime*2)
	{
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,3.0,angle+i*30+j*1.5,73,5);
		}
	}
	wait(45);
	}
	wait(95);
	MoveToPlayer03(rand(50, 70), rand(-30, 30), 10,2,
                     GetClipMinX + 100, GetClipMinY +  32,
                     GetClipMaxX - 100, GetClipMinY + 128);
	ascent(let i in 0..9)
	{
		CreateShot02(GetX,GetY,1,rand(60,120),0.05,5,73,5);
		wait(5);
	}
	wait(30);
	wait(60);
	summon;
	Concentration01(30);
	wait(30);
	looptime+=1;
}

}
//////////////////////////////////////////////////////////////////////
task shotA
{
let looptime=0;
wait(30);
loop
{
	SetAction(ACT_SHOT_A,225);
	loop(5)
	{
	kunaishot(GetAngleToPlayer,RED31);
	wait(45);
	}
	wait(95);
	MoveToPlayer03(rand(50, 70), rand(-30, 30), 10,2,
                     GetClipMinX + 100, GetClipMinY +  32,
                     GetClipMaxX - 100, GetClipMinY + 128);
	ascent(let i in 0..15)
	{
		CreateShot01(GetX,GetY,3+0.4*i,90,73,5);
		CreateShot01(GetX,GetY,3+0.4*i,45,73,5);
	//	CreateShot01(GetX,GetY,3+0.4*i,60,73,5);
		CreateShot01(GetX,GetY,3+0.4*i,120,73,5);
	//	CreateShot01(GetX,GetY,3+0.4*i,135,73,5);
		wait(3);
	}
	wait(30);
	wait(60);
	summon;
	Concentration01(30);
	wait(30);
	looptime+=1;
}

task kunaishot(let angle,let color)
{
	loop(5)
	{
	ascent(let i in -(looptime+2)..looptime+3)
	{
	CreateShot01(GetX,GetY,5,angle+i*(15-looptime*2),73,5);
	}
	wait(3);
	}
}

}

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

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
    @Initialize {
	SetCoordinateType(COODINATE_TYPE_PARENT);
	let num = GetArgument;
        SetLife(500);
        SetDamageRateEx(100,100,0,0);
        SetTexture(imgFam);
        setGraphic;
	TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 48);
        MSDSetCollisionB(GetX, GetY, 8);
        yield;
    }

    @DrawLoop {
      //  DrawGraphic(GetX, GetY);
    }

        @Finalize
        {
	if(GetEnemyLife>0)
	{
		loop(10)
		{
		FinalizeItemSet(1);
		}
	}
        }

    task TMain {
        yield;
	GetDamege;
	OutDamageRateZero;
	ZakoEnemyLifeDisplay;
	move;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","None"))
	case("Moderate")
	{
	shotM;
	}
	case("Extream")
	{
	shotE;
	}
	case("Apocalypse")
	{
	shotA;
	}
	ZakoEffect(255,0,0);
    }

task move
{
	SetMovePosition02(100*num, 0, 30);
	wait(30);
	let X=100*num;
	let Y=0;
	loop(365)
	{
	SetX(X);
	SetY(Y);
	yield;
	}
	SetAngle(GetAngleToPlayer);
	let speed=0;
	loop
	{
		SetSpeed(speed);
		speed+=0.1;
		yield;
		if(GetY>GetClipMaxY+32){VanishEnemy;}
	}

}

task shotM
{
wait(30);
loop(4)
{
let angle=GetAngleToPlayer;
ascent(let i in -3..4)
{
CreateShot01(GetX,GetY,3,angle+i*1.5,14,5);
}
wait(60);
}
wait(20);
let angle=rand(0,360);
ascent(let i in 0..12)
{
CreateShotA(0,GetX,GetY,5);
SetShotDataA(0,0,3,angle+i*30,6*num,0,0,16);
SetShotDataA(0,30,3,NULL,0,0,0,16);
SetShotKillTime(0,31);

CreateShotA(1,0,0,0);
SetShotDataA(1,0,4.5,180+angle+i*30,0,0,0,9);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,4.25,180+angle+i*30,0,0,0,10);
CreateShotA(3,0,0,0);
SetShotDataA(3,0,4.0,180+angle+i*30,0,0,0,11);
CreateShotA(4,0,0,0);
SetShotDataA(4,0,3.75,180+angle+i*30,0,0,0,12);
CreateShotA(5,0,0,0);
SetShotDataA(5,0,3.5,180+angle+i*30,0,0,0,13);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,3.25,180+angle+i*30,0,0,0,14);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,3.0,180+angle+i*30,0,0,0,15);

AddShot(30,0,1,0);
AddShot(30,0,2,0);
AddShot(30,0,3,0);
AddShot(30,0,4,0);
AddShot(30,0,5,0);
AddShot(30,0,6,0);

FireShot(0);
}
wait(60);

ascent(let i in 0..15)
{
	CreateShot01(GetX,GetY,3+0.3*i,90,78,5);
	wait(3);
}

}
/////////////////////////////////////////////////////////
task shotE
{
wait(30);
wait(15+num*15);
loop(4)
{
let angle=GetAngleToPlayer;
loop(10)
{
CreateShot01(GetX,GetY,5,angle,78,5);
wait(3);
}
wait(30);
}
wait(15-num*15);
let angle=rand(0,360);
ascent(let i in 0..24)
{
CreateShotA(0,GetX,GetY,5);
SetShotDataA(0,0,3,angle+i*15,6*num,0,0,16);
SetShotDataA(0,30,3,NULL,0,0,0,16);
SetShotKillTime(0,31);

CreateShotA(1,0,0,0);
SetShotDataA(1,0,4,180+angle+i*30,0,0,0,9);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,3.75,180+angle+i*30,0,0,0,10);
CreateShotA(3,0,0,0);
SetShotDataA(3,0,3.5,180+angle+i*30,0,0,0,11);
CreateShotA(4,0,0,0);
SetShotDataA(4,0,3.25,180+angle+i*30,0,0,0,12);
CreateShotA(5,0,0,0);
SetShotDataA(5,0,3,180+angle+i*30,0,0,0,13);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,2.75,180+angle+i*30,0,0,0,14);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,2.5,180+angle+i*30,0,0,0,15);

AddShot(30,0,1,0);
AddShot(30,0,2,0);
AddShot(30,0,3,0);
AddShot(30,0,4,0);
AddShot(30,0,5,0);
AddShot(30,0,6,0);
FireShot(0);
}
wait(50);

ascent(let i in 0..9)
{
	CreateShot02(GetX,GetY,1,rand(60,120),0.05,5,78,5);
	wait(5);
}

}
////////////////////////////////////////////////////////////
task shotA
{
wait(30);
loop(4)
{
	let angle=rand(0,360);
	ascent(let j in 0..11)
	{
		ascent(let i in 0..12)
		{
			CreateShot01(GetX,GetY,3.0,angle+i*30+j*1.5,78,5);
		}
	}
wait(60);
}
wait(20);
let angle=rand(0,360);
ascent(let i in 0..36)
{
CreateShotA(0,GetX,GetY,5);
SetShotDataA(0,0,3,angle+i*10,6*num,0,0,16);
SetShotDataA(0,30,3,NULL,0,0,0,16);
SetShotKillTime(0,31);

CreateShotA(1,0,0,0);
SetShotDataA(1,0,5,180+angle+i*30,0,0,0,9);
CreateShotA(2,0,0,0);
SetShotDataA(2,0,4.75,180+angle+i*30,0,0,0,10);
CreateShotA(3,0,0,0);
SetShotDataA(3,0,4.5,180+angle+i*30,0,0,0,11);
CreateShotA(4,0,0,0);
SetShotDataA(4,0,4.25,180+angle+i*30,0,0,0,12);
CreateShotA(5,0,0,0);
SetShotDataA(5,0,4,180+angle+i*30,0,0,0,13);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,3.75,180+angle+i*30,0,0,0,14);
CreateShotA(6,0,0,0);
SetShotDataA(6,0,3.75,180+angle+i*30,0,0,0,15);

AddShot(30,0,1,0);
AddShot(30,0,2,0);
AddShot(30,0,3,0);
AddShot(30,0,4,0);
AddShot(30,0,5,0);
AddShot(30,0,6,0);

FireShot(0);
}
wait(60);

ascent(let i in 0..15)
{
	CreateShot01(GetX,GetY,3+0.4*i,90,78,5);
	//CreateShot01(GetX,GetY,3+0.4*i,60,78,5);
	CreateShot01(GetX,GetY,3+0.4*i,45,78,5);
	CreateShot01(GetX,GetY,3+0.4*i,120,78,5);
	//CreateShot01(GetX,GetY,3+0.4*i,135,78,5);
	wait(3);
}

}
    // グラフィックの設定
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
#include_function ".\..\txt/StageEnemydata.txt"
}

#include_script ".\..\txt/EnemyShotData.txt"
