Jump to content

AI not putting spawned workers to work


SciGuy42
 Share

Recommended Posts

I am working on a scenario and as a way of boosting the AI a bit, I periodically spawn some random citizen soldiers by their civic centre. To my surprise, the AI wasn't using them to do any work and they just keep standing where they were spawned.

Then, I decided to try something different - I spawn the same units as Gaia entities and change their ownership to the player through code. Now, the AI immediately puts them to work! My guess is that the latter method trigger some function similar to what happens when the AI produces a worker through its building, while simply spawning the units for the AI to use them as it sees fit, does not.

  • Like 1
Link to comment
Share on other sites

Yeah, it seems PetraAI must have the metadata.

if (ent.getMetadata(PlayerID, "role") === PETRA.Worker.ROLE_WORKER)

How do you spawn the units?

[EDIT]
When the AI produces something it adds metadata to know later what the produced unit is used for. If it doesn't have any, it is probably used in the next attack only. When converting the entity, indeed another message is sent that is also picked up by the AI.

Edited by Freagarach
Some longer explanation.
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...