#include "hostAPI.txt"

#include "global.txt"

var count;
var deflect;
var i;
var ran;
var ran2;
var type;
var tt;
var bx;
var by;
var px;
var py;
var px2;
var py2;
var ppx2;
var ppy2;
var ppx;
var ppy;
var color1;
var color2;
var color3;
var color4;
var color5;
var color6;
var k;
var cx;
var cy;
var j;
var count2;
var nowx;
var nowy;
var deg;
var f;

var ttd;
var aangle;

func line2(x,y,degree)
{
htInsertBulletVec(5,13,x,y,0,degree);

htSetBulletLifeTime(10);
}

func line(x,y,degree)
{
htInsertBulletVec(5,0,x,y,0,degree);

htSetBulletLifeTime(10);
}


func update() {
         
	
        bx = htGetBossX();
	by = htGetBossY();

if (count % 60 == 0)
{

	px = htGetPlayerX();
	py = htGetPlayerY();

for (i=0;i<=12;++i)
 {htInsertBulletVec(5,0,px+150*cos(360/12*i), py+150*sin(360/12*i),3,360/12*i+90);
  htSetBulletDeflectionEx(3.01/60/3.14159*360,0,0,60);  
  htBindScriptFuncToBullet("line",1,-1);
  htInsertBulletVec(5,0,px+150*cos(360/12*i), py+150*sin(360/12*i),3,360/12*i+90);
  htSetBulletDeflectionEx(3.01/300/3.14159*360,0,0,60);  
  htBindScriptFuncToBullet("line",1,-1);  
  htInsertBulletVec(5,0,px+150*cos(360/12*i), py+150*sin(360/12*i),3,360/12*i-90);
  htSetBulletDeflectionEx(-3.01/60/3.14159*360,0,0,60);  
  htBindScriptFuncToBullet("line",1,-1); 
htInsertBulletVec(5,0,px+150*cos(360/12*i), py+150*sin(360/12*i),3,360/12*i-90);
  htSetBulletDeflectionEx(-3.01/300/3.14159*360,0,0,60);  
  htBindScriptFuncToBullet("line",1,-1);
  }
	px2 = htGetBossX();
	py2 = htGetBossY();
ran2= randomfloat(0,360);
for (i=0;i<=15;++i)
 {
for (j=0;j<=2;++j)
{
htInsertBulletVec(5,2,px2, py2,3+0.1*j,360/15*i+ran2+90);
  htSetBulletDeflectionEx(5,-0.1,0,60);  
  htInsertBulletVec(5,2,px2, py2,3+0.1*j,360/15*i+ran2-90);
  htSetBulletDeflectionEx(-5,0.1,0,60);  
} 
  }
}
if ((count % 60 !=0)&&(count % 30 ==0))

{ 
ran= randomint(0,11);
cx=px+120*cos(360/12*ran);
cy=py+120*sin(360/12*ran);
ppx = htGetPlayerX();
ppy = htGetPlayerY();
deg=GetDegreeBetweenTwoPoints(cx,cy,ppx,ppy);
htInsertBulletVec(0,3,cx,cy,3,deg);
htSetBulletPause(0,20);
htBindScriptFuncToBullet("line2",1,-1); 

ran= ran+4;
cx=px+120*cos(360/12*ran);
cy=py+120*sin(360/12*ran);
ppx = htGetPlayerX();
ppy = htGetPlayerY();
deg=GetDegreeBetweenTwoPoints(cx,cy,ppx,ppy);
htInsertBulletVec(0,3,cx,cy,3,deg);
htSetBulletPause(0,20);
htBindScriptFuncToBullet("line2",1,-1); 
ran= ran+4;
cx=px+120*cos(360/12*ran);
cy=py+120*sin(360/12*ran);
ppx = htGetPlayerX();
ppy = htGetPlayerY();
deg=GetDegreeBetweenTwoPoints(cx,cy,ppx,ppy);
htInsertBulletVec(0,3,cx,cy,3,deg);
htSetBulletPause(0,20);
htBindScriptFuncToBullet("line2",1,-1); 



}





++count;

}

func init() {
htMoveBossTo(400,100, 30);
htSetBulletScreenRect(150-120,-25-120,650+120,625+120);
	count = -50;
         count2 =0;
	deflect = 0;
	i = 0;
	type = 0;
	color1=0;
        color2=2;
        color3=5;
	color4=8;
	color5=12;
        color6=15; 
	bx = 0;
	by = 0;
}