How to make a unit gain exp per turn?
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.
-
CloudCandy
- Posts: 1
- Joined: February 25th, 2026, 1:28 pm
How to make a unit gain exp per turn?
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
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
Re: How to make a unit gain exp per turn?
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:
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]
- lhybrideur
- Posts: 512
- Joined: July 9th, 2019, 1:46 pm
Re: How to make a unit gain exp per turn?
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
Something like
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.
Re: How to make a unit gain exp per turn?
Unit type supports events. Effect also works.
- lhybrideur
- Posts: 512
- Joined: July 9th, 2019, 1:46 pm
Re: How to make a unit gain exp per turn?
I was more worried about the $this_unit, but I now realize that this variable is automatically initialized by [modify_unit]
Re: How to make a unit gain exp per turn?
If an unit is being fed XP outside of combat, would it advance on its own?
- lhybrideur
- Posts: 512
- Joined: July 9th, 2019, 1:46 pm
Re: How to make a unit gain exp per turn?
It depends how it is done, but normally yes.