The Wiki for Tale 6 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

User:Anka/Macros/Barley

From ATITD6
Jump to navigationJump to search
//Brute Force Barley Macro - updated for T6

//Pin your "Barley" plant window in the far top right corner.  There is a menu with
//this macro now but the plant coordinates are not implemented yet.  There are delays
//you can change if the macro is going too fast.
//Have about 70 water and fertilizer per round.  The batch feature will work but be
//certain you have enough water.  It will drift away from your starting position.  I
//will be fixing this later.

// The comments below are from the old version of the macro.  All can be changed in
// the menu now.

//I will be cleaning this up a bit. :)  Anka

Constants
  
  Plants = 2 //This is the number of Barley beds you want to plant.
  
  SleepTime	= 200		//If you're having major problems with lag try moving this to a higher
  //number (these are in milliseconds).  This delay is used between most
  //commands
  
  MoveSleepTime = 1500 	//This is the delay used for when the character is actually moving.
  //Again this is in milliseconds, if lag is troubling you, try
  //Upping this number.
  
  LoopWaitTime = 1000		//This is used in the loop to check if it should feed or water the
  //barley more.  If you Change the times above up or down you may need
  //to do the inverse with this in order to not waste fertilizer or
  //worse, harvest the barley before it's done.
  
  
  PlantX = 973 	//If you don't want the barley planting box in the upper right,
  //can change this (and the Y value below this).
  PlantY = 47		//See above comment
  
  Batch = 2
  newx = 0
  newy = 0
  DragX = 103
  DragY = 44
  AddX = 210
  AddY = 0
  PinX = 194
  PinY = 47
  BarY = 163
  HarvestX = 114
  HarvestY = 229
  CloseX = 180
  CloseY = 107
  BWin = 0
  StepRightX = 0
  StepRightY = 0
  StepDownX = 0
  StepDownY = 0
  StepLeftX = 0
  StepLeftY = 0
  ResetX = 0
  ResetY = 0
  WaterY = 116
  FertY = 136
  
  varX = 0
  varY = 0
  Adding = 0
  LoopNum = 0
  WinNum = 1
  NumberAdded = 0
  varColourY = 0
  varColourX = 0
  varAddX = 0
  
  varOriginalMouseX = 0
  varOriginalMouseY = 0
  
  MousePosX = 0
  MousePosY = 0
  varDelay = 0
  MDelay = 50
  Res = 0
  Windows = 0
  PlantCount = 1
End

Object Danger //6x8 116, 135
  231=2,2|230=2,4|230=2,6
  117=4,0|236=4,2|235=4,4|237=4,6|119=4,8
  231=6,0|115=6,2|115=6,6|229=6,8
End

Object Harvest  //6x8 134, 135
  231=2,0|226=2,2|226=2,6|230=2,8
  235=4,0|234=4,2|234=4,6|233=4,8
End


Form Barley, Settings
  ed1=Editbox:# of Plants:2
  ed2=Editbox:Sleep Time:200
  ed3=Editbox:Move Sleep Time:1500
  ed4=Editbox:Loop Wait Time:1000
  ed5=Editbox:XCoords of Plant Barley:973
  ed6=Editbox:YCoords of Plant Barley:47
  ed7=Editbox:Batch:2
  ed8=Combobox:Resolution:1024x768, 1280x1024, 1360x768, 1920x1080
  ed9=Checkbox:Venery?:False
end

FormLoad Barley, Barley.frm

if ShowForm Barley
  Set Plants = Barley[ed1]
  Set SleepTime = Barley[ed2]
  Set MoveSleepTime = Barley[ed3]
  Set LoopWaitTime = Barley[ed4]
  Set PlantX = Barley[ed5]
  Set PlantY = Barley[ed6]
  Set Batch = Barley[ed7]
  Set Res = Barley[ed8]
else
  stop
end

FormSave Barley, Barley.frm

Keydown @{Tab} 200
Delay 2000

call Resolution
If Barley[ed9] = True
  	Compute WaterY = $WaterY + 9
  	Compute FertY = $FertY + 9
  	Compute BarY = $BarY + 9
  End
Loop $Batch
  Loop $Plants
    call MakeBarley
    Compute NewX = {screenwidth} / 2
    Compute NewY = {screenheight} / 2
    Case
    When $PlantCount <= 4
      SetConst $MousePosX = $StepRightX
      SetConst $MousePosY = $StepRightY
      Call LeftClick2
      Delay $MoveSleepTime
    When $PlantCount = 5
      SetConst $MousePosX = $StepDownX
      SetConst $MousePosY = $StepDownY
      Call LeftClick2
      Delay $MoveSleepTime
    When $PlantCount < $Plants
      SetConst $MousePosX = $StepLeftX
      SetConst $MousePosY = $StepLeftY
      Call LeftClick2
      Delay $MoveSleepTime
    End
    Inc PlantCount
  End
  
  Loop 63
    SetConst WinNum = 1
    Loop $Plants
      Case
      When $WinNum <= $Windows
        Compute NewX = $PinX + ($AddX * ( {loopno} - 1)) - 18
        Compute NewY = $BarY
      When $WinNum > $Windows
        Compute NewX = $PinX + ($AddX * ( {loopno} - $Windows - 1)) - 18
        Compute NewY = $BarY + $AddY
      End
      SetConst varColourX = $NewX
      SetConst varColourY = $NewY
      Call TestColor
      Inc $WinNum
    End
    Delay $LoopWaitTime
  End
  //Harvest
  SetConst WinNum = 1
  Loop $Plants
    Case
    When $WinNum <= $Windows
      Compute NewX = $HarvestX + ($AddX * ( {loopno} - 1))
      Compute NewY = $HarvestY
    When $WinNum > $Windows
      Compute NewX = $HarvestX + ($AddX * ( {loopno} - $Windows - 1))
      Compute NewY = $HarvestY + $AddY
    End
    SetConst $MousePosX = $NewX
    SetConst $MousePosY = $NewY
    Call Rightclick2
    //Close Window
    Case
    When $WinNum <= $Windows
      Compute NewX = $CloseX + ($AddX * ( {loopno} - 1))
      Compute NewY = $CloseY
    When $WinNum > $Windows
      Compute NewX = $CloseX + ($AddX * ( {loopno} - $Windows - 1))
      Compute NewY = $CloseY + $AddY
    End
    SetConst $MousePosX = $NewX
    SetConst $MousePosY = $NewY
    Call Rightclick2
    Inc $WinNum
  End
  SetConst $MousePosX = $ResetX
  SetConst $MousePosY = $ResetY
  //Call Leftclick2
  Bell
  stop
End

Procedure MakeBarley
  SetConst MousePosX = $PlantX
  SetConst MousePosY = $PlantY
  call RightClick2 //plant barley spot
  Compute MousePosX =  {screenwidth} / 2
  Compute MousePosY = ( {screenheight} / 2 ) + 80
  call RightClick2 // click on barley
  Call GetMousePos
  MousePos $BWin
  Delay $MDelay
  Case
  When $WinNum <= $Windows
    Compute NewX = $DragX + ($AddX * ($PlantCount - 1))
    Compute NewY = $DragY
    //Timestamp $NewY
  When $WinNum > $Windows
    Compute NewX = $DragX + ($AddX * ($PlantCount - $Windows - 1))
    Compute NewY = $DragY + $AddY
  End
  DragTo $NewX, $NewY //Drag Barley to appropriate spot
  //timestamp $NewY
  Delay $MDelay
  Call SetMousePos
  Case
  When $WinNum <= $Windows
    Compute NewX = $PinX + ($AddX * ($PlantCount - 1))
    Compute NewY = $PinY
  When $WinNum > $Windows
    Compute NewX = $PinX + ($AddX * ($PlantCount - $Windows - 1))
    Compute NewY = $PinY + $AddY
  End
  SetConst MousePosX = $NewX
  SetConst MousePosY = $NewY
  call RightClick2 //This pins the window open
  //water
  Loop 2
    Case
    When $WinNum <= $Windows
      Compute NewX = $PinX + ($AddX * ($PlantCount - 1))
      Compute NewY = $PinY + $WaterY
    When $WinNum > $Windows
      Compute NewX = $PinX + ($AddX * ($PlantCount - $Windows - 1))
      Compute NewY = $PinY + $WaterY + $AddY
    End
    SetConst MousePosX = $NewX
    SetConst MousePosY = $NewY
    timestamp $newX, $NewY "Water"
    call Rightclick2
    Case
    When $WinNum <= $Windows
      Compute NewX = $PinX + ($AddX * ($PlantCount - 1))
      Compute NewY = $PinY + $FertY
    When $WinNum > $Windows
      Compute NewX = $PinX + ($AddX * ($PlantCount - $Windows - 1))
      Compute NewY = $PinY + $FertY + $AddY
    End
    
    SetConst MousePosX = $NewX
    SetConst MousePosY = $NewY
    timestamp $newx, $newY "fert"
    call RightClick2
    
  End
  Inc $WinNum
End

Procedure TestColor  //This actually tests the colours based on the position set in TestColourWhich
  LoadRGB $varColourX, $varColourY
  timestamp $varColourX, $varColourY
  if {RGBBlue} > 220 //If it's really high in blue content
  else
    Call GetMousePos
    Compute NewX = $varColourX + 18
    SetConst MousePosX = $NewX
    SetConst MousePosY = $varColourY
    call RightClick2
    Compute MousePosY = $MousePosY + 20
    call Rightclick2
    Call SetMousePos
    Delay 100
  end
  
end

Procedure StepRight
  SetConst $MousePosX = 1343
  SetConst $MousePosY = 567
  Call LeftClick2
End

Procedure GetMousePos //find the original coords of the mouse
  SetConst varOriginalMouseX = {MouseX}
  SetConst varOriginalMouseY = {MouseY}
End

Procedure SetMousePos //set the mouse back where it came from
  MousePos $varOriginalMouseX, $varOriginalMouseY
End

Procedure LeftClick2
  call GetMousePos
  MousePos $MousePosX, $MousePosY
  Delay $MDelay
  LeftClick
  Delay $MDelay
  Call SetMousePos
End

Procedure RightClick2
  Call GetMousePos
  MousePos $MousePosX, $MousePosY
  Delay $MDelay
  RightClick
  Delay $MDelay
  Call SetMousePos
End

Procedure Resolution
  Case
  When $Res = 1920x1080
    SetConst PlantX = 1859
    SetConst PlantY = 39
    SetConst BWin = 1061, 525
    SetConst StepRightX = 1330
    SetConst StepRightY = 580
    SetConst StepDownX = 955
    SetConst StepDownY = 1000
    SetConst StepLeftX = 535
    SetConst StepLeftY = 580
    SetConst Windows = 9
    SetConst AddY = 712
    SetConst ResetX =
    SetConst ResetY =
  When $Res = 1360x768
    SetConst PlantX = 1300
    SetConst PlantY = 40
    SetConst BWin = 781, 370
    SetConst StepRightX = 977
    SetConst StepRightY = 410
    SetConst StepDownX = 667
    SetConst StepDownY = 694
    SetConst StepLeftX = 352
    SetConst StepLeftY = 410
    SetConst Windows = 6
    SetConst AddY = 483
    SetConst ResetX = 91
    SetConst ResetY = 136
  When $Res = 1280x1024
    SetConst PlantX = 1220
    SetConst PlantY = 40
    SetConst BWin = 742, 498
    SetConst StepRightX = 899
    SetConst StepRightY = 544
    SetConst StepDownX = 633
    SetConst StepDownY = 879
    SetConst StepLeftX = 331
    SetConst StepLeftY = 534
    SetConst Windows = 5
    SetConst AddY = 750
    SetConst ResetX = 158
    SetConst ResetY = 164
  When $Res = 1024x768
    SetConst PlantX = 963
    SetConst PlantY = 40
    SetConst BWin = 614, 370
    SetConst StepRightX = 739
    SetConst StepRightY = 400
    SetConst StepDownX = 516
    SetConst StepDownY = 654
    SetConst StepLeftX = 286
    SetConst StepLeftY = 400
    SetConst Windows = 4
    SetConst AddY = 497
    SetConst ResetX = 5
    SetConst ResetY = 124
  End
End
//Updated by Anka for Tale 6