Furthermore, when I put a command "AiSet("unit-dwarves-cottage", 1)" in the AI script, it does build it. It's only when the AI is out of food that it won't build them.
So, what do I have done scripting-wise that would be relevant to know? The load order of relevant scripts in stratagus.lua goes like this: units (inside it are also the animations and buttons), upgrades, AiHelper, land_attack-dwarves (the AI script used in my tests).
https://sourceforge.net/p/battle4mandic ... atagus.lua
The unit-dwarves-worker is the one supposed to build the cottages.
https://sourceforge.net/p/battle4mandic ... worker.lua
In the file for unit-dwarves-cottage we have these relevant lines:
Code: Select all
Supply = 6,
DefineButton( { Pos = 3, Level = 2, Icon = "icon-dwarves-cottage",
Action = "build", Value = "unit-dwarves-cottage",
Key = "c", Hint = _("BUILD ~!COTTAGE"),
ForUnit = {"unit-dwarves-worker", "unit-dwarves-advanced-worker", "unit-dwarves-advanced-worker2"} } )
DefineAllow("unit-dwarves-cottage", "AAAAAAAAAAAAAAAA")
In the upgrade.lua for dwarves there aren't any dependencies for cottages.
https://sourceforge.net/p/battle4mandic ... pgrade.lua
In the ai.lua (contains the DefineAiHelper) I tried the game with just this:
Code: Select all
race1 = "dwarves"
race2 = "darkness"
DefineAiHelper(
{"build", "unit-dwarves-worker",
"unit-dwarves-town-center", "unit-dwarves-cottage", "unit-dwarves-guard-tower",
"unit-dwarves-market",
"unit-dwarves-blacksmith", "unit-dwarves-lumber-mill"},
{"unit-limit", "unit-dwarves-cottage", "food"}
)
--
-- Some functions used by Ai
--
-- Create some counters used by ai
local function CreateAiGameData()
if stratagus == nil then
stratagus = {}
end
if stratagus.gameData == nil then
stratagus.gameData = {}
end
if stratagus.gameData.AIState == nil then
stratagus.gameData.AIState = {}
stratagus.gameData.AIState.index = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
stratagus.gameData.AIState.loop_index = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
end
end
local function CleanAiGameData()
if stratagus ~= nil and stratagus.gameData ~= nil then
stratagus.gameData.AIState = nil
end
end
function ReInitAiGameData()
CleanAiGameData()
CreateAiGameData()
end
--
-- Load the actual individual scripts.
--
ReInitAiGameData()
Load("scripts/ai/passive.lua")
Load("scripts/ai/land_attack-dwarves.lua")
Load("scripts/ai/land_attack-darkness.lua")
Load("scripts/ai/luhdaga.lua")
https://sourceforge.net/p/battle4mandic ... pts/ai.lua
The land_attack-dwarves script uses the new layout suggested to me that doesn't put every order inside "function() return" and "end,". The layout was pretty much copied from Aleona's Tales' adaptive AI. The land_attack-dwarves will train workers until it has enough money to do other things. However, I've tried even with a stripped down version in which it will only train workers. It does utilize my self-made CheckDependency function but I doubt that's the problem since I've tested this with the unpatched Stratagus and it doesn't work either.
https://sourceforge.net/p/battle4mandic ... warves.lua
So, have you got any ideas what the problem might be? Also, another strange problem I'm having which I haven't yet had time to properly address but I'll say it anyway in case someone has had a similar problem: When I or the AI is building something, when the building is finished the worker won't stop automatically "building" it. It will just stays there hacking the air with its axe (the building animation).