#include "hostAPI.txt"

#include "global.txt"

var count;
var deflect;
var i;

var type;
var tt;
var bx;
var by;
var px;
var py;

func goleft(x, y, degree) {


htRemoveCurrBullet();

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


			htInsertBulletVec(5, 5, x, y, 2.75,75/9*i+degree+180);
                        htSetBulletDeflectionEx	(-1,0,0,30);
                        }
                     

}
                        
func goright(x, y, degree) {


htRemoveCurrBullet();

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

			htInsertBulletVec(5, 5, x, y, 2.75,-75/9*i+degree+180);
                        htSetBulletDeflectionEx	(1,0,0,30);
                        }
                     

}                     




func exxx(x, y, degree) {


htRemoveCurrBullet();
for(i=0; i<10; ++i) {


			htInsertBulletVec(5, 5, x, y, 4,-150/10*i+degree-180);
                        
                        htBindScriptFuncToBullet("goleft",40,-1);
                     

}
for(i=0; i<10; ++i) {


			htInsertBulletVec(5, 5, x, y, 4,150/10*i+degree-180);
                     
                        htBindScriptFuncToBullet("goright",40,-1);
                     

}


}
func update() {

if (count == 100)
{
	bx = htGetBossX();
	by = htGetBossY();
	
	px = htGetPlayerX();
	py = htGetPlayerY();
var color = 2;	
tt = sqrt((bx-px)*(bx-px)+(by-py)*(by-py))/5/4.5;

var dgrbp = GetDegreeBetweenTwoPoints(bx,by,px,py);
htInsertBulletVec(0,color,bx,by,5,dgrbp);
htBindScriptFuncToBullet("exxx",tt,-1);



htMoveBossTo(px+randomfloat(-50,50),randomfloat(100,150),60);
}
if (count == 200)
{
	bx = htGetBossX();
	by = htGetBossY();
	
	px = htGetPlayerX();
	py = htGetPlayerY();

tt = sqrt((by-py)*(by-py))/5/4.5;

htInsertBulletVec(0,color,bx,by,5,90);
htBindScriptFuncToBullet("exxx",tt,-1);



htMoveBossTo(px+randomfloat(-50,50),randomfloat(100,150),60);
count = 0;
}	
	
	++count;
}

func init() {
htMoveBossTo(400, 100, 30);
htSetBulletScreenRect(100, -50, 750, 700);
	count = 0;
	deflect = 0;
	i = 0;
	type = 0;
	
	bx = 0;
	by = 0;
}