#Title[こいし通常５]
#Text[古明地こいしの通常]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss=csd~"img\ExKoishi.png";
        let angle=0;
	let shotseA=csd~"se\ShotSE02.wav";

    @Initialize {
        SetLife(2750);
        SetTimer(50);
        SetDamageRate(100,100);
	SetEnemyMarker(true);

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

        @MainLoop
        {
	if(count>=150&&count%10==0){
		SetShotDirectionType(ABSOLUTE);
		angle=GetAngleToPlayer;
		PlaySE(shotseA);
		let i=3;
		while(i<20)
		{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,i/1.2,angle+90,0,-0.02*i,0,176);
			SetShotDataA(shotA,49,3,angle,0,0,3,176);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,i/1.2,angle-90,0,-0.02*i,0,176);
			SetShotDataA(shotA,49,3,angle,0,0,3,176);
			FireShot(shotA);
			i++;
			}
		}
	if(count>=150&&count%20==0){
		SetShotDirectionType(ABSOLUTE);
		let shotA=0;
		CreateShotA(shotA,GetX,GetY,0);
		SetShotDataA(shotA,0,3,angle,0,0,0,24);
		FireShot(shotA);
		}
	if(count>=300&&count%300==0){
		SetMovePositionRandom01(rand(20,40),rand(20,40),3,GetClipMinX()+150,150,GetClipMaxX()-150,200);
		}
        	SetCollisionA(GetX(),GetY(),18);
        	SetCollisionB(GetX(),GetY(),18);
        	count++;
        yield;

}
    @Finalize {
		DeleteGraphic(imgBoss);
    }

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