Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize backstab weapon special #488

Closed
wants to merge 8 commits into from
Closed

Generalize backstab weapon special #488

wants to merge 8 commits into from

Conversation

CelticMinstrel
Copy link
Member

This pull request generalizes the backstab weapon special by extending the [filter_adjacent] tag, as well as a few other related changes (see commit list for details). The core backstab special has been rewritten in the new syntax.

The implementation uses a combination of two new features:

  1. A new relative_to= key in the adjacency filters which specifies the unit to whom a unit or location must be adjacent to match. It defaults to "self", which is the original behaviour of [filter_location] and [filter_adjacent_location]. For backstab, it's set to "opponent", which means the matched unit or location must be adjacent to the opponent rather than the unit with the special weapon. Other possible values are "attacker" and "defender".
  2. Five new possible directions for the adjacent= key. These directions use the primary unit (by default, the unit with the special weapon) as a centre point and the secondary unit as a boundary point and find a location relative to both units. Currently, the five directions are cw (clockwise from the secondary unit), ccw (counter-clockwise from the secondary unit), opp (opposite, ie the primary unit lies directly between the secondary unit and the matched unit), -cw (clockwise from the opposite point), -ccw (counter-clockwise from the opposite point). I'm not entirely keen on these names, and if anyone has a better idea, I would welcome it.

This commit also makes [filter_adjacent] and [filter_adjacent_location] work more like their counterparts in standard unit and location filters, respectively - supporting the count= key and, in the case of [filter_adjacent], the is_enemy= key (the latter being crucial for the new implementation of backstab). This change is applied to unit abilities as well as weapon specials.

The only thing left to do on this branch is show deprecated messages for the use of the backstab= key and possibly change the names of the relative directions.

Also accessible in:
- Weapon specials ([filter_self], [filter_opponent], [filter_attacker], [filter_defender])
- Abilities ([affect_adjacent][filter])

The backstab weapon special is now implemented using this.
(In a weapon special filter, units are guaranteed to be facing each other.)
Note: It's no longer supported to use the macro in a unit with a non-matching level,
for example giving a 2nd-level unit 4th-level leadership.
@CelticMinstrel
Copy link
Member Author

In response to zookeeper's critique of this PR, I've created a completely new generalization of the backstab ability. I believe it is much less likely to be confusing to add-on developers. Basically, some unit filters now match on two units rather than just one - this is done in any [filter_adjacent] tag as well as [filter_opponent] etc within weapon specials and [affect_adjacent][filter] in unit abilities. The second unit can be accessed through the $other_unit variable.

Here's a sample weapon special that uses this new variable as well as the rotate operators for directions:

[damage]
    id=flank
    name=_"flank"
    description=_"When used offensively, this attack deals triple damage if there is an enemy of the target on both of the two spaces behind the target but not directly opposite, and neither unit is incapacitated (turned to stone or otherwise paralyzed)."
    multiply=3
    active_on=offense
    [filter_opponent]
        [filter_adjacent]
            adjacent=$other_unit.facing|.cw, $other_unit.facing|.ccw
            count=2
            is_enemy=yes
            [not]
                status=petrified
            [/not]
        [/filter_adjacent]
    [/filter_opponent]
[/damage]

It's similar to backstab, but requires two additional units positioned behind and to the side of the opponent (a position which traps the enemy via ZoC).

There's still one minor problem with this in my opinion - the syntax .cw and .ccw is not a very good choice for the rotate operators, because they'll nearly always be used in conjunction with a variable, thus forcing the user to use the $var| syntax. Alternate suggestions are welcome.

@CelticMinstrel
Copy link
Member Author

Merged manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants