[engine] configurable AMLA costs

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderators: Forum Moderators, Developers

Forum rules
Before posting a new idea, you must read the following:
Post Reply
ArcdeSeel
Posts: 13
Joined: October 25th, 2016, 1:32 am

[engine] configurable AMLA costs

Post by ArcdeSeel » January 3rd, 2019, 6:37 am

AMLA don't automatically heal or remove poison. This is a nice option. They do automatically set experience to zero.

I'm trying to make the AMLA take a set amount of experience. Trying to circumvent the fact that AMLA always takes all of the unit's experience is clunky — my first idea was to subtract X experience in the advancement, then add experience equal to the max experience, making the total a decrease of X. This was foiled by the fact that subtracting can't take experience below 1 [weirdly enough not 0]. Currently I'm facing having to store the unit beforehand, filter for what AMLA the unit gets, and subtract based on that.

It would be much easier if there was an option under [advancement] to not remove XP and instead you'd do it manually as an effect.

User avatar
josteph
Developer
Posts: 740
Joined: August 19th, 2017, 6:58 pm

Re: [engine] configurable AMLA costs

Post by josteph » January 3rd, 2019, 12:09 pm

The implementation of type and modification advancements is here:

https://github.com/wesnoth/wesnoth/blob ... #L287-L316

Looking at the code, I tend to agree: it would be good to allow modification AMLAs not to reset experience to the "overflow" experience, in order to allow UMC to use custom mechanics there via EffectWML. However, what exactly should be done instead? Suppose a unit is has 49XP out of 50XP max and then kills a lvl4 unit; what would happen then?

ArcdeSeel
Posts: 13
Joined: October 25th, 2016, 1:32 am

Re: [engine] configurable AMLA costs

Post by ArcdeSeel » January 4th, 2019, 9:59 pm

The default setting would be that the experience is reset. If reset_experience=no, and none of the effects actually reduce the XP or increase the max XP, the unit will level up all 20 legal times. That's on the UMC creator, though.

I haven't worked much with C++, but from what I can tell, the tag would be under mod_option there and a simple conditional could do it.

User avatar
josteph
Developer
Posts: 740
Joined: August 19th, 2017, 6:58 pm

Re: [engine] configurable AMLA costs

Post by josteph » January 4th, 2019, 10:50 pm

If you started with 49XP and got 32XP from the kill, after the AMLA the experience won't be "reset"; the unit will have 31XP, not 0XP.

I don't understand where the "20" comes from.

What I was trying to get at in my question is what would be the unit's state when the AMLA is applied. Will it have experience=49 or experience=81 (81 = 49+32)? If the latter, how will the custom AMLA "know" how many excess XP the unit is supposed to have? What would happen if even after the AMLA was applied, not all of the "excess" 31XP were consumed? When proposing an engine change, the new semantics must be defined exactly, for all possible cases.

User avatar
Ravana
Forum Moderator
Posts: 2261
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [engine] configurable AMLA costs

Post by Ravana » January 4th, 2019, 11:01 pm

I understand 20 as [advancement]max_times value.

Other than incorrect xp preview from advancement selection, this should be possible to implement with events.

ArcdeSeel
Posts: 13
Joined: October 25th, 2016, 1:32 am

Re: [engine] configurable AMLA costs

Post by ArcdeSeel » January 4th, 2019, 11:12 pm

You're right. I keep using reset when I mean overflow or something.

Currently, you can advance several times in a row. If after the first advancement, your new XP is still greater than your new max XP, the advancement process will repeat. However, in the code you showed me, there's a hard limit on 20 advancements in a row. After that, there will be an error.

First, the unit will gain the 32 experience, in this case leaving it at experience=81 and max_experience=50.
Since experience is greater than max_experience, an AMLA will occur. For example

Code: Select all

    [advancement]
       	full_experience_cost=no
        [effect]
            apply_to=hitpoints
            increase_total=3
            heal_full=yes
        [/effect]
        [effect]
            apply_to=experience
            increase=-25
        [/effect]
    [/advancement]
would result in experience=56 and max_experience=50. So, the AMLA is applied a second time, leaving the unit at experience=31 and with 6 more max hp.

User avatar
josteph
Developer
Posts: 740
Joined: August 19th, 2017, 6:58 pm

Re: [engine] configurable AMLA costs

Post by josteph » January 6th, 2019, 3:39 pm

Sounds good to me.

@Ravana to be fair, the whole concept of advancements could be implemented with events anyway (an attack end that checks XP and does [transform_unit or gives the unit an object).

User avatar
Ravana
Forum Moderator
Posts: 2261
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [engine] configurable AMLA costs

Post by Ravana » January 6th, 2019, 3:51 pm

Concept could be implemented, but not its UI.

Post Reply