 ; Picando

set %fallo 0
set %llevamucho 0
set %transcurrido 0
set #LOBJECTID %PicoID
set #LtargetID YC
set #ltargetkind 2
set #ltargetx %picarx
set #ltargety %picary
    set %MineralBueno NoLoSe
apicar:

if %maxpeso <= #weight
 exit
if %fallo > 6
     exit

 DeleteJournal 
 wait 2
 EVENT Macro %LastObject
 target 4s
 EVENT Macro %LastTarget
 wait 2
 set %initpicar #SCNT

clickok:
                   call keepalive
;Aqui es donde separamos el mineral
 call SeparaMineral
 if %sepcontrol = SiSeparado
   call SeparaMineral

set %tmp #scnt
set %transcurrido %tmp - %initpicar

  if %transcurrido > 12
     {
      set %fallo %fallo + 2
      goto apicar
     }

set %i 1
JournalLoop:
 scanjournal %i

 if N/A in #journal
   {
     if %i > 3
        DELETEJOURNAL
     goto clickok
   }


if %msg_noview in #journal
  exit

if %msg_norock in #journal
  exit

if %msg_noore in #journal
   exit


if %msg_fail in #journal
  {
     set %llevamucho %llevamucho + 1
     if %llevamucho > 6
             exit
     if %transcurrido < 4
          wait 7s
     goto apicar
   }

if %msg_saveworld in #journal 
 {
  DeleteJournal
  wait 22s
  goto clickok
 }

if %msg_getore in #journal
   {
    if %MineralBueno = Si
        goto apicar        
    for %j 1 %oresdistintos
    {
      call ARRAY GET %j
      if %2 in #journal
         goto MineralEncontrado
     }
 ; No conocemos que mineral es!?    
      event sysmessage Aviso, este mineral no lo tengo en la tabla de minerales!
      set %MineralBueno Si
     goto apicar
  
    MineralEncontrado:
    if %1 in %evitar
        {
 ;        event sysmessage Evitando %2
         exit
        }
   
    set %MineralBueno Si
    goto apicar
   }


 
 set %i %i + 1
 if %i > 10
     {  
       DELETEJOURNAL
       goto clickok
     }

goto JournalLoop

Journal_End: 

;msg $Sacabo$
;halt