How to force AI with no leader to play defensively

The place to post your WML questions and answers.

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.
Post Reply
Argothair
Posts: 53
Joined: May 10th, 2014, 12:01 am

How to force AI with no leader to play defensively

Post by Argothair »

I'm designing a multiplayer scenario, and it includes some neutral monsters. I would like the monsters to stay near their points of origin, attack anyone who wanders too close to their start point, and perhaps occupy the occasional nearby village. Instead, the monsters all immediately charge toward the human players' units, very aggressively. I don't notice any difference at all in the ai's behavior no matter how I set the "aggression" and "caution" values. I don't think I want to use the micro_ai because there are about 20 neutral monsters and I'd like all of them to follow essentially the same behavior.

I figure I must be doing something completely wrong and that my code is just failing to update the ai's instructions. I've read the standard guide on RCA AI and modifying AI components, but I don't yet see where I'm messing up. The relevant part of my scenario CFG file is below, along with a couple of example units -- does anyone have any suggestions? (Thank you!)

Code: Select all

[multiplayer]
[side]
	side=7
	team_name=2
	controller="ai"
	allow_player=no

	fog=no
	gold=0
	hidden=no
	income=0
	no_leader=yes
	share_vision="none"
	shroud=no
	faction=Custom

	[ai]
		aggression=0.01
		caution=0.99
		grouping = defensive
		[goal]
        		name=protect_location
        		[criteria]
           		 x,y=42,5
        		[/criteria]
        		protect_radius=5
        		value=1
    		[/goal]
	[/ai]
        [unit]
		facing="n"
		type="Cuttle Fish"
		x=46
		y=1
	[/unit]
        [unit]
		facing="s"
		type="Giant Spider"
		x=53
		y=6
	[/unit]
[/side]
[/multiplayer]
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: How to force AI with no leader to play defensively

Post by vghetto »

add leader_value=0.0 to the [ai] block. This might not work on wesnoth 1.15 or with experimental ai.
Argothair
Posts: 53
Joined: May 10th, 2014, 12:01 am

Re: How to force AI with no leader to play defensively

Post by Argothair »

Works great! Thank you. :)
User avatar
lhybrideur
Posts: 357
Joined: July 9th, 2019, 1:46 pm

Re: How to force AI with no leader to play defensively

Post by lhybrideur »

You can also use ai_special=guardian in the [unit] tag
Post Reply