Default AI not attacking leaders if they're too strong.
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Default AI not attacking leaders if they're too strong.
Hi, I've encountered a problem in that AI units do not attack leaders if those leaders have too high resistances or attacks.
I've tried reading into the AI wml, but I don't really see where I could change the evaluation criteria for leaders specifically.
The simple solution would be to set aggression to a high value, but I'd rather find a solution that keeps the AI's level of play at about the same level.
Does anyone know of a way to solve this?
I've tried reading into the AI wml, but I don't really see where I could change the evaluation criteria for leaders specifically.
The simple solution would be to set aggression to a high value, but I'd rather find a solution that keeps the AI's level of play at about the same level.
Does anyone know of a way to solve this?
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Default AI not attacking leaders if they're too strong.
In order not to have the AI go berserk all the time while still attacking strong enemy leaders, I've made a small event which determines the aggression and caution variables of AI sides on every turn based on their vision of enemy leaders. It's very rudimentary but it does the job and I'm kind of liking how the AI plays "dynamically". If anyone has any better ideas I'd be happy too, since this really isn't what I set out to do in the beginning.
Code: Select all
[event]
id=AIaggcautchange
name=turn refresh
first_time_only=no
[if]
[have_unit]
canrecruit=yes
[and]
[filter_vision]
visible=yes
side=$side_number
[/filter_vision]
[/and]
[and]
[filter_side]
[has_enemy]
side=$side_number
[/has_enemy]
[/filter_side]
[/and]
[and]
[not]
[filter_wml]
[status]
general=yes
[/status]
[/filter_wml]
[/not]
[/and]
[/have_unit]
[then]
[modify_side]
[filter_side]
controller=ai
[/filter_side]
[ai]
side=$side_number
aggression=0.99
[/ai]
[/modify_side]
[modify_side]
[filter_side]
side=$side_number
controller=ai
[/filter_side]
[ai]
caution=0.1
[/ai]
[/modify_side]
[/then]
[else]
[modify_side]
[filter_side]
controller=ai
[/filter_side]
[ai]
side=$side_number
aggression=-10.0
[/ai]
[/modify_side]
[modify_side]
[filter_side]
side=$side_number
controller=ai
[/filter_side]
[ai]
caution=1000
[/ai]
[/modify_side]
[/else]
[/if]
[/event]
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Re: Default AI not attacking leaders if they're too strong.
Nyanyanyan: Another option would be to use the Simple Attack Micro AI set to attack only enemy leaders. The behavior would be somewhat different from what you have right now. For example, it would only attack enemy leaders and it would always attack those (both of which is mostly but not 100% the case for your event-based solution). It would also always attack the enemy leaders first before continuing with "normal" attacks (or last, depending on the value of
ca_score
). So depending on your preferences, that might not be what you want.SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on