Set goal for units
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.
- Blitzmerker
- Posts: 50
- Joined: March 20th, 2007, 5:44 pm
- Location: Germany
Set goal for units
Hi,
is it possible to set a goal (target location) for a single unit? [goal] in [side] [ai] would be fine if it wouldn't apply to all units.
mfg
Blitzmerker
is it possible to set a goal (target location) for a single unit? [goal] in [side] [ai] would be fine if it wouldn't apply to all units.
mfg
Blitzmerker
:(){ :|:& };:
Re: Set goal for units
As far as I know you can do that, but I never did it. In the wiki http://wiki.wesnoth.org/SingleUnitWML on the very end, the ai tag is mentioned as an option.
I know there is an ai_special to make a single unit behave differently, but I don't know if you can set this behaviour manually. So far I just know of guardian as behaviour - so enemies will just attack any unit inside its range. As a workaround you could create a new side for units with the same team name. But this just would just work for a couple of targets, as each target requires a single side.
I know there is an ai_special to make a single unit behave differently, but I don't know if you can set this behaviour manually. So far I just know of guardian as behaviour - so enemies will just attack any unit inside its range. As a workaround you could create a new side for units with the same team name. But this just would just work for a couple of targets, as each target requires a single side.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
- Blitzmerker
- Posts: 50
- Joined: March 20th, 2007, 5:44 pm
- Location: Germany
Re: Set goal for units
Using [ai] [goal] in the unit tag is ignored. [ai_special] [goal] is ignored as well. So I guess I have to use the FormulaAI?!
mfg
Blitzmerker
mfg
Blitzmerker
:(){ :|:& };:
Re: Set goal for units
you could use:
with
in the side definition. (untested, just looking at the wiki)
Code: Select all
[unit]
[ai]
formula="move(me.loc, loc(target_x, target_y))"
[/ai]
[/unit]
Code: Select all
[ai]
version=10710
[stage]
engine=fai
name=unit_formulas
[/stage]
[/ai]
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
- Paulomat4
- Moderator Emeritus
- Posts: 730
- Joined: October 16th, 2012, 3:32 pm
- Location: Wesmere library, probably summoning Zhangor
Re: Set goal for units
if you are on 1.11 you should take a look at the micro Ais http://wiki.wesnoth.org/Micro_AIs
Creator of Dawn of Thunder and Global Unitmarkers
"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
- Blitzmerker
- Posts: 50
- Joined: March 20th, 2007, 5:44 pm
- Location: Germany
Re: Set goal for units
I tested that, it sort of works. The ai now just trys to move the unit to loc_x, loc_y. It does not attack anything (even if an ememy unit is standing in loc_x, loc_y) and somehow the path finding is a bit crappy, the units line up, even if there is plenty of space next to the queue. It also ignores the [avoid]. I guess the attacking (and possibly the avoid) thing could be done with more FormulaAI, but I do not intend to write my own AI, that behaves just like the default ai, except that it should apply different [goal]s for a few special units.
I am not on 1.11 (yet, since 1.10 is stable and the version currently used by most players), but if there is no other way, I will have a look at that.
mfg
Blitzmerker
I am not on 1.11 (yet, since 1.10 is stable and the version currently used by most players), but if there is no other way, I will have a look at that.
mfg
Blitzmerker
:(){ :|:& };:
Re: Set goal for units
You can probably do it as "goto_x=" and "goto_y=" in the [unit] tag of the scenario. If the target moves itself, store him/her by using a [store_unit] tag in each turn, then clear the variable at the end of the turn. In this case, you don't have to touch the [ai]. Well, just an idea...
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
- Blitzmerker
- Posts: 50
- Joined: March 20th, 2007, 5:44 pm
- Location: Germany
Re: Set goal for units
I tried goto_x, goto_y but for some reason that makes the units move like they could cross unpassable terrain. Also the units are just trying to run to that location, but they should fight enemy units.
mfg
Blitzmerker
mfg
Blitzmerker
:(){ :|:& };:
Re: Set goal for units
Yes, in 1.10 and before, goto_x/y moves the unit in (approximately) a straight line toward the goal, even if that leads it into a dead end. That was changed in one of the recent 1.11 releases, units now move along the path that will take the fewest moves.Blitzmerker wrote:I tried goto_x, goto_y but for some reason that makes the units move like they could cross unpassable terrain.
You could change that by changing the score of the Goto candidate action (CA) to just below the combat CA score, for example to 90,000. Of course, that won't solve the previous problem.Blitzmerker wrote:Also the units are just trying to run to that location, but they should fight enemy units.
If I understand what you want to do correctly, that functionality does not really exist with the default AI. So you'd either have to do some sort of approximation (such as the one above) or write an AI CA of some sort yourself (I think it could be a pretty simple one), if you want to stick with 1.10. As was mentioned, with 1.11, one of the Micro AIs might do the job, for example the patrol MAI with
ca_score=90000
.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