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.
Post Reply
User avatar
Barbaros
Posts: 63
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 310 times
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

User avatar
beetlenaut
Developer
Posts: 2482
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: 63
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: 2482
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: 63
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: 63
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: 2482
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

Barbaros wrote:
August 4th, 2020, 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:
August 4th, 2020, 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:
August 4th, 2020, 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

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

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

Code: Select all

#define WEAPON_SPECIAL_FLAMING_SWORD NUMBER
    [dummy]
        id=Flaming_Sword Number
        name= _ "Flaming 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=Flaming_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=$x2, $y2
    [/filter]
  amount={NUMBER}
  damage_type=fire
  fire_event=yes
  kill=yes
  animate=no
  experience=no
  alignment=lawful
[/harm_unit]
[/event]
What the hell is this error I'm getting on the code of Weapon Special?

The following add-on had errors and could not be loaded:
C:\Users\Beast King Barbaros\Documents\My Games\Wesnoth1.14/data/add-ons/Reign_of_the_Lords/_main.cfg

Please report this to the author or maintainer of this add-on.

Details:

Macro/file 'NUMBER' is missing
at ~add-ons/Reign_of_the_Lords/macros/weapon-specials-3.cfg:46
included from ~add-ons/Reign_of_the_Lords/_main.cfg:44

What am I still missing, for the game to tell me that?... :annoyed:
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

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

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

It looks like you are missing an #enddef.

The error message is where the game first noticed the problem, but it's not always where the problem is located. In this case, the #define was never finished, so it doesn't know what to do with {NUMBER}.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

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

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

I fixed the first error, so I got this error from the "NUMBER", and now I'm trying, but I'm not sure what to do to fix it.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

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

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

Barbaros wrote:
August 5th, 2020, 11:31 pm
I'm not sure what to do to fix it.
Did you add the #enddef?
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

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

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

beetlenaut wrote:
August 5th, 2020, 11:41 pm
Barbaros wrote:
August 5th, 2020, 11:31 pm
I'm not sure what to do to fix it.
Did you add the #enddef?

Code: Select all

#define WEAPON_SPECIAL_FLAMING_SWORD NUMBER
    [dummy]
        id=Flaming_Sword Number
        name= _ "Flaming Sword ({NUMBER})"
        description=_"When struck by this weapon, for each successful hit, the target takes a residual fire damage."
    [/dummy]
[/specials]
[/attack]
#enddef
Yes, I added.
I tried other forms of syntax:

id = Flaming_Sword {NUMBER}
id = Flaming_Sword {VALUE}

NOTHING SOLVED...

As soon as I made the first post, then I saw that it was "#enddef" missing, then I corrected it.
Last edited by Barbaros on August 5th, 2020, 11:59 pm, edited 1 time in total.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

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

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

AAAAAAAHHHHHH what an urge to cry, when I'm stumbling over a foolishness that I don't know what it is ...
And finally, when I get it, I'm going to be angry for being a damn idiot...
Last edited by Barbaros on August 6th, 2020, 12:00 am, edited 1 time in total.
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

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

Re: Help for New Abilities and Weapon Specials

Post by beetlenaut »

No, you needed #enddef at the end. You have {NUMBER} in [harm_unit] after your #enddef. That's why the computer thinks {NUMBER} is missing.
Barbaros wrote:
August 5th, 2020, 11:54 pm
I tried other forms of syntax:
Inventing other forms of syntax never helps. It will only frustrate you.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

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

Re: Help for New Abilities and Weapon Specials

Post by Barbaros »

beetlenaut wrote:
August 6th, 2020, 12:00 am
No, you needed #enddef at the end. You have {NUMBER} in [harm_unit] after your #enddef. That's why the computer thinks {NUMBER} is missing.
Barbaros wrote:
August 5th, 2020, 11:54 pm
I tried other forms of syntax:
Inventing other forms of syntax never helps. It will only frustrate you.
The following add-on had errors and could not be loaded:
C:\Users\Beast King Barbaros\Documents\My Games\Wesnoth1.14/data/add-ons/Reign_of_the_Lords/_main.cfg

Please report this to the author or maintainer of this add-on.

Details:

Found invalid closing tag [/specials] for tag [unit_type]
opened at ~add-ons/Reign_of_the_Lords/units/loyalists/Phoenix_Knight.cfg:2
included from ~add-ons/Reign_of_the_Lords/_main.cfg:54
closed at ~add-ons/Reign_of_the_Lords/units/loyalists/Phoenix_Knight.cfg:65
included from ~add-ons/Reign_of_the_Lords/_main.cfg:54

Code: Select all

#textdomain wesnoth-units
[unit_type]
    id=Phoenix_Knight
    name= _ "Phoenix Knight"
    {TRAIT_FEARLESS_MUSTHAVE}
    race=human
    gender=male
    image="units/loyalists/Phoenix Knight/Phoenix Knight.png"
    profile="portraits/human/phoenixknight.png"         small_profile="portraits/human/phoenixknight.png{PATHWAYSIZE}"
#
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/human/phoenixknight.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/human/phoenixknight.png"
    [/portrait]
#
    {MAGENTA_IS_THE_TEAM_COLOR}
    hitpoints=65
    movement_type=smallfoot
    movement=6
    num_traits=3 
    experience=150
    level=3
    alignment=lawful
    advances_to=null
    {ADVANCE_IFHAVEANDCAMPAGIN (Swordsman)}
    {AMLA_DEFAULT}
    undead_variation=null		
    cost=54
    usage=fighter
    description= _ "Ages ago a noble paladin befriended a mythical bird of flame and formed a small order of knights that bore the phoenix insignia. Wether through knowledge of the secrets of eternal fire, pacts with the phoenixes or some other means, these warriors bring with them on the battlefield the destructive power of fire. Just like the Phoenix these warriors can rise from defeat, healing their wounds quickly and are all but impervious to flames."
    die_sound={SOUND_LIST:HUMAN_DIE}
    {DEFENSE_ANIM "units/human-loyalists/Phoenix Knight/PhoenixKnight_Defend.png" "units/human-loyalists/Phoenix Knight/PhoenixKnight_Defend.png" {SOUND_LIST:HUMAN_HIT} }
#
    [resistance]
            blade=70
            pierce=110
            impact=85
            fire=30
            cold=110
            arcane=80
    [/resistance]
#
    [abilities]
        {ABILITY_REBIRTH}
    [/abilities]
#
    [attack]
        name=sword_flame
        description=_"Flaming Greatsword"
        icon=attacks/sword-flaming.png
        type=blade
        range=melee
        damage=7
        number=4
    [specials]
        {WEAPON_SPECIAL_FLAMING_SWORD 4}
    [/specials]
    [/attack]
#
    [attack]
        name=sword_pierce
        description=_"Flaming Charge"
	  icon=attacks/greatsword-human.png
        type=fire
        range=melee
        damage=22
        number=1
    [specials]
        {WEAPON_SPECIAL_FOCUS}
    [/specials]
    [/attack]
#
[idle_anim]
        [frame]
            begin=0
            end=100
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Idle -[1~4].png"
        [/frame]
[/idle_anim]
#
    [movement_anim]
        start_time=0
        [frame]
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Moving.png:150"
        [/frame]
    [/movement_anim]
#
    [death]
        start_time=0
        [if]
            direction=sw,s,se
            [frame]
                image="units/loyalists/Phoenix Knight/Phoenix Knight - Dead -1.png:100"
            [/frame]
        [/if]
        [else]
            direction=nw,n,ne
            [frame]
                image="units/loyalists/Phoenix Knight/Phoenix Knight - Dead -2.png:100"
            [/frame]
        [/else]
    [/death]
#
[attack_anim]
        [attack_filter]
            name=sword_flame
        [/attack_filter]
        [frame]
            begin=-400	#-200
            end=-300		#-150
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Dual Cut -[2~6].png"
        [/frame]
        [frame]
            begin=-300	#-150
            end=-200		#-100
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Dual Cut -[7~11].png"
        [/frame]
        [frame]
            begin=-200	#-100
            end=100		#0
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Dual Cut -[12~16].png"
        [/frame]
        [if]
            hits=no
            [frame]
                begin=100	#0
                end=200	#50
                image="units/loyalists/Phoenix Knight/Phoenix Knight - Dual Cut -[12~16].png"
                sound={SOUND_LIST:MISS}
            [/frame]
        [/if]
        [else]
            hits=yes
            [frame]
                begin=100	#0
                end=200	#50
                image="units/loyalists/Phoenix Knight/Phoenix Knight - Dual Cut -[12~16].png"
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/else]
        [frame]
            begin=200		#50
            end=270		#120
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Dual Cut -17.png"
        [/frame]
        [frame]
            begin=270		#120
            end=350		#200
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Idle -1.png"
        [/frame]
    [/attack_anim]
#
    [attack_anim]
        [attack_filter]
            name=sword_pierce
        [/attack_filter]
        [frame]
            begin=-400	#-200
            end=-200		#-150
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Uper Sword -[2~9].png"
        [/frame]
        [frame]
            begin=-200	#-150
            end=0		#-100
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Uper Sword -[10~17].png"
        [/frame]
 	  [if]
            hits=no
            [frame]
                begin=0	#-100
                end=200	#100
                image="units/loyalists/Phoenix Knight/Phoenix Knight - Uper Sword -[10~17].png"
                sound={SOUND_LIST:MISS}
            [/frame]
        [/if]
        [else]
            hits=yes
            [frame]
                begin=0	#-100
                end=200	#100
                image="units/loyalists/Phoenix Knight/Phoenix Knight - Uper Sword -[10~17].png"
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/else]
        [frame]
            begin=200		#100
            end=250		#150
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Uper Sword -1.png"
        [/frame]
        [frame]
            begin=250		#100
            end=350		#200
            image="units/loyalists/Phoenix Knight/Phoenix Knight - Idle -2.png"
        [/frame]
    [/attack_anim]
#
[/unit_type]
This damned Weapon Special, now came to say that there is a tag error in my unit, ridiculous that.
I've checked the entire unit three times. :evil:
If from 15 to 30 years old, you have not been successful in life, you are already doomed.

Post Reply