Used in HW Classic, for Sajuuk and other Amiral ship, but doesn’t use in HWRM, so IA can’t build Sajuuk and other amiral ship.
EDIT :
The new error (after made lot of print to find the issue of other) :
parameter: attempt to index a nil value
stack traceback:
1: function `CpuBuildSS_ProcessEachBuildShip' at line 61 [string ""]
2: function `CpuBuildSS_DoBuildSubSystem' at line 149 [string ""]
3: function `DoMilitaryBuild' at line 353 [string ""]
4: function `CpuBuild_Process' at line 325 [string ""]
5: function `SpendMoney' at line 240 [string ""]
6: function `doai' at line 255 [string ""]
between line 60 and 61 of cpubildsubsystem.lua add print("Build ship is - "..buildShip). This is the “numbered” value of the ship that isn’t in ai_data or for which UpgradeDemand doesn’t appear in it’s ai_data.
You could try switching line 61 and 62 around.
[Edit]
I’m unsure of any proper way of getting the name of the ship, but you could try adding a new function
function getBuilderIndexPos(nShip)
local nget = getn(squadclass[eBuilder])
if (nget == 0) then
print("No builders"); return
end
local npos = 0
for i = 1,nget do
npos = npos + 1
if (squadclass[eBuilder][i]~= nil and squadclass[eBuilder][i]== nShip) then
print("Builder at position "..npos)
return
end
end
print("Builder not found")
end
Then replace the earlier print function with print("Builder at pos - "..getBuilderIndexPos(buildShip))
Then in classdef.lua, find squadclass[eBuilder] and the ship should be at the position the print statement said. If all works, that unit is either not in ai_data, or it doesn’t include UpgradeDemand.
It’s the mothership … But can’t build by the AI because it’s one ship don’t have build option in build.lua ^^
So, need to add to database the mothership ?
By the way, even if we have this error, AI build units and attack.
It’s more on Basicdemand value i need clarification. Higher value = more demand for AI (like : You need to build this when you can) or lower value ? [Because i see, when all is 0, AI build the same number of Ressource collector / rafinery / corvette / fighter ]
But, the AI don’t go harvest RU, only build and made “shopping” with a limited Credit Card It’s the first problem here … But i can launch more than 3 AI with 3 different race.
Thanks a lot for this code, @HW_Lover! I’ve already implemented it in my mod for the next release (the source of the code will be listed in the mod description, of course).
There’s a bug reported by my players and that I reproduced: when the AI Script is turned on, trying to save the game lead to an immediate CTD (if I rename the ai folder as ai-old, it doesn’t crash) with the log saying:
parameter: invalid key for `next’
parameter: unable to recover; exiting