#include "./../../../system/functions/functions_boss.txt"

let imgB = GetCurrentScriptDirectory ~ "img/Sprite_Boss.png";

@MainLoop{yield;}
@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
		{
		SetScriptResult(life);
		}
	case(EV_REQUEST_TIMER)
		{
		SetScriptResult(-1);
		}
	case(EV_REQUEST_SPELL_SCORE)
		{
		SetScriptResult(30000);
		}
}
@Finalize{DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);}
task ObjShot_SetBreak(shot,val)
	{
	Obj_SetValue(shot,"IS_BROKEN",val);
	}
function ObjShot_IsBreak(shot)
	{
	return Obj_GetValueD(shot,"IS_BROKEN",false);
	}
function CreateSnakeA1(x,y,s,a,d,dir,g,del,sc,c)
	{
	let shot = CreateBulletA1(x,y,0,0,g,del,sc,c);
	TMove;
	return shot;

	task TMove
		{
		let c = -1;
		let ang = 90;
		while(!Obj_IsDeleted(shot))
			{
			c+=1;
			if(c >= del-1)
				{
				x+=s*cos(a);
				y+=s*sin(a);
				}
			ang+=dir;
			let xA = d*cos(ang);
			let dA = GetDistance(0,0,0,xA);
			let aA = atan2(0,-xA)+90+a;
			if(c >= del-1)
				{
				ObjMove_SetDestAtFrame(shot,x+dA*cos(aA),y+dA*sin(aA),1);
				}
			else
				{
				ObjMove_SetPosition(shot,x+dA*cos(aA),y+dA*sin(aA));
				}
			yield;
			}
		}	
	}