Skip to content

Mapping (World & Image Coordinates)

Andrew edited this page Sep 16, 2013 · 1 revision

Mapping

Mapping entity information to the in-game world.

The protobuf messages pass coordinates in two parts: a cell and an offset within that cell. These can be converted into the in-game world coordinates using the following algorithm.

MAX_COORD_INTEGER = 16384
def coordFromCell(entity):
    cellwidth = 1 << entity[(u'DT_BaseEntity', u'm_cellbits')]

    x = ((entity[(u'DT_DOTA_BaseNPC', u'm_cellX')] * cellwidth) - MAX_COORD_INTEGER)\
        + entity[(u'DT_DOTA_BaseNPC', u'm_vecOrigin')][0]

    y = ((entity[(u'DT_DOTA_BaseNPC', u'm_cellY')] * cellwidth) - MAX_COORD_INTEGER)\
        + entity[(u'DT_DOTA_BaseNPC', u'm_vecOrigin')][1]

    return (x, y)

Mapping world coordinates to image coordinates

These utilities will allow you to create images and animations using the in-game coordinates: