StandardUnitFilter, adjacent to tile
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.
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
StandardUnitFilter, adjacent to tile
I'm firing a catapult in the general direction of a hero, though it actually hits somewhere within a small radius. This means there's no guarantee that there is a unit where it hits. Wherever it actually hits, I want any unit on that tile to take 12 damage, and any unit on an adjacent TILE to take 6. The second harm_unit in the following doesn't seem to work when $hit_locs[$i].x,$hit_locs[$i].y does not contain a unit.
I'm wondering what [filter_adjacent] means. I now think it means "adjacent to the unit at...", while I was originally hoping it meant "adjacent to the tile at ...". If I'm correct, is there a simple solution, or do I just have to iterate over [store_location] x,y... radius=1 ?
I'm wondering what [filter_adjacent] means. I now think it means "adjacent to the unit at...", while I was originally hoping it meant "adjacent to the tile at ...". If I'm correct, is there a simple solution, or do I just have to iterate over [store_location] x,y... radius=1 ?
Code: Select all
[harm_unit]
[filter]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
[/filter]
damage_type=impact
amount=12
posioned=yes
animate=yes
[/harm_unit]
[harm_unit]
[filter]
[filter_adjacent]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
[/filter_adjacent]
[/filter]
damage_type=impact
amount=6
posioned=yes
animate=yes
[/harm_unit]
Speak softly, and carry Doombringer.
Re: StandardUnitFilter, adjacent to tile
filter_adjacent -> filter_location+radius should work.
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: StandardUnitFilter, adjacent to tile
Thanks, I think I see what's up now.
I assume if I wanted to match ONLY adjacent I'd do something like:
or
or
Obviously I struggle with the syntax a bit, especially when radius is involved.
The first example is of particular interest to me (in the general case, not necessarily for this example). As I understand it, radius=N actually means radius<=N, so if I want (the correct) radius=N I'd need to do 'radius=N and not radius=N-1'.
I assume if I wanted to match ONLY adjacent I'd do something like:
Code: Select all
[harm_unit]
[filter]
[filter_location]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
radius=1
[not]
radius=0
[/not]
[/filter_location]
[/filter]
Code: Select all
[harm_unit]
[filter]
[filter_location]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
radius=1
[/filter_location]
[filter_location]
[not]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
[/not]
[/filter]
Code: Select all
[harm_unit]
[filter]
[filter_location]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
radius=1
[/filter_location]
[not]
[filter_location]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
[filter_location]
[/not]
[/filter]
The first example is of particular interest to me (in the general case, not necessarily for this example). As I understand it, radius=N actually means radius<=N, so if I want (the correct) radius=N I'd need to do 'radius=N and not radius=N-1'.
Speak softly, and carry Doombringer.
Re: StandardUnitFilter, adjacent to tile
I would avoid multiple radius.
There is also filter_adjacent_location, but you would have to consult documentation to know if it fits use case.
Code: Select all
[harm_unit]
[filter]
[not]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
[/not]
[filter_location]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
radius=1
[/filter_location]
[/filter]
- Celtic_Minstrel
- Developer
- Posts: 2274
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: StandardUnitFilter, adjacent to tile
I think I would suggest using
Something like this (untested):
[filter_adjacent_location]
instead of [filter_adjacent]
. As you suspected, [filter_adjacent]
requires a unit to be present (it is, after all, part of StandardUnitFilter).Something like this (untested):
Code: Select all
[harm_unit]
[filter_location]
[filter_adjacent_location]
x,y=$hit_locs[$i].x,$hit_locs[$i].y
[/filter_adjacent_location]
[/filter_location]
[/harm_unit]