[UMC] Ally Defense Ability (& how to Implement it)

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
Post Reply
KingBigMac
Posts: 12
Joined: May 20th, 2018, 4:10 pm

[UMC] Ally Defense Ability (& how to Implement it)

Post by KingBigMac »

Hello, I have an idea for a unit ability that might be a good addition, but I don't know how to code it, so this is both a presentation of the ability itself and a query about how to implement it.

Original conception is that this is an ability for a branching promotion of the Dwarvish Guardsman, in part to fill a niche for the Knalgan Alliance of a support unit (a la healing or leadership), and to make the Guardsman line more viable and interesting by letting it lend its durability to other units.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Ability Name: Shield

Adds 10% defense to allies in adjacent hexes, up to a maximum of 70%. Excludes itself. (This I think I can implement.)

BUT when that 10% comes into play, what happens is the unit with Shield is attacked instead. So not regular defense as in simply a 10% higher miss chance, but the 10% miss on the ally being attacked sort of "transfers" the attack to the Shield(ing) unit.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
That's the main idea, I was thinking of a way to implement something that is elegant but not boring/overpowered like a 10% defense bonus with no strings attached. This is more interesting to me than healing which also indirectly increases ally survivability because unlike healing a risk/tradeoff is involved.

Details to establish would be things like does the unit with Shield retaliate when Shield procs (I think no) or get XP for that combat (again I think no) or indeed should the Shield proc be a sort of mini combat in of itself which permits the Shield(ing) unit to use its own defenses or something (in my view no). There's also the question of whether the Shield ability is in effect when a blow would kill the Shield(ing) unit, which I think should be the case but ONLY if the originally attacked unit would die itself because it would very frustrating gameplay wise if a Shield(ing) unit dies when the attacked ally is perfectly safe and additionally it makes thematic sense that the unit with Shield would sacrifice itself for an ally in need but not be suicidal. Another point is if the ability takes effect when the adjacent ally is being attacked and/or doing the attacking (I think only when being attacked).

So all in all it's quite simple; in effect an additional 10% defense for allies (assuming defense below 70%) which are attacked while adjacent to the unit with the Shield ability, and in the event that 10% procs for the unit with Shield to take guaranteed damage instead, gain no XP, and not retaliate (but for the ally unit being attacked directly to retaliate as usual).
(I would also like to code for contingencies where multiple units with Shield are adjacent to the same ally, possibly just choosing a Shield(ing) unit randomly in that case.)

I think making the damage guaranteed is what would make this ability balanced, immersive (because it's as if a hit that would have landed is intercepted by the Shield unit), and more exciting (and so, fun) to use because of the inherent risk (especially when compared with abilities like heal for example, although that's fine because heal only takes effect at the start of your own turn). The balance comes from the fact that even though hypothetically a 10% increase in defenses can be huge (a 33% increase in Effective HP in Mountains for many Dwarvish units, for example), in practice that damage is still being dealt, just to a different unit.
Distributing damage over more units especially if the additional units won't be (pointlessly) fatally damaged is obviously inherently good, and so even making the Shield proc have no desirable effects other than the damage distribution itself I still think the Shield(ing) units should be comparatively (very) weak to compensate.


Anyway all that being said, I don't know how to code this and have no experience with Wesnoth modding in general, so any help is appreciated.


P.S. Just a first draft of a hypothetical Dwarvish Guardsman alternate promotion with this ability.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Name: Dwarvish Shieldbearer

Traits: [standard Dwarvish]

Abilities: shield

HP: 48
Moves: 4
Cost: 30
Alignment: neutral

Description: Partly due to innate selflessness, and partly to shun the stigma sometimes experienced by those fighting from behind the safety of tower shields, there are Dwarves who chose to extend the protection of their shields to their comrades despite the personal risk. Abandoning all arms other than the shields themselves allows these noble souls to make the most of their remarkable acquired skill, affording them a reverence otherwise reserved for berserkers.

Attacks:
Shield bash | Strikes: 9x2 | Range: melee | Type: impact

Resistances:
arcane: 15% | blade: 30% | cold: 15% | fire: 15% | impact: 30% | pierce: 30%

Terrain Modifiers: [identical to Dwarvish Guardsman]
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The idea is that a unit with Shield has higher than typical for its allies (in this case Dwarves) resistances to not just distribute damage with the Shield ability, but also somewhat mitigate it overall.
That being said, I got rid of steadfast because it would probably synergize too well with Shield, and I didn't want to make Shieldbearer resistances higher than the Stalwart path on defense, depriving that path of unique flavor.
The impact damage is thematic, differentiates from the Stalwart line, and gives the Dwarves another source of what is a relatively rare damage type.
Maybe this unit advances, maybe it doesn't, I don't know what's better.

Tell me whether you think this idea is any good, and whether the provisional Dwarvish Shieldbearer is remotely balanced!

P.S.S. This got me thinking about other abilities which take effect when adjacent allies are attacked or are attacking. Anyone know of any cool existing ones? And damage distribution in general. Any other ideas?
LienRag
Posts: 127
Joined: September 24th, 2018, 4:03 pm

Re: [UMC] Ally Defense Ability (& how to Implement it)

Post by LienRag »

Not sure about this particular implementation, but shield-bearers able to make a shield wall (each one protecting the unit to its left) is nice and somehow historical.
newfrenchy83
Code Contributor
Posts: 164
Joined: October 6th, 2017, 12:57 pm

Re: [UMC] Ally Defense Ability (& how to Implement it)

Post by newfrenchy83 »

i don't all understand buti youplay in 1.16/1.17 then you can use ability like that:

Code: Select all

#define SHIELD ID GREATER_THAN
    [chance_to_hit]
        id={ID}
        apply_to=opponent
        sub=10
        [filter_base_value]
            greater_than_equal_to={GREATER_THAN}
        [/filter_base_value]
        affect_self=no
 	affect_allies=yes
        [affect_adjacent]
        [/affect_adjacent]
    [/chance_to_hit]
#enddef
#define ABILITY_SHIELD
    [chance_to_hit]
        id=shield
        name= _ "Shield"
        female_name= _ "female^Shield"
        description= _ "adds 10% defense to allies in adjacent hexes, up to a maximum of 70%. Excludes itself. (This I think I can implement.)."
        apply_to=opponent
        sub=10
        [filter_base_value]
            greater_than_equal_to=40
        [/filter_base_value]
        affect_self=no
        affect_allies=yes
        [affect_adjacent]
        [/affect_adjacent]
    [/chance_to_hit]
    {SHIELD shield2 50}
    {SHIELD shield3 60}
    {SHIELD shield4 70}
    {SHIELD shield5 80}
    {SHIELD shield6 90}
        [chance_to_hit]
        id=sield7
        apply_to=opponent
        sub=10
        [filter_base_value]
            equals=100
        [/filter_base_value]
        affect_self=no
 	affect_allies=yes
        [affect_adjacent]
        [/affect_adjacent]
    [/chance_to_hit]
#enddef
Last edited by newfrenchy83 on April 18th, 2023, 1:59 pm, edited 1 time in total.
newfrenchy83
Code Contributor
Posts: 164
Joined: October 6th, 2017, 12:57 pm

Re: [UMC] Ally Defense Ability (& how to Implement it)

Post by newfrenchy83 »

and implement in [abilities] tags, not [specials]
newfrenchy83
Code Contributor
Posts: 164
Joined: October 6th, 2017, 12:57 pm

Re: [UMC] Ally Defense Ability (& how to Implement it)

Post by newfrenchy83 »

excuse me, if effect not cumule then it is like that:

Code: Select all

#define ABILITY_SHIELD
    [chance_to_hit]
        id=shield
        name= _ "Shield"
        female_name= _ "female^Shield"
        description= _ "adds 10% defense to allies in adjacent hexes, up to a maximum of 70%. Excludes itself. (This I think I can implement.)."
        apply_to=opponent
        sub=10
        [filter_base_value]
            greater_than_equal_to=40
        [/filter_base_value]
        affect_self=no
        affect_allies=yes
        [affect_adjacent]
        [/affect_adjacent]
    [/chance_to_hit]
#enddef
newfrenchy83
Code Contributor
Posts: 164
Joined: October 6th, 2017, 12:57 pm

Re: [UMC] Ally Defense Ability (& how to Implement it)

Post by newfrenchy83 »

the problemis what shield can protect one unit only, and i don't see how doing that execpt with adjacent=nw by exemple
Post Reply