Filtering Question (on AMLA) (new title)

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.

Filtering Question (on AMLA) (new title)

Postby stegyre » September 4th, 2017, 4:40 pm

I would like to change a unit to one of its variations as an AMLA advancement. I have successfully implemented a number of other AMLA advancements (Yay, me!), but this one is giving me troubles, and I cannot understand why.

The base unit I'm using is essentially a modified Ruffian. That unit has been successfully implemented and tested. The complete current code for the variant is as follows:
Code: Select all
#textdomain wesnoth-Sif_Era
# Same as normal, except has stealthfoot movement type and defenses

[unit_type]
    [base_unit]
        id=Sif Refugee
    [/base_unit]
    id=Nimble Refugee
    name= _ "Stealthy"
    alignment=chaotic
    movement_type=stealthfoot
    hide_help=true
    do_not_list=yes
[/unit_type]


The code for the AMLA advancement is:
Code: Select all
#define NIMBLE
    id=nimble
    always_display=true
    image="icons/boots_elven.png"
    description= _ "Reduce armor to become faster and more agile."
    [effect]
        apply_to=variation
        name=Nimble Refugee
    [/effect]
    [effect]
        apply_to=movement
        increase=1
    [/effect]
#enddef

This advancement option is displaying, and when I select it, the unit gets the movement increase, but the variation change is clearly not happening. (None of the defenses are changed for the new movement type; alignment does not change.)

Based on my abysmal knowledge of coding in general, I'm probably missing something basic. I just cannot figure out what.

For background, I am trying to see if I can use unit variations to implement changes that I cannot readily do by other means. (Some of these may be changes that are possible in WML but beyond my coding ability. For example: changing a unit's alignment -- something I've seen done in the World Conquest code, but in a manner that's beyond my current ability to replicate; or having two mutually-exclusive AMLA advancements: WML 1.13.2 adds the exclude_amla key, which will make this trivial, but in the meantime, I'm wrestling with how to do it.)

As always, your advice is greatly appreciated. :)
Last edited by stegyre on September 20th, 2017, 10:18 pm, edited 1 time in total.
stegyre
 
Posts: 53
Joined: August 18th, 2008, 4:35 pm

Re: Cannot change unit variation

Postby James_The_Invisible » September 4th, 2017, 5:48 pm

Uhm, there is no [variation] in your code, just [unit_type]. For changing into a different unit type, you should use [effect] apply_to=type. Definition of a variation looks like this: https://github.com/konecnyjakub/For_Pow ... 1082-L1122.
My content: For Power series
Ports: Danse Macabre Story of the Wose
Royal Guard/Silver Mage
User avatar
James_The_Invisible
 
Posts: 416
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces

Re: Cannot change unit variation

Postby zookeeper » September 4th, 2017, 5:52 pm

Your Nimble Refugee is a unit type on its own, it's not a variation of any unit type. What your code tries to do is to change the unit to a variation (named Nimble Refugee) of its current unit type, but whatever its unit type is, it has no such variation.

What you probably want is to have a variation of your Sif Refugee type, which means a [variation] tag inside that [unit_type], not a new unit type that derives from it via [base_unit]. Or, alternatively, you could simply change apply_to=variation to apply_to=type in order to have the unit type change to Nimble Refugee, but that might not be what you want.
User avatar
zookeeper
WML Wizard
 
Posts: 9617
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Cannot change unit variation

Postby stegyre » September 4th, 2017, 7:21 pm

Huzzah!

Thank you both, kindly. I have now successfully implemented a variation type, and I can continue my experiments to see what else I can do with this functionality. :D
stegyre
 
Posts: 53
Joined: August 18th, 2008, 4:35 pm

Re: Filtering Question (on AMLA) (new title)

Postby stegyre » September 20th, 2017, 10:19 pm

My latest question (updated the thread title for this)

I am (unsuccessfully) trying to use filtering on a custom AMLA advancement, but my complete failure convinces me that I don’t understand filtering at all. I could use some input.

What I’m specifically trying to do:
My units are 0-level units, and each AMLA increases their XP requirement for the next AMLA by 10% (starting at 10, then 11, 12, etc.). What I want to do is increase the unit level to level 1 after a certain number of advancements. It seemed the best way to do this was by filtering for the current XP requirement. I tried both the following codes, without success:
Code: Select all
    [effect]
        [filter_max_experience]
            greater_than=13
        [/filter_max_experience]
        level=1
    [/effect]


I also tried substituting “experience” for “max_experience.” All that happened is that the XP requirement would re-set to 10 each time it reached 13.

As I also tried some different filters (like filtering for movement speed and changing it) without any success, I’m convinced that I’m clueless about the filtering instructions. (I have tried to read and understand both the StandardUnitFilter and FilterWML pages, but I’m clearly not getting it.)
stegyre
 
Posts: 53
Joined: August 18th, 2008, 4:35 pm

Re: Filtering Question (on AMLA) (new title)

Postby Ravana » September 20th, 2017, 10:30 pm

That is not valid use of [effect] https://wiki.wesnoth.org/EffectWML
As you see from that, effect cannot change unit level. You need to use event to for that.


For filtering you use [filter] with keys from https://wiki.wesnoth.org/StandardUnitFilter inside, not [filter_random_name]. For comparison operators WML is not always enough, formula or Lua might be needed.
User avatar
Ravana
Moderator
 
Posts: 1482
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: Filtering Question (on AMLA) (new title)

Postby stegyre » September 20th, 2017, 10:57 pm

Ravana wrote:That is not valid use of [effect] https://wiki.wesnoth.org/EffectWML
As you see from that, effect cannot change unit level. You need to use event to for that.

I see. In the past, I've worked around this by implementing the change through a unit variation or unit type. I will try that route here.
For filtering you use [filter] with keys from https://wiki.wesnoth.org/StandardUnitFilter inside, not [filter_random_name]. For comparison operators WML is not always enough, formula or Lua might be needed.

I will play around with this. At this point, I want to see if I can make my own filter work for anything. I hope I don't need formula or Lua for what I want to try -- those are still areas where I'm way out of my depth.

Thanks for the feedback.
stegyre
 
Posts: 53
Joined: August 18th, 2008, 4:35 pm


Return to WML Workshop

Who is online

Users browsing this forum: Bing [Bot] and 1 guest