Total War: WARHAMMER II

Total War: WARHAMMER II

AI General II: Spectator Mode Advanced
 This topic has been pinned, so it's probably important
paperpancake  [developer] Apr 8, 2020 @ 5:42pm
FAQs
This mod isn't working for me.
Check the troubleshooting page. If the problem persists, please file a bug report.

How does AI General II work?

This mod allows you to give units to the game's existing Script AI Planner and units just follow the Script AI's instructions for most of the battle. Near the end of the battle when most of the enemy is routing or dead, the Script AI Planner would often have most units doing nothing, so this mod takes control and tells your units to charge nearby enemies.

How is AI General II different from Spectator Mode II?

AI General II is newer. Spectator Mode II doesn't have some of the features and bug fixes that Hambango added over time and that paperpancake added more recently. (For example, AI General II is compatible with quest battles, though it's not very good at some of them.) Both mods use the game's built-in Script AI Planner, they just access it differently. Recently, Spectator Mode II has become outdated, so we recommend using AI General II instead.

Some hotkeys are different, but AI General II can now do all the assignments that Spectator Mode II can do (for example, Shift+F10 can work like Lord Mode and Reinforcement Mode now that AI General II extends selections by default).

If you notice something that Spectator Mode II consistently does better than AI General II, please file a bug report and I'll see if I can do anything about it.

Decomposed's slide says "redesigned and improved AI behavior". Does that mean that this will make the enemy AI smarter?

No. This mod was redesigned and units you give to this mod will have improved behavior compared to what this mod had before they wrote that. This mod does not attempt to change the enemy AI. This mod just allows you to give control of your units to the Script AI Planner.

How does AI General II compare to the enemy AI in the game?

The Script AI Planner is similar to but not the the same as the AI that enemies use in the game. It's unclear what the differences are, but there are some things that modders don't have access to (siege battle AI is one that's specifically mentioned in the documentation). If this mod does something foolish, don't assume the enemy AI would do the same thing. If the Script AI Planner was fully featured and meant for players to use, it would likely be included in the game instead of needing a mod to unlock it.

Since the game gives the enemy stat bonuses on harder battle difficulties, don't expect this mod's AI to do as well as the enemy on harder battle difficulties without you helping it. It can still be useful for controlling portions of your army while you handle high-value units.

How does AI General II compare to a human player?

AI General II can give lots of orders quickly and shouldn't lose track of units, so it can be better than many players at handling a massive line of cheap infantry or a chariot that needs to be constantly moving. AI General II is not as smart as a human, though, so it will likely be worse at controlling strategic decisions, like when to use spells or abilities or whether your wizard should jump into hand-to-hand combat. Many people use this mod to control a portion of their rank-and-file army while the player keeps control of spellcasters and other important characters.

If you want to make more of the decisions yourself but lose track of some units in the heat of the battle, I'd recommend the Find Idle Units mod (which is compatible with AI General II or can be used on its own).

Will AI General II use army abilities like Dark Elf Black Ark bombardments or Skaven's Menace Below?

No. It will use many kinds of unit abilities, but no army abilities. You can still use army abilities yourself while the AI is controlling your units, though.

Can I use this for every kind of battle?

AI General II is enabled for all types of battles except the starting tutorial battles. That said, there are situations where it doesn't perform as well, so you might need to take control of at least some of your army for at least some of the time. Some such situations that I'm aware of are:
  • Many siege battles, especially if you change your AI selection in the middle of the battle or have more than a full stack of reinforcements.
  • Players have reported that sometimes your defending army will hide in a corner and let the enemy bombard them to death. If this happens, you can take control of your army for a bit, give them an order to attack the enemy, and then give the AI control again once they're close.
  • Quest battle seems to work well generally (for example, it works in the final Vortex battle), but this mod's AI struggles when asked to shift objectives in some of the quest battles.

Is there a way to default rallying units to on?

Yes. This and more can done by configuring the mod.

Does this work with custom hotkeys?

Yes. As the mod's description explains, this mod piggybacks on the Save Camera Bookmark 1-5 hotkeys. Shift+F9 - F12 are just the default hotkeys for those commands (and Save Camera Bookmark 5 doesn't have a default hotkey). If you have or want to use custom hotkeys, just use whatever hotkey you chose for those commands instead.

Does this mod work in multiplayer?

I haven't played enough multiplayer using this mod that I can say one way or the other. If you try it, I'd like to hear about your experience in the comments. Comments from before my recent updates report sometimes getting desyncs if a battle is put on fast-forward while using this mod. I don't know whether the recent updates improved this or not. It's also possible that with some settings the AI might try to give commands to units you've gifted to a spectator during a coop battle.

The AI is doing a stupid thing. Can you make the AI better?

If the underlying problem turns out to be how units are given to the Script AI Planner, then I might be able to do something. For example, I was able to fix when units stopped getting new orders because that was a problem with how the old version was originally giving units to the AI. However, this usually isn't what people mean when they ask this question.

I don't have access to the code that controls the AI. Modders can access the Lua script and the database, but not the underlying C++ code. That makes it difficult or impossible to change the existing AI or to try to write a new one.

I've heard of mods in the past that attempted to influence how the enemy AI acts by changing database values for how units are categorized (saying that Vampire Counts on foot were cavalry, for example) or how a unit's threat value is assessed. You can experiment with that if you'd like (with or without AI General II), but I didn't want to mess with that here since that's not the purpose of this mod.

The only part of the decision-making in AI General II that I have direct control over is what happens at the end of the battle. More on that in the next question.

How does AI General II decide how to chase enemies at the end of the battle?

AI General II goes through a list of enemies in order and assigns the closest friendly unit under its control to attack that enemy. (There's some extra logic for unusual cases, but that's the basic idea.)

While this kind of works, it's not ideal. AI General II might assign a slow unit to chase a fast one that it can't reach when it has a target that it can. Or it might tell your unit to chase something far away just because nothing else you have is closer.

We're aware of this, have thought about it, and have talked with others about it. Unfortunately, we don't have easy access to some basic information about the units from within a script that could help fix this. I have a few ideas for things I could experiment with in the future, but this is what we've got for now. If another modder has an idea and wants to submit some code to me or Decomposed, we're certainly open to quality improvements.

Can another mod like SFO or Boyz will be Boyz affect the decisions made by this mod?

Potentially yes, and probably in ways the other mod would want to happen if so. It's hard to say for sure because the Script AI Planner is a black box--we can give it control over units and see what it will do, but we can't see the code that controls the decisions it is making.

I'm not familiar enough with SFO or BwbB/CTT to speak to them specifically, but If you use another mod that changes a unit's classification or relative value in the game's database, then it's possible that the Script AI Planner will take that into account in its decisions.

Hambango created this mod originally. Decomposed uploaded it. Why did you (paperpancake) get involved?

Hambango's mods inspired me to start making battle mods in the first place. When I made the Find Idle Units mod, I wanted it to be compatible with AI General II. In the time since Hambango created this mod, CA added some improvements to their scripts. I asked Decomposed and Hambango if AI General II could be updated to use one of those new improvements, the new battle manager's phase listener, which would fix the incompatibility in our mods.

Hambango is very busy with real life, so Hambango and Decomposed kindly allowed me to make the change and submit it. While I was updating the mod, I also worked on some other improvements and bug fixes using what I'd learned from wrestling with my own mod.

Hambango gave Decomposed permission to upload and manage this mod on Steam (Hambango feels too busy to want to do it). I submit any updates and suggestions for the mod or its description to Decomposed, who has the final decision on uploads and updates. I have been trying to respond to the questions in comments and discussions, though, since I was the last person to work on the code.

Will you port this to Three Kingdoms or some other Total War game?

I have already re-written this for Troy[www.epicgames.com]. :) I don't own any other Total War games, my budget is tight, and I'm not sure I'd want to put in the time to port this version to other games. However, you or another modder may if you'd like. Others have tried to use it as-is in Three Kingdoms with no luck, so you probably need to have at least a decent understanding of basic programming/scripting concepts if you want to try.
Last edited by paperpancake; Aug 23, 2021 @ 7:34pm