#e
#Title[uACXXl[N-Easyv]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "uACXXl[N-Easyv";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_cirno.png"; 
    let imgFam  = csd ~ "img\familiar.png";
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
	let DrawY=330;
	let count=-wIni;
	let Bonus;
	let DBonusItem;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","Normal"))
	case("Easy")
	{
		DBonusItem=1;
	}
	case("Normal")
	{
		DBonusItem=2;
	}
	case("Hard")
	{
		DBonusItem=3;
	}
	case("Lunatic")
	{
		DBonusItem=4;
	}
	let StandardSpellBonus=GetCommonDataDefault("BONUSPOINT",10000)*(20*DBonusItem+10*GetCommonDataDefault("STAGEPROGRESS",2));
	let SpellTimer=50;
	let SpellBonus=StandardSpellBonus/3;
    @Initialize {
	SetShotAutoDeleteClip(32,32,32,32);
	StartSpellHistory(3);

        SetLife(800);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
        SetTexture(imgBoss);

	InitializeAction();
        TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	Bonus=GetSpellCardBonusScore-(SpellBonus*3)/(SpellTimer*60);
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
	DrawBoss( imgBoss );
	DrawSpellHistory;
    }

    @Finalize {
		DeleteGraphic(imgBoss);
		EndSpellHistory(3);
	loop(10)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),1);
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
    }

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

task Trate
{
	wait(120);
        SetDamageRate(25, 25);
}




sub standBy//ʒu
{
	SetAction(ACT_MOVE, wIni);
	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
	{
		snake(GetAngleToPlayer);
		wait(150);
	}
}

task snake(Pangle)
{
			let d=15;
			let ad=300;
			let px=GetPlayerX+ad*cos(Pangle);
			let py=GetPlayerY+ad*sin(Pangle);
			let x=GetX;
			let y=GetY;
			let angle=Pangle+rand(-45,45);
			loop(8)
			{
				loop(5)
				{
					iceshot(x,y,60);
					x+=d*cos(angle);
					y+=d*sin(angle);
					wait(1);
				}
			angle=atan2(py-y,px-x)+rand(-45,45);	
			}
}

function iceshot(x,y,delay)
{
		CreateShotA(0,x,y,delay);
		SetShotDataA(0,0,3,rand(0,360),0,-0.2,rand(0.8,1.2),BLUE01);
		FireShot(0);
}


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