advancing units for story reasons (with amla)
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.
- ChrundleTheGreat
- Posts: 83
- Joined: May 3rd, 2023, 1:25 am
- Location: The land of chapaqueños
advancing units for story reasons (with amla)
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.
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.
- Spannerbag
- Posts: 562
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: advancing units for story reasons (with amla)
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:
Hope this helps!
Cheers!
--Spannerbag
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}
Cheers!
--Spannerbag
Re: advancing units for story reasons (with amla)
If the unit type only has default AMLAs (full heal, and a few extra max HP), then Secrets of the Ancients'
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.
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.
Re: advancing units for story reasons (with amla)
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.
Wesnoth-related GitHub repos:
General mods collection, SotBEEE, AToTBWaTD, The Earth's Gut, A Little Adventure, FtF
Social media: Mastodon: @egallager@treehouse.systems, Steam: egallager
General mods collection, SotBEEE, AToTBWaTD, The Earth's Gut, A Little Adventure, FtF
Social media: Mastodon: @egallager@treehouse.systems, Steam: egallager