#e
#Title[uuÒ̃t[Cgv]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "uuÒ̃t[Cgv";
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 {
       LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");
	StartSpellHistory(28);
        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(28);
	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(120);
        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
{
loop
{
let angle=rand(0,360);
ascent(let i in 0..6)
{
Pashot(GetX,GetY,2,angle+i*60);
}
wait(120);
}
}

task Pashot(let x, let y, let speed, let angle) 
{
	let itemx=x;
	let itemy=y;
        let obj = Obj_Create(OBJ_SHOT);
        ObjShot_SetGraphic(obj, 167);
        Obj_SetAngle(obj, angle);
        Obj_SetSpeed(obj, speed);
        Obj_SetPosition(obj,x, y);
	loop(60)
	{
		itemx=Obj_GetX(obj);
		itemy=Obj_GetY(obj);	
		if(Obj_BeDeleted(obj))
		{
			CreateShotChengeToItem(itemx,itemy);
			return;
		}
		yield;
	}
	if(Obj_BeDeleted(obj)==false)
	{
	exp(Obj_GetX(obj),Obj_GetY(obj));
	}
        Obj_Delete(obj);
}

task exp(let x,let y)
{
ascent(let i in 0..18)
{
	shotL(x,y,2,i*20,243,244,30);
	shotL(x,y,2,i*20+10,243,244,30);
}
}

    task shotL(let x, let y, let speed, let angle,let grf1,let grf2,let delay) {
 
	let itemx=x;
	let itemy=y;
        let objE = Obj_Create(OBJ_SHOT);
        ObjShot_SetGraphic(objE, grf1);
        Obj_SetAngle(objE, angle);
        Obj_SetSpeed(objE, speed);
        Obj_SetPosition(objE, x, y);


        let objE2 = Obj_Create(OBJ_SHOT);
        ObjShot_SetGraphic(objE2, grf2);
        Obj_SetAngle(objE2, angle);
        Obj_SetSpeed(objE2, speed);
        Obj_SetPosition(objE2, x, y);
        Obj_SetCollisionToPlayer(objE2, false);
	ObjShot_SetDelay(objE,delay);
	ObjShot_SetDelay(objE2,delay);
	loop(delay)
	{
		itemx=Obj_GetX(objE);
		itemy=Obj_GetY(objE);	
		if(Obj_BeDeleted(objE))
		{
			CreateShotChengeToItem(itemx,itemy);
			return;
		}
		yield;
	}
	while(!Obj_BeDeleted(objE))
	{
		itemx=Obj_GetX(objE);
		itemy=Obj_GetY(objE);	
		yield;
	}
	CreateShotChengeToItem(itemx,itemy);
    }


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