function effect_Unsize2Death(particle)
{
	if(particle._doInit)
	{
		particle._affectFlow=1;
	}else
	if(particle._time>500){
		particle._w-=0.4*particle._delta;
		particle._h-=0.4*particle._delta;
		if(particle._w<2.0)
		{
			particle._alpha-=0.4*particle._delta;
		}
		if(particle._w<0.1)
		{
			particle._dieNow=1;
		}
	}
	return;
}

function effect_InitPRSAD(particle)
{
	particle._affectPosition=1;
	particle._affectRotation=1;
	particle._affectSize=1;
	particle._affectAlpha=1;
	particle._affectFade=0;
	particle._affectFlow=1;
	particle._affectColor=0;
	particle._sharedMode=0;
	particle._dieNow=0;
}

function effect_StarA_init(particle)
{
	effect_InitPRSAD(particle);
	local iAngle=360/(particle._parameter.tointeger())*particle._cloneNumber;
	particle._angle <- 3.1415*iAngle/180;
	particle._initialSizeW <- particle._w;
	particle._initialSizeH <- particle._h;
	particle._alphaFrom <- core_Rnd(0,300);
	particle._alphaTo <- core_Rnd(400,900);
	particle._spd <- core_Rnd(0.3,0.6);
	//Вызывается автоматом effect_StarA(particle);
}

function effect_StarA(particle)
{
	if(particle._time<particle._alphaFrom){
		particle._alpha=0;
		return;
	}
	local gtime=(particle._time-particle._alphaFrom);
	//particle._angle+=core_Rnd(-0.6,0.6)*particle._delta;
	local xSpd=particle._spd*cos(particle._angle);
	local ySpd=particle._spd*sin(particle._angle);
	particle._x+=xSpd*particle._delta;
	particle._y+=ySpd*particle._delta;
	
	if((particle._cloneNumber%2)==0 && gtime>200){
		particle._y-=particle._delta*(gtime*gtime)*0.04;
	}
	
	local size = sin(gtime*0.01*particle._spd)+1.0;
	particle._w=particle._initialSizeW*size;
	particle._h=particle._initialSizeH*size;
	particle._rotation+=size*0.1+particle._angle*0.01;
	
	if(gtime>particle._alphaTo)
	{
		particle._alpha-=0.4*particle._delta;
		if(particle._w<0.1 || (particle._alpha<0.5 /*&& core_Rnd()>0.5*/) || gtime>particle._alphaTo+600){
			particle._dieNow=1;
		}
	}else{
		particle._alpha+=0.4*particle._delta;
	}
	return;
}

function effect_StarB_init(particle)
{
	effect_InitPRSAD(particle);
	particle._alphaFrom <- core_Rnd(0,700);
	particle._alphaTo <- core_Rnd(500,1500);
	local maxDistance = particle._parameter.tofloat();//*((2+particle._cloneNumber)/10);
	local xd=core_Rnd(-maxDistance,maxDistance);
	local yd=core_Rnd(-maxDistance,maxDistance);
	if(xd*xd+yd*yd>maxDistance*maxDistance)
	{
		xd=xd*core_Rnd(0.1,0.3);
		yd=yd*core_Rnd(0.1,0.3);
	}
	particle._x+=xd;
	particle._y+=yd;
	particle._speedX <- core_Rnd(0.001,0.02)*sgn(xd);
	particle._speedY <- core_Rnd(0.001,0.02)*sgn(yd);
	particle._initialSizeW <- particle._w+core_Rnd(0,0.3);
	particle._initialSizeH <- particle._h+core_Rnd(0,0.3);
	particle._sizeScale <- core_Rnd(0.001,0.5);
}

function effect_StarB(particle)
{
	if(particle._time<particle._alphaFrom){
		particle._alpha=0;
		return;
	}
	if(particle._time>particle._alphaTo){
		particle._alpha-=0.1*particle._delta;
		if(particle._alpha<0.1)
		{
			if(particle._time<2000 && core_Rnd(0,100)>50)
			{
				particle._alphaFrom=particle._time+core_Rnd(500,1000);
				particle._alphaTo=particle._alphaFrom+core_Rnd(300,700);
			}else{
				particle._dieNow=1;
			}
			return;
		}
	}else{
		particle._alpha+=0.1*particle._delta;
		if(particle._alpha>0.5){
			particle._alpha=0.5;
		}
	}
	particle._rotation+=particle._alpha*0.2;
	particle._w=particle._initialSizeW+particle._alpha*particle._sizeScale;
	particle._h=particle._initialSizeH+particle._alpha*particle._sizeScale;
	particle._x+=particle._speedX;
	particle._y+=particle._speedY;	
}

function effect_BHoleOutInit(particle)
{
	effect_InitPRSAD(particle);
	local iAngle=360/(particle._parameter.tointeger())*particle._cloneNumber;
	particle._rotation=iAngle;
	particle._initialSizeW <- particle._w;
	particle._initialSizeH <- particle._h;
	local effectTime=core_Rnd(800,1200);
	particle._timeOffset <- core_Rnd(0,effectTime);
	particle._timeRound <- effectTime;//core_Rnd(300,900);
	particle._dir <- 1;
	//Вызывается автоматом  effect_BHoleOut(particle);
}

function effect_WHoleOutInit(particle)
{
	effect_BHoleOutInit(particle);
	particle._dir <- -1;
	effect_BHoleOut(particle);
}

function effect_BHoleOut(particle)
{
	local gtime=((particle._time+particle._timeOffset)%particle._timeRound)/particle._timeRound;
	local size = gtime;
	if(particle._dir==1)
	{
		size = 1-gtime;
	}
	particle._alpha=sin(3.14*gtime)*0.5;
	particle._w=particle._initialSizeW*size;
	particle._h=particle._initialSizeH*size;
	particle._rotation+=size*0.1;
}

function effect_Thunder_init(particle)
{
	effect_InitPRSAD(particle);
	particle._affectRotation=0;
	particle._alphaFrom <- core_Rnd(0,700);
	particle._alphaTo <- core_Rnd(500,1500);
	local maxDistance = particle._parameter.tofloat();//*((2+particle._cloneNumber)/10);
	local xd=core_Rnd(-maxDistance,maxDistance);
	local yd=core_Rnd(-maxDistance,maxDistance);
	if(xd*xd+yd*yd>maxDistance*maxDistance)
	{
		xd=xd*core_Rnd(0.1,0.3);
		yd=yd*core_Rnd(0.1,0.3);
	}
	particle._x+=xd;
	particle._y+=yd;
	particle._speedX <- core_Rnd(0.001,0.015)*sgn(xd);
	particle._speedY <- core_Rnd(0.001,0.015)*sgn(yd);
	particle._initialSizeW <- particle._w+core_Rnd(0,0.3);
	particle._initialSizeH <- particle._h+core_Rnd(0,0.3);
	particle._sizeScale <- core_Rnd(0.001,0.5);
}

function effect_Thunder(particle)
{
	if(particle._time<particle._alphaFrom){
		particle._alpha=0;
		return;
	}
	if(particle._time>particle._alphaTo){
		particle._alpha-=0.1*particle._delta;
		if(particle._alpha<0.1)
		{
			if(particle._time<2000 && core_Rnd(0,100)>50)
			{
				particle._alphaFrom=particle._time+core_Rnd(500,1000);
				particle._alphaTo=particle._alphaFrom+core_Rnd(300,700);
			}else{
				particle._dieNow=1;
			}
			return;
		}
	}else{
		particle._alpha+=0.1*particle._delta;
		if(particle._alpha>1.0){
			particle._alpha=1.0;
		}
	}
	particle._w=particle._initialSizeW+particle._alpha*particle._sizeScale;
	particle._h=particle._initialSizeH+particle._alpha*particle._sizeScale;
	particle._x+=particle._speedX;
	particle._y+=particle._speedY;	
}