//\Z
#e[Player]
#ScriptVersion[3]	//XNvgo[W3K{ł
#ID["Sakuya"]
#Title[""]
#Text["AiduVo[u[hvgpj"]
#ReplayName["Sakuya"]

let objPlayer = GetPlayerObjectID();
let PlayerPower=400;
let PlayerPower_Int=PlayerPower/100;
let objOption =[];
let OptionX=[GetStgFrameWidth/2,GetStgFrameWidth/2,GetStgFrameWidth/2,GetStgFrameWidth/2];
let OptionY=[416,416,416,416];
let RodFlag=false;
let RodX;
let RodY;
let SpellMove=0;
let RebirthFlag=false;
let DimensionFlag=false;

let OnSpell=false;
let InvincibleSystem=true;
let AutoBombFlag=false;
let InvincibleFlag=false;
let InvincibleCount=0;

let current = GetCurrentScriptDirectory();

#include "./Option.txt"
#include "./Shot.txt"
#include "./Spell.txt"
//#include "./file.txt"

#include "./../../Common/lib/Player.txt"
#include "./../../Common/lib/Effect.txt"
#include "./../../Common/lib/Invincible.txt"
#include "./../../Common/lib/Library.txt"
#include "./../../Common/lib/Load.txt"
#include "./../../Common/lib/Config.txt"
#include "./../../Common/lib/file.txt"

IMG_PLAYER=IMG_SAKUYA;
IMG_OPTION=IMG_SAKUYA_OPTION;

@Initialize
{
	let path = current ~ "../../Common/lib/ShotData.txt";
	LoadPlayerShotData(path); //e摜[h

	ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 0.3, 35); //蔻o^
	SetPlayerSpeed(4.5,2.0);

	TImage();//@`p^XNN
	OptionMove;//IvVړp^XN
	TRenderOption;//IvV`p^XN
	TShot();//e˗p^XNN
	TShot2();//e˗p^XNN
	SlowEffect;//ᑬwGtFNgp^XN
	InvincibleSystemTask;//ꖳGp^XN
	SetPlayerRebirthFrame(8);
	SetPlayerRebirthLossFrame(0);
	SetPlayerDownStateFrame(40);
	SoundLoad;
}

@MainLoop
{
	yield;
}

@Finalize
{
}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_SPELL)
	{
		//XyJ[hv
		let spell = GetPlayerSpell();//cXy
		if((spell >= 1 && !RebirthFlag) || AutoBombFlag)
		{
			SetScriptResult(true);//Xy\
			if(!AutoBombFlag || GetVirtualKeyState(VK_BOMB)==KEY_PUSH && !OnSpell)
			{
			SetPlayerSpell(spell-1);//Xy1炷
			TSpell();//Xy^XNN
			}
			else
			{
			DummySpell();//Xy^XNN
			}
		}
		else
		{
			SetScriptResult(false);//Xys
		}
		AutoBombFlag=false;
	}
	case(EV_HIT)
	{
		//e
		if(InvincibleCount>0)
		{
		AutoBombFlag=true;
		CallSpell;
		}
		else if(DimensionFlag)
		{
		PlaySE(SE_PLAYERDOWN2);
		AutoBombFlag=true;
		CallSpell;
		}
		else
		{
		PlaySE(SE_PLAYERDOWN);
		TExplosion();
		}
	}
	case(EV_PLAYER_REBIRTH)
	{
		//A
		SetPlayerSpell(3);
		SetPlayerInvincibilityFrame_Special(240);
	}
	case(EV_GET_ITEM)
	{
		//ACe擾ʒm
		let itemType = GetEventArgument(0);
		alternative(itemType)
		case(ITEM_SPELL)
		{
			WriteLog("ITEM_SPELL");
		}
		case(ITEM_SPELL_S)
		{
			WriteLog("ITEM_SPELL_S");
		}
		case(ITEM_POWER)
		{
			WriteLog("ITEM_POWER");
		}
		case(ITEM_POWER_S)
		{
			WriteLog("ITEM_POWER_S");
		}
	}
	case(EV_GRAZE)
	{
		//OCYʒm
		GrazeEffect(GetEventArgument(1));
		PlaySE(SE_GRAZE);
	}
}

