#e[Player]
#ScriptVersion[2]
#Menu[@ђʑ]
#Text[
VbgFuV[vlX[U[v
{FuzCgjOXp[Nv
VbgЗ́F
Vbǵ͈F
{З́F@@
ړxF@@]
#ReplayName[marisa2]	
script_player_main
{
	let current = GetCurrentScriptDirectory();
	let player= current~"dot_marisa.png";
	let slow= current~"slow_effect.png";
	let angle=0;
	let alpha=0;
	let shotCount = -1;
	let bNextShot = false;
	let op=0;
	let opx=[0];
	let opy=[0];
	let ppower=100;
	let misscount=0;
	@Initialize
	{
		SetPlayerLifeImage(player,1,150,25,175);
		LoadGraphic(player);
		LoadGraphic(slow);
		SetSpeed(4, 1.6);
		LoadPlayerShotData(current~"marisaShotData.txt");
		SetItemCollectLine(160);
		SetAutoEffect(false);
		shottask;
		optask;
	}
	
	@MainLoop
	{
		SetIntersectionCircle(GetPlayerX,GetPlayerY,0);
		yield;
	}
	@Missed
	{
		misscount++;
		yield;
		if(misscount==74)
		{
			ppower-=100;
			misscount=-1;
		}
	}
	@SpellCard
	{
		UseSpellCard("musouhuuinen",0);
	}
	
	@DrawLoop
	{
		let i=0;
		SetColor(255, 255, 255);
		SetRenderState(ALPHA);
		SetTexture(player);
		if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD)
		{
			SetGraphicRect(1,101,50,150);
		}
		else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD)
		{
			SetGraphicRect(1,51,50,100);
		}
		else 
		{
			SetGraphicRect(1,1,50,50);
		}
		SetGraphicAngle(0,0,0);
		if(GetTimeOfPlayerInvincibility>0)
		{
			SetAlpha(96);
		}
		else
		{
			SetAlpha(255);
		}
		DrawGraphic(GetPlayerX,GetPlayerY);
		loop(op)
		{
			SetTexture(player);
			SetGraphicRect(1,151,25,175);
			SetGraphicAngle(0,0,angle);
			if(GetTimeOfPlayerInvincibility>0)
			{
				SetAlpha(96);
			}
			else
			{
				SetAlpha(255);
			}
			DrawGraphic(opx[i],opy[i]);
			i++;
		}
		SetTexture(slow);
		SetGraphicRect(0,0,61,61);
		SetGraphicAngle(0,0,angle);
		if(GetTimeOfPlayerInvincibility>0)
		{
			SetAlpha(alpha/3);
		}
		else
		{
			SetAlpha(alpha);
		}
		DrawGraphic(GetPlayerX,GetPlayerY);
		angle+=2;
		SetFontColor(255,255,255,255,255,128);
		DrawText(NumToString(ppower/100)~"/4.00",GetClipMinX,GetClipMaxY-64,18,255);
		DrawText("",GetClipMinX,GetClipMaxY-83,18,255);
		SetFontColor(255,255,255,255,255,255);
	}
	@Finalize
	{
		DeleteGraphic(player);
		DeleteGraphic(slow);
	}
	task shottask
	{
		loop(2)
		{
			yield;
		}
		loop
		{
			if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD || bNextShot==true)&&shotCount==-1)
			{
				shotCount=0;
				bNextShot=false;
			}
			if(GetKeyState(VK_SHOT)==KEY_HOLD&&shotCount>0)
			{
				bNextShot=true;
			}
			if(GetKeyState(VK_SHOT))
			{
				let i=0;
				loop(op)
				{
					razer(i);
					i++;
				}
			}
			if(shotCount%5==0)
			{
				CreatePlayerShot01(GetPlayerX-10,GetPlayerY,15,270,4,1,1);
				CreatePlayerShot01(GetPlayerX+10,GetPlayerY,15,270,4,1,1);
			}
			if(shotCount >= 0)
			{
				shotCount++;
			}
			if(shotCount == 30)
			{
				shotCount=-1;
			}
			yield;
		}
	}
	task optask
	{
		let gp=0;
		let a=30;
		loop
		{
			ppower+=(GetPoint-gp)*5;
			op=trunc(ppower/100);
			if(op>4)
			{
				op=4;
			}
			if(op<1)
			{
				op=1;
			}
			if(ppower>400)
			{
				ppower=400;
			}
			if(ppower<100)
			{
				ppower=100;
			}
			if(op==1)
			{
				opx=[GetPlayerX];
				opy=[GetPlayerY-a*2];
			}
			if(op==2)
			{
				opx=[GetPlayerX+a,GetPlayerX-a];
				opy=[GetPlayerY-a*2,GetPlayerY-a*2];
			}
			if(op==3)
			{
				opx=[GetPlayerX,GetPlayerX+a*1.5,GetPlayerX-a*1.5];
				opy=[GetPlayerY-a*2,GetPlayerY-a*2,GetPlayerY-a*2];
			}
			if(op==4)
			{
				opx=[GetPlayerX+a*0.75,GetPlayerX-a*0.75,GetPlayerX+a*2.25,GetPlayerX-a*2.25];
				opy=[GetPlayerY-a*2,GetPlayerY-a*2,GetPlayerY-a*2,GetPlayerY-a*2];
			}
			if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
			{
				if(a>15)
				{
					a-=2;
				}
				if(alpha<255)
				{
					alpha+=15;
				}
			}
			else
			{
				if(a<30)
				{
					a+=2;
				}
				if(alpha>0)
				{
					alpha-=15;
				}
			}
			gp=GetPoint;
			yield;
		}
	}
	task razer(i)
	{
		let count=0;
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,opx[i],opy[i]);
		Obj_SetAngle(obj,270);
		ObjLaser_SetLength(obj,500);
		ObjLaser_SetWidth(obj,80);
		ObjLaser_SetSource(obj,false);
		ObjShot_SetGraphic(obj, 2);
		ObjShot_SetDamage(obj, 1);
		ObjShot_SetPenetration(obj, 2);
		while(!Obj_BeDeleted(obj))
		{
			Obj_SetAlpha(obj,255-(count*25));
			if(count==1){Obj_Delete(obj);}
			count++;
			yield;
		}
	}
	function NumToString(let num)
	{
		let leng = trunc(log10(num))+1;
		if(num==0){leng = 0}
		let string = ToString(num);
		let str = " ";
		let zero =ToString(0);
		times(1-leng)
		{
			string = str ~ string;
		}
		if(num==0)
		{
				string = zero~ string;
			loop(3)
			{
				string = str ~ string;
			}
		}
		return string[0..4];
	}
}

script_spell musouhuuinen
{
	let current=GetCurrentScriptDirectory();
	let bomb=current~"marisa_bomb.png";

	@Initialize
	{
		LoadGraphic(bomb);
		SetPlayerInvincibility(420);
		run();
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
		DeleteGraphic(bomb);
	}
	task run()
	{
		SetSpeed(1,1);
		manterspark(50,255,128,128);
		manterspark(0,128,255,128);
		manterspark(-50,128,128,255);
		loop(360){;yield;}
		SetSpeed(4, 1.6);
		End();
	}
	task manterspark(a,r,b,g)
	{
		let x=GetPlayerX;
		let y=GetPlayerY;
		let count=0;
		let alpha=0;
		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetSpeed(obj,0);
		ObjEffect_SetTexture(obj,bomb);
		ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj,ADD);
		ObjEffect_CreateVertex(obj,4);
		ObjEffect_SetVertexXY(obj,0,GetPlayerX-170,GetPlayerY-500);
		ObjEffect_SetVertexXY(obj,1,GetPlayerX-170,GetPlayerY+20);
		ObjEffect_SetVertexXY(obj,2,GetPlayerX+170,GetPlayerY-500);
		ObjEffect_SetVertexXY(obj,3,GetPlayerX+170,GetPlayerY+20);
		ObjEffect_SetVertexUV(obj,0,0,0);
		ObjEffect_SetVertexUV(obj,1,0,400);
		ObjEffect_SetVertexUV(obj,2,309,0);
		ObjEffect_SetVertexUV(obj,3,309,400);
		while(!Obj_BeDeleted(obj))
		{
			ObjSpell_SetIntersecrionLine(obj,GetPlayerX+a,GetPlayerY-500,GetPlayerX,GetPlayerY,300,3,true);
			ObjEffect_SetVertexXY(obj,0,GetPlayerX-170+a,GetPlayerY-500);
			ObjEffect_SetVertexXY(obj,1,GetPlayerX-170,GetPlayerY+20);
			ObjEffect_SetVertexXY(obj,2,GetPlayerX+170+a,GetPlayerY-500);
			ObjEffect_SetVertexXY(obj,3,GetPlayerX+170,GetPlayerY+20);
			ObjEffect_SetVertexColor(obj,0,alpha,r,b,g);
			ObjEffect_SetVertexColor(obj,1,alpha,r,b,g);
			ObjEffect_SetVertexColor(obj,2,alpha,r,b,g);
			ObjEffect_SetVertexColor(obj,3,alpha,r,b,g);
			if(count<51)
			{
				alpha+=5;
			}
			if(count>275)
			{
				alpha-=3;
			}
			if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD)
			{
				a--;
			}
			else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD)
			{
				a++;
			}
			count++;
			yield;
		}
	}
}
