Summon unit on death

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.
Post Reply
Spitoven
Posts: 10
Joined: December 2nd, 2019, 2:52 pm

Summon unit on death

Post by Spitoven »

Hello :D

I'm trying to make all units with a certain trait summon a specific unit when they die, like their soul is going out of their body to continue fighting. So it would be just like Plague but not depending on what weapon delivered the killing blow and with the summoned unit being on the same side than the killed unit :eng:

My main problem is that I can't find how to apply filters that recognize the dying unit. And it looks like you can't use events with traits and I'm unsure of how to proceed with a custom function. Yet I guess a code which would work for both traits and abilities would be more usefull to the community :hmm:

Can you help me please :augh:
Spitoven
Posts: 10
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven »

Ooooh thank you :D

I only have one more question: What happens with this code when an unit with this summon-on-death ability is killed by an unit with Plague? Which one takes precedence? :hmm:
User avatar
Ravana
Forum Moderator
Posts: 2997
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Summon unit on death

Post by Ravana »

Should be event because of [kill].
Spitoven
Posts: 10
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven »

Oh, ok! I want Plague to take precedence. So I added a filter but... it doesn't work :cry:

Code: Select all

        [filter_second]
            [filter_weapon]
                [not]
                    special_id_active=plague
                [/not]
            [/filter_weapon]
        [/filter_second]
What did I do wrong :doh:
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Summon unit on death

Post by Elvish_Hunter »

Spitoven wrote: December 3rd, 2019, 11:05 am What did I do wrong :doh:
[filter] (and [filter_second], for that matter) doesn't support [filter_weapon] inside itself; instead, it uses [has_attack]. Here's a list of what's allowed in unit filters: https://wiki.wesnoth.org/StandardUnitFilter.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Spitoven
Posts: 10
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven »

Thank you! So I changed the code :D

Code: Select all

        [filter_second]
            [has_attack]
                [not]
                    special_id_active=plague
                [/not]
            [/has_attack]
        [/filter_second]
But with this filter on the unit I wanted to summon never shows up anymore, even when the enemy doesn't have plague! How? :cry:
User avatar
Ravana
Forum Moderator
Posts: 2997
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Summon unit on death

Post by Ravana »

special_id_active might not work as you expect. First get it working with special= instead.

Instead of filter_second->has_attack you can use [filter_second_weapon].
Spitoven
Posts: 10
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven »

Thanks! So now the code is :eng:

Code: Select all

        [filter_second_weapon]
            [not]
                special=plague
            [/not]
        [/filter_second_weapon]
But now, whether the enemy has plague or not, my unit just gets summoned anyway again (and same result if I still rather use special_id_active=plague) :shock:
What's wrong with this damn plague :augh:
User avatar
Ravana
Forum Moderator
Posts: 2997
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Summon unit on death

Post by Ravana »

Actually filter_second_attack not filter_second_weapon.
Spitoven
Posts: 10
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven »

Oh, thank you it... WORKS! At last :-D

But there's still a problem, right? I guess "special=plague" will prevent the summoning even if the dying unit is unplageable. So I added this:

Code: Select all

        [filter]
            [not]
                status=unplagueable
            [/not]
        [/filter]
...and I duplicated the event, in which I reversed this last filter and removed the other one. Should work right? :D
Spitoven
Posts: 10
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven »

Yes it works! Thank you very much to you both :-D
Post Reply