What happens to a unit after it reaches its location goal?

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
User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

What happens to a unit after it reaches its location goal?

Post by Neuromancer »

Ai is instructed to move units to position x,y:

Code: Select all

[goal]
  name=target_location
  [criteria]
    x,y=10,10
  [/criteria]
  value=10
[/goal]
Will these units try to move to that exact location? What will happen after these units reach the desired location?

------

I have AI-controlled side consisting of saurians and I want them to prefer swamps, forests, hills over flat terrain when choosing where to position units (both when taking defensive positions and attacking enemy units). Is there some way to achieve this behavior?
Last edited by Pentarctagon on September 11th, 2011, 5:30 pm, edited 1 time in total.
Reason: Next time if you have two questions on a similar topic at the same time, just ask them both in one thread.
User avatar
LapinRose
Posts: 8
Joined: September 6th, 2011, 1:47 pm
Location: France

Re: What happens to a unit after it reaches its location goa

Post by LapinRose »

have you looked in the folder faction?
cfg in there is a line "terrain_liked=Hh, Ha, Ds, Ss etc"
Sorry for my bad english :)
User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: What happens to a unit after it reaches its location goa

Post by Neuromancer »

Thanks for suggestion LapinRose. Unfortunately both google and forum search turned nothing useful on the topic and the same goes for wiki. No information about this tag.
SigurdFireDragon
Developer
Posts: 546
Joined: January 12th, 2011, 2:18 am
Location: Pennsylvania, USA

Re: What happens to a unit after it reaches its location goa

Post by SigurdFireDragon »

Wiki EraWML wrote:terrain_liked: an unseparated list of terrains (see TerrainCodesWML). On random maps, these terrains will determine which keep the side is assigned, attempting to put it near the listed terrains.
It's not really useful for what you're trying to do with AI behavior.
Co-Author of Winds of Fate
My Add-ons: Random Campaign, Custom Campaign, Ultimate Random Maps, Era of Legends, Gui Debug Tools
Erfworld: The comic that lead me to find Wesnoth.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: What happens to a unit after it reaches its location goa

Post by mattsc »

Neuromancer: as for your second question, it is my understanding that, to some extent, the AI already does something like that. All things being equal, it will position units on terrain on which they have stronger defense. Now, all things usually aren't equal, and in that case the units will certainly be placed on "weak terrain". Do I understand this right that you want to avoid that?

I am not aware of a standard WML way of doing that other than having them avoid certain terrain entirely by using the [avoid] tag - but that would be extremely restrictive. The only other way I know of is to change the AI side behavior. You can either do that with events, or by changing the AI behavior (such as with FormulaAI, as I only recently learned myself). If this kind of "advertising" is allowed, have a look at the post I just made at the "Coder's Corner" forum. It's not exactly the same as what you are looking for, but it might give you some idea of what can be done.

If you want, I'd be happy to help you with this, but you'd have to wait a week or two until I have time to look into it. I'm also not exactly a FormulaAI expert, having never done anything with it until 3 days ago, so take anything I say for what it's worth.
User avatar
Neuromancer
Posts: 204
Joined: September 10th, 2010, 9:49 pm

Re: What happens to a unit after it reaches its location goa

Post by Neuromancer »

mattsc wrote:Neuromancer: as for your second question, it is my understanding that, to some extent, the AI already does something like that. All things being equal, it will position units on terrain on which they have stronger defense. Now, all things usually aren't equal, and in that case the units will certainly be placed on "weak terrain". Do I understand this right that you want to avoid that?
Yes, exactly. I know aggression and caution can influence this terrain-choosing behaviour, but I want these saurians to be pretty aggresive yet positioning themselves on their 60%-defense terrain nearly all the time. While "casually" attacking, they should always choose favorable terrain and they will come out of it only when attacking unit with low hp.
mattsc wrote: If you want, I'd be happy to help you with this, but you'd have to wait a week or two until I have time to look into it.
Id be pleased and I think your work may be useful for other campaign designers too.
I always wondered why in many scenarios (even mainline) AI is just set to ignore everything and crush itself upon players defenses. I want to create some AI leader which values his troops. For example there is this small company of saurians attacking elvish patrol. I already mentioned I want them to attack from their favorable terrain, but they should also retreat more often! In current state of the AI they just keep attacking even during the day and to the last man. What about organised retreat (Im currently using only event which sets a location goal after number of attackers drops below a certain point), or staging defensive lines along the edge of the swamp (with healers in second lines)? I think this all can be achieved through FormulaAI and easily modified for various campaign creators' purposes.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: What happens to a unit after it reaches its location goa

Post by mattsc »

Well, programming a fully new AI behavior is very difficult (and definitely beyond my abilities at this point), but I think you're right that at least some, if not all, of what you suggest could be done by modifying, for example, the movement stage in the AI. From what I have seen (caveat: I've never actually done this), you probably don't even need FormulaAI for this. I'd also bet that lots of this has been done already and can be found in the bowels of the forum.

Anyways, let's hook up again next week sometime and discuss what exactly you might want. Unless somebody else has already done this and can point us to it, this sounds like another fun problem to tackle. I'll send you a PM in a moment.
Post Reply