$${
IF(automine2);
ACHIEVEMENTGET(Assistente OFF,270);UNSET(automine2);
setlabel(T3,,T3);setlabel(T2,,T2);setlabel(T1,,T1);
setlabel(Y3,,Y3);setlabel(Y2,,Y2);setlabel(Y1,,Y1);
setlabel(U3,,U3);setlabel(U2,,U2);setlabel(U1,,U1);
setlabel(II,,II);setlabel(OO,,OO);setlabel(LT,,LT);
STOP();
ELSE;
ACHIEVEMENTGET(Assistente ON,270);SET(automine2);set(lado);unset(perigo);#nblocos=1;
endif;
DO;
// ======================================= DIREÇÃO
&ff = %DIRECTION%;
ifmatches(%&ff%,N);&ff=NORTH;&fa=SOUTH;&fd=EAST;&fe=WEST;#nx1=1;#nx2=0;#nx3=-1;#nz1=-2;#nz2=-2;#nz3=-2;#nxb=0;#nzb=-1;endif;
ifmatches(%&ff%,S);&fa=NORTH;&ff=SOUTH;&fe=EAST;&fd=WEST;#nx1=-1;#nx2=0;#nx3=1;#nz1=2;#nz2=2;#nz3=2;#nxb=0;#nzb=1;endif;
ifmatches(%&ff%,E);&fe=NORTH;&fd=SOUTH;&ff=EAST;&fa=WEST;#nz1=1;#nz2=0;#nz3=-1;#nx1=2;#nx2=2;#nx3=2;#nxb=1;#nzb=0;endif;
ifmatches(%&ff%,W);&fd=NORTH;&fe=SOUTH;&fa=EAST;&ff=WEST;#nz1=-1;#nz2=0;#nz3=1;#nx1=-2;#nx2=-2;#nx3=-2;#nxb=-1;#nzb=0;endif;
// ======================================= LEITURA DO TERRENO
GETIDREL(%#nx1%,2,%#nz1%,&lid1a);GETIDREL(%#nx2%,2,%#nz2%,&lid1b);GETIDREL(%#nx3%,2,%#nz3%,&lid1c);
GETIDREL(%#nx1%,1,%#nz1%,&lid2a);GETIDREL(%#nx2%,1,%#nz2%,&lid2b);GETIDREL(%#nx3%,1,%#nz3%,&lid2c);
GETIDREL(%#nx1%,0,%#nz1%,&lid3a);GETIDREL(%#nx2%,0,%#nz2%,&lid3b);GETIDREL(%#nx3%,0,%#nz3%,&lid3c);
GETIDREL(%#nxb%,-1,%#nzb%,&lid4b);GETIDREL(%#nxb%,2,%#nzb%,&lid5b);
// ======================================= NOMES
GETITEMINFO(%&lid1a%,&lidn1a);GETITEMINFO(%&lid1b%,&lidn1b);GETITEMINFO(%&lid1c%,&lidn1c);
GETITEMINFO(%&lid2a%,&lidn2a);GETITEMINFO(%&lid2b%,&lidn2b);GETITEMINFO(%&lid2c%,&lidn2c);
GETITEMINFO(%&lid3a%,&lidn3a);GETITEMINFO(%&lid3b%,&lidn3b);GETITEMINFO(%&lid3c%,&lidn3c);
GETITEMINFO(%&lid4b%,&lidn4b);GETITEMINFO(%&lid5b%,&lidn5b);
// ======================================= CORES E NUMERACAO
#lid1a=1;#lid1b=1;#lid1c=1;
#lid2a=1;#lid2b=1;#lid2c=1;
#lid3a=1;#lid3b=1;#lid3c=1;
#lid4b=1;#lid5b=1;
&cor1a=f;&cor2a=f;&cor3a=f;
&cor1b=f;&cor2b=f;&cor3b=f;
&cor1c=f;&cor2c=f;&cor3c=f;
&cor4b=f;&cor5b=f;
// LAVA
ifmatches(%&lid1a%,lava);&cor1a=4;#lid1a=11;endif;
ifmatches(%&lid1b%,lava);&cor1b=4;#lid1b=11;endif;
ifmatches(%&lid1c%,lava);&cor1c=4;#lid1c=11;endif;
ifmatches(%&lid2a%,lava);&cor2a=4;#lid2a=11;endif;
ifmatches(%&lid2b%,lava);&cor2b=4;#lid2b=11;endif;
ifmatches(%&lid2c%,lava);&cor2c=4;#lid2c=11;endif;
ifmatches(%&lid3a%,lava);&cor3a=4;#lid3a=11;endif;
ifmatches(%&lid3b%,lava);&cor3b=4;#lid3b=11;endif;
ifmatches(%&lid3c%,lava);&cor3c=4;#lid3c=11;endif;
ifmatches(%&lid4b%,lava);&cor4b=4;#lid4b=11;endif;
ifmatches(%&lid5b%,lava);&cor5b=4;#lid5b=11;endif;
// AGUA
ifmatches(%&lid1a%,water);&cor1a=3;#lid1a=9;endif;
ifmatches(%&lid1b%,water);&cor1b=3;#lid1b=9;endif;
ifmatches(%&lid1c%,water);&cor1c=3;#lid1c=9;endif;
ifmatches(%&lid2a%,water);&cor2a=3;#lid2a=9;endif;
ifmatches(%&lid2b%,water);&cor2b=3;#lid2b=9;endif;
ifmatches(%&lid2c%,water);&cor2c=3;#lid2c=9;endif;
ifmatches(%&lid3a%,water);&cor3a=3;#lid3a=9;endif;
ifmatches(%&lid3b%,water);&cor3b=3;#lid3b=9;endif;
ifmatches(%&lid3c%,water);&cor3c=3;#lid3c=9;endif;
ifmatches(%&lid4b%,water);&cor4b=3;#lid4b=9;endif;
ifmatches(%&lid5b%,water);&cor5b=3;#lid5b=9;endif;
// CASCALHO
ifmatches(%&lid1a%,gravel);&cor1a=e;#lid1a=13;endif;
ifmatches(%&lid1b%,gravel);&cor1b=e;#lid1b=13;endif;
ifmatches(%&lid1c%,gravel);&cor1c=e;#lid1c=13;endif;
ifmatches(%&lid2a%,gravel);&cor2a=e;#lid2a=13;endif;
ifmatches(%&lid2b%,gravel);&cor2b=e;#lid2b=13;endif;
ifmatches(%&lid2c%,gravel);&cor2c=e;#lid2c=13;endif;
ifmatches(%&lid3a%,gravel);&cor3a=e;#lid3a=13;endif;
ifmatches(%&lid3b%,gravel);&cor3b=e;#lid3b=13;endif;
ifmatches(%&lid3c%,gravel);&cor3c=e;#lid3c=13;endif;
ifmatches(%&lid4b%,gravel);&cor4b=e;#lid4b=13;endif;
ifmatches(%&lid5b%,gravel);&cor5b=e;#lid5b=13;endif;
// AR
ifmatches(%&lid1a%,air);&lidn1a=;endif;
ifmatches(%&lid1b%,air);&lidn1b=;endif;
ifmatches(%&lid1c%,air);&lidn1c=;endif;
ifmatches(%&lid2a%,air);&lidn2a=;endif;
ifmatches(%&lid2b%,air);&lidn2b=;endif;
ifmatches(%&lid2c%,air);&lidn2c=;endif;
ifmatches(%&lid3a%,air);&lidn3a=;endif;
ifmatches(%&lid3b%,air);&lidn3b=;endif;
ifmatches(%&lid3c%,air);&lidn3c=;endif;
ifmatches(%&lid4b%,air);&cor4b=d;#lid4b=0;&lidn4b=Vazio;endif;
ifmatches(%&lid5b%,air);&lidn5b=;endif;
ifmatches(%&lid4b%,air);#lid4b=0;endif;
// ======================================= LABELS
setlabel(T3,&%&cor1a%%&lidn1a%,T3);setlabel(T2,&%&cor1b%%&lidn1b%,T2);setlabel(T1,&%&cor1c%%&lidn1c%,T1);
setlabel(Y3,&%&cor2a%%&lidn2a%,Y3);setlabel(Y2,&%&cor2b%%&lidn2b%,Y2);setlabel(Y1,&%&cor2c%%&lidn2c%,Y1);
setlabel(U3,&%&cor3a%%&lidn3a%,U3);setlabel(U2,&%&cor3b%%&lidn3b%,U2);setlabel(U1,&%&cor3c%%&lidn3c%,U1);
setlabel(II,&%&cor4b%%&lidn4b%,II);setlabel(OO,&%&cor5b%%&lidn5b%,OO);
//======================================== LEITURA DE CONDIÇÕES
IF((%#lid1a%=11)|(%#lid2a%=11)|(%#lid3a%=11));#teste=4;&teste=&4LAVA DETECTADA;
ELSEIF((%#lid1b%=11)|(%#lid2b%=11)|(%#lid3b%=11));#teste=4;&teste=&4LAVA DETECTADA;
ELSEIF((%#lid1c%=11)|(%#lid2c%=11)|(%#lid3c%=11));#teste=4;&teste=&4LAVA DETECTADA;
ELSEIF((%#lid4b%=11)|(%#lid5b%=11));#teste=4;&teste=&4LAVA DETECTADA;
ELSEIF(%#lid4b%=0);#teste=3;&teste=&dQUEDA DETECTADA;
ELSEIF((%#lid1a%=9)|(%#lid2a%=9)|(%#lid3a%=9));#teste=2;&teste=&3AGUA DETECTADA;
ELSEIF((%#lid1b%=9)|(%#lid2b%=9)|(%#lid3b%=9));#teste=2;&teste=&3AGUA DETECTADA;
ELSEIF((%#lid1c%=9)|(%#lid2c%=9)|(%#lid3c%=9));#teste=2;&teste=&3AGUA DETECTADA;
ELSEIF((%#lid4b%=9)|(%#lid5b%=9));#teste=2;&teste=&3AGUA DETECTADA;
ELSEIF((%#lid1a%=13)|(%#lid2a%=13)|(%#lid3a%=13));#teste=1;&teste=&eCASCALHO DETECTADO;
ELSEIF((%#lid1b%=13)|(%#lid2b%=13)|(%#lid3b%=13));#teste=1;&teste=&eCASCALHO DETECTADO;
ELSEIF((%#lid1c%=13)|(%#lid2c%=13)|(%#lid3c%=13));#teste=1;&teste=&eCASCALHO DETECTADO;
ELSEIF((%#lid4b%=13)|(%#lid5b%=13));#teste=1;&teste=&eCASCALHO DETECTADO;
ELSE;#teste=0;&teste=&fSetor limpo;ENDIF;
setlabel(LT,%&teste% - Nível de Perigo: %#teste%,LT);
LOOP;
}$$