Re: Naval AI not repairing its ships!
Posted: Tue May 10, 2016 6:12 pm
I stopped messing with the AI scripts after I got all kinds of strange errors including crazy stuff like "Access violation - no RTTI data" which seems pretty severe to me.
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.
While this won't force the AI to return damaged ships to port it should at least provide repairs at the usual pp/mp costs for ships that are in ports.
Let's see if that helps.
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.