[engine] Different defences for melee and ranged attacks

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
Spirit_of_Currents
Posts: 161
Joined: April 26th, 2014, 4:44 pm

[engine] Different defences for melee and ranged attacks

Post by Spirit_of_Currents »

People could make unit-terrain-combinations that have higher defence against melee than ranged attacks. Some other unit-terrain-combinations would have higher defence against ranged than melee attacks.
There are very much electrochemical currents in my brain.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Different defences for melee and ranged attacks

Post by WhiteWolf »

Based on the wiki, since 1.15.0 you can already do this with the [resistance] ability tag, because you can filter on the weapons. (so you can have one for melee and one for a ranged second_weapon.)

It's actually quite a nice idea :)

EDIT:
Sorry, you meant defense, not resistance.
That's easily possible in the current stable versions as well, through a weapon special with [chance_to_hit], where you can also filter on the range of weapons.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Spirit_of_Currents
Posts: 161
Joined: April 26th, 2014, 4:44 pm

Re: [engine] Different defences for melee and ranged attacks

Post by Spirit_of_Currents »

To get understood better, I tell an imaginary example: Let's modify Iron Mauler slightly. Now he has 40 % defence against every non-magical melee attack. He still has 30 % defence against every ranged attack.

EDIT:
Oops! I forgot to say: on flat terrain.
There are very much electrochemical currents in my brain.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [engine] Different defences for melee and ranged attacks

Post by WhiteWolf »

Spirit_of_Currents wrote: February 24th, 2019, 11:29 amLet's modify Iron Mauler slightly. Now he has 40 % defence against every non-magical melee attack. He still has 30 % defence against every ranged attack. on flat terrain.
Here's the example code, let's say you apply this mod to every iron mauler that appears:

Code: Select all

[event]
    name=unit placed
    first_time_only=no
    [filter]
        type=Iron Mauler
    [/filter]
    [object]
        [filter]
            x,y=$x1,$y1
        [/filter]
        [effect]
            # the actual mod
            apply_to=attack
            # theoretically you could filter here for range=melee, but let's keep it universal and apply to all attacks and we'll filter inside the special
            [set_specials]
                mode=append
                [chance_to_hit]
                    id=different_defense_modifyer
                    apply_to=opponent
                    add=-10
                    [filter_self]
                        [filter_weapon]
                            range=melee # filter here for range
                        [/filter_weapon]
                        [filter_location]
                            terrain= # filter here for flat, I don't know the exact terrain codes by heart
                        [/filter_location]
                    [/filter_self]
                    
                    # doesn't apply to magical
                    [filter_opponent]
                        [not]
                            [filter_weapon]
                                 special=magical
                            [/filter_weapon]
                        [/not]
                    [/filter_opponent]
                [/change_to_hit]
            [/set_specials]
        [/effect]
    [/object]
[/event]
That should do it, I did not test the code however, there might be typos and such.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Spirit_of_Currents
Posts: 161
Joined: April 26th, 2014, 4:44 pm

Re: [engine] Different defences for melee and ranged attacks

Post by Spirit_of_Currents »

I hope interface would show both defence percentages so that they can be seen easily.
There are very much electrochemical currents in my brain.
Post Reply