wesnoth / wesnoth

An open source, turn-based strategy game with a high fantasy theme.
https://www.wesnoth.org/
GNU General Public License v2.0
5.54k stars 1.02k forks source link

WFL weapon object for weapon specials #6226

Open MrTitainin opened 3 years ago

MrTitainin commented 3 years ago

I need to be able to use WFL weapon object, like self in weapon filter, for value calculation in context of weapon specials, preferably including conferred specials. It would be good if there are ones for both attacker and defender. They could be named weapon and other_weapon for example. Consider the following code as the example of possible application:

    [swarm]
        id = revswarm
        name = _"reverse swarm"
        description = _"The number of strikes increases up to twice the base number as this unit's health decreases."
        special_note = _"This unit has attacks that gain strikes proportionately to health lost."
        swarm_attacks_min = (weapon.attacks*2)
        swarm_attacks_max = (weapon.attacks)
    [/swarm]

Fixed value is not viable in my case because base changes.

CelticMinstrel commented 3 years ago

Just off the top of my head, I suspect this may not be viable to implement, at least in the exact way that you describe - the information required simply might not be available at the point where the swarm attacks values are evaluated. But I'll leave this open at least until I or someone else has had a chance to confirm or deny this.

ProditorMagnus commented 3 years ago
        [specials]
            [attacks]
                id="AE_efm_frenzy"
                name=_"frenzy"
                description= _ "The more wounded this unit is the more attacks he gets"
                multiply="(1 + ((((1.099999 * max_hitpoints) + 0.0) - hitpoints) / max_hitpoints))"
            [/attacks]
        [/specials]

https://github.com/ProditorMagnus/Ageless-for-1-14/blob/1dcabd78e1ac8ea497cf1bf0d2451af0b66bbd1b/units/EotF_units/Nordhris/Oathsworn.cfg#L34

MrTitainin commented 3 years ago
        [specials]
            [attacks]
                id="AE_efm_frenzy"
                name=_"frenzy"
                description= _ "The more wounded this unit is the more attacks he gets"
                multiply="(1 + ((((1.099999 * max_hitpoints) + 0.0) - hitpoints) / max_hitpoints))"
            [/attacks]
        [/specials]

https://github.com/ProditorMagnus/Ageless-for-1-14/blob/1dcabd78e1ac8ea497cf1bf0d2451af0b66bbd1b/units/EotF_units/Nordhris/Oathsworn.cfg#L34

This solves my immediate issue, thanks. I'll keep the overall issue open though, because I'm sure there are more applications for WFL weapon objects there though.