Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance Force
- F1::
- CoordMode Pixel, Window
- Game = Binding of Isaac: Rebirth
- Rooms := { "NoRoom" : 0, "Left" : 1, "Right" : 2, "Top" : 3, "Bottom" : 4 }
- Room = Rooms["NoRoom"]
- loop
- {
- if(norestart != 0) {
- ControlSend ahk_parent, {R down}, %Game%
- Sleep 1200
- ControlSend ahk_parent, {R up}, %Game%
- Sleep 750
- }
- Boundaries := CalculateMap()
- CurseOfTheLost := Boundaries[1]
- If (CurseOfTheLost == 0)
- {
- Map := Boundaries[2]
- Room := MapCrossSearch(Map[1],Map[2],Map[3],Map[4],0x26eeea,3,Rooms)
- }
- else
- {
- DoorLeft := Boundaries[2]
- DoorRight := Boundaries[3]
- DoorTop := Boundaries[4]
- DoorBottom := Boundaries[5]
- Room := DoorAreaSearch(DoorLeft[1], DoorLeft[2], DoorLeft[3], DoorLeft[4], Rooms["Left"], 1,Rooms)
- if(Room==Rooms["NoRoom"]) {
- Room := DoorAreaSearch(DoorRight[1], DoorRight[2], DoorRight[3], DoorRight[4], Rooms["Right"], 1,Rooms)
- if(Room==Rooms["NoRoom"]) {
- Room := DoorAreaSearch(DoorTop[1], DoorTop[2], DoorTop[3], DoorTop[4], Rooms["Top"], 1,Rooms)
- if(Room==Rooms["NoRoom"]) {
- Room := DoorAreaSearch(DoorBottom[1], DoorBottom[2], DoorBottom[3], DoorBottom[4], Rooms["Bottom"], 1,Rooms)
- }
- }
- }
- }
- } until Room != Rooms["NoRoom"] || norestart == 0
- MoveIsaac(Room, Rooms, Game)
- return
- ; end of story
- MapCrossSearch(TotalLeft, TotalRight, TotalTop, TotalBottom, Color, Threshold, Rooms) {
- Third := (TotalRight-TotalLeft)/3
- TopPlusThird := TotalTop+Third
- LeftPlusThird := TotalLeft+Third
- RightMinusThird := TotalRight-Third
- BottomMinusThird := TotalBottom-Third
- ; search whole map
- PixelSearch OutX, OutY, TotalLeft, TotalTop, TotalRight, TotalBottom, Color, Threshold, Fast
- If ErrorLevel = 0
- {
- ;search horizontal
- PixelSearch OutX, OutY, TotalLeft, TopPlusThird, TotalRight, BottomMinusThird, Color, Threshold, Fast
- If ErrorLevel = 0
- {
- ;search left
- PixelSearch OutX, OutY, TotalLeft, TopPlusThird, LeftPlusThird, BottomMinusThird, Color, Threshold, Fast
- If ErrorLevel = 0
- {
- return Rooms["Left"]
- }
- Else
- {
- return Rooms["Right"]
- }
- }
- else
- {
- ;search top
- PixelSearch OutX, OutY, LeftPlusThird, TotalTop, RightMinusThird, TopPlusThird, Color, Threshold, Fast
- If ErrorLevel = 0
- {
- return Rooms["Top"]
- }
- Else
- {
- return Rooms["Bottom"]
- }
- }
- } else {
- return Rooms["NoRoom"]
- }
- }
- DoorAreaSearch(DoorLeft, DoorRight, DoorTop, DoorBottom, ReturnCode, Threshold, Rooms) {
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x06537B, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0xBCB5B1, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0xA8A19E, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x5F92A5, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0xB8B2AF, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x0E84B0, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x116D90, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x054262, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- PixelSearch OutX, OutY, DoorLeft, DoorTop, DoorRight, DoorBottom, 0x426673, Threshold, Fast
- If ErrorLevel = 0
- return ReturnCode
- return Rooms["NoRoom"]
- }
- MoveIsaac(Room, Rooms, Game)
- {
- ;left
- if(Room == Rooms["Left"])
- {
- ControlSend ahk_parent, {A down}, %Game%
- ControlSend ahk_parent, {W down}, %Game%
- Sleep 700
- ControlSend ahk_parent, {W up}, %Game%
- Sleep 1000
- ControlSend ahk_parent, {S down}, %Game%
- Sleep 300
- ControlSend ahk_parent, {S up}, %Game%
- Sleep 720
- ControlSend ahk_parent, {W down}, %Game%
- ControlSend ahk_parent, {A up}, %Game%
- Sleep 300
- ControlSend ahk_parent, {W up}, %Game%
- }
- ;right
- else if (Room == Rooms["Right"])
- {
- ControlSend ahk_parent, {D down}, %Game%
- ControlSend ahk_parent, {W down}, %Game%
- Sleep 700
- ControlSend ahk_parent, {W up}, %Game%
- Sleep 1000
- ControlSend ahk_parent, {S down}, %Game%
- Sleep 300
- ControlSend ahk_parent, {S up}, %Game%
- Sleep 720
- ControlSend ahk_parent, {W down}, %Game%
- ControlSend ahk_parent, {D up}, %Game%
- Sleep 300
- ControlSend ahk_parent, {W up}, %Game%
- }
- ;up
- else if (Room == Rooms["Top"])
- {
- ControlSend ahk_parent, {W down}, %Game%
- Sleep 2500
- ControlSend ahk_parent, {W up}, %Game%
- }
- ;down
- else if (Room == Rooms["Bottom"])
- {
- ControlSend ahk_parent, {S down}, %Game%
- Sleep 1500
- ControlSend ahk_parent, {S up}, %Game%
- }
- ;move down and exit
- if(Room != Rooms["NoRoom"]) {
- ControlSend ahk_parent, {S down}, %Game%
- Sleep 1000
- ControlSend ahk_parent, {S up}, %Game%
- Sleep 500
- MsgBox Item found!
- }
- }
- GetStats() {
- SysGet, xborder, 32
- SysGet, yborder, 33
- SysGet, caption, 4
- WinGetPos WinX, WinY, WinWidth, WinHeight, Binding of Isaac: Rebirth
- WinWidth := WinWidth-(xborder+xborder)
- WinHeight := WinHeight-(caption+yborder+yborder)
- ratio := (WinWidth-(xborder+xborder))/(WinHeight-(caption+yborder+yborder))
- return [WinWidth, WinHeight, xborder, yborder, caption, ratio]
- }
- CalculateMap() {
- Stats := GetStats()
- Width := Stats[1]
- Height := Stats[2]
- Xborder := Stats[3]
- YBorder := Stats[4]
- Caption := Stats[5]
- Ratio := Stats[6]
- Center := Width/2
- CenterH := Height/2
- MapX := Width-315
- MapX2 := Width-205
- MapY := 180
- MapY2 := 280
- ; starting with lowest resolution
- MapWidthX1 := 55
- MapWidthX2 := 35
- MapX := Width-MapWidthX1
- MapX2 := Width-MapWidthX2
- MapY := 60
- MapY2 := 80
- DoorHWidth := 25
- DoorHHeight := 22.5
- DoorVWidth := 22.5
- DoorVHeight := 25
- RoomWidth := 390
- RoomHeight := 218
- RoomBorderX := Floor((Width-RoomWidth)/2)-XBorder
- RoomBorderY := Floor((Height-RoomHeight)/2)-YBorder
- while(RoomBorderX >= 195 && RoomBorderY >= 117)
- {
- MapWidthX1 := MapWidthX1 + 65
- MapWidthX2 := MapWidthX2 + 42.5
- MapX := Floor(Width-MapWidthX1)
- MapX2 := Floor(Width-MapWidthX2)
- MapY := Floor(MapY) + 30
- MapY2 := Floor(MapY2) + 50
- DoorHHeight := Floor(DoorHHeight + 23.75)
- DoorHWidth := Floor(DoorHWidth + 25)
- DoorVHeight := Floor(DoorVHeight + 23.75)
- DoorVWidth := Floor(DoorVWidth + 25)
- RoomWidth := RoomWidth + 390
- RoomHeight := RoomHeight + 234
- RoomBorderX := Floor((Width-RoomWidth)/2)-XBorder
- RoomBorderY := Floor((Height-RoomHeight)/2)-YBorder
- }
- MapHCenter := Floor((MapX+(MapX2-MapX)/2)-1)
- MapVCenter := Floor((MapY+(MapY2-MapY)/2)-1)
- MapHCenter2 := MapHCenter+2
- MapVCenter2 := MapVCenter+2
- PixelSearch OutX, OutY, MapHCenter, MapVCenter, MapHCenter2, MapVCenter2, 0xD4D4D4, 1, Fast
- If ErrorLevel = 0
- {
- Map := [MapX, MapX2, MapY, MapY2]
- return [0, Map]
- }
- else
- {
- DoorTop := [Floor(Center-DoorVWidth), Floor(Center+DoorVWidth),Floor(RoomBorderY+Caption+YBorder),Floor(RoomBorderY+Caption+YBorder+DoorVHeight)]
- DoorBottom := [Floor(Center-DoorVWidth), Floor(Center+DoorVWidth),Floor((Caption+YBorder+Height)-(RoomBorderY+DoorVHeight)), Floor((Caption+YBorder+Height)-RoomBorderY)]
- DoorRight := [Width-DoorHWidth-RoomBorderX, Width-RoomBorderX, Floor(CenterH-DoorHHeight), Floor(CenterH+DoorHHeight)]
- DoorLeft := [RoomBorderX, RoomBorderX+DoorHWidth, Floor(CenterH-DoorHHeight), Floor(CenterH+DoorHHeight)]
- return [1, DoorLeft, DoorRight, DoorTop, DoorBottom]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment