#東方弾幕風
#Title[狂歌「セイレーンソング-Easy」]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "狂歌「セイレーンソング-Easy」";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_mystia.png"; 
    let imgFam  = csd ~ "..\img\familiar.png";
SetRateScoreSystemEnable(false);
    // 初期位置
    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+20*GetCommonDataDefault("STAGEPROGRESS",2));
	let SpellTimer=50;
	let SpellBonus=StandardSpellBonus/3;

    @Initialize {
	StartSpellHistory(23);
        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 {
	SetCommonData("MoveReverse",false);
        DeleteGraphic(imgBoss);
	EndSpellHistory(23);
	loop(15)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),1);
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
    }

    // メインタスク
task TMain 
{
	yield;
	standBy;
	spell;
	Trate;
	loop(3)
	{
	ascent(let i in 0..120)
	{
		shotL(GetX, GetY, 20, i*3);
	}
	wait(5);
	}
	wait(20);
	Seiren;
	wait(30);
	shot;
}

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

task Seiren
{
SetCommonData("MoveReverse",true);
loop
{
	if(GetLife<=20)
	{
		SetCommonData("MoveReverse",false);
	}
	let hspeed=GetPlayerInfo(PLAYER_SPEED_HIGH);
	let lspeed=GetPlayerInfo(PLAYER_SPEED_LOW);
	if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD && GetPlayerMoveState==MOVE_NORMAL)
	{
		SetPlayerY(GetPlayerY+hspeed*2);
		if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD)
		{
			SetPlayerY(GetPlayerY+hspeed*(2^0.5-2));
		}
		if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD)
		{
			SetPlayerY(GetPlayerY+hspeed*(2^0.5-2));
		}
	}
	if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD && GetPlayerMoveState==MOVE_SLOW)
	{
		SetPlayerY(GetPlayerY+lspeed*2);
		if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD)
		{
			SetPlayerY(GetPlayerY+lspeed*(2^0.5-2));
		}
		if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD)
		{
			SetPlayerY(GetPlayerY+lspeed*(2^0.5-2));
		}
	}
	if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD && GetPlayerMoveState==MOVE_NORMAL)
	{
		SetPlayerY(GetPlayerY-hspeed*2);
		if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD)
		{
			SetPlayerY(GetPlayerY-hspeed*(2^0.5-2));
		}
		if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD)
		{
			SetPlayerY(GetPlayerY-hspeed*(2^0.5-2));
		}
	}
	if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD && GetPlayerMoveState==MOVE_SLOW)
	{
		SetPlayerY(GetPlayerY-lspeed*2);
		if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD)
		{
			SetPlayerY(GetPlayerY-lspeed*(2^0.5-2));
		}
		if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD)
		{
			SetPlayerY(GetPlayerY-lspeed*(2^0.5-2));
		}
	}
	if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD && GetPlayerMoveState==MOVE_NORMAL)
	{
		SetPlayerX(GetPlayerX+hspeed*2);
		if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD)
		{
			SetPlayerX(GetPlayerX+hspeed*(2^0.5-2));
		}
		if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD)
		{
			SetPlayerX(GetPlayerX+hspeed*(2^0.5-2));
		}
	}
	if(GetKeyState(VK_LEFT) == KEY_PUSH || GetKeyState(VK_LEFT) == KEY_HOLD && GetPlayerMoveState==MOVE_SLOW)
	{
		SetPlayerX(GetPlayerX+lspeed*2);
		if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD)
		{
			SetPlayerX(GetPlayerX+lspeed*(2^0.5-2));
		}
		if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD)
		{
			SetPlayerX(GetPlayerX+lspeed*(2^0.5-2));
		}
	}
	if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD && GetPlayerMoveState==MOVE_NORMAL)
	{
		SetPlayerX(GetPlayerX-hspeed*2);
		if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD)
		{
			SetPlayerX(GetPlayerX-hspeed*(2^0.5-2));
		}
		if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD)
		{
			SetPlayerX(GetPlayerX-hspeed*(2^0.5-2));
		}
	}
	if(GetKeyState(VK_RIGHT) == KEY_PUSH || GetKeyState(VK_RIGHT) == KEY_HOLD && GetPlayerMoveState==MOVE_SLOW)
	{
		SetPlayerX(GetPlayerX-lspeed*2);
		if(GetKeyState(VK_UP) == KEY_PUSH || GetKeyState(VK_UP) == KEY_HOLD)
		{
			SetPlayerX(GetPlayerX-lspeed*(2^0.5-2));
		}
		if(GetKeyState(VK_DOWN) == KEY_PUSH || GetKeyState(VK_DOWN) == KEY_HOLD)
		{
			SetPlayerX(GetPlayerX-lspeed*(2^0.5-2));
		}
	}
yield;
}
}


sub standBy//初期位置へ
{
	SetAction(ACT_MOVE, 60);
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni);
	wait(wIni);
}

sub spell//発動モーション
{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
        SetTimer(SpellTimer);
        SetScore(SpellBonus);
	SetAction(ACT_SPELL,90);
	wait(90);
}


task shot
{
let speed=2.5;
loop
{
let angle1=rand(0,360);

	ascent(let i in 0..20)
	{
		CreateShotA(1,GetX,GetY,30);
		SetShotDataA(1,0,speed,angle1+i*18,2,0,0,RED01);
		SetShotDataA(1,60,2.5,NULL,0,0,0,RED21);
		FireShot(1);
	}
	wait(30);
	let angle2=rand(0,360);
	ascent(let i in 0..20)
	{
		CreateShotA(1,GetX,GetY,30);
		SetShotDataA(1,0,speed,angle2+i*18,-2,0,0,BLUE01);
		SetShotDataA(1,60,2.5,NULL,0,0,0,BLUE21);
		FireShot(1);
	}
	wait(30);
	speed+=0.05;
}
}

task shotL(let x, let y, let speed, let angle) 
{
        let obj = Obj_Create(OBJ_SHOT);
        ObjShot_SetGraphic(obj, RED01);
        Obj_SetAngle(obj, angle);
        Obj_SetSpeed(obj, speed);
        Obj_SetPosition(obj,x, y);
       Obj_SetCollisionToPlayer(obj, false);
	ObjShot_SetBombResist(obj,true);
	Obj_SetAlpha(obj,0);
 
        let objE = Obj_Create(OBJ_SHOT);
        ObjShot_SetGraphic(objE, RED01);
        Obj_SetAngle(objE, angle);
        Obj_SetSpeed(objE, speed);
        Obj_SetPosition(objE, x, y);
       Obj_SetCollisionToPlayer(objE, false);
	Obj_SetAlpha(objE,0);
	ObjShot_SetBombResist(objE,true);
        loop(90)
	{
	ObjShot_SetDelay(objE,30);
            Obj_SetPosition(objE, Obj_GetX(obj) + speed * cos(angle),
                                  Obj_GetY(obj) + speed * sin(angle));
            yield;
        }
        Obj_Delete(objE);
        Obj_Delete(obj);
    }


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