#東方弾幕風
#Title[「ドゥームズデイ」]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "「ドゥームズデイ」";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_eiki.png"; 
    let imgFam  = csd ~ "img\familiar.png";
    let imgBG  = csd ~ "..\img\st6bg1.png";
SetRateScoreSystemEnable(false);
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
	let DrawY=330;
	let count=-wIni;
	let Alphanum=255;

	#include_function ".\..\txt\SpellCardBonusDefine.txt"
	let SpellTimer=150;

	let bgy=0;
	let EnemyLife=2500;
    @Initialize {

       LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");
	StartSpellHistory(100);

        SetLife(2500);
        SetDamageRate(1, 1);
        LoadGraphic(imgBoss);
        LoadGraphic(imgBG);
	InitializeAction();
	SetEffectForZeroLife(60,200,200);
        TMain;
    }

    @MainLoop {
	GetBossShadowPosition;
        SetCollisionA(GetX, GetY, 96);
        SetCollisionB(GetX, GetY, 16);
	Bonus=GetSpellCardBonusScore-(SpellBonus*3)/(SpellTimer*60);
        yield;

    }


    @DrawLoop {
	DrawBossShadow( imgBoss,150,255,0,255);
     	SetAlpha(Alphanum);
	DrawBoss( imgBoss );

	DrawSpellHistory;
    }

task Alpha
{
	loop
	{
		if(GetTimeOfPlayerInvincibility>15)
		{
			Alphanum=0;
			while(GetTimeOfPlayerInvincibility>10){yield;}
			wait(60);
 			Alphanum=255;
		}
		yield;
	}
}

    @Finalize {
        DeleteGraphic(imgBoss);
        DeleteGraphic(imgBG);
		EndSpellHistory(100);
    }
	@BackGround
	{
		SetTexture(imgBG);
		SetGraphicRect(0,0,1280,960+bgy);
		SetColor(150,150,150);
		SetAlpha(100);
		DrawGraphic(224, 240);
		bgy+=3;
	}
    // メインタスク
task TMain 
{
	Alpha;
	standBy;
	spell;
	Trate;
	Shot1;
	Shot2;
	Laser;
}

task Trate
{
	while(OnBomb==true){yield;}
	wait(120);
     	SetDamageRate(20, 20);
	loop
	{
		if(GetTimeOfPlayerInvincibility>15)
		{
     	   		SetDamageRate(1, 1);
			while(GetTimeOfPlayerInvincibility>0){yield;}
			wait(60);
     			SetDamageRate(20, 20);
		}
		yield;
	}
}




sub standBy//初期位置へ
{
	SetAction(ACT_MOVE, wIni);
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni);
	wait(wIni);
}

sub spell//発動モーション
{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
        SetTimer(SpellTimer);
        SetScore(SpellBonus);
	SetAction(ACT_SPELL,90);
	wait(90);
}


task Shot1
{
wait(180);
let color=165;
let angle=90;
let speed=2.5;
let rad=[];
rad=[20,40,60,80];
loop
{
/*	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180,color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[0],color,5);
*/	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180,color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[0],color,5);
	if(GetLife<EnemyLife*3/4 || GetTimer<90)
	{
/*	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[1],color,5);
*/	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[1],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[1],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[1],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[1],color,5);
	}
	if(GetLife<EnemyLife*2/4 || GetTimer<60)
	{
/*	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[2],color,5);
*/	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[2],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[2],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[2],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[2],color,5);
	}
	if(GetLife<EnemyLife*1/4 || GetTimer<30)
	{
/*	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[3],color,5);
*/	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[3],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[3],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[3],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[3],color,5);
	}
	angle+=8;
	wait(25);
}
}

task Shot2
{
wait(180);
let color=170;
let angle=90;
let speed=2.5;
let rad=[];
rad=[20,40,60,80];
loop
{
/*	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180,color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[0],color,5);
*/	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180,color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[0],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[0],color,5);
	if(GetLife<EnemyLife*3/4 || GetTimer<90)
	{
/*	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[1],color,5);
*/	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[1],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[1],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[1],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[1],color,5);
	}
	if(GetLife<EnemyLife*2/4 || GetTimer<60)
	{
/*	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[2],color,5);
*/	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[2],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[2],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[2],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[2],color,5);
	}
	if(GetLife<EnemyLife*1/4 || GetTimer<30)
	{
/*	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[3],color,5);
*/	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+rad[3],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle-rad[3],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[3],color,5);
	CreateShot01ToItem(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[3],color,5);
	}
	angle-=8;
	wait(25);
}
}

task Laser
{
loop
{
		Effect;
		CreateLaserA(0,GetX,GetY,800,90,PURPLE01,60);		
		SetLaserDataA(0,0,GetAngleToPlayer,0,0,0,0);
		SetShotKillTime(0,120);
		FireShot(0);
		wait(240);
}
}

task Effect
{
let rad=[];
let color1=RED01;
let color2=BLUE01;
rad=[15,30,45,60];
	EffectLaser(GetAngleToPlayer+90,color1);
	EffectLaser(GetAngleToPlayer+90+rad[0],color1);
	EffectLaser(GetAngleToPlayer+90-rad[0],color1);
	if(GetLife<EnemyLife*3/4 || GetTimer<90)
	{
		EffectLaser(GetAngleToPlayer+90+rad[1],color1);
		EffectLaser(GetAngleToPlayer+90-rad[1],color1);
	}
	if(GetLife<EnemyLife*2/4 || GetTimer<60)
	{
		EffectLaser(GetAngleToPlayer+90+rad[2],color1);
		EffectLaser(GetAngleToPlayer+90-rad[2],color1);
	}
	if(GetLife<EnemyLife*1/4 || GetTimer<30)
	{
		EffectLaser(GetAngleToPlayer+90+rad[3],color1);
		EffectLaser(GetAngleToPlayer+90-rad[3],color1);
	}

		EffectLaser(GetAngleToPlayer-90,color2);
		EffectLaser(GetAngleToPlayer-90+rad[0],color2);
		EffectLaser(GetAngleToPlayer-90-rad[0],color2);
	if(GetLife<EnemyLife*3/4 || GetTimer<90)
	{
		EffectLaser(GetAngleToPlayer-90+rad[1],color2);
		EffectLaser(GetAngleToPlayer-90-rad[1],color2);
	}
	if(GetLife<EnemyLife*2/4 || GetTimer<60)
	{
		EffectLaser(GetAngleToPlayer-90+rad[2],color2);
		EffectLaser(GetAngleToPlayer-90-rad[2],color2);
	}
	if(GetLife<EnemyLife*1/4 || GetTimer<30)
	{
		EffectLaser(GetAngleToPlayer-90+rad[3],color2);
		EffectLaser(GetAngleToPlayer-90-rad[3],color2);
	}
}

task EffectLaser(angle,color)
{

	CreateLaserA(0,GetX,GetY,800,20,color,60);		
	SetLaserDataA(0,0,angle,0,0,0,0);
	SetShotKillTime(0,120);
	FireShot(0);
}

#include_function ".\..\txt\data.txt"
#include_function ".\..\txt\Spelldata.txt"
#include_function ".\..\lib/lib_anime_Eiki.txt"
}
