Uighur_Caesar
Comandante en Jefe
I'm trying to make a UA that will allow your units to move across pillaged tiles with no cost. I currently have this although it isn't doing exactly what I want:
This isn't exactly making it ignore cost when moving onto pillaged tiles. It works fine for the first tile, but if the unit crosses a second pillaged tile in the same turn it stops working in that the unit has 1 move rather than 2. To give an example, let's say I have a unit starting it's turn a tile away from a pillaged tile. The unit spends one move to get adjacent to the pillaged tile and then spends no moves to enter the pillaged tile. However, if I try to move from that pillaged tile to another adjacent pillaged tile, the unit runs out of moves rather than continuing to have 1 move left. The number of displayed moves available also goes down anyway, although I don't think there's important. Any ideas about what I need to change?
Code:
local isApacheActive = JFD_IsCivilisationActive(apacheID)
function ApachePillageMovement(playerID, unitID, unitX, unitY)
local player = Players[playerID]
local teamID = player:GetTeam()
local playerTeam = Teams[teamID]
local unit = player:GetUnitByID(unitID)
if player:GetCivilizationType() == apacheID and player:IsAlive() then
local plot = unit:GetPlot()
if (plot:GetImprovementType() ~= -1) then
if plot:IsImprovementPillaged() then
unit:ChangeMoves(1)
end
end
end
end
if isApacheActive then
GameEvents.UnitSetXY.Add(ApachePillageMovement)
end
This isn't exactly making it ignore cost when moving onto pillaged tiles. It works fine for the first tile, but if the unit crosses a second pillaged tile in the same turn it stops working in that the unit has 1 move rather than 2. To give an example, let's say I have a unit starting it's turn a tile away from a pillaged tile. The unit spends one move to get adjacent to the pillaged tile and then spends no moves to enter the pillaged tile. However, if I try to move from that pillaged tile to another adjacent pillaged tile, the unit runs out of moves rather than continuing to have 1 move left. The number of displayed moves available also goes down anyway, although I don't think there's important. Any ideas about what I need to change?