#include "hostAPI.txt"

#include "global.txt"

var count;
var deflect;
var i;

var type;
var tt;
var bx;
var by;
var px;
var py;
var fulllife;
var bosslife;
var rx;
var ry;
var deg;
var degg;
var movex;
var movey;
func line(x,y,degree)
{
htInsertBulletVec(5,2, x, y,0,degree);
htSetBulletLifeTime	(20);
if ((count % 60 ==0)&&(y<600))
{
for (i=0;i<=8;++i)
{
htInsertBulletVec(5,5, x, y,2,45*i+degree);


}
}


}


func fire(x,y,degree)

{

htRemoveCurrBullet();
px = htGetPlayerX();
py = htGetPlayerY();
deg=GetDegreeBetweenTwoPoints(x,y,px,py);
htInsertBulletVec(5,2,x,y,10,deg);
htSetBulletDeflectionEx	(10,0,0,360/1);
htBindScriptFuncToBullet("line",1,-1);
htInsertBulletVec(5,2,x,y,10,deg);
htSetBulletDeflectionEx	(-10,0,0,360/10);
htBindScriptFuncToBullet("line",1,-1);

}




func update() {
++count;
if(count < 0)
	return;
bosslife=htGetBossLife();
	bx = htGetBossX();
	by = htGetBossY();
	
	px = htGetPlayerX();
	py = htGetPlayerY();

if (count % 120==0)
{

for (i=0;i<=6;++i)
{

rx=randomfloat(225,575);
ry=randomfloat(0,250);
degg=GetDegreeBetweenTwoPoints(bx,by,rx,ry);
htInsertBulletVec(5,0,bx,by,10,degg);

htBindScriptFuncToBullet("fire",sqrt((rx-bx)*(rx-bx)+(ry-by)*(ry-by))/10+30,1);
htSetBulletPause(sqrt((rx-bx)*(rx-bx)+(ry-by)*(ry-by))/10,sqrt((rx-bx)*(rx-bx)+(ry-by)*(ry-by))/10+30);




}
movex=px+randomfloat(-100,100);
if (movex<175+50) movex=175+50;
if (movex>625-50) movex=625-50;
movey=randomfloat(50,200);
htMoveBossTo(movex,movey, 60);

}
}

func init() {


htMoveBossTo(400, 100, 30);
htSetBulletScreenRect(100, -50, 750, 700);
	count = -60;
	htPlayBossEnergyAnim(90);
	deflect = 0;
	i = 0;
	type = 0;
	
	bx = 0;
	by = 0;
}