Tekamthi
Emperor
- Joined
- Aug 12, 2016
- Messages
- 1,662
I've been trying to have a unit "drift" while in ocean tiles... I have created some basic lua to accomplish this -- problem is I'm not super familiar with how X/Y coordinates work on a hex grid... result is sometimes my unit drifts 2 tiles.
edit: nvm.. got it, posted below in case anyone else comes across this:
i still get the occasional exception from AI units concerning nil pPlot, but it seems to work as intended nonetheless
edit: nvm.. got it, posted below in case anyone else comes across this:
Code:
for pUnit in pPlayer:Units() do
local pPlot = pUnit:GetPlot()
local pType = pUnit:GetUnitType()
if ... then
local pDrift = Game.Rand(7, "Drift Roll") - 1
local pAdjacentPlot = Map.PlotDirection(pPlot:GetX(), pPlot:GetY(), pDrift)
pUnit:SetXY(pAdjacentPlot:GetX(), pAdjacentPlot:GetY())
end
Last edited: