Make `Grants [promotion] to adjacent units` triggerable, allowing Great Admirals
This makes the unique Grants [promotion] ([comment]) to adjacent [mapUnitFilter] units for the rest of the game Triggerable, meaning it can be used as a mechanism for Great Admirals' "Repair Fleet".
The unique name is long, so it looks messy, but does seem to work. Would there be a better way to accomplish this?
Two questions...
- The
for the rest of the gameis kind of self-explanatory, can we remove it? - Would this be better as a trigger?
Triggers a [Repair Fleet] event <by consuming this unit>, but that would require a translation for "Repair Fleet"
Would there be a better way to accomplish this
Certainly. [^1]
[^1]: See Douglas Adams
- Mixing mechanics and content in one PR
- Not sure the Adminral[^1] you are defining is how the Adrimnals of our template game behaved. You're giving the fleet the ability to heal themselves for free, once, anytime later. I'd expect the heal to be performed the moment the Arnimlad sacrifices itself to enact the ability... Or am I blind? Edit: https://civilization.fandom.com/wiki/Great_Admiral_(Civ5)
[^1]: Think sudo apt install water-walking
What's actually happening here is a trigger for adjacent units. So let's call the child by it's name and make a trigger modifier that can turn any trigger into one that triggers on each adjacent unit! Also this is the kind of modifier we can expand upon and do for each adjacent tile, for each tile in N radius, etc
I'd expect the heal to be performed the moment the Arnimlad sacrifices itself to enact the ability
That's exactly what this does.
make a trigger modifier that can turn any trigger into one that triggers on each adjacent unit
Something like this?
[Water] units gain the [Repair Fleet] promotion <in adjacent tiles> <by consuming this unit>
Trigger a [Repair Fleet] event <in adjacent tiles> <by consuming this unit>
Possibly modify unitTriggerTarget?
[{Adjacent} {Water}] heals [100] HP <by consuming this unit>
A conditional mapUnitFilter would be cool too...
[{Adjacent} {Water}] units gain the [Repair Fleet] promotion <by consuming this unit>
Precisely!
The place for this would be in UniqueTriggerActivation.getTriggerFunction, the mechanics would be like "if the modifier exists: triggeredFunctions = tile.neighbors.mapNotNull{getTriggerFunction(...stuff)}, if triggeredFunctions.isEmpty() return null else return { for (function in triggeredFunctions) function() }
We need to ensure that the recursive call doesn't also retrigger so we need to send a modifier-less version of the unique on getTriggerFunction(...stuff), this is not the first time we need a "this unique but without this modifier" - we have it in timed uniques as well - so that sounds like a prerequisite, but apart from that it's pretty straightforward IMO
Going to have to think about this one.