WML - modify unit, so it have different damage type and slows

The place to post your WML questions and answers.

Moderator: Forum Moderators

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
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

WML - modify unit, so it have different damage type and slows

Post by Elven »

Hello,

I have a hero units, and I wish to make it so that unit (drake fighter) have cold attack and it can slow other units when melee fighting. I do not want to change ranged attack. How can I do it? Also i wish this to work, when hero advances to better unit. Here is what I have so far:

[unit]
type=Drake Fighter
id=Kazin
name= _ "Kazin"
side=1
x=28
y=31
experience=25
{IS_HERO}
[modifications]
{TRAIT_LOYAL}
{TRAIT_STRONG}
{TRAIT_RESILIENT}
[/modifications]
[/unit]

Also i am sure that more examples in pages like this will be super helpful: https://wiki.wesnoth.org/UnitTypeWML
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Ravana »

Add [object] with [effect] apply_to=attack to this unit.
User avatar
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Elven »

i believe i found what was looking for here... https://wiki.wesnoth.org/index.php?titl ... &section=5

[attack]
type=cold
[/attack]
{WEAPON_SPECIAL_SLOW}


is this okay, or going the wrong way again? not on pc with wesnoth so cannot run it...
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Elven »

Ravana wrote: March 9th, 2021, 12:37 pm Add [object] with [effect] apply_to=attack to this unit.
thanks. still not very good with syntax. can you pls re-write that unit with this?
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Elven »

it looks like HTTT helps - sort of. still not working, donno why. Moremirmu the white mage have the same as I need, so i will just make small changes :) so cold is okay. but how to add slowing effect, like elvish shaman have?

This is my code and it have no effect :(

Code: Select all

		[modifications]
			{TRAIT_STRONG}
			{TRAIT_RESILIENT}
                [object]
                    [effect]
                        apply_to=attack
                        range=melee
                        set_type=cold
                    [/effect]
					[specials]
						{WEAPON_SPECIAL_SLOW}
					[/specials]
                [/object]
        [/modifications]
Last edited by Ravana on March 9th, 2021, 8:01 pm, edited 1 time in total.
Reason: [code]
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Ravana »

[object][specials] has no specific meaning. Functionality of object needs to be in [effect], with proper apply_to.
User avatar
MoonyDragon
Posts: 149
Joined: November 29th, 2017, 5:46 pm

Re: WML - modify unit, so it have different damage type and slows

Post by MoonyDragon »

The 'WML Reference' is generally clear enough on the tags and keys that can be used inside one another. I first went to SingleUnitWML, found the [modifications] tag, then jumped to DirectActionsWML for [object] and finally looked up EffectWML, where all your questions about 'apply_to=attack' are explained.
At last, the result:

Code: Select all

[object]
    [effect]
        apply_to=attack
        range=melee
        set_type=cold

        [set_specials]
            {WEAPON_SPECIAL_SLOW}
        [/set_specials]
    [/effect]
[/object]
Default L0 Era - Level 1 leaders with level 0 recruits!
User avatar
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Elven »

trying... but still no luck. I even copy+paste Moremirmu from HTTT, but even he does not work. his melee attack have different icon, but his attack is still the original one (impact in this instance)

testing on wesnoth 1.5.9.
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2359
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Lord-Knightmare »

This should do the trick.

Code: Select all

[unit]
    type=Drake Fighter
    id=Kazin
    name= _ "Kazin"
    side=1
    x=28
    y=31
    experience=25
    {IS_HERO}
    [modifications]
        {TRAIT_LOYAL}
        {TRAIT_STRONG}
        {TRAIT_RESILIENT}
        [object]
            id="cold_melee_buff"
            silent=yes
            duration=forever
            [effect]
                apply_to=attack
                set_type="cold"
                [set_specials]
                    mode=append
                    {WEAPON_SPECIAL_SLOW}
                [/set_specials]
            [/effect]
        [/object]
    [/modifications]
[/unit]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Elven »

well... this is very strange. moremirmu works. he is a white mage and now he have arcane attack. i coppied EVERYTHING to my drake fighter hero, but he is still using blade attack. no idea why. I also looked at HTTT files and there are no modifications to moremirmu outside of this file. so... absolutly lost :(

why does it work on 1 unit and not on another unit?
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Elven »

Thanks Lord, tested. but not working :( game bug? i will try it on other versions of Wesnoth...
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Elven »

on 1.14 it works like a charm, on 1.15.9 it does not work.

so, many of you helped me and i am very glad, but it looks like there is a bug in 1.15... going to test on 1.5.10...
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
Elven
Posts: 182
Joined: February 3rd, 2008, 12:02 am
Location: Slovakia
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Elven »

so...

1.14.15 - okay
1.15.9 - not working, bugs
1.15.10 - okay

thanks everyone a lot :)
Creator of Greenie knižnica and Greenie Linux and Wesnoth unofficial LiveCD; Slovak/Czech translator and creator of many campaigns. Everything is here on one place.
User avatar
MoonyDragon
Posts: 149
Joined: November 29th, 2017, 5:46 pm

Re: WML - modify unit, so it have different damage type and slows

Post by MoonyDragon »

I just tested your campaign on 1.15.9 and my code worked flawlessly. Is it possible that you are forgot to restart wesnoth (F5) after making your changes?

Code: Select all

[unit]
    type=Drake Fighter
    id=Kazin
    name= _"Kazin"
    side=1
    x,y=28,31
    experience=25

    [modifications]
            [object]
                [effect]
                    apply_to=attack
                    range=melee
                    set_type=cold

                    [set_specials]
                        {WEAPON_SPECIAL_SLOW}
                    [/set_specials]
                [/effect]
            [/object]

            {TRAIT_LOYAL}
            {TRAIT_STRONG}
            {TRAIT_RESILIENT}
    [/modifications]

    {IS_HERO}
[/unit]
Default L0 Era - Level 1 leaders with level 0 recruits!
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2359
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: WML - modify unit, so it have different damage type and slows

Post by Lord-Knightmare »

Is it possible that you are forgot to restart wesnoth (F5) after making your changes?
1.15.9 - not working, bugs
1.15.9 had a bug with the {IS_HERO}/{IS_LOYAL} macros. The solution (for 1.15.9's bug) is shown in Moony Dragon's code where the {IS_HERO} has been moved to after the [/modifications].
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Post Reply