advancing units for story reasons (with amla)

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
User avatar
ChrundleTheGreat
Posts: 82
Joined: May 3rd, 2023, 1:25 am
Location: The land of chapaqueños

advancing units for story reasons (with amla)

Post by ChrundleTheGreat »

hi everyone! :)
im working on a campaign where i want a couple single units with amlas to change unit type at a certain point of the story regardless of their xp, the changes made from one unit type to another would be minor and wouldnt interfere with amlas.
is this posible? if so how could i do this?
im hoping this question has an obvious answer, that it can be done and i just havent seen it done before.
im a newbie to programing, so apollogies if it is obvious. :)
thanks in advance for your thoughts.
User avatar
Spannerbag
Posts: 556
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: advancing units for story reasons (with amla)

Post by Spannerbag »

Hi,
It's quite possible there are cleverer ways of doing this that I've not thought of... however, as far as I know AMLAs (including the defaul AMLA) are defined as part of the unit_type so if you are changing the unit's type, say for example by using transform_unit then you'll have to have the same AMLAs incorporated into the new unit type.

I presume that at this point the units in question will not yet have actually received any AMLAs?
If they have, I think these would be preserved because they are almost always effects but it's something you might want to check?

There are a couple of other options that might be worth considering depending upon why you need to change the unit's type.
If it is to simply change the unit's appearance and/or type name then you could perhaps just "re-skin" the existing unit type by creating a variation?
You could also use base_unit but this creates a new, separate unit type.

Even simpler if you just want to add/remove abilities or modify the unit's attributes in some way then modify_unit, effect and/or object might do what you want?

As a starting point in changing unit type, this code from Northern Rebirth scenario 6 (Old Friend) might help:

Code: Select all

        # Change Tallin to be of Sergeant line
        # Check his level, and set new type to be a commander of the same level.
        {STORE_UNIT_VAR id=Tallin level old_tallin_level}

        [switch]
            variable=old_tallin_level

            [case]
                value=0,1
                {VARIABLE new_tallin_type Sergeant}
            [/case]

            [case]
                value=2
                {VARIABLE new_tallin_type Lieutenant}
            [/case]

            [else]
                {VARIABLE new_tallin_type General}
            [/else]
        [/switch]

        [transform_unit]
            id=Tallin
            transform_to=$new_tallin_type
        [/transform_unit]

        [heal_unit]
            [filter]
                id=Tallin
            [/filter]

            moves=full
        [/heal_unit]

        {CLEAR_VARIABLE old_tallin_level,new_tallin_type,heal_amount}
Hope this helps!
Cheers!
--Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
octalot
General Code Maintainer
Posts: 791
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: advancing units for story reasons (with amla)

Post by octalot »

If the unit type only has default AMLAs (full heal, and a few extra max HP), then Secrets of the Ancients' TURN_INTO_A_LICH macro does what you're after, calculating how much XP the unit had and then reapplying it to the transformed unit. It also does a custom portrait for one character.

If it has custom AMLAs, then there might be something more relevant in 1.17's version of Descent into Darkness, but I haven't found it in a quick search.
User avatar
egallager
Posts: 587
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: advancing units for story reasons (with amla)

Post by egallager »

I think AtS had some code like this for when you're temporarily separated from some of your allies, and they went off and had their own adventures while you were gone.
Post Reply