Stopping the AI leader from moving to attack?
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.
Stopping the AI leader from moving to attack?
Hey there. I need the AI to be able to do everything it would normally do with its leader, but need to get rid of its suicidal tendency to attack with its leader when it'd be better off sitting on a keep. is there any way to make the leader unwilling to attack?
Here's what I have:
This seems to prevent the AI from attacking with the leader - however, I want to stop it from *moving* to attack with the leader - attacking with the leader is fine if the AI doesn't commit suicide doing it.
Here's what I have:
Code: Select all
[ai]
[aspect]
id=attacks
[facet]
invalidate_on_gamestate_change=yes
[filter_own]
[not]
canrecruit=yes
[/not]
[/filter_own]
[/facet]
[/aspect]
[/ai]
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
Re: Stopping the AI leader from moving to attack?
Have you tried setting
I forget which AI settings work when, but that attribute claims to do what you seem to be asking for.
[wiki=AiWML#The_.5Bai.5D_Tag:_Defining_Aspects]leader_aggression =[/wiki] -4000000
?I forget which AI settings work when, but that attribute claims to do what you seem to be asking for.
Re: Stopping the AI leader from moving to attack?
That won't work, unfortunately, at least not entirely. The problem is that "damage received by enemy for this attack" is a multiplicative factor in all of this and thus, if it there is no damage to be received in the attack itself the AI will attack, not matter how dangerous a position it gets its leader into with that. And yes, I did try. I had a Dwarvish Berserker leader happily attack a Dark Adept surrounded by Troll Warriors withJaMiT wrote:Have you tried setting[wiki=AiWML#The_.5Bai.5D_Tag:_Defining_Aspects]leader_aggression =[/wiki] -4000000
?
leader_aggression = -1,000,000
. For future reference, A Guy also asked this question on IRC. Here's some of the relevant text:
Code: Select all
20130626 00:17:18< mattsc> A_Guy: I assume you still want the leader to grab villages etc.? Otherwise you could simply set moves=0 at the beginning of the turn.
20130626 00:27:06< A_Guy> mattsc>Yes, I want the AI to use its leader for everything it would normally do, except suicidally charging when there's a keep it can retreat to.
20130626 00:30:15< mattsc> Well, setting leader_aggression=-1000 (or so) will only partly prevent that.
20130626 00:31:15< mattsc> If you want to go with the approach from your post, you could put an [or] tag parallel to the [not] that includes leaders that have enemies next to them.
20130626 00:32:03< mattsc> But that doesn't guarantee that the leader will attack that enemy, only that it only attacks with the leader when there's an adjacent enemy.
20130626 00:33:09< mattsc> So, if you wanted to be absolutely certain, you'd have to exclude the leader as you do in your post, and then add an additional attack candidate action only for the leader. That would have to be custom written though.
20130626 00:38:48< A_Guy> Uh-huh, thanks.
20130626 00:47:12< mattsc> A_Guy: actually, I think there is a different way. You could incude the combat CA twice, once with the attacks aspect set as in your post; and the second with [filter}own} set to the leader, and [filter_enemy] to units adjacent to the leader.
20130626 00:47:38< A_Guy> Hmm. I'll try that, thanks.
20130626 00:47:42< mattsc> oops: [filter_own]
20130626 00:48:11< mattsc> You probably want to set the CA score to 99,999 for the second CA in that case
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
Re: Stopping the AI leader from moving to attack?
I choose to fail to see the problem with that.mattsc wrote:I had a Dwarvish Berserker leader happily attack a Dark Adept surrounded by Troll Warriors withleader_aggression = -1,000,000
.
Re: Stopping the AI leader from moving to attack?
How about a Peasant leader leaving his keep to throw a spear at a Troll Warrior? Same setting forJaMiT wrote:I choose to fail to see the problem with that.mattsc wrote:I had a Dwarvish Berserker leader happily attack a Dark Adept surrounded by Troll Warriors withleader_aggression = -1,000,000
.
leader_aggression
. 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
Re: Stopping the AI leader from moving to attack?
The Peasant deserves a medal for valor!
Okay, I thought the AI evaluated safety better than that. There is code (somewhere) that evaluates how much power the enemy can bring to bear on a given hex. That calculation must be going awry, since the AI is doing those things with its leaders. Maybe that part of the code is lacking a "save the leader" clause? It might be a bug.
... but I still choose to fail to see a problem.
Okay, I thought the AI evaluated safety better than that. There is code (somewhere) that evaluates how much power the enemy can bring to bear on a given hex. That calculation must be going awry, since the AI is doing those things with its leaders. Maybe that part of the code is lacking a "save the leader" clause? It might be a bug.
... but I still choose to fail to see a problem.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Stopping the AI leader from moving to attack?
Setting max_moves very low works pretty well in practice. Typically that low that the leader cannot move into terrain which is bad for him with the moves of only 1 turn. You may want a village within these moves in the case of poison.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign