#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 ran;

func go(xx, yy, deg) {


htRemoveCurrBullet();

			htInsertBulletVec(5, 5, xx, yy, 1,deg);
                       
                        
                     

}

func clea(xxx, yyy, de) {


htRemoveCurrBullet();

                     

}

func exxx(x, y, degree) {


htRemoveCurrBullet();
ran = randomfloat(0,360);
for(i=0; i<15; ++i) {


			htInsertBulletVec(5, 5, x, y, 4, 360/15*i+ran);
                        htSetBulletDeflectionEx	(15,0,0,120);
                        htBindScriptFuncToBullet("go",120,-1);
                     

}


}
func update() {

if (count % 70 == 0)
{
	bx = htGetBossX();
	by = htGetBossY();
	
	px = htGetPlayerX();
	py = htGetPlayerY();
var color = 2;	
tt = sqrt((bx-px)*(bx-px)+(by-py)*(by-py))/6;
var dgrbp = GetDegreeBetweenTwoPoints(bx,by,px,py);
htInsertBulletVec(0,color,bx,by,6,dgrbp);
htBindScriptFuncToBullet("exxx",tt,-1);
for (i=0; i<15; ++i) {
htInsertBulletVec(0,color,bx+20*sin(360/15*i),by+20*cos(360/15*i),6,dgrbp);
htBindScriptFuncToBullet("clea",tt,-1);
}

htInsertBulletVec(0,color,bx,by,6,dgrbp+30);
htBindScriptFuncToBullet("exxx",tt,-1);
for (i=0; i<15; ++i) {
htInsertBulletVec(0,color,bx+20*sin(360/15*i),by+20*cos(360/15*i),6,dgrbp+30);
htBindScriptFuncToBullet("clea",tt,-1);
}


htInsertBulletVec(0,color,bx,by,6,dgrbp-30);
htBindScriptFuncToBullet("exxx",tt,-1);
for (i=0; i<15; ++i) {
htInsertBulletVec(0,color,bx+20*sin(360/15*i),by+20*cos(360/15*i),6,dgrbp-30);
htBindScriptFuncToBullet("clea",tt,-1);
}


htMoveBossTo(px+randomfloat(-50,50),randomfloat(100,200),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;
}