Guest User

Untitled

a guest
Aug 16th, 2015
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance Force
  2. F1::
  3. CoordMode Pixel, Window
  4. Game = Binding of Isaac: Rebirth
  5. Rooms := { "NoRoom" : 0, "Left" : 1, "Right" : 2, "Top" : 3, "Bottom" : 4 }
  6. Room = Rooms["NoRoom"]
  7. loop
  8. {
  9.     if(norestart != 0) {
  10.         ControlSend ahk_parent, {R down},  %Game%
  11.         Sleep 1200
  12.         ControlSend ahk_parent, {R up},  %Game%
  13.         Sleep 750
  14.     }
  15.     Boundaries := CalculateMap()
  16.     CurseOfTheLost := Boundaries[1]
  17.     If (CurseOfTheLost == 0)
  18.     {
  19.         Map := Boundaries[2]
  20.         Room := MapCrossSearch(Map[1],Map[2],Map[3],Map[4],0x26eeea,3,Rooms)
  21.     }
  22.     else
  23.     {
  24.         DoorLeft := Boundaries[2]
  25.         DoorRight := Boundaries[3]
  26.         DoorTop := Boundaries[4]
  27.         DoorBottom := Boundaries[5]
  28.         Room := DoorAreaSearch(DoorLeft[1], DoorLeft[2], DoorLeft[3], DoorLeft[4], Rooms["Left"], 1,Rooms)
  29.         if(Room==Rooms["NoRoom"]) {
  30.             Room := DoorAreaSearch(DoorRight[1], DoorRight[2], DoorRight[3], DoorRight[4], Rooms["Right"], 1,Rooms)
  31.             if(Room==Rooms["NoRoom"]) {
  32.                 Room := DoorAreaSearch(DoorTop[1], DoorTop[2], DoorTop[3], DoorTop[4], Rooms["Top"], 1,Rooms)
  33.                 if(Room==Rooms["NoRoom"]) {
  34.                     Room := DoorAreaSearch(DoorBottom[1], DoorBottom[2], DoorBottom[3], DoorBottom[4], Rooms["Bottom"], 1,Rooms)
  35.                 }
  36.             }
  37.         }
  38.  
  39.     }
  40. } until Room != Rooms["NoRoom"] || norestart == 0
  41.  
  42. MoveIsaac(Room, Rooms, Game)
  43. return
  44. ; end of story
  45.  
  46. MapCrossSearch(TotalLeft, TotalRight, TotalTop, TotalBottom, Color, Threshold, Rooms) {
  47.     Third := (TotalRight-TotalLeft)/3
  48.    
  49.     TopPlusThird := TotalTop+Third
  50.     LeftPlusThird := TotalLeft+Third
  51.    
  52.     RightMinusThird := TotalRight-Third
  53.     BottomMinusThird := TotalBottom-Third
  54.    
  55.     ; search whole map
  56.     PixelSearch OutX, OutY, TotalLeft, TotalTop, TotalRight, TotalBottom, Color, Threshold, Fast
  57.     If ErrorLevel = 0
  58.     {
  59.         ;search horizontal
  60.         PixelSearch OutX, OutY, TotalLeft, TopPlusThird, TotalRight, BottomMinusThird, Color, Threshold, Fast
  61.         If ErrorLevel = 0
  62.         {
  63.             ;search left
  64.             PixelSearch OutX, OutY, TotalLeft, TopPlusThird, LeftPlusThird, BottomMinusThird, Color, Threshold, Fast
  65.             If ErrorLevel = 0
  66.             {
  67.                 return Rooms["Left"]
  68.             }
  69.             Else
  70.             {
  71.                 return Rooms["Right"]
  72.             }
  73.         }
  74.         else
  75.         {
  76.             ;search top
  77.             PixelSearch OutX, OutY, LeftPlusThird, TotalTop, RightMinusThird, TopPlusThird, Color, Threshold, Fast
  78.             If ErrorLevel = 0
  79.             {
  80.                 return Rooms["Top"]
  81.             }
  82.             Else
  83.             {
  84.                 return Rooms["Bottom"]
  85.             }
  86.         }
  87.     } else {
  88.         return Rooms["NoRoom"]
  89.     }
  90.  }
  91.  
  92. DoorAreaSearch(DoorLeft, DoorRight, DoorTop, DoorBottom, ReturnCode, Threshold, Rooms) {
  93.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x06537B, Threshold, Fast
  94.     If ErrorLevel = 0
  95.         return ReturnCode
  96.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0xBCB5B1, Threshold, Fast
  97.     If ErrorLevel = 0
  98.         return ReturnCode
  99.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0xA8A19E, Threshold, Fast
  100.     If ErrorLevel = 0
  101.         return ReturnCode
  102.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x5F92A5, Threshold, Fast
  103.     If ErrorLevel = 0
  104.         return ReturnCode
  105.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0xB8B2AF, Threshold, Fast
  106.     If ErrorLevel = 0
  107.         return ReturnCode
  108.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x0E84B0, Threshold, Fast
  109.     If ErrorLevel = 0
  110.         return ReturnCode
  111.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x116D90, Threshold, Fast
  112.     If ErrorLevel = 0
  113.         return ReturnCode
  114.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x054262, Threshold, Fast
  115.     If ErrorLevel = 0
  116.         return ReturnCode
  117.     PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x426673, Threshold, Fast
  118.     If ErrorLevel = 0
  119.         return ReturnCode
  120.     return Rooms["NoRoom"]
  121.  }
  122.  
  123. MoveIsaac(Room, Rooms, Game)
  124. {
  125.     ;left
  126.     if(Room == Rooms["Left"])
  127.     {
  128.         ControlSend ahk_parent, {A down},  %Game%
  129.         ControlSend ahk_parent, {W down},  %Game%
  130.         Sleep 700
  131.         ControlSend ahk_parent, {W up},  %Game%
  132.         Sleep 1000
  133.         ControlSend ahk_parent, {S down},  %Game%
  134.         Sleep 300
  135.         ControlSend ahk_parent, {S up},  %Game%
  136.         Sleep 720
  137.         ControlSend ahk_parent, {W down},  %Game%
  138.         ControlSend ahk_parent, {A up},  %Game%
  139.         Sleep 300
  140.         ControlSend ahk_parent, {W up},  %Game%
  141.     }
  142.     ;right
  143.     else if (Room == Rooms["Right"])
  144.     {
  145.         ControlSend ahk_parent, {D down},  %Game%
  146.         ControlSend ahk_parent, {W down},  %Game%
  147.         Sleep 700
  148.         ControlSend ahk_parent, {W up},  %Game%
  149.         Sleep 1000
  150.         ControlSend ahk_parent, {S down},  %Game%
  151.         Sleep 300
  152.         ControlSend ahk_parent, {S up},  %Game%
  153.         Sleep 720
  154.         ControlSend ahk_parent, {W down},  %Game%
  155.         ControlSend ahk_parent, {D up},  %Game%
  156.         Sleep 300
  157.         ControlSend ahk_parent, {W up},  %Game%
  158.     }
  159.     ;up
  160.     else if (Room == Rooms["Top"])
  161.     {
  162.         ControlSend ahk_parent, {W down},  %Game%
  163.         Sleep 2500
  164.         ControlSend ahk_parent, {W up},  %Game%
  165.     }
  166.     ;down
  167.     else if (Room == Rooms["Bottom"])
  168.     {
  169.         ControlSend ahk_parent, {S down},  %Game%
  170.         Sleep 1500
  171.         ControlSend ahk_parent, {S up},  %Game%
  172.     }
  173.     ;move down and exit
  174.     if(Room != Rooms["NoRoom"]) {
  175.         ControlSend ahk_parent, {S down},  %Game%
  176.         Sleep 1000
  177.         ControlSend ahk_parent, {S up},  %Game%
  178.         Sleep 500
  179.         MsgBox Item found!
  180.     }
  181. }
  182.  
  183.  GetStats() {
  184.     SysGet, xborder, 32
  185.     SysGet, yborder, 33
  186.     SysGet, caption, 4
  187.     WinGetPos WinX, WinY, WinWidth, WinHeight, Binding of Isaac: Rebirth
  188.     WinWidth := WinWidth-(xborder+xborder)
  189.     WinHeight := WinHeight-(caption+yborder+yborder)
  190.     ratio := (WinWidth-(xborder+xborder))/(WinHeight-(caption+yborder+yborder))
  191.     return [WinWidth, WinHeight, xborder, yborder, caption, ratio]
  192. }
  193.  
  194. CalculateMap() {
  195.     Stats := GetStats()
  196.     Width := Stats[1]
  197.     Height := Stats[2]
  198.     Xborder := Stats[3]
  199.     YBorder := Stats[4]
  200.     Caption := Stats[5]
  201.     Ratio := Stats[6]
  202.    
  203.     Center := Width/2
  204.     CenterH := Height/2
  205.    
  206.     MapX := Width-315
  207.     MapX2 := Width-205
  208.     MapY  := 180
  209.     MapY2 := 280
  210.  
  211.     ; starting with lowest resolution
  212.     MapWidthX1 := 55
  213.     MapWidthX2 := 35
  214.    
  215.     MapX := Width-MapWidthX1
  216.     MapX2 := Width-MapWidthX2
  217.     MapY := 60
  218.     MapY2 := 80
  219.    
  220.     DoorHWidth := 25
  221.     DoorHHeight := 22.5
  222.    
  223.     DoorVWidth := 22.5
  224.     DoorVHeight := 25
  225.    
  226.     RoomWidth := 390
  227.     RoomHeight := 218
  228.    
  229.     RoomBorderX := Floor((Width-RoomWidth)/2)-XBorder
  230.     RoomBorderY := Floor((Height-RoomHeight)/2)-YBorder
  231.        
  232.     while(RoomBorderX >= 195 && RoomBorderY >= 117)
  233.     {
  234.         MapWidthX1 := MapWidthX1 + 65
  235.         MapWidthX2 := MapWidthX2 + 42.5
  236.         MapX := Floor(Width-MapWidthX1)
  237.         MapX2 := Floor(Width-MapWidthX2)
  238.         MapY := Floor(MapY) + 30
  239.         MapY2 := Floor(MapY2) + 50
  240.        
  241.         DoorHHeight := Floor(DoorHHeight + 23.75)
  242.         DoorHWidth := Floor(DoorHWidth + 25)
  243.        
  244.         DoorVHeight := Floor(DoorVHeight + 23.75)
  245.         DoorVWidth := Floor(DoorVWidth + 25)
  246.    
  247.         RoomWidth := RoomWidth + 390
  248.         RoomHeight := RoomHeight + 234
  249.         RoomBorderX := Floor((Width-RoomWidth)/2)-XBorder
  250.         RoomBorderY := Floor((Height-RoomHeight)/2)-YBorder
  251.     }
  252.        
  253.     MapHCenter := Floor((MapX+(MapX2-MapX)/2)-1)
  254.     MapVCenter := Floor((MapY+(MapY2-MapY)/2)-1)
  255.     MapHCenter2 := MapHCenter+2
  256.     MapVCenter2 := MapVCenter+2
  257.    
  258.     PixelSearch OutX, OutY, MapHCenter, MapVCenter, MapHCenter2, MapVCenter2, 0xD4D4D4, 1, Fast
  259.     If ErrorLevel = 0
  260.     {
  261.         Map := [MapX, MapX2, MapY, MapY2]
  262.         return [0, Map]
  263.     }
  264.     else
  265.     {
  266.         DoorTop := [Floor(Center-DoorVWidth), Floor(Center+DoorVWidth),Floor(RoomBorderY+Caption+YBorder),Floor(RoomBorderY+Caption+YBorder+DoorVHeight)]
  267.         DoorBottom := [Floor(Center-DoorVWidth), Floor(Center+DoorVWidth),Floor((Caption+YBorder+Height)-(RoomBorderY+DoorVHeight)), Floor((Caption+YBorder+Height)-RoomBorderY)]
  268.         DoorRight := [Width-DoorHWidth-RoomBorderX, Width-RoomBorderX, Floor(CenterH-DoorHHeight), Floor(CenterH+DoorHHeight)]
  269.         DoorLeft := [RoomBorderX, RoomBorderX+DoorHWidth, Floor(CenterH-DoorHHeight), Floor(CenterH+DoorHHeight)]
  270.        
  271.         return [1, DoorLeft, DoorRight, DoorTop, DoorBottom]
  272.     }
  273. }
Advertisement
Add Comment
Please, Sign In to add comment