hectorgimenez / d2go

Utilities related to Diablo 2 Resurrected, written in Go. Just for fun
MIT License
14 stars 14 forks source link

notes about menu offset 0x16c #11

Closed iceisfun closed 3 months ago

iceisfun commented 7 months ago

i am not 100% sure about how this works but I've expanded some menu data, most of this is just for completeness sake but there is one unclear item here about offset 0x16c that might be interesting.

I'm not submitting a PR because this is from my own code and only related because I initially lifted some of your go code and expanded it, you may or may not need this data. I initially was making sure no menu states popped up in the user interface over the region a mouse might interact with just in case the user presented a key event outside what the bot expects (with a belt or chat for example) causing the project/unproject to be incorrect.

this specific value at offset 0x16c flickers when teleporting, changing areas through clicking on a exit or using a waypoint and entering/leaving games. I have used it some to not teleport too fast in a laggy game figuring out if the controlled unit is allowed to move.

below are some snippets of the added information.. also I've added you on discord too, maybe we can discuss other things and compare some notes.

the values that seem to be reasonable

const (
    OpenMenus_CanMove_MoveAllowed       = 0
    OpenMenus_CanMove_CannotMove        = 1
    OpenMenus_CanMove_CannotMoveLoading = 2
    OpenMenus_CanMove_UNKNOWN           = 255
)

some expanded items

type OpenMenus struct {
    InGame        bool
    CanMove       OpenMenus_JoinGameState
    Belt          bool
    Chat          bool
    Merc          bool
    Party         bool
 ... snip ...
}

offsets

    om := OpenMenus{
        InGame:        blob.Data[0x0] != 0,
        Chat:          blob.Data[0x5] != 0,
        Party:         blob.Data[0x15] != 0,
        Belt:          blob.Data[0x1a] != 0,
        Merc:          blob.Data[0x1e] != 0,
        QuestLog:      blob.Data[0x0e] != 0,
                ...snip known data ...
    }

    switch blob.Data[0x16c] {
    case OpenMenus_CanMove_MoveAllowed:
        om.CanMove = OpenMenus_CanMove_MoveAllowed
    case OpenMenus_CanMove_CannotMove:
        om.CanMove = OpenMenus_CanMove_CannotMove
    case OpenMenus_CanMove_CannotMoveLoading:
        om.CanMove = OpenMenus_CanMove_CannotMoveLoading
    default:
        om.CanMove = OpenMenus_CanMove_UNKNOWN
        panic(fmt.Sprintf("unknown move state %d", blob.Data[0x16c]))
    }
hectorgimenez commented 5 months ago

Thanks! I believe it will be really useful!