script_enemy_main{

let side=GetCommonData("WarningSide"); //1-top 2-left 3-bottom 4-right
let xpos=GetCommonData("WarningX");
let ypos=GetCommonData("WarningY");
let waittime=GetCommonData("WarningTime");
let size=GetCommonData("WarningSize");
let type=GetCommonData("WarningType");

let effect1=0;
let custom=0;
if(GetArgument==1){ custom=1; }

let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;
let SEwarning1=("\script\SoundEffects\warning1.wav");
let SEwarning2=("\script\SoundEffects\warning2.wav");
let GReffect=("\script\Images\OtherEffects\Warnings.png");

@Initialize{
	LoadSE("\script\SoundEffects\warning1.wav");
	LoadSE("\script\SoundEffects\warning2.wav");
	LoadGraphic("\script\Images\OtherEffects\Warnings.png");

	SetScore(1);
	SetLife(1);
	MagicCircle(false);
}
	
@MainLoop{

if(time==0 && side==1 && custom==0){
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,xpos,miny+40+(20*size));
	ObjEffect_SetScale(effect1,size,size);
	ObjEffect_SetLayer(effect1,7); ObjEffect_SetTexture(effect1,GReffect); ObjEffect_SetRenderState(effect1,ALPHA);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-30,-30); ObjEffect_SetVertexUV(effect1,0,0,0);
	ObjEffect_SetVertexXY(effect1,1,30,-30); ObjEffect_SetVertexUV(effect1,1,60,0);
	ObjEffect_SetVertexXY(effect1,2,-30,30); ObjEffect_SetVertexUV(effect1,2,0,60);
	ObjEffect_SetVertexXY(effect1,3,30,30); ObjEffect_SetVertexUV(effect1,3,60,60);
	ObjEffect_SetVertexColor(effect1,0,200,255,255,255); ObjEffect_SetVertexColor(effect1,1,200,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,200,255,255,255); ObjEffect_SetVertexColor(effect1,3,200,255,255,255);
}
if(time==0 && side==2 && custom==0){
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,minx+10+(20*size),ypos);
	ObjEffect_SetScale(effect1,size,size);
	ObjEffect_SetLayer(effect1,7); ObjEffect_SetTexture(effect1,GReffect); ObjEffect_SetRenderState(effect1,ALPHA);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-30,-30); ObjEffect_SetVertexUV(effect1,0,60,0);
	ObjEffect_SetVertexXY(effect1,1,30,-30); ObjEffect_SetVertexUV(effect1,1,120,0);
	ObjEffect_SetVertexXY(effect1,2,-30,30); ObjEffect_SetVertexUV(effect1,2,60,60);
	ObjEffect_SetVertexXY(effect1,3,30,30); ObjEffect_SetVertexUV(effect1,3,120,60);
	ObjEffect_SetVertexColor(effect1,0,200,255,255,255); ObjEffect_SetVertexColor(effect1,1,200,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,200,255,255,255); ObjEffect_SetVertexColor(effect1,3,200,255,255,255);
}
if(time==0 && side==3 && custom==0){
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,xpos,maxy-10-(20*size));
	ObjEffect_SetScale(effect1,size,size);
	ObjEffect_SetLayer(effect1,7); ObjEffect_SetTexture(effect1,GReffect); ObjEffect_SetRenderState(effect1,ALPHA);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-30,-30); ObjEffect_SetVertexUV(effect1,0,0,60);
	ObjEffect_SetVertexXY(effect1,1,30,-30); ObjEffect_SetVertexUV(effect1,1,60,60);
	ObjEffect_SetVertexXY(effect1,2,-30,30); ObjEffect_SetVertexUV(effect1,2,0,120);
	ObjEffect_SetVertexXY(effect1,3,30,30); ObjEffect_SetVertexUV(effect1,3,60,120);
	ObjEffect_SetVertexColor(effect1,0,200,255,255,255); ObjEffect_SetVertexColor(effect1,1,200,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,200,255,255,255); ObjEffect_SetVertexColor(effect1,3,200,255,255,255);
}
if(time==0 && side==4 && custom==0){
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,maxx-10-(20*size),ypos);
	ObjEffect_SetScale(effect1,size,size);
	ObjEffect_SetLayer(effect1,7); ObjEffect_SetTexture(effect1,GReffect); ObjEffect_SetRenderState(effect1,ALPHA);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-30,-30); ObjEffect_SetVertexUV(effect1,0,60,60);
	ObjEffect_SetVertexXY(effect1,1,30,-30); ObjEffect_SetVertexUV(effect1,1,120,60);
	ObjEffect_SetVertexXY(effect1,2,-30,30); ObjEffect_SetVertexUV(effect1,2,60,120);
	ObjEffect_SetVertexXY(effect1,3,30,30); ObjEffect_SetVertexUV(effect1,3,120,120);
	ObjEffect_SetVertexColor(effect1,0,200,255,255,255); ObjEffect_SetVertexColor(effect1,1,200,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,200,255,255,255); ObjEffect_SetVertexColor(effect1,3,200,255,255,255);
}
if(time==0 && custom==1){
	effect1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(effect1,xpos,ypos);
	ObjEffect_SetScale(effect1,size,size);
	ObjEffect_SetLayer(effect1,7); ObjEffect_SetTexture(effect1,GReffect); ObjEffect_SetRenderState(effect1,ALPHA);
	ObjEffect_SetPrimitiveType(effect1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(effect1,4);
	ObjEffect_SetVertexXY(effect1,0,-30,-30); ObjEffect_SetVertexUV(effect1,0,0,0);
	ObjEffect_SetVertexXY(effect1,1,30,-30); ObjEffect_SetVertexUV(effect1,1,60,0);
	ObjEffect_SetVertexXY(effect1,2,-30,30); ObjEffect_SetVertexUV(effect1,2,0,60);
	ObjEffect_SetVertexXY(effect1,3,30,30); ObjEffect_SetVertexUV(effect1,3,60,60);
	ObjEffect_SetVertexColor(effect1,0,200,255,255,255); ObjEffect_SetVertexColor(effect1,1,200,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,200,255,255,255); ObjEffect_SetVertexColor(effect1,3,200,255,255,255);
}


if((time+0)%30==0){
	ObjEffect_SetVertexColor(effect1,0,200,255,255,255); ObjEffect_SetVertexColor(effect1,1,200,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,200,255,255,255); ObjEffect_SetVertexColor(effect1,3,200,255,255,255);
if(type==1){ PlaySE(SEwarning1); }
if(type==2){ PlaySE(SEwarning2); }
}
if((time+15)%30==0){
	ObjEffect_SetVertexColor(effect1,0,0,255,255,255); ObjEffect_SetVertexColor(effect1,1,0,255,255,255);
	ObjEffect_SetVertexColor(effect1,2,0,255,255,255); ObjEffect_SetVertexColor(effect1,3,0,255,255,255);
}

if(time==waittime-1){ Obj_Delete(effect1); VanishEnemy; }


time++;
frame++;

}

@Finalize{
}

}