//얲`
#e[Player]
#ScriptVersion[3]	//XNvgo[W3K{ł
#ID["Reimu"]
#Title["얲"]
#Text["얲AiduP_vgpj"]
#ReplayName["Reimu"]

let objPlayer = GetPlayerObjectID();
let PlayerPower=400;
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 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/Library.txt"
#include "./../../Common/lib/Config.txt"

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

	ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 0.2, 30); //蔻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
	SetPlayerRebirthFrame(12);
	SetPlayerRebirthLossFrame(0);
	SetPlayerDownStateFrame(40);
	LoadSound(SE_GRAZE);
	LoadSound(SE_PLAYERDOWN);
	LoadSound(SE_SHOT);
	LoadSound(SE_SPELL1);
	LoadSound(SE_SPELL2);
	LoadSound(SE_SPELL3);
}

@MainLoop
{
	if(InvincibleCount>0){InvincibleCount--;}
	if(InvincibleSystem)
	{
	Obj_SetValue(objPlayer,"OnSpell",OnSpell);
	}
	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
		{
		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);
	}
}

