#include "hostAPI.txt"

#include "global.txt"

var count;
var deflect;
var i;
var ran;
var type;
var tt;
var bx;
var by;
var px;
var py;

func hom(x,y,degree){
px = htGetPlayerX();
py = htGetPlayerY();
if (sqrt((px-x)*(px-x)+(py-y)*(py-y)) <=100 )
  {  tt=GetDegreeBetweenTwoPoints(x, y, px, py);
     htRemoveCurrBullet();
htInsertBulletVec(5,0,x,y,1.5,tt);
    
   }

}


func update() {

	
	px = htGetPlayerX();
	py = htGetPlayerY();
      htInsertBulletVec(5,4,px+sin(count*9)*100,py+cos(count*9)*100,5,count*9-90);
	htSetBulletLifeTime(2);
 htInsertBulletVec(5,4,px+sin(-count*9)*100,py+cos(-count*9)*100,5,-count*9+90);
	htSetBulletLifeTime(2);
 htInsertBulletVec(5,4,px+sin(-count*9+180)*100,py+cos(-count*9+180)*100,5,-count*9+180+90);
	htSetBulletLifeTime(2);
 htInsertBulletVec(5,4,px+sin(count*9+180)*100,py+cos(count*9+180)*100,5,count*9+180-90);
	htSetBulletLifeTime(2);
	++count;
if (count % 100 == 0)
 {   bx = htGetBossX();
     by = htGetBossY();
ran=randomfloat(0,360);
     for (i=0;i<10;++i)
      {   
          htInsertBulletVec(5, 4, bx, by,2,360/10*i+ran);
          htSetBulletReflectTime(1000,1);
          htBindScriptFuncToBullet("hom",1,100000);

       }
htMoveBossTo(px+randomfloat(-50,50),randomfloat(100,200),60);
  }
   
}

func init() {
htMoveBossTo(400, 100, 30);
htSetBulletScreenRect(150, -25, 650, 625);
	count = 0;
	deflect = 0;
	i = 0;
	type = 0;
	
	bx = 0;
	by = 0;
}