Help for New Abilities and Weapon Specials

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
Barbaros
Posts: 57
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Is it possible to filter damage from an attack to two types of damage?

Example: A sword on fire, to calculate damage by types: Blade and Fire.
Attachments
Phoenix Knight - Dual Cut -15.png
Phoenix Knight - Dual Cut -15.png (19.01 KiB) Viewed 184 times
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

User avatar
beetlenaut
Developer
Posts: 2476
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

You will have to use a weapon special to give two types of damage at the same time, so you can filter on the special. However, the normal way to do this in Wesnoth is to give the unit two possible attacks to choose with different damage types.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
Barbaros
Posts: 57
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

beetlenaut wrote:
August 2nd, 2020, 7:22 pm
You will have to use a weapon special to give two types of damage at the same time, so you can filter on the special.

Could you give a simple example of what you just said, for me to try to develop this?
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

User avatar
beetlenaut
Developer
Posts: 2476
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

I'm not sure what you want an example of. "Weapon special?" No, you have written those. "Filter on the special?" No, you have done that too. "Give two types of damage?" Maybe that's what you want: Use an [event] that does [harm_unit] on "attacker hits" events. That's simpler than most other code in this thread.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
Barbaros
Posts: 57
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

beetlenaut wrote:
August 3rd, 2020, 12:19 pm
I'm not sure what you want an example of. "Weapon special?" No, you have written those. "Filter on the special?" No, you have done that too. "Give two types of damage?" Maybe that's what you want: Use an [event] that does [harm_unit] on "attacker hits" events. That's simpler than most other code in this thread.
So, I meant this:

Code: Select all

    [attack]
        name=sword_flame
        description=_"flaming greatsword"
        icon=attacks/sword-flaming.png
        type=blade
        range=melee
        damage=10
        number=4
    [specials]
        {XXX}
    [/specials]
    [/attack]
In the above situation, the type of attack is blade, and what I want the weapon special to increase or decrease is the damage of the attack, taking into account the "Fire Resistance" of the target.

I think I explained the best I can.

Something that works like Arcane Focus, which follows below, although I don't understand what those like these complex codes work for. "It looks like magic to me".

Code: Select all

#define WEAPON_SPECIAL_ARCANE_FOCUS

    # fake special used to describe the mechanic
    [dummy]
        id=arcane_focus
        name= _ "arcane focus"
        name_inactive= _ "arcane focus"
        description= _ "The opposite of arcane resistance is used for damage calculation. Thus, this attack is more efficient against most humans." 
        description_inactive= _ "The opposite of arcane resistance is used for damage calculation. Thus, this attack is more efficient against most humans." 
        apply_to=opponent
    [/dummy]
# wmlxgettext: [specials]
[/specials]
# wmlxgettext: [attack]
[/attack]

[event]
    name=turn refresh
    first_time_only=no
    [store_unit]
        [filter]
            [not]
                [filter_wml]
                    [resistance]
                        arcane_focus=$this_unit.variables.has_arcane_focus_res
                    [/resistance]
                [/filter_wml]
            [/not]
        [/filter]
        variable=give_arcane_focus_res
        mode=append
    [/store_unit]
    [while]
        [variable]
            name=i
            less_than=$give_arcane_focus_res.length
        [/variable]
        [do]
            [set_variable]
                name=give_arcane_focus_res[$i].resistance.arcane_focus
                value=200
            [/set_variable]
            [set_variable]
                name=give_arcane_focus_res[$i].resistance.arcane_focus
                add=-$give_arcane_focus_res[$i].resistance.arcane
            [/set_variable]
            [set_variable]
                name=give_arcane_focus_res[$i].variables.has_arcane_focus_res
                value=$give_arcane_focus_res[$i].resistance.arcane_focus
            [/set_variable]
            [unstore_unit]
                variable=give_arcane_focus_res[$i]
            [/unstore_unit]
            [set_variable]
                name=i
                add=1
            [/set_variable]
        [/do]
    [/while]
    {CLEAR_VARIABLE i}
    {CLEAR_VARIABLE give_arcane_focus_res}
[/event]

[+attack]
# wmlxgettext: [/attack]
    [+specials]
# wmlxgettext: [/specials]
#enddef
Use an [event] that does [harm unit] on "attacker hits" events.

I kept thinking about what you said...
So this event could take into account the Fire Resistance of the attacked unit?
If the Event works like that, it definitely resolves the issue for me.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

User avatar
Barbaros
Posts: 57
Joined: July 17th, 2020, 7:42 pm

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

I'm trying, but it's difficult.

Code: Select all

#define WEAPON_SPECIAL_FLAMMING_SWORD NUMBER
    [dummy]
        id=Flamming_Sword Number
        name= _ "Flamming Sword ({NUMBER})"
        description=_"When struck by this weapon, for each successful hit, the target takes a residual fire damage."
    [/dummy]
[/specials]
[/attack]

[event]
name=attacker hits
first_time_only=no
id=Burning
    [filter_attack]
        special=Flamming_Sword Number
    [/filter_attack]
    [filter_second]
      [not]
        race=drake
         [or]
           ability=fireborn
         [/or]
         [or]
           [filter_location]
               terrain=W*,W**,St,Sm
           [/filter_location]
         [/or]
         [or]
           type=Fire Dragon,Black Dragon
         [/or]
      [/not]
    [/filter_second]

[harm_unit]
    [filter]
        x,y=$x1,$y1
    [/filter]
  amount={NUMBER}
  damage_type=fire
  fire_event=yes
  kill=yes
  animate=yes
  experience=yes
  alignment=lawful
[/harm_unit]
[/event]
I don't know how to make the effect damage take into account the fire resistance of the attack target, what a more complicated business!!! :x
I also don't understand how the "NUMBER" in the name of the Weapon Special can become the customizable value of the Special. :annoyed:
Damn variable usage system that gives me a blind knot in my head, and I almost never get to use it... :evil:
It gives the impression that it would have to have some of them, or a strange formula... :hmm:
Help me please... :cry:
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

User avatar
beetlenaut
Developer
Posts: 2476
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

Barbaros wrote:
Yesterday, 6:21 am
I'm trying, but it's difficult.
I will be more likely to give you help that way. Most of us think the same way.
Barbaros wrote:
Yesterday, 6:21 am
I don't know how to make the effect damage take into account the fire resistance of the attack target
You already did that with damage_type=fire.
Barbaros wrote:
Yesterday, 6:21 am
I also don't understand how the "NUMBER" in the name of the Weapon Special can become the customizable value of the Special.
It is when you call the macro (inside [specials] in this case). You just put {WEAPON_SPECIAL_FLAMMING_SWORD 7}, and now {NUMBER} is 7 in your code.

Other problems that I see:
In your terrain, you can't do W**. I think you want W*^*.
You are harming the attacking unit with $x1, $y1. The defending unit is $x2, $y2.
I don't think you want experience or animation to be "yes". The normal attack will already do those things, and putting them here will cause them to be doubled.
"Flaming" is spelled with only one "m".
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

Post Reply