AMLA code not quite working

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
User avatar
LordAwsomeness
Posts: 189
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

AMLA code not quite working

Post by LordAwsomeness »

Hi so im experimenting with some AMLA coding and im having some issues. Currently im trying to use a variable to increase the unit's current hp as an alternative to full healing. unfortunately the variable AMLA is not working. it shows up fine in the inspect window so I know that the code is fine.

Here's the code:

Code: Select all

#define LA_AMLA_BUFF
    [advancement]
        strict_amla=yes
        max_times=100
        id=la_amla_buff
        description= _ "Max HP bonus +4, Max XP +10%"
        image="icons/amla-default.png"
        [effect]
            apply_to=hitpoints
            increase_total=4
			increase=$la_hero[$unit.side].amla.hp_recovery
			violate_maximum=no
#            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=10%
        [/effect]
        [effect]
            apply_to=status
            remove=poisoned
        [/effect]
        [effect]
            apply_to=status
            remove=slowed
        [/effect]
    [/advancement]
#enddef
here's essentially what the code is supposed to do:

Code: Select all

#define LA_AMLA_BUFF
    [advancement]
        strict_amla=yes
        max_times=100
        id=la_amla_buff
        description= _ "Max HP bonus +4, Max XP +10%"
        image="icons/amla-default.png"
        [effect]
            apply_to=hitpoints
            increase_total=4
			increase=16
			violate_maximum=no
#            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=10%
        [/effect]
        [effect]
            apply_to=status
            remove=poisoned
        [/effect]
        [effect]
            apply_to=status
            remove=slowed
        [/effect]
    [/advancement]
#enddef
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA

Shiki
Developer
Posts: 288
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: AMLA code not quite working

Post by Shiki »

I guess that the $unit variable is not available in this context. It's only available in [event]s
$side_number should work, though that fits only offensively.

User avatar
LordAwsomeness
Posts: 189
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: AMLA code not quite working

Post by LordAwsomeness »

Shiki wrote:
February 12th, 2020, 3:07 am
I guess that the $unit variable is not available in this context. It's only available in [event]s
Isn't post_advance an event though?

Shiki wrote:
February 12th, 2020, 3:07 am
$side_number should work, though that fits only offensively.
I figured $unit.side would be better since you can level up when its not your turn


EDIT:
I just created an object effect in a post_advance event and made the modifications that I wanted to there. Thank you for your help though! Problem is now solved!
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA

Shiki
Developer
Posts: 288
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: AMLA code not quite working

Post by Shiki »

LordAwsomeness wrote:
February 12th, 2020, 3:15 am
Isn't post_advance an event though?
It is, but the [advancement] doesn't happen in an event.
But you can save the value of $unit.side in a pre advancement event to another variable, and clear it in post advancement.
If that it the problem.
LordAwsomeness wrote:
February 12th, 2020, 3:15 am
I figured $unit.side would be better since you can level up when its not your turn
Definitely.

User avatar
LordAwsomeness
Posts: 189
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: AMLA code not quite working

Post by LordAwsomeness »

Just edited my last post. Put it in an object in a post_advance event and it worked perfectly. Thank you for your help!
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA

Post Reply