//霧雨魔理沙
#東方弾幕風[Player]
#ScriptVersion[3]	//スクリプトバージョン3が必須です
#ID["Marisa"]
#Title["魔理沙"]
#Text["魔理沙B（妖器を使用しない）"]
#ReplayName["Marisa"]

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 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_MARISA;
IMG_OPTION=IMG_MARISA_OPTION;

@Initialize
{
	let path = current ~ "../../Common/lib/ShotData.txt";
	LoadPlayerShotData(path); //自弾画像ロード

	ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 0.3, 40); //当たり判定登録
	SetPlayerSpeed(5.0,2.0);

	TImage();//自機描画用タスク起動
	OptionMove;//オプション移動用タスク
	TRenderOption;//オプション描画用タスク
	TShot();//弾発射用タスク起動
	TShot2();//弾発射用タスク起動
	SlowEffect;//低速魔方陣エフェクト用タスク
	InvincibleSystemTask;//特殊無敵用タスク
	SetPlayerRebirthFrame(8);
	SetPlayerRebirthLossFrame(0);
	SetPlayerDownStateFrame(40);
	SoundLoad;
}

@MainLoop
{
	yield;
}

@Finalize
{
}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_SPELL)
	{
		//スペルカード要求
		let spell = GetPlayerSpell();//残りスペル数
		if((spell >= 1 && !RebirthFlag) || AutoBombFlag)
		{
			SetScriptResult(true);//スペル発動可能
			if(!AutoBombFlag || GetVirtualKeyState(VK_BOMB)==KEY_PUSH && !OnSpell)
			{
			SetPlayerSpell(spell-1);//スペル数を1減らす
			TSpell();//スペルタスク起動
			}
			else
			{
			DummySpell();//スペルタスク起動
			}
		}
		else
		{
			SetScriptResult(false);//スペル発動不可
		}
		AutoBombFlag=false;
	}
	case(EV_HIT)
	{
		//被弾
		if(InvincibleCount>0)
		{
		AutoBombFlag=true;
		CallSpell;
		}
		else
		{
		PlaySE(SE_PLAYERDOWN);
		TExplosion();
		}
	}
	case(EV_PLAYER_REBIRTH)
	{
		//復帰
		SetPlayerSpell(3);
		SetPlayerInvincibilityFrame_Special(240);
	}
	case(EV_GET_ITEM)
	{
		//アイテム取得通知
		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)
	{
		//グレイズ通知
		GrazeEffect(GetEventArgument(1));
		PlaySE(SE_GRAZE);
	}
}

