Allied AI only defending their part of the map
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.
Allied AI only defending their part of the map
Hello!
I was playing around with the map editor and WML to write a small campaign.
My problem: I want an AI allied to the player not to cross a ford, only fighting enemies that actually cross the ford. I tried using [avoid] tags, but that seems to only keep the AI from placing units directly on the ford. Or, as I'm using multiple [avoid] tags at the moment, every [avoid] tag might overwrite the last one. The ford is the only way to cross the river, it's all deep water around it.
Is there something like a "defend only" tag for the AI? While reading through the references, I can only spot things like aggression that don't seem to help me with my problem.
So short but simple: Is there a way to confine a AI to a certain part of the map, which it will defend, but won't leave? Is one [avoid] tag overwriting the one before?
Thank you very much!
I was playing around with the map editor and WML to write a small campaign.
My problem: I want an AI allied to the player not to cross a ford, only fighting enemies that actually cross the ford. I tried using [avoid] tags, but that seems to only keep the AI from placing units directly on the ford. Or, as I'm using multiple [avoid] tags at the moment, every [avoid] tag might overwrite the last one. The ford is the only way to cross the river, it's all deep water around it.
Is there something like a "defend only" tag for the AI? While reading through the references, I can only spot things like aggression that don't seem to help me with my problem.
So short but simple: Is there a way to confine a AI to a certain part of the map, which it will defend, but won't leave? Is one [avoid] tag overwriting the one before?
Thank you very much!
- Pentarctagon
- Project Manager
- Posts: 5732
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Allied AI only defending their part of the map
you can put a range of locations into a single avoid tag, so i'd image you could just tell the ai to avoid the entire map beyond the ford.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: Allied AI only defending their part of the map
That might just do the trick, thank you.
Will multiple [avoid] tags add up or replace themselves? (Is it possible that I just tell the AI to avoid the northern half of the map and the western half of the map or will telling it to avoid the west reallow it to use the north? And is there something like [unavoid] to change AI's behaviour later?
Will multiple [avoid] tags add up or replace themselves? (Is it possible that I just tell the AI to avoid the northern half of the map and the western half of the map or will telling it to avoid the west reallow it to use the north? And is there something like [unavoid] to change AI's behaviour later?
- Luke the Flaming
- Posts: 215
- Joined: October 18th, 2006, 6:25 pm
Re: Allied AI only defending their part of the map
[avoid] just means that the AI will note end its movement upon that tile(s). Thus if you just use [avoid] for the ford, but the AI can cross it at once, it'll do so. You MUST use [avoid] on whole parts of map to get the behaviour you wish.
If you want to [avoid] several zones, put them all in the same tag (you can use multiple ranges, like x=1-8,20 and y=1-20,16-20).
If you later use [modify_side], you will able to specify [avoid] anew... I'm not sure if THAT is a replacement or an addition, however (but it should be really easy to test).
If you want to [avoid] several zones, put them all in the same tag (you can use multiple ranges, like x=1-8,20 and y=1-20,16-20).
If you later use [modify_side], you will able to specify [avoid] anew... I'm not sure if THAT is a replacement or an addition, however (but it should be really easy to test).
O, Wind, if Winter comes, can Spring be far behind?
Re: Allied AI only defending their part of the map
'avoid' aspect allows to specify the standard location filter of DESTINATIONS which will be avoided by the AI.
use [modify_ai] to change the avoid aspect on the fly. See scenario #2 of the Legend of Wesmere campaign for the example. note that [modify_ai] will work regardless of the syntax style used for avoid.
how to debug it: to see the current 'avoided locations' of the AI, droid it (to make it human-controlled), and, then, from that side, from formula ai console ( :f in debug mode ), invoke something like
(the above formula means: for each map hex, if it's avoided, print a label 'avoid' on it).
How it's done in LoW scenario 2:
code to add avoid aspect named 'stay_in_own_land' to side 2:
where OLURFS_LAND is a macro defining a part of the SLF. - the ai will avoid all other locations (thanks to [not][/not] part )
code to delete that aspect (thus, giving the AI access to the entire map):
where stay_in_own_land is the id.
p.s.: make sure to make your standard location filter (in avoid) fast enough. Plus, as a workaround for a bug: set caution to 0 or drop the retreat stage to make it faster.
use [modify_ai] to change the avoid aspect on the fly. See scenario #2 of the Legend of Wesmere campaign for the example. note that [modify_ai] will work regardless of the syntax style used for avoid.
they add up, sort of. but only the last one will be used.Will multiple [avoid] tags add up or replace themselves?
(Is it possible that I just tell the AI to avoid the northern half of the map and the western half of the map or will telling it to avoid the west reallow it to use the north?
set the avoid standard location filter to [not][/not], or drop all avoid aspects.And is there something like [unavoid] to change AI's behaviour later?
how to debug it: to see the current 'avoided locations' of the AI, droid it (to make it human-controlled), and, then, from that side, from formula ai console ( :f in debug mode ), invoke something like
Code: Select all
map(filter(map.terrain,is_avoided_location(loc(x,y))=1),debug_label(loc(x,y),'avoid'))
How it's done in LoW scenario 2:
code to add avoid aspect named 'stay_in_own_land' to side 2:
Code: Select all
{MODIFY_AI_ADD_ASPECT 2 avoid (
[facet]
id="stay_in_own_land"
[value]
[not]
{OLURFS_LAND}
[/not]
[/value]
[/facet]
)}
code to delete that aspect (thus, giving the AI access to the entire map):
Code: Select all
{MODIFY_AI_TRY_DELETE_ASPECT 2 avoid stay_in_own_land}
p.s.: make sure to make your standard location filter (in avoid) fast enough. Plus, as a workaround for a bug: set caution to 0 or drop the retreat stage to make it faster.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Allied AI only defending their part of the map
The wesnoth map editor has a functionality "copy marked coordinates to the clipboard". That way one can e.g. mark all of the land beyond a river and then paste the coordinates directly into a single [avoid] tag. Causes large files, but is quick & easy and works (and doesn't need a SLF).
In your case I would probably use this method since it is enough to mark an area which is large enough so that the particular side can't cross it with a single move in any case (Consider that sides' fastest unit, terrain, movement cost.).
In your case I would probably use this method since it is enough to mark an area which is large enough so that the particular side can't cross it with a single move in any case (Consider that sides' fastest unit, terrain, movement cost.).
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
Re: Allied AI only defending their part of the map
Thank you all very much!
I'll try it out this weekend.
I'll try it out this weekend.