//Functions to shorten your Danmakufu code by Karanum
//Version 3.0g
//New function for CommonData loading has been added
//
//
//Edited for Touhou Genyoubu. Please do not use this version for other scripts.


/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Function for boss initialization

Parameters:
-Enemy life
-Shot damage percent
-Bomb damage percent
-Timer (set 0 to freeze timer)
-Invincibility time
-Magic circle (true or false)
-Enemy marker (true or false)
-Spellcard (true or false)
-Spell bonus (only if spellcard is true)
-Durable spell bonus (true or false, only in spellcard is true)
-Last word spell (true or false, only if spellcard is true)
*/

function Init(let hp, let sdr1, let sdr2, let time, let inv, let mc, let em, let spell, let score, let durable, let last)
{
	SetLife(hp);
	SetDamageRate(sdr1, sdr2);
	if(time!=0){SetTimer(time);}
	SetInvincibility(inv);
	MagicCircle(mc);
	SetEnemyMarker(em);
	if(spell==true)
	{
		SetScore(score);
		if(durable==true){SetDurableSpellCard;}
		if(last==true){LastSpell;}
	}
}


/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Function to draw an image

Parameters:
-Path to image (image requires to be loaded prior to using this function)
-Upper-left corner x
-Upper-left corner y
-Lower-right corner x
-Lower-right corner y
-Draw position x
-Draw position y
*/

function Draw(let path, let x1, let y1, let x2, let y2, let x, let y)
{
	SetTexture(path);
	SetGraphicRect(x1, y1, x2, y2);
	DrawGraphic(x, y);
}


/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Collision A+B in one

Parameters:
-Collision x
-Collision y
-Collision radius
*/

function SetCollision(let x, let y, let r)
{
	SetCollisionA(x, y, r);
	SetCollisionB(x, y, r);
}


/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Wait a specified amount of frames, for use in tasks
(Requires yield to be placed in MainLoop)

Parameters:
-Frames
*/

function Wait(let frames)
{
	loop(frames){yield;}
}


/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Wait until all enemies have disappeared/died/whatever, for use in stages
(Requires yield to be placed in MainLoop)

Parameters:
None
*/

function WaitEnemy
{
	while(GetEnemyNum!=0){yield;}
}


/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Wait until all enemy bullets have disappeared, for use in tasks
(Requires yield to be placed in MainLoop)

Parameters:
None
*/

function WaitShot
{
	while(GetEnemyShotCount!=0){yield;}
}

/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Reduces a variable by a certain amount as many times as possible
(Requires yield to be placed in MainLoop)

Parameters:
-Reducable number
-Reduction amount
*/

function reduce(let p, let r)
{
	let rp = p;

	while((rp-r)>0)
	{
		rp-=r;
	}
	return rp;
}

/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------
TOUHOU GENYOUBU ONLY!
*/

