How to make a unit gain exp per turn?

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
CloudCandy
Posts: 1
Joined: February 25th, 2026, 1:28 pm

How to make a unit gain exp per turn?

Post by CloudCandy »

Is there any way in a unit's code to make them gain a certain amount of experience after every turn passes?

I'm trying to make an egg, and originally I based it off of the Ant Egg, however that unit hatches depending on factors that I do not want.
I wish for my egg to hatch after a certain amount of turns, aka, each turn that passes gives it one more exp point until it reaches the advancement point.

My closest guess on how to achieve this would be to trigger an event if a turn passes, and that event would add one experience point every time its activated.

I am new to WML, and so I do not know what terms to use to make this happen if possible. Any help is appreciated, thanks <3
User avatar
Ravana
Forum Moderator
Posts: 3417
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How to make a unit gain exp per turn?

Post by Ravana »

Yes, event is correct way. But if you want it not interact with fight xp then you may use variable instead.

AI is able to provide suitable code for that:

Code: Select all

[event]
    name=side turn
    first_time_only=no
    id=egg_hatching_timer
    [modify_unit]
        [filter]
            type=Your_Egg_Unit_ID # Replace this with your egg's actual unit ID
            side=$side_number     # Only affects eggs belonging to the current side
        [/filter]
        experience="$($this_unit.experience + 1)"
    [/modify_unit]
[/event]
User avatar
lhybrideur
Posts: 512
Joined: July 9th, 2019, 1:46 pm

Re: How to make a unit gain exp per turn?

Post by lhybrideur »

I think you missed the part where he wrote he would like to put it in the unit type.
You would need to change the experience=... to an [effect] IMHO.
Something like

Code: Select all

[effect]
	apply_to=experience
	increase=1
[/effect
Last edited by lhybrideur on February 27th, 2026, 7:54 am, edited 1 time in total.
User avatar
Ravana
Forum Moderator
Posts: 3417
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How to make a unit gain exp per turn?

Post by Ravana »

Unit type supports events. Effect also works.
User avatar
lhybrideur
Posts: 512
Joined: July 9th, 2019, 1:46 pm

Re: How to make a unit gain exp per turn?

Post by lhybrideur »

I was more worried about the $this_unit, but I now realize that this variable is automatically initialized by [modify_unit]
BajMic
Posts: 148
Joined: January 24th, 2023, 1:22 am

Re: How to make a unit gain exp per turn?

Post by BajMic »

If an unit is being fed XP outside of combat, would it advance on its own?
Post Reply