Summon unit on death

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

Summon unit on death

Post by Spitoven » December 3rd, 2019, 12:10 am

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: 7
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven » December 3rd, 2019, 2:45 am

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: 2262
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Summon unit on death

Post by Ravana » December 3rd, 2019, 7:01 am

Should be event because of [kill].

Spitoven
Posts: 7
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven » December 3rd, 2019, 11:05 am

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
Forum Moderator
Posts: 1406
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Summon unit on death

Post by Elvish_Hunter » December 3rd, 2019, 11:43 am

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:
1.14: The Sojournings of Grog, A Rough Life, The White Troll (co-author), Wesnoth Lua Pack
1.12: Children of Dragons

Spitoven
Posts: 7
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven » December 3rd, 2019, 1:04 pm

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: 2262
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Summon unit on death

Post by Ravana » December 3rd, 2019, 3:29 pm

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: 7
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven » December 3rd, 2019, 6:01 pm

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: 2262
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Summon unit on death

Post by Ravana » December 3rd, 2019, 8:47 pm

Actually filter_second_attack not filter_second_weapon.

Spitoven
Posts: 7
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven » December 5th, 2019, 10:57 pm

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: 7
Joined: December 2nd, 2019, 2:52 pm

Re: Summon unit on death

Post by Spitoven » December 8th, 2019, 10:36 pm

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

Post Reply