blackdtools / Blackd-Proxy-CLASSIC

Blackd Proxy CLASSIC
MIT License
9 stars 7 forks source link

An cavebot xyz recorder would be nice. #19

Open divinity76 opened 9 years ago

divinity76 commented 9 years ago

a cavebot xyz auto recorder would be nice i made one myself, but i didn't know where to put the buttons etc, and i don't like the fact that my version modifies the frmHardcoreCheats->positionUpdate code, which afaik, can be very cpu intensive, so there's probably a better way to do this, but i don't know how. so i'm just gonna post my (tested & working) sample implementation here, and hope that you'll make something similar (or improve my code?) for the official blackd proxy:

in frmCavebot , add a AutoRecord checkbox button. and the click event:

Private Sub AutoRecord_Click()
    If (AutoRecord.Value = 1) Then
        frmHardcoreCheats.chkAutoUpdateMap.Value = 1
        'setting it to true triggers the click event, according to https://msdn.microsoft.com/en-us/library/kd7e4yte%28v=vs.90%29.aspx
        'but according to my debugger... it's 1 or 0 , not true or false, and it matters..
    Else
        frmHardcoreCheats.chkManualUpdate = 1
    End If
End Sub

then in frmHardcoreCheats add new function:

Private Sub lblPosition_Change()
    Static oldX As Long
    Static oldY As Long
    Static oldZ As Long
    Dim newX As Long
    Dim newY As Long
    Dim newZ As Long
    Dim oldtext As String
    Dim newtext As String
    If (frmCavebot.AutoRecord.Value <> 1) Then
        'auto record disabled.
        Exit Sub
    End If
    If (modMap.cavebotIDselected <> mapIDselected) Then
        'I DONT KNOW WHAT TO DO IN THIS CASE...
        Debug.Print "modCavebot.cavebotIDselected is not equal to mapIDselected bug... fixme"
        Exit Sub    'to avoid writing to some other characters cavebot list.. not sure how to fix this.
    End If
    newX = myX(mapIDselected)
    newY = myY(mapIDselected)
    newZ = myZ(mapIDselected)
    If (oldX = newX And oldY = newY And oldZ = newZ) Then
        Exit Sub
    End If
    oldX = newX
    oldY = newY
    oldZ = newZ
    oldtext = LCase(frmCavebot.lstScript.List(frmCavebot.lstScript.ListCount - 1))
    newtext = "move " & newX & "," & newY & "," & newZ
    If (oldtext = newtext) Then    'don't make duplicates
        'Debug.Print "oldtext = newtext, skipping.."
        Exit Sub
    End If
    modCavebot.AddCavebotMovePoint mapIDselected, newX, newY, newZ
    'note: currently AddCavebotMovePoint actually ignores mapIDselected/idConnection..
End Sub

again, note that in frmHardcoreCheats , there's a warning about chkAutoUpdateMap being slow ( i guess that means it use a lot of cpu), so there's probably a better way to do this.. i just don't know it.

anyway, the result is that a move x,y,z is automatically added each time you move your character, which is nice, especially on areas where the cavebot easily get confused/stuck and unable to find the path, in those areas, i have experienced that being very explicit about move instructions, help the cavebot to not get stuck

blackdtools commented 9 years ago

Hi again, Sorry for the big delay in my answer. I had to do a big transfer of a lot of domains to a better hosting because my old one (hosting24.com) had a combo of multiple disasters in few time and their lack of admin skill was causing me a lot of problems and headaches. Well, now I am back.

blackdtools commented 9 years ago

About cavebot recorder: It is a good idea, but considering the way that my cavebot works, I would recommend you to only add 1 waypoint each 4 squares. Exception: if you changed floor then you should add the new position inmediately.

blackdtools commented 9 years ago

About speed optimization: The fastest way would be to add the points to cavebot script in the event of receiving a packet that modify myx, myy or myz. That is modMap.bas , function LearnFromPacket, in following cases:

Case &HBE
 ' up -1 floor
Case &HBF
  ' down +1 floor
Case &H65
  ' north update

Case &H66
 ' right update

Case &H67
 ' south update

Case &H68
 ' left update
blackdtools commented 9 years ago

You can make some array of vars, for multiclient recording, to store last saved x,y,z and decide if you add the point or not: Public myAutoCavebotX() As Long Public myAutoCavebotY() As Long Public myAutoCavebotZ() As Long

Finally do a function tryAddToCavebot(idConnection,x,y,z) and there decide if you should add a new point or not, based on the distance to the last added point. If z is different then you should always add it. When you add a point you should update myAutoCavebotX(idConnection),myAutoCavebotY(idConnection) and myAutoCavebotZ(idConnection) with the new point.