Events - (special abilities) do not work
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.
Events - (special abilities) do not work
Hello,
I decided to create a wesnoth era and campaign based on my children dnd games. When we were children, we used to imagine a lot and me and my friends created quite nice and original ideas for fantasy world that i recently discovered in form of notebooks. Since it made me very happy to discover these old notebooks with all the monsters and weapons we created, I got excited about using this lore in some way. And because I love wesnoth I decided to try implement these memories into it.
I started with creating era and units, it goes well and so far i have learned to use all the generic game content to create units i need.
But! I am having trouble creating special abilities or even implementing SA created by someone else.
I tried to implement ability mind flay, from here https://wiki.wesnoth.org/Wml_abilities
When I put it itno my unit.cfg it gave me the missing macro/file quote, so I searched this forum and found that I have to put my abilities.cfg into the code before units.
I did and the error disappeared but it still seems that the ability is not working not even is visible in the desription.
The thing where I am currently pointing to is to create my own special which is little bit similar to the mind flay, but i cant get implemented even the abilities that should be working so i have to do something wrong.
This is the code for my ability, it should be like hatching for eggs, the idea is very simple, i just need to add certain amount of XP points to unit at the end of each turn.
I put the ability into abilities.cfg file and there is a path for it in my main.cfg. I also tried to copy the event into [era] and [unit_type] but none of these helped.
I believe that the event is somehow not triggering
So i am looking for help, it has to be somethning simple and obvious but i just wasnt able to reveal where the issue is.
I am no IT specialst so pardon me if its completely stupid question
I decided to create a wesnoth era and campaign based on my children dnd games. When we were children, we used to imagine a lot and me and my friends created quite nice and original ideas for fantasy world that i recently discovered in form of notebooks. Since it made me very happy to discover these old notebooks with all the monsters and weapons we created, I got excited about using this lore in some way. And because I love wesnoth I decided to try implement these memories into it.
I started with creating era and units, it goes well and so far i have learned to use all the generic game content to create units i need.
But! I am having trouble creating special abilities or even implementing SA created by someone else.
I tried to implement ability mind flay, from here https://wiki.wesnoth.org/Wml_abilities
When I put it itno my unit.cfg it gave me the missing macro/file quote, so I searched this forum and found that I have to put my abilities.cfg into the code before units.
I did and the error disappeared but it still seems that the ability is not working not even is visible in the desription.
The thing where I am currently pointing to is to create my own special which is little bit similar to the mind flay, but i cant get implemented even the abilities that should be working so i have to do something wrong.
This is the code for my ability, it should be like hatching for eggs, the idea is very simple, i just need to add certain amount of XP points to unit at the end of each turn.
Code: Select all
#define ABILITY_LIHNUTI
[dummy]
id=lihne_se
name=_"lihnuti"
description= _ "Teprve se klube"
[/dummy]
#enddef
[event]
name=end turn
first_time_only=no
[store_unit]
[filter]
ability=lihne_se
side=$side_number
[/filter]
variable=klubaci
[/store_unit]
[modify_unit]
[filter]
ability=lihne_se
side=$side_number
[/filter]
{VARIABLE_OP unit.experience add 1}
[/modify_unit]
[foreach]
array=klubaci
[do]
[floating_text]
x,y=$this_item.x,$this_item.y
text="<span color='#00fffa'>" + _ "Klub" + "</span>"
[/floating_text]
[/do]
{CLEAR_VARIABLE klubaci}
[/foreach]
[/event]
I believe that the event is somehow not triggering
So i am looking for help, it has to be somethning simple and obvious but i just wasnt able to reveal where the issue is.
I am no IT specialst so pardon me if its completely stupid question

- Atreides
- Posts: 798
- Joined: March 30th, 2019, 10:38 pm
- Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off
- Contact:
Re: Events - (special abilities) do not work
Maybe move the clear variable outside of the foreach.
Re: Events - (special abilities) do not work
Investigate step by step. First ensure game knows about your event (:inspect), then ensure event triggers ([message]), then check that variables during event contain information you expect ([inspect][/inspect] during event)
In this case I can already tell that [modify_unit][set_variable] does not change unit experience, it changes unit variables. [modify_unit] documentation has example how to change unit hitpoints, same way will work for experience.
In this case I can already tell that [modify_unit][set_variable] does not change unit experience, it changes unit variables. [modify_unit] documentation has example how to change unit hitpoints, same way will work for experience.
- Celtic_Minstrel
- Developer
- Posts: 2032
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Events - (special abilities) do not work
Change this:
To this:
VARIABLE_OP only works for variables, not for base unit parameters.
EDIT: Also, "end turn" is likely not what you think it is. It triggers once per turn, where "turn" means that each side has made their move. If you want it to trigger when you hit the End Turn button, you should use "side turn end".
Code: Select all
{VARIABLE_OP unit.experience add 1}
Code: Select all
experience="$($this_unit.experience + 1)"
EDIT: Also, "end turn" is likely not what you think it is. It triggers once per turn, where "turn" means that each side has made their move. If you want it to trigger when you hit the End Turn button, you should use "side turn end".