#e
#Title[uo^tCeyXgv]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "uo^tCeyXgv";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_wriggle.png"; 
    let imgFam  = csd ~ "img\familiar.png";
    let imgBG  = csd ~ "..\img\st3bg1.png";
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
	let DrawY=330;
	let count=-wIni;

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

	let bgx=0;
	let bgy=0;
    @Initialize {
SetShotAutoDeleteClip(16,16,16,16);
       LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");
	StartSpellHistory(36);
        SetLife(900);
        SetDamageRate(1, 1);
        LoadGraphic(imgBoss);
        LoadGraphic(imgBG);
	InitializeAction();
        TMain;
    }

    @MainLoop {
	GetBossShadowPosition;
        SetCollisionA(GetX, GetY, 48);
        SetCollisionB(GetX, GetY, 8);
	Bonus=GetSpellCardBonusScore-(SpellBonus*3)/(SpellTimer*60);
        yield;
	bgx+=1;
	bgy-=1;
    }

    @DrawLoop {
	DrawBossShadow( imgBoss,150,255,255,0);
	DrawBoss( imgBoss );
	DrawSpellHistory;
    }

    @Finalize {
        DeleteGraphic(imgBoss);
	EndSpellHistory(36);
	loop(20)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),1);
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
    }
	@BackGround
	{
		SetTexture(imgBG);
		SetGraphicRect(0,bgy,1280+bgx,960);
		SetColor(150,150,150);
		SetAlpha(100);
		DrawGraphic(224, 240);	
	}

    // C^XN
task TMain 
{
	standBy;
	spell;
	Trate;
	shot;
}

task Trate
{
	while(OnBomb==true){yield;}
	wait(420);
        SetDamageRate(25, 25);
}




sub standBy//ʒu
{
	SetAction(ACT_MOVE, 60);
	let wIni = 60;
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni);
	wait(wIni);
}

sub spell//[V
{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
        SetTimer(SpellTimer);
        SetScore(SpellBonus);
	SetAction(ACT_SPELL,90);
	wait(90);
}


task shot
{
let w=60;
loop
{
roundshot(RED05,BLUE05,1,8);
wait(64);
roundshot(GREEN05,YELLOW05,-1,8);
wait(64);
}
}

task roundshot(grf1,grf2,dir,w)
{
let rangle=rand(-2,2);
	ascent(let i in 0..16)
	{
	bugshot(GetX,GetY,2,0+i*7.5*dir,grf1,5,140-i*8,rangle);
	bugshot(GetX,GetY,2,60+i*7.5*dir,grf2,5,140-i*8,rangle);
	bugshot(GetX,GetY,2,120+i*7.5*dir,grf1,5,140-i*8,rangle);
	bugshot(GetX,GetY,2,180+i*7.5*dir,grf2,5,140-i*8,rangle);
	bugshot(GetX,GetY,2,240+i*7.5*dir,grf1,5,140-i*8,rangle);
	bugshot(GetX,GetY,2,300+i*7.5*dir,grf2,5,140-i*8,rangle);
	wait(w);
	}
}

task bugshot(let x, let y, let speed,let angle, let graphic, let delay,let w,let rangle)
{
	let itemx=x;
	let itemy=y;
	let count=0;
	let count1=0;
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, x, y);
	Obj_SetSpeed(obj, speed);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, graphic);
	ObjShot_SetDelay(obj, delay);
	ObjShot_SetBombResist(obj,true);
	loop(120)
	{
		Obj_SetSpeed(obj, speed);
		speed-=2/120;
		yield;
    	}
	if(graphic==YELLOW05)
	{
		wait(w);
		Obj_SetSpeed(obj, 1.25);
		Obj_SetAngle(obj,angle-150+rangle);
		ObjShot_SetGraphic(obj, 107);
	}
	
	if(graphic==GREEN05)
	{
		wait(w+96);
		Obj_SetSpeed(obj, 1.25);
		Obj_SetAngle(obj, angle+150+rangle);
		ObjShot_SetGraphic(obj, 108);
	}

	if(graphic==BLUE05)
	{
		wait(w);
		Obj_SetSpeed(obj, 1.25);
		Obj_SetAngle(obj,angle-150+rangle);
		ObjShot_SetGraphic(obj, 110);
	}
	
	if(graphic==RED05)
	{
		wait(w+96);
		Obj_SetSpeed(obj, 1.25);
		Obj_SetAngle(obj, angle+150+rangle);
		ObjShot_SetGraphic(obj, 105);
	}
	ObjShot_SetBombResist(obj,false);
	while(!Obj_BeDeleted(obj))
	{
		itemx=Obj_GetX(obj);
		itemy=Obj_GetY(obj);
		yield;
	}
	CreateShotChengeToItem(itemx,itemy);
}

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