#TouhouDanmakufu[Player]
#ScriptVersion[3]
#ID["CIRNO"]
#Title["Cirno"]
#Text["‡H Type"]
#Image["./Face.png"]
#ReplayName["Cirno"]

#include "./../functions1.txt"

PlayerSpeed = [4.5,2.125];

task TMain
{
	PlayerPath = GetCurrentScriptDirectory ~ "Sprite.png";
	GrazeBox = 28;
}

task TShot
{
	let spread = [0,0];
	let counter = 0;
	let angle;
	let soundS = false;

	let IsShooting = false;
	let IsFocus = false;

	let angleO1 = 180;
	let angleO2 = 0;
	let angleO3 = 0;
	let distOM = 0;
	let distO = 0;	
	let type = 0;
	let count = 0;

	loop
		{
		if(GetVirtualKeyState(VK_SLOWMOVE) == KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE) == KEY_HOLD)
			{
			angle = 40;		
			spread = [5,4];
			count = 2;
			distOM = 25;
			IsFocus = true;
			type = 1;
			}
		else
			{
			angle = 105;	
			spread = [3,8];
			count = 1;
			distOM = 50;
			IsFocus = false;
			type = 0;
			}
		distO += (distOM-distO)/5;
		if((GetVirtualKeyState(VK_SHOT) == KEY_PUSH || GetVirtualKeyState(VK_SHOT) == KEY_HOLD))
			{
			if(GetPlayerState == STATE_NORMAL && IsPermitPlayerShot == true && ShotPermit == true)
				{
				ascent(i0 in 0..2)
					{
					if(counter%(5+i0*count) == 0)
						{
						PlaySound("se_PlayerShot1",120);
						ascent(i1 in 0..spread[i0])
							{
							i1 = i1-spread[i0]/2+0.5;
							let angleS;
							let x;
							let y;
							if(i0 == 0)
								{
								angleS = 270;
								let dist = 75;
								if(IsFocus == true)
									{
									dist = 50;
									}
								x = i1*dist/spread[i0];
								y = -17.5;
								}
							else
								{
								angleS = 270+i1*angle/spread[i0];
								x = 17.5*cos(angleS);
								y = 17.5*sin(angleS);
								}
							TSpam(GetPlayerX+x,GetPlayerY+y,angleS);
							}
						}
					}
				IsShooting = true;
				}
			else
				{
				IsShooting = false;
				}
			counter+=1;
			}
		else if(counter%5 != 0)
			{
			counter+=1;
			IsShooting = false;
			}
		else
			{
			IsShooting = false;
			}
		yield;
		}

	task TSpam(x,y,angle)
		{
		if(IsPermitPlayerShot == false){return;}

		let shot = CreatePlayerShotA1(x,y,15,angle,4.3,1,CIRNO);
		ObjMove_SetAcceleration(shot,0.2);
		ObjMove_SetMaxSpeed(shot,100);
		Obj_SetRenderPriority(shot,0.35);

		let alpha = 65;
		ObjRender_SetAlpha(shot,alpha);

		if(Effect >= 2){return;}
		while(!Obj_IsDeleted(shot))
			{
			x = ObjMove_GetX(shot);
			y = ObjMove_GetY(shot);
			angle = ObjMove_GetAngle(shot);
			yield;
			}
		if(IsPermitPlayerShot == false || x > GetStgFrameWidth+32 || x < -32 || y < -32){return;}
		let spam = CreatePlayerShotA1(x,y,0.33,angle,0,10^10,CIRNO);
		descent(t in 0..20)
			{
			ObjRender_SetAlpha(spam,alpha*t/20);
			yield;
			}
		Obj_Delete(spam);
		}

}