[engine] Different defences for melee and ranged attacks

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

Moderators: Forum Moderators, Developers

Forum rules
Before posting a new idea, you must read the following:
Post Reply
Spirit_of_Currents
Posts: 76
Joined: April 26th, 2014, 4:44 pm

[engine] Different defences for melee and ranged attacks

Post by Spirit_of_Currents » February 23rd, 2019, 12:40 pm

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 electrical currents in my brain.

User avatar
WhiteWolf
Forum Regular
Posts: 564
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

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

Post by WhiteWolf » February 23rd, 2019, 1:38 pm

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.
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

Spirit_of_Currents
Posts: 76
Joined: April 26th, 2014, 4:44 pm

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

Post by Spirit_of_Currents » February 24th, 2019, 11:29 am

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 electrical currents in my brain.

User avatar
WhiteWolf
Forum Regular
Posts: 564
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

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

Post by WhiteWolf » February 24th, 2019, 5:56 pm

Spirit_of_Currents wrote:
February 24th, 2019, 11:29 am
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. 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.
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

Spirit_of_Currents
Posts: 76
Joined: April 26th, 2014, 4:44 pm

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

Post by Spirit_of_Currents » April 6th, 2019, 12:38 pm

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

Post Reply