Gaining XP whenever a unit is killed by plague
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.
Re: Gaining XP whenever a unit is killed by plague
Yes, it's late here, too. I should've gone to bed a while ago. But I felt like I was on the precipice of a breakthrough, so I kept thinking...just a little longer.
I put fungal plague in quotes. And turned-off the id=Moho part. Dang, I forgot what I learned in the playtest. I think Moho stopped getting experience. All these playtests are blurring together.
Filters! Arg!
I put fungal plague in quotes. And turned-off the id=Moho part. Dang, I forgot what I learned in the playtest. I think Moho stopped getting experience. All these playtests are blurring together.
Filters! Arg!
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: Gaining XP whenever a unit is killed by plague
I'm going to call it quits for the night. My next idea would take a while. I'm thinking maybe I need an [if] and [then]. It feels wrong, though. Thanks for the help!
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: Gaining XP whenever a unit is killed by plague
Yes, argh.
My preliminary results are as follows: I stripped out all of the "optional" stuff, added an indicator, and set up a very simple test scenario. It seems to work so far...
(In other words, I have made it properly filter for plague. So now we know how to filter for a special.) Next up: filter for the correct special!
---
EDIT: Eureka! It appears that the attack filters (in practice) don't work with the special's name after all! The wiki lied to me!
I made a quick and sloppy unit with a fungal plague special. Then here are the filters I tried:
Oddly, this one (just "plague") matched not only the regular plague, but also the fungal plague. I don't know why. Maybe it's because all of the plague-type specials are classified as plague? I mean, if you look at it, the special definition opens with
---
Second attempt. This event never fired. At all. Like Wesnoth apparently thought there was no such special as "fungal plague".
---
Third attempt. This one worked perfectly, at least as far as I tested it. When one of my "FungalZombie" units killed an enemy, then I got the message that said it was working. When a different unit killed an enemy, no message.
---
And now I had better test whether it works to combine this with an ID-based filter. BRB.
---
Everything seems to work!
You will need to "fix" two parts: change "FungalZombie" to the unit type that fungal plague actually creates, and change Moho's XP boost back to the variable that depends on the difficulty. (You said the XP boost part was working already, and I didn't want to have to re-create variable assignments in my simple test scenario if I didn't need to.)
I think that solves everything, so I'm off to bed now. Goodnight!
My preliminary results are as follows: I stripped out all of the "optional" stuff, added an indicator, and set up a very simple test scenario. It seems to work so far...
Code: Select all
[event]
name=die
first_time_only=no
[filter_second_attack]
special=plague
[/filter_second_attack]
[message]
speaker=narrator
message= _ "A $second_unit.type| has just slain a $unit.type| with a plague attack."
[/message]
[/event]
---
EDIT: Eureka! It appears that the attack filters (in practice) don't work with the special's name after all! The wiki lied to me!
I made a quick and sloppy unit with a fungal plague special. Then here are the filters I tried:
Code: Select all
[filter_second_attack]
special="plague"
[/filter_second_attack]
[plague]
and closes with [/plague]
, just like how ambush and submerge are both [hides]
. Huh. I ought to run some tests on that. Not tonight, though.---
Code: Select all
[filter_second_attack]
special="fungal plague"
[/filter_second_attack]
---
Code: Select all
[filter_second_attack]
special="fungal plague(FungalZombie)"
[/filter_second_attack]
---
And now I had better test whether it works to combine this with an ID-based filter. BRB.
---
Everything seems to work!
Code: Select all
[event]
name=die
first_time_only=no
[filter_second]
side=1
[not]
id=Moho
[/not]
[/filter_second]
[filter_second_attack]
special="fungal plague(FungalZombie)"
[/filter_second_attack]
[modify_unit]
[filter]
id=Moho
[/filter]
[effect]
apply_to=experience
increase=5
[/effect]
[/modify_unit]
[/event]
I think that solves everything, so I'm off to bed now. Goodnight!
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Gaining XP whenever a unit is killed by plague
This is quite some misinterpretation… but I guess you've gotten it figured out by now, right?
I am very confused at how this could possibly work, though maybe I'm missing some other change you made. Still, even then, if this really works, it seems like a weird undocumented feature, which also means there's no guarantee that it will continue to work in later versions.Pilauli wrote: ↑October 21st, 2020, 5:17 amThird attempt. This one worked perfectly, at least as far as I tested it. When one of my "FungalZombie" units killed an enemy, then I got the message that said it was working. When a different unit killed an enemy, no message.Code: Select all
[filter_second_attack] special="fungal plague(FungalZombie)" [/filter_second_attack]
The reason why all the other attempts weren't working is because
special
checks the tag name of the ability, which in this case is [plague]
, rather than the id. There is a new feature to check the ID instead using special_id
, but I'm not sure if it works in version 1.14. I thought it did, but the wiki says it doesn't. If special_id
doesn't work in 1.14 though, you could use a formula:Code: Select all
[filter_second_attack]
formula="index_of('fungal plague', specials) >= 0"
[/filter_second_attack]
Re: Gaining XP whenever a unit is killed by plague
Wow, the code works. Thank you!
Yes, at long last, I understandCeltic_Minstrel wrote: ↑October 21st, 2020, 12:58 pmThis is quite some misinterpretation… but I guess you've gotten it figured out by now, right?
filter_second
. Thanks for asking.Pilauli wrote: ↑October 21st, 2020, 5:17 amCode: Select all
[filter_second_attack] special="fungal plague(FungalZombie)" [/filter_second_attack]
I tested it and it almost works. If a side 1 unit without the special fungal plague kills an enemy unit, Moho gains bonus experience, which is not desirable. Moho should only gain the experience bonus when a unit becomes a fungal monster.Celtic_Minstrel wrote: ↑October 21st, 2020, 12:58 pmI am very confused at how this could possibly work, though maybe I'm missing some other change you made. Still, even then, if this really works, it seems like a weird undocumented feature, which also means there's no guarantee that it will continue to work in later versions.
The reason why all the other attempts weren't working is becausespecial
checks the tag name of the ability, which in this case is[plague]
, rather than the id. There is a new feature to check the ID instead usingspecial_id
, but I'm not sure if it works in version 1.14. I thought it did, but the wiki says it doesn't. Ifspecial_id
doesn't work in 1.14 though, you could use a formula:
Code: Select all
[filter_second_attack] formula="index_of('fungal plague', specials) >= 0" [/filter_second_attack]
I've been working in 1.15.5, so I didn't test special_id in 1.14. Now that I think about it, I probably should be working in 1.14. I'm not sure if this is accurate, but it seemed like the animations in 1.15 ran smoother than in 1.14, and since I'm doing custom animations, I've been using 1.15.5.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: Gaining XP whenever a unit is killed by plague
TheCeltic_Minstrel wrote: ↑October 21st, 2020, 12:58 pm
The reason why all the other attempts weren't working is becausespecial
checks the tag name of the ability, which in this case is[plague]
, rather than the id. There is a new feature to check the ID instead usingspecial_id
, but I'm not sure if it works in version 1.14.
special_id
worked in 1.15.5 like you indicated. A whole mess of new problems arose when I added my campaign to the 1.14 add-ons folder, so I couldn't test special_id
there.Code: Select all
[filter_second_attack]
special_id="fungal plague(Shroomling)" # Celtic_Minstrel << works
# special="fungal plague(Shroomling)" # Pilauli << works
# formula="index_of('fungal plague', specials) >= 0" # Celtic_Minstrel << almost works
[/filter_second_attack]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: Gaining XP whenever a unit is killed by plague
Matching the id withCeltic_Minstrel wrote: ↑October 21st, 2020, 12:58 pm it seems like a weird undocumented feature, which also means there's no guarantee that it will continue to work in later versions.
special=
is actually documented, although deprecated in recent development versions. From the wiki:
I was trying to use the older syntax so the campaign would have backwards compatibility with 1.14, but if it doesn't work there anyway, then yeah,https://wiki.wesnoth.org/FilterWML#Filtering_Weapons wrote: special: filter on the attack's special power, matches both id and tag name. (Version 1.15.2 and later only) Deprecated, see special_id and special_type instead.
special_id="fungal plague(FungalZombie)"
or special_tag=plague
would be better choices.(The reason I was confused about "fungal plague" (the special's name) not working is because I misread "tag name" as plain old "name", so I expected it to work with the special's name. I'm not confused about that anymore; thanks for explaining, CelticMinstrel!)
Re: Gaining XP whenever a unit is killed by plague
Thanks for doing that. Even though I'm coding for 1.15, I've been trying to avoid using the new tags that won't work with 1.14, so my campaign will run on 1.14 when it's done. But I'm also trying to avoid code that will be invalidated in the near future.
I like how WML keep evolving, with simpler and more powerful tags. Keep up the good work, developers!
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Gaining XP whenever a unit is killed by plague
Ah, I think get why the weird code with
I would recommend using
"fungal plague(FungalZombie)"
works. It's because the ID of the special wasn't what I expected from all the prior examples, but is instead this weird value with the parentheses.I would recommend using
special
(for 1.14) or special_id
(for 1.15) rather than a formula - I only posted the formula because I wasn't sure if there was another way to do it in 1.14.Re: Gaining XP whenever a unit is killed by plague
Oh. Thank you for clearing that up.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Gaining XP whenever a unit is killed by plague
Bit late, but the reason this doesn't work is that "special" simply isn't a valid unit filter.
Only things listed on this wiki page are valid entries for the [filter] tag: https://wiki.wesnoth.org/StandardUnitFilter
Using the [has_weapon] tag should do the trick.
Only things listed on this wiki page are valid entries for the [filter] tag: https://wiki.wesnoth.org/StandardUnitFilter
Using the [has_weapon] tag should do the trick.
Code: Select all
[filter_second]
[has_weapon]
special=fungal plague
[/has_weapon]
[/filter_second]
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Gaining XP whenever a unit is killed by plague
The previous examples weren't using it in a unit filter either. Your example is also wrong, because it'll trigger when a unit with a plague weapon kills something with a different weapon (for example, if you removed the "fungal" part it would match a necromancer who killed something with Chill Wave). Putting it in
[filter_attack]
or [filter_second_attack]
, which specifically matches the weapon being used for the attack, is the correct answer.- Nyanyanyan
- Posts: 73
- Joined: May 11th, 2018, 10:40 pm
Re: Gaining XP whenever a unit is killed by plague
Truth be told I didn't realize there was a second page of replies :9
And oh yeah, you're right. [filter_attack] is definitely the way to go. I was trying to show how to filter a unit having a weapon, like Helmet tried to do. Didn't think about the case of multiple weapons.
And oh yeah, you're right. [filter_attack] is definitely the way to go. I was trying to show how to filter a unit having a weapon, like Helmet tried to do. Didn't think about the case of multiple weapons.
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.
Re: Gaining XP whenever a unit is killed by plague
Wow! Tested and proved effective. Thank you for anticipating and solving a subtle problem that would've arisen later.Celtic_Minstrel wrote: ↑November 5th, 2020, 2:43 pm Putting it in[filter_attack]
or[filter_second_attack]
, which specifically matches the weapon being used for the attack, is the correct answer.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.