Getting locations adjacent to a certain unit
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.
Getting locations adjacent to a certain unit
What I want to do:
Have a unit be "prisoner" (I removed their movement points). To achieve this I use an event that "frees" the unit, when I come close to it, i.e. restores the movement points and makes it change to the player's side. Also I got an avoid statement for the ennemies to prevent them from getting next to the unit
What happens:
-ennemies don't recruit (I suppose it is because they somehow try to avoid the whole map)
-the moveto event triggers moving ANYWHERE on the map.
That's what I used for both the avoid statement and the moveto event.
Can somebody explain, why it doesn't work?
Have a unit be "prisoner" (I removed their movement points). To achieve this I use an event that "frees" the unit, when I come close to it, i.e. restores the movement points and makes it change to the player's side. Also I got an avoid statement for the ennemies to prevent them from getting next to the unit
What happens:
-ennemies don't recruit (I suppose it is because they somehow try to avoid the whole map)
-the moveto event triggers moving ANYWHERE on the map.
That's what I used for both the avoid statement and the moveto event.
Code: Select all
[filter_adjacent_location]
[filter]
id=prisoner
side=3
[/filter]
[/filter_adjacent_location]
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
Re: Getting locations adjacent to a certain unit
Okay, then let me reformulate: how do I need to implement the filter to have a specific location for my event that corresponds to the hexes adjacent to a certain unit?
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
Re: Getting locations adjacent to a certain unit
Could you post the full code you're using in both cases, instead of just the filter contents? It sounds like you may have misinterpreted how the filter tags are supposed to be used.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Getting locations adjacent to a certain unit
With the link he posted, zookeeper was pointing out that you have several specific options for filtering a moveto event, and [filter_adjacent_location] is not one of them. That filter does not exist in any context, actually. I know that because it's not on the wiki. (The wiki is your friend.) If you follow that link and read where it describes "moveto" and the variables it automatically stores, you might be able to see a way to do what you want. If not, then follow shadowm's excellent suggestion.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Getting locations adjacent to a certain unit
Okay, I looked up the moveto event but I didn't see any information on what filters are allowed with it. I tried filter_adjacent now, but it doesn't change anything.
That's the code for the moveto-event.
That's the avoid statement I used.
That's the code for the moveto-event.
Spoiler:
Spoiler:
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
Re: Getting locations adjacent to a certain unit
For the first one, [event]s don't accept [filter_adjacent], but they do accept [filter], which is a standard unit filter.... So just put the [filter_adjacent] inside a [filter].
for the second one, [avoid] contains a standard location filter. Since this one is a location filter, not a unit filter, it doesn't accept [filter_adjacent]. Instead you should use [filter_adjacent_location] then inside that put [filter] to hold the adjacent unit filter.
Note: when I said "doesn't accept"... the wiki will show you what contents are allowed in every tag, as I have shown with links above. If you put something in a place where it is not listed, then it will be ignored.
for the second one, [avoid] contains a standard location filter. Since this one is a location filter, not a unit filter, it doesn't accept [filter_adjacent]. Instead you should use [filter_adjacent_location] then inside that put [filter] to hold the adjacent unit filter.
Note: when I said "doesn't accept"... the wiki will show you what contents are allowed in every tag, as I have shown with links above. If you put something in a place where it is not listed, then it will be ignored.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Getting locations adjacent to a certain unit
With this code the AI would leave at least 1 hex distance to the units who match the filter
Edit: Sapient has the explanation how it works above
Spoiler:
Try out the dark board theme.
Re: Getting locations adjacent to a certain unit
Thanks, that solved my problem.
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)