#Title[火車「死葬超特急」]
#Text[火焔猫燐のスペルカード]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name="火車「死葬超特急」";
        let csd=GetCurrentScriptDirectory;
        let imgBoss =csd~"img\ExOrin.png";
	let Motion=1;
	let angle=0;
	let bngle=100;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
	let shotseA=csd~"se\Powar.wav";
	let shotseB=csd~"se\BOM.wav";

    @Initialize {
    CutIn(YOUMU,name,0,0,0,0,0);

        SetLife(600);
        SetTimer(60);
        SetScore(3000000);
        SetDamageRate(50,25);

        SetInvincibility(100);
	LoadGraphic(imgBoss);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
    }

        @MainLoop
        {
	if(count==150){
		SetMovePosition02(-100,GetY,50);
		}
	if(count>=100&&count<=150&&count%2==0){
		PlaySE(shotseA);
        	SetDamageRate(50,25);
        	let shot01=1;
        	SetShotDirectionType(ABSOLUTE);
        	CreateShotA(shot01,GetX-20,GetY+15,5);
        	SetShotDataA(shot01,0,0.5,rand(0,360),0,0,0.5,67);
        	SetShotDataA(shot01,75,NULL,NULL,0,0.01,rand(0.5,1.5),67);
        	FireShot(shot01);
		}
	if(count>=150&&Motion==1){
        	SetDamageRate(bngle,25);
        	SetShotDirectionType(ABSOLUTE);
        	let shot01=1;
        	CreateShotA(shot01,GetX-30,GetY+15,0);
        	SetShotDataA(shot01,0,0.5,rand_int(0,360),0,0,0.5,67);
        	SetShotDataA(shot01,75,NULL,NULL,0,0.01,rand(0.5,1.5),67);
        	FireShot(shot01);
        	SetCollisionB(GetX(),GetY(),22);
		SetCollisionA(GetX(),GetY(),60);
		}
	if(count>=150&&Motion==-1){
        	SetDamageRate(bngle,25);
        	SetShotDirectionType(ABSOLUTE);
        	let shot01=1;
        	CreateShotA(shot01,GetX+30,GetY+15,0);
        	SetShotDataA(shot01,0,0.5,rand_int(0,360),0,0,0.5,67);
        	SetShotDataA(shot01,75,NULL,NULL,0,0.01,rand(0.5,1.5),67);
        	FireShot(shot01);
        	SetCollisionB(GetX(),GetY(),22);
		SetCollisionA(GetX(),GetY(),60);
		}
	if(count==225){
		PlaySE(shotseA);
		angle=GetPlayerY;
		let laser=0;
		CreateLaserA(laser,20,angle,600,100,71,25);
		SetLaserDataA(laser,0,0,0,0,0,0);
		SetShotKillTime(laser,25);
		FireShot(laser);
		SetMovePosition02(-100,angle,25);
		Motion=-1;
		bngle+=5;
		}
	if(count==250){
		PlaySE(shotseB);
		SetMovePosition02(548,angle,50);
		}
	if(count==325){
		PlaySE(shotseA);
		angle=GetPlayerY;
		let laser=0;
		CreateLaserA(laser,20,angle,600,100,71,25);
		SetLaserDataA(laser,0,0,0,0,0,0);
		SetShotKillTime(laser,25);
		FireShot(laser);
		SetMovePosition02(548,angle,25);
		Motion=1;
		bngle+=5;
		}
	if(count==350){
		PlaySE(shotseB);
		SetMovePosition02(-100,angle,50);
		count=150;
		}
	if(count<150){
		SetCollisionB(GetX(),GetY(),22);
		SetCollisionA(GetX(),GetY(),22);
		}
        count++;
        yield;
        }

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(Motion,1);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicAngle(0,0,0);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(128,0,255,127);}
		else {SetGraphicRect(256,0,383,127);}
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
	loop(50)
	{
		angle=rand(0,360);
		CreateItem(ITEM_SCORE,GetX+cos(angle)*rand(35,45),GetY+sin(angle)*rand(35,45));
	}
		DeleteGraphic(imgBoss);
        }
}