Getting the AI to use worker units without all worker jobs enabled

AvalancheMaster

Not the face of mercy.
Joined
Jun 27, 2012
Messages
190
Location
Yubaba's Bath House
Introduction

It seems that one of the biggest frustrations to modders is the fact that while you are allowed to enable/disable what worker jobs a unit can do, the AI cannot use a worker unit unless all worker jobs have been enabled. Let's check which are those unit actions:

  • Build Colony
  • Build Road
  • Build Railroad
  • Build Mine
  • Irrigate
  • Automate
  • Build Airfield
  • Build Outpost
  • Build Fort
  • Build Barricade
  • Chop Down Forest
  • Clear Wetlands
  • Plant Forest
  • Clear Damage
  • Join City
  • Build Radar Tower

While there have been some solutions to this problem, they don't solve all problems caused by this issue. In my mod I want Build Colony to be available only to a specific Colonist unit that is acquired later on. I also want specialized worker units later on (e.g. road builders, farmers, etc.) that have more worker power (that is how quick does the worker finish the job). None of the solutions that are currently known allow this, and until now it was thought to be impossible.

I am going to teach you how to fix this problem in such a way, that disallowing worker jobs would not affect the AI. This does not mean that the AI will adapt to use different workers in different situations (e.g. use those new units in a complex and comprehensive way), due to the nature of the AI, but it will still use AND produce all of the worker units that are currently available to the AI civs.

And all that in 3 easy steps! Who would've known!

For the purpose of this mod you need basic understandings of hex editing, a hex editor (I recommend Hex Editor Neo), and some patience. Also recommended is this awesome guide to the BIQ file format, though it is not required. Still, it helps a lot.

So, without further ado, let's jump straight to the tutorial.

Step I: Create a new map with custom rules enabled

Create a new map with custom rules enabled. Go to the Units tab, select "Worker" from the top-down menu, and disable the worker jobs that you want to disable.

You'll see that the "Terraform" AI checkbox turns gray. This is due to the fact that some clever guy at Firaxis made the editor disable the Terraform option if not all worker jobs are selected - for no apparent reason. However, this is not hardcoded in the game, it's only in the editor. Can't say the same thing for the number of Eras, sadly, but that's a whole other topic.

Step II: Save the map with compress option disabled

Close the Edit Rules window. Go to View -> Options, and deselect "Compress BIC files". That is an important step, so do not miss it!

Step III: Open your map in a hex editing program

Now that's where we get our hands dirty with the nitty and gritty stuff.

Once you've opened the BIQ in the Hex Editing program, find the section that says "PRTO", and then find "Worker" under it. The big orange rectangle loosely represents all the data about the Worker unit we've edited in the Conquest editor. The smaller blue rectangular is where the AI flags are stored in binary, and the smallest of all shows where the "Terraform" and "Naval Carrier" flags are stored. Since we've edited the allowed worker actions, the editor automatically changed this from 10 to 00. Change the first digit of the sequence with 1, as shown on the screenshot, save, and open in Conquest.

And there you have it! Now the AI will still use worker units, regardless of whether or not all worker jobs are enabled. Best of all, if AI is able to build two Terraforming-AI units with different worker jobs enabled, it will build both regardless of worker strength or shield cost.

Credits

Credits go to Gramphos of Apolyton for the extremely useful guide to BIC/BIQ file format. Seriously, without it this wouldn't be possible.

Also, credits go to Sid Meier, Ozymandias for the nice chat that resulted in me checking if this will solve the problem, and Arvo Pärt, for making nice music that helps me stay awake to write this tutorial when my brain clearly screams "please shut me down for a long nap".

Also, you can credit me. I don't mind not being credited, though, as it's just a solution I found; nothing that I've actually created. :)

~Peter G.
 

Attachments

  • 01.png
    01.png
    6.1 KB · Views: 492
  • 02.png
    02.png
    7.7 KB · Views: 325
  • 03.png
    03.png
    3.2 KB · Views: 344
  • 04.png
    04.png
    21.9 KB · Views: 454
  • 05.png
    05.png
    17.6 KB · Views: 422
  • 06.png
    06.png
    17.5 KB · Views: 331
  • 07.png
    07.png
    17.6 KB · Views: 347
I think it's more of a case that no-one knew if the AI would be able to use them or not until now - you've provided us with the answer to that :)
 
And nobody found out until now?

Do understand that desires along these lines have been shouted to the Heavens for over a decade. Regardless of the tools used, you are the one who made it happen!

:xmascheers: ,

:)z
 
Checked it with Quintillus' editor, it works there. Ah, the tutorial will get so short when I redo it...

I'll keep the previous one as well just for the sake of archiving. Will do it tonight.

Do understand that desires along these lines have been shouted to the Heavens for over a decade. Regardless of the tools used, you are the one who made it happen!

:xmascheers: ,

:)z

Your reaction amuses me. :D Your overjoy reminds me of Tiger from Winnie the Pooh, seriously.

Thank you! :)
 
Checked it with Quintillus' editor, it works there. Ah, the tutorial will get so short when I redo it...

I'll keep the previous one as well just for the sake of archiving. Will do it tonight.


Your reaction amuses me. :D Your overjoy reminds me of Tiger from Winnie the Pooh, seriously.

Thank you! :)

:lol: My girlfriend generally compares me to Eeyore.
 
AvalancheMaster, thank you for finding a fix to exactly the problem I've been trying to fix. Following your instructions, I've think I've found the hexes you describe, but they don't look like the ones in your example. Moreover, my scenario has several worker units: do they all have to have their hexes changed? Find enclosed a screenshot from my hex editor.
 

Attachments

  • WorkerHex.png
    WorkerHex.png
    67.3 KB · Views: 272
AvalancheMaster, thank you for finding a fix to exactly the problem I've been trying to fix. Following your instructions, I've think I've found the hexes you describe, but they don't look like the ones in your example. Moreover, my scenario has several worker units: do they all have to have their hexes changed? Find enclosed a screenshot from my hex editor.

Yes, they all need to be changed.

As far as I can see, the hexes don't look any different, besides the names. However that doesn't matter, as Virote pointed out that I've found a method to do this, but apparently the tools to do it more easily already exist. I will rewrite the tutorial this week (and it will get summed up to 2 lines), but basically you need to download the Cross-Platform editor, and check the "Terraforming" flags of those worker units of yours. ;)
 
Okay, I just checked the Conquest "Fall Of Rome" scenario, and the Legion unit has the "Worker/Engineer Actions" "Build Road" & "Build Fort" boxes checked; of course the "Terraform" AI Strategy box is greyed-out.

I've not played this one myself, but WTF?? Anyone have any clues??

-:confused:z
 
Okay, I just checked the Conquest "Fall Of Rome" scenario, and the Legion unit has the "Worker/Engineer Actions" "Build Road" & "Build Fort" boxes checked; of course the "Terraform" AI Strategy box is greyed-out.

I've not played this one myself, but WTF?? Anyone have any clues??

-:confused:z

My guess is that they made it with tools, unavailable to the public, and the main reason why they disabled the "AI" checkbox is due to unpredictability of the AI (as in my case - making a special unit for Build Colony - who knows how this'll work).
 
Yes, they all need to be changed.

As far as I can see, the hexes don't look any different, besides the names. However that doesn't matter, as Virote pointed out that I've found a method to do this, but apparently the tools to do it more easily already exist. I will rewrite the tutorial this week (and it will get summed up to 2 lines), but basically you need to download the Cross-Platform editor, and check the "Terraforming" flags of those worker units of yours. ;)

Or use Steph's editor, which I've been using all along, if I understand Virote correctly. Okay, thanks. Problem solved, I guess. I've been having trouble getting the AI to build them, but Vuldacon would tell me to automate that part anyway.
 
I have tried Avalances tip with Quintillus Editor on my combat engineers (roadbuilding and clear swamp, forest and pollution). And I have successfully observed the KI using the ancient version of it. So I guess it works. :thumbsup:

However as soon as you change the scenario in the Firaxis Editor it will remove the AI Strategie checkbox. :gripe:

I also removed the "Disband Order" from the regular worker orders as the KI allways disband their workers when low on money befor reducing its military forces. Since I did this I see a lot more KI workers on the map (and they still can join a city ;) ).
 
I just want to say thanks for this! This was super easy and quick, and it helps me out a lot with the scenario I've been working on.
 
Hi all, i know this is an old post, but can someone please share what hex editing program they used for this? For example, I used UltraEdit and I tried searching (using CTRL+F) for "PRTO" but it did not give me any results that I understand.

I also do not see anything that says "Settler" like in the sceenshots from previous posts. Can you please help this novice, and help me solve my issue or let me know what other hex editor I can use? =)

Thanks!

upload_2021-2-28_21-2-3.png
 
Hi Ozy! Thanks for your reply. I'm only trying to get workers to be used correctly by AI even when all worker jobs are selected. I was hoping for a way to do this without switching away from the standard editor (for fear of some unforseen instability from a different editor, that might be caused by all the changes I've made in my mod). I've had my mod crash and be unrecoverable before with an alternative editor, so I'm fearful.

I love the idea of Quintillus' editor and was considering using it. In your experience, are there any extra bugs you've experienced with this editor?
 
Top Bottom