Difference between revisions of "Coordinate Functions"
Jump to navigation
Jump to search
imported>Rasikko |
imported>Rasikko m |
||
Line 39: | Line 39: | ||
coordinateX = coordinateX * 4096 + 4096 | coordinateX = coordinateX * 4096 + 4096 | ||
else | else | ||
coordinateX + 4096 | |||
endif | |||
if coordinateY < 0 | if coordinateY < 0 | ||
coordinateY = coordinateY * 4096 + 4096 | |||
else | else | ||
coordinateY + 4096 | |||
endif | endif | ||
Revision as of 10:32, 21 November 2020
Putting my coordinate functions here since my personal pages are getting too big.
Int[] Function GetCellCoordinates(ObjectReference akRef)
; Returns an array of this references' cell coordinates.
int posX = akRef.GetPositionX() as int
int posY = akRef.GetPositionY() as int
if (posX < 0)
posX = (posX / 4096) - 1
else
posX = posX / 4096
endif
if (posY < 0)
posY = (posY / 4096) - 1
else
posY = posY / 4096
endif
Int[] CellCoordinates = new Int[2]
CellCoordinates[0] = posX
CellCoordinates[1] = posY
return CellCoordinates
EndFunction
The following requires GetCellCoordinates(). To explain what the function below does, the origin in the game, for example has the x axis positions of 0, 4096, respectively.
Int[] Function GetCellStartingWorldPositions(Int[] aiCoordinates)
; Returns an array of starting world positions for this cell.
Int coordinateX = aiCoordinates[0]
Int coordinateY = aiCoordinates[1]
Int[] startPos = new int[2]
if coordinateX < 0
coordinateX = coordinateX * 4096 + 4096
else
coordinateX + 4096
endif
if coordinateY < 0
coordinateY = coordinateY * 4096 + 4096
else
coordinateY + 4096
endif
startPos[0] = coordinateX
startPos[1] = coordinateY
return startPos
EndFunction