#TouhouDanmakufu
#Title[Bro Sign "Fist Tornado"]
#Text[]
#Image[]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let frame=0;
    let BossCutIn=GetCurrentScriptDirectory~"FIST.png";
	#include_function ".\spellcard.txt";
	#include_function ".\fist_replace.txt";
task attack{
    let angle=0;
    PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
    Concentration01(60);
    loop(85){yield;}
    loop{
        loop(50){
            angle=rand(0, 359);
            PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
            ascent(i in 0..8){
                CreateShotA(1, GetX, GetY, 0);
                SetShotDataA(1, 0, 3, angle+i*45, rand(0.1, 1), -rand(0.01, 0.03), -rand(3, 5), RED01);
                SetShotDataA(1, 100, NULL, NULL, rand(0.1, 1), 0, 0, RED01);
                SetShotDataA(1, 150, NULL, NULL, rand(0.1, 1), rand(0.01, 0.03), rand(3, 5), RED01);
                SetShotDataA(1, 200, NULL, NULL, 0, rand(0.01, 0.03), rand(3, 5), RED01);
                FireShot(1);
            }
            loop(3){yield;}
        }
        loop(150){yield;}
        PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
        Concentration01(60);
        loop(60){yield;}
        loop(50){
            angle=rand(0, 359);
            PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
            ascent(i in 0..8){
                CreateShotA(1, GetX, GetY, 0);
                SetShotDataA(1, 0, 3, angle+i*45, -rand(0.1, 1), -rand(0.01, 0.03), -rand(3, 5), BLUE01);
                SetShotDataA(1, 100, NULL, NULL, -rand(0.1, 1), 0, 0, BLUE01);
                SetShotDataA(1, 150, NULL, NULL, -rand(0.1, 1), rand(0.01, 0.03), rand(3, 5), BLUE01);
                SetShotDataA(1, 200, NULL, NULL, 0, rand(0.01, 0.03), rand(3, 5), BLUE01);
                FireShot(1);
            }
            loop(3){yield;}
        }
        loop(150){yield;}
        PlaySE(GetCurrentScriptDirectory~"sound\Charge.wav");
        Concentration01(60);
        loop(60){yield;}
    }
}
task bossgraphic{
    yield;
    let obj=Obj_Create(OBJ_EFFECT);
    Obj_SetPosition(obj, GetX, GetY);
    ObjEffect_SetTexture(obj, BossCutIn);
    ObjEffect_SetLayer(obj, 4);
    ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
    ObjEffect_CreateVertex(obj, 4);
    ObjEffect_SetVertexUV(obj, 0, 0, 0);
    ObjEffect_SetVertexUV(obj, 1, 256, 0);
    ObjEffect_SetVertexUV(obj, 2, 0, 416);
    ObjEffect_SetVertexUV(obj, 3, 256, 416);
    ObjEffect_SetVertexXY(obj, 0, -128, -208);
    ObjEffect_SetVertexXY(obj, 1, 128, -208);
    ObjEffect_SetVertexXY(obj, 2, -128, 208);
    ObjEffect_SetVertexXY(obj, 3, 128, 208);
    ascent(i in 0..4){ObjEffect_SetVertexColor(obj, i, 255, 255, 255, 255);}
    while(Obj_BeDeleted(obj)==false){
        Obj_SetPosition(obj, GetX, GetY-121);
        ObjEffect_SetAngle(obj, 0, 0, 180);
        yield;
    }
}
	@Initialize
	{
		SetInvincibility(200);
		SetLife(500);
		LoadGraphic(BossCutIn);
		SetMovePosition02(GetCenterX,120,20);
		CutIn(YOUMU, "Bro Sign ''Fist Tornado''",BossCutIn,0,0,256,416);
		spellbonus(10000000);
		timer;
		SetCommonData("timercount", 5400);
        bossgraphic;
        SetCommonData("ONSPELL", "TRUE");
        if(GetCommonDataDefault("NOMISSCOUNT", -1)==-1){
            initmeh;
        }
	}
	
	@MainLoop
	{
        SetShotAutoDeleteClip(300, 300, 300, 300);
        if(OnBomb==true){SetDamageRate(0, 0);}else{SetDamageRate(10+floor(30-30*GetCommonData("timercount")/5400),5);}
		SetCollisionA(GetX(),GetY(),75);
		SetCollisionB(GetX(),GetY(),75);
		frame++;
		yield;
        if(frame==90){attack;}
}
	
	@Finalize
	{
        SetCommonData("ONSPELL", "FALSE");
        SetShotAutoDeleteClip(32, 32, 32, 32);
		AddScore(spellbonustotal);
		if(spellbonustotal>0)
		{
		PlaySE(GetCurrentScriptDirectory~"sound\se_cardget.wav");
		loop(50)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY+rand(20,100));
		}
		}else{
		loop(15)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY+rand(20,100));
		}
		}
		 
        if(GetMissCountInThisSpell==0){
            SetCommonData("NOMISSCOUNT", GetCommonData("NOMISSCOUNT")+1);
        }
	}
	
	@DrawLoop
	{
	}
}