I'll try to "remote-control" the AI via events now.
So for the time being I suggest the following function as a workaround to be inserted into the events list which will repair AI ships which are in ports until they are at full hp.
Code: Select all
function navalrepair()
for alliance in game.alliances do
if alliance.id ~= 0 and alliance.id ~= player.alliance.id then
for faction in alliance.factions do
for unit in faction.units do
if unit.alive and unit.type == Unit.NAVAL and unit.hex.construction ~= nil and unit.hex.construction.type == Construction.TYPE_PORT then
if unit.prototype.name == "submarine" or unit.prototype.name ~= "lightcruiser" then
if unit.hp <= 70 then
unit.hp = unit.hp + 30
faction:ConsumeManpower(2)
faction:ConsumeProductionPoints(3)
elseif unit.hp <= 80 then
unit.hp = unit.hp + 20
faction:ConsumeManpower(1)
faction:ConsumeProductionPoints(2)
elseif unit.hp <= 90 then
unit.hp = unit.hp + 10
faction:ConsumeManpower(1)
faction:ConsumeProductionPoints(2)
end
elseif unit.prototype.name == "dreadnought" or unit.prototype.name == "battlecruiser" then
if unit.hp <= 90 then
unit.hp = unit.hp + 10
faction:ConsumeManpower(1)
faction:ConsumeProductionPoints(1)
end
elseif unit.prototype.name == "pre-dreadnought" or unit.prototype.name == "armouredcruiser" then
if unit.hp <= 70 then
unit.hp = unit.hp + 30
elseif unit.hp <= 80 then
unit.hp = unit.hp + 20
elseif unit.hp <= 90 then
unit.hp = unit.hp + 10
end
end
end
end
end
end
end
end
Let's see if that helps.
