function HealthBar{

if(time==0){
maxlife=GetLife;

	loop(2){
	health=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(health,cx-20,miny+12);
	ObjEffect_SetScale(health,1,1);
	ObjEffect_SetLayer(health,7); ObjEffect_SetTexture(health,GRhealthbar); ObjEffect_SetRenderState(health,ALPHA);
	ObjEffect_SetPrimitiveType(health,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(health,4);
	ObjEffect_SetVertexXY(health,0,0,-11); ObjEffect_SetVertexUV(health,0,16,0);
	ObjEffect_SetVertexXY(health,1,1,-11); ObjEffect_SetVertexUV(health,1,16,0);
	ObjEffect_SetVertexXY(health,2,0,11); ObjEffect_SetVertexUV(health,2,17,22);
	ObjEffect_SetVertexXY(health,3,1,11); ObjEffect_SetVertexUV(health,3,17,22);
	ObjEffect_SetVertexColor(health,0,255,255,255,255); ObjEffect_SetVertexColor(health,1,255,255,255,255);
	ObjEffect_SetVertexColor(health,2,255,255,255,255); ObjEffect_SetVertexColor(health,3,255,255,255,255);
	health1=health1~[health];
	}

	sides=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(sides,cx-20-sidesmove,miny+12);
	ObjEffect_SetScale(sides,1,1); ObjEffect_SetAngle(sides,0,0,0);
	ObjEffect_SetLayer(sides,7); ObjEffect_SetTexture(sides,GRhealthbar); ObjEffect_SetRenderState(sides,ALPHA);
	ObjEffect_SetPrimitiveType(sides,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(sides,4);
	ObjEffect_SetVertexXY(sides,0,-6.5,-11); ObjEffect_SetVertexUV(sides,0,1,0);
	ObjEffect_SetVertexXY(sides,1,6.5,-11); ObjEffect_SetVertexUV(sides,1,14,0);
	ObjEffect_SetVertexXY(sides,2,-6.5,11); ObjEffect_SetVertexUV(sides,2,1,22);
	ObjEffect_SetVertexXY(sides,3,6.5,11); ObjEffect_SetVertexUV(sides,3,14,22);
	ObjEffect_SetVertexColor(sides,0,255,255,255,255); ObjEffect_SetVertexColor(sides,1,255,255,255,255);
	ObjEffect_SetVertexColor(sides,2,255,255,255,255); ObjEffect_SetVertexColor(sides,3,255,255,255,255);
	sides1=sides1~[sides];

	sides=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(sides,cx-20+sidesmove,miny+12);
	ObjEffect_SetScale(sides,1,1); ObjEffect_SetAngle(sides,0,0,0);
	ObjEffect_SetLayer(sides,7); ObjEffect_SetTexture(sides,GRhealthbar); ObjEffect_SetRenderState(sides,ALPHA);
	ObjEffect_SetPrimitiveType(sides,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(sides,4);
	ObjEffect_SetVertexXY(sides,0,-6.5,-11); ObjEffect_SetVertexUV(sides,0,19,0);
	ObjEffect_SetVertexXY(sides,1,6.5,-11); ObjEffect_SetVertexUV(sides,1,32,0);
	ObjEffect_SetVertexXY(sides,2,-6.5,11); ObjEffect_SetVertexUV(sides,2,19,22);
	ObjEffect_SetVertexXY(sides,3,6.5,11); ObjEffect_SetVertexUV(sides,3,32,22);
	ObjEffect_SetVertexColor(sides,0,255,255,255,255); ObjEffect_SetVertexColor(sides,1,255,255,255,255);
	ObjEffect_SetVertexColor(sides,2,255,255,255,255); ObjEffect_SetVertexColor(sides,3,255,255,255,255);
	sides1=sides1~[sides];

	timerbar=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(timerbar,maxx-30,miny+13);
	ObjEffect_SetLayer(timerbar,7); ObjEffect_SetTexture(timerbar,GRhealthbar); ObjEffect_SetRenderState(timerbar,ALPHA);
	ObjEffect_SetPrimitiveType(timerbar,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(timerbar,4);
	ObjEffect_SetVertexXY(timerbar,0,-20,-12); ObjEffect_SetVertexUV(timerbar,0,33,1);
	ObjEffect_SetVertexXY(timerbar,1,20,-12); ObjEffect_SetVertexUV(timerbar,1,73,1);
	ObjEffect_SetVertexXY(timerbar,2,-20,12); ObjEffect_SetVertexUV(timerbar,2,33,25);
	ObjEffect_SetVertexXY(timerbar,3,20,12); ObjEffect_SetVertexUV(timerbar,3,73,25);
	ObjEffect_SetVertexColor(timerbar,0,255,255,255,255); ObjEffect_SetVertexColor(timerbar,1,255,255,255,255);
	ObjEffect_SetVertexColor(timerbar,2,255,255,255,255); ObjEffect_SetVertexColor(timerbar,3,255,255,255,255);

	loop(3){
	timereffect=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(timereffect,maxx-30,miny+13);
	ObjEffect_SetLayer(timereffect,7); ObjEffect_SetTexture(timereffect,GRhealthbar); ObjEffect_SetRenderState(timereffect,ADD);
	ObjEffect_SetPrimitiveType(timereffect,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(timereffect,4);
	ObjEffect_SetVertexXY(timereffect,0,-5,-9); ObjEffect_SetVertexUV(timereffect,0,74,1);
	ObjEffect_SetVertexXY(timereffect,1,5,-9); ObjEffect_SetVertexUV(timereffect,1,84,1);
	ObjEffect_SetVertexXY(timereffect,2,-5,9); ObjEffect_SetVertexUV(timereffect,2,74,19);
	ObjEffect_SetVertexXY(timereffect,3,5,9); ObjEffect_SetVertexUV(timereffect,3,84,19);
	ObjEffect_SetVertexColor(timereffect,0,255,255,255,0); ObjEffect_SetVertexColor(timereffect,1,255,255,255,0);
	ObjEffect_SetVertexColor(timereffect,2,255,255,255,0); ObjEffect_SetVertexColor(timereffect,3,255,255,255,0);
	timercounter=timercounter~[timereffect];
	}

let ypos=0;
	loop(spellcards){
	spellseffect=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(spellseffect,minx+9,miny+12+ypos);
	ObjEffect_SetLayer(spellseffect,7); ObjEffect_SetTexture(spellseffect,GRhealthbar); ObjEffect_SetRenderState(spellseffect,ALPHA);
	ObjEffect_SetPrimitiveType(spellseffect,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(spellseffect,4);
	ObjEffect_SetVertexXY(spellseffect,0,-9,-9); ObjEffect_SetVertexUV(spellseffect,0,0,22);
	ObjEffect_SetVertexXY(spellseffect,1,9,-9); ObjEffect_SetVertexUV(spellseffect,1,18,22);
	ObjEffect_SetVertexXY(spellseffect,2,-9,9); ObjEffect_SetVertexUV(spellseffect,2,0,40);
	ObjEffect_SetVertexXY(spellseffect,3,9,9); ObjEffect_SetVertexUV(spellseffect,3,18,40);
	ObjEffect_SetVertexColor(spellseffect,0,255,255,255,255); ObjEffect_SetVertexColor(spellseffect,1,255,255,255,255);
	ObjEffect_SetVertexColor(spellseffect,2,255,255,255,255); ObjEffect_SetVertexColor(spellseffect,3,255,255,255,255);
	ypos+=15;
	}
}


if(sidesmove<146 || time<110){ sidesmove+=5+6*cos(sidesmove); }
Obj_SetPosition(sides1[0],cx-20-sidesmove,miny+12);
Obj_SetPosition(sides1[1],cx-20+sidesmove,miny+12);

ObjEffect_SetScale(health1[0],(sidesmove*2),1);
ObjEffect_SetScale(health1[1],(sidesmove*2)*(GetLife/maxlife),1);
ObjEffect_SetVertexColor(health,0,255,255,255*(GetLife/maxlife),255*(GetLife/maxlife));
ObjEffect_SetVertexColor(health,1,255,255,255*(GetLife/maxlife),255*(GetLife/maxlife));
ObjEffect_SetVertexColor(health,2,255,255,255*(GetLife/maxlife),255*(GetLife/maxlife));
ObjEffect_SetVertexColor(health,3,255,255,255*(GetLife/maxlife),255*(GetLife/maxlife));
if(GetLife<=5){ Obj_Delete(health); SetLife(0);}

let number=0;
let digit=0;
let i=0;
loop(3){
	let horizontal=0;
	let vertical=0;
	Obj_SetPosition(timercounter[i],maxx-40+number,miny+14);
		if(i==2){ digit=floor(GetTimer)%10; }
		if(i==1){ digit=floor(GetTimer/10)%10; }
		if(i==0){ digit=floor(GetTimer/100)%10; }
		loop(digit){
			horizontal+=11;
			if(horizontal>=55){ horizontal=0; vertical+=18; }
		}
	ObjEffect_SetVertexUV(timercounter[i],0,74+horizontal,1+vertical);
	ObjEffect_SetVertexUV(timercounter[i],1,84+horizontal,1+vertical);
	ObjEffect_SetVertexUV(timercounter[i],2,74+horizontal,19+vertical);
	ObjEffect_SetVertexUV(timercounter[i],3,84+horizontal,19+vertical);
	if(GetTimer<10 && GetTimer>=3){
		ObjEffect_SetVertexColor(timercounter[i],0,255,255,128,0); ObjEffect_SetVertexColor(timercounter[i],1,255,255,128,0);
		ObjEffect_SetVertexColor(timercounter[i],2,255,255,128,0); ObjEffect_SetVertexColor(timercounter[i],3,255,255,128,0);
	}
	if(GetTimer<3){
		ObjEffect_SetVertexColor(timercounter[i],0,255,255,0,0); ObjEffect_SetVertexColor(timercounter[i],1,255,255,0,0);
		ObjEffect_SetVertexColor(timercounter[i],2,255,255,0,0); ObjEffect_SetVertexColor(timercounter[i],3,255,255,0,0);
	}
	i++;
	number+=11;
}


if(GetLife<50 && oldlife>GetLife && (time+0)%4==0){ PlaySE(SElowhealth1); }
if(GetLife<50 && oldlife>GetLife && (time+2)%4==0){ PlaySE(SElowhealth2); }
oldlife=GetLife;

if(GetLife>0){
	if(GetTimer<=10 && GetTimer>3 && time%60==0){ PlaySE(SEtimeout1); }
	if(GetTimer<=3 && time%60==0 && timercount<3){ PlaySE(SEtimeout2); timercount+=1; }
}

if(GetCommonDataDefault("NoAutoDispel",0)==0 && GetLife==0 && dispelled==0){
	if((GetLife==0 && dispelled==0 && spellcards==1) ||
	GetCommonDataDefault("SpellcardPractise",0)==1){
	CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,character);
	dispelled=1;
	}
}

if(GetKeyState(VK_BOMB)==KEY_PUSH && GetCommonDataDefault("SpellcardPractise",0)==1){
	VanishEnemy;
	SetCommonData("RetrySpellcard",1);
	SetCommonData("BackToSpellcardPractise",1);
}
if((GetKeyState(VK_USER)==KEY_PUSH || GetMissCountInThisSpell>0) && GetCommonDataDefault("SpellcardPractise",0)==1){
	VanishEnemy;
	SetCommonData("RetrySpellcard",0);
	SetCommonData("BackToSpellcardPractise",1);
}


}
