#TouhouDanmakufu[Player]
#ScriptVersion[3]
#ID["GizmoPlayer"]
#Title["Gizmo"]
#Text["This is something just to fill [r] in the text space."]
#Image["./GizmoCutinThing.png"]
#ReplayName["Gizmo"]

let FireRate = -1;
let objPlayer = GetPlayerObjectID();

@Initialize{
addkeys;
FireControl;
ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 1, 20); //Giving the player its hitbox. (X location, Y location, Hitbox, Grazebox)
Image;
LoadPlayerShotData(GetCurrentScriptDirectory~"ShotSheetGizmo.txt");
} 

@MainLoop{
	
	yield;
} 

@Finalize{

} 

@Event{

}

task addkeys {
AddVirtualKey(VK_SHOT,KEY_Z,KEY_INVALID);
}

task Image{
ObjPrim_SetTexture(objPlayer, GetCurrentScriptDirectory()~"GizmoSprite.png");
loop{
	ObjSprite2D_SetSourceRect(objPlayer, 0, 0, 24, 24);
	ObjSprite2D_SetDestCenter(objPlayer);
	yield;
}
}

task FireControl {
	loop {
	if(GetVirtualKeyState(VK_SHOT) == KEY_HOLD && FireRate == -1) {
	FireRate = 0;
	
	}
	if(FireRate%5==0){fire;}
	if(FireRate >= 0) {
	FireRate++;
	}
	if(FireRate == 30) {
	FireRate = -1;
	}
	yield;
	}

}

task fire {
let objShot = CreatePlayerShotA1(GetPlayerX,GetPlayerY,10,270,4,1,2);
ObjRender_SetScaleXYZ(objShot,0.5,0.5,0);
}