    let imgWhite=GPSD~"img\white.png";
    let imgAlice=GPSD~"img\alice.png";

    let drawlogic=0;
    let alice3d=0;

    let tk=0;
    let tz=0;
    let txv;
    let tyv;
    let td;

    let sparkx=[0,0,0,0,0,0,0,0,0,0];
    let sparky=[0,0,0,0,0,0,0,0,0,0];
    let sparkt=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];
    let sparkxf=[0,0,0,0,0,0,0,0,0,0];
    let sparkyv=[0,0,0,0,0,0,0,0,0,0];

    let percent=0;
    let visible=true;


    let blurx=[0,0,0,0,0,0,0,0,0,0];
    let blury=[0,0,0,0,0,0,0,0,0,0];
    let blurxv=[0,0,0,0,0,0,0,0,0,0];
    let blurt=[0,0,0,0,0,0,0,0,0,0];

task MoveOffscreen(dir){
	if(GetY>GetClipMinY){
		SetMovePositionNew(GetCenterX+250*dir,0,120);
		Wait(120);
	}
	visible=false;
}

function AliceDrawLogic{
	if(drawlogic%6==0){
		sparkx[drawlogic/6%10]=GetX;
		sparky[drawlogic/6%10]=GetY+rand(80,160);
		sparkt[drawlogic/6%10]=drawlogic;
		sparkxf[drawlogic/6%10]=rand(0,360);
		sparkyv[drawlogic/6%10]=rand(-100,-140);
		blurx[drawlogic/6%10]=GetX;
		blury[drawlogic/6%10]=GetY;
		blurxv[drawlogic/6%10]=rand(-30,30);
		blurt[drawlogic/6%10]=drawlogic;
	}
	td=rand_int(0,9);
	blurx[td]=blurx[td]+rand(-3,3);
	drawlogic++;
}

sub AliceDrawLoop{

	SetTexture(imgAlice);
	SetGraphicAngle(0,0,0);
	SetRenderState(ADD);
	tk=0;
	loop(10){
		if(blurt[tk]>=0){
			SetGraphicRect(203+tk%4*50,100,253+tk%4*50,256);

			percent=((drawlogic)-blurt[tk])/60;
			SetColor((100-percent*100)*Rainbow(0,tk*36),(100-percent*100)*Rainbow(1,tk*36),(100-percent*100)*Rainbow(2,tk*36));
			SetGraphicScale(1,1);
			DrawGraphic(blurx[tk]+percent*blurxv[tk],blury[tk]-100*percent);
		}
		tk++;
	}

	SetColor(255,255,255);

	tk=0;
	loop(10){
		if(sparkt[tk]>=0){
			SetGraphicRect(203+tk%5*50,trunc(tk/5)*50,253+tk%5*50,50+trunc(tk/5)*50);

			percent=sin( (((drawlogic-1)-sparkt[tk])/60)*180 );
			SetColor(percent*255,percent*255,percent*255);
			SetGraphicScale(percent,1);
			percent=((drawlogic-1)-sparkt[tk])/60;
			td=cos(drawlogic*4+sparkxf[tk]);
			DrawGraphic((GetX+sparkx[tk])/2+td*30,(GetY+sparky[tk])/2+sparkyv[tk]*percent);
			DrawGraphic((GetX+sparkx[tk])/2-td*30,(GetY+sparky[tk])/2+sparkyv[tk]*percent);
		}
		tk++;
	}

	SetRenderState(ALPHA);
	SetGraphicRect(trunc(drawlogic/6%4)*50,alice3d*120,50+trunc(drawlogic/6%4)*50,115+alice3d*120);
	SetGraphicAngle(0,0,0);
	SetAlpha(255);
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	DrawGraphic(GetX,GetY+sin(drawlogic*3)*3);
}
sub AliceDrawLoopShield{

}
function DrawDoll(x,y,frame,fade){
	SetTexture(imgAlice);
	SetGraphicRect(460,trunc(frame/4%4)*64,510,64+trunc(frame/4%4)*64);
	SetAlpha(fade*255);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetGraphicScale(0.5,0.5);
	DrawGraphic(x,y);
}
task AliceInit{
	if(trunc(GetCommonDataDefault("Random",1)%20)==0){
		alice3d=1;
	}
	DeleteEnemyShotInCircle(ALL,GetCenterX,GetCenterY,1000000);
	DeleteCommonData("Alicedamage");
	yield;
	DeleteEnemyShotInCircle(ALL,GetCenterX,GetCenterY,1000000);
	DeleteCommonData("KillDoll");
}
sub AliceFinalize{
	DeleteCommonData("Alicedamage");
	SetCommonData("KillDoll",true);
}
sub HandleAliceDamage{
	if(GetTimeOfInvincibility==0){
		AddLife(GetCommonDataDefault("Alicedamage",0));
	}
	DeleteCommonData("Alicedamage");
}
function DamageAlice(num){
	SetCommonData("Alicedamage",GetCommonDataDefault("Alicedamage",0)-num);
}