without explicit #undef

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.
User avatar
Gwledig
Posts: 537
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: without explicit #undef

Post by Gwledig » July 18th, 2019, 12:03 am

so I can do this?...
thanks that seems to sort out the #undef error for leadership, which I'd added as a custom macro as it's being deprecated... simply by adding #undef MACRONAME before the macro... presumably disabling the core one I spose..
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)

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

Re: without explicit #undef

Post by Ravana » July 18th, 2019, 6:26 am

Yes.

User avatar
Gwledig
Posts: 537
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: without explicit #undef

Post by Gwledig » July 18th, 2019, 10:23 am

This is the kind of thing I'm adding into my abilities.cfg to restore leadership then in my unit lists I can add this as an ability:

Code: Select all

#undef ABILITY_LEADERSHIP_LEVEL_1
#define ABILITY_LEADERSHIP_LEVEL_1
# included in an [abilities] clause
[leadership]
value=25
affect_allies=yes
affect_enemies=no
affect_self=no
cumulative=no
name= _ "Leadership"
female_name= _ "Female^Leadership"
description= _ "This unit can lead your own units that are next to it, making them fight better.
Adjacent own units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
[affect_adjacent]
adjacent=n,ne,se,s,sw,nw
[/affect_adjacent]
[/leadership]
#enddef
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)

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

Re: without explicit #undef

Post by Ravana » July 18th, 2019, 3:03 pm

Note that your ability does not do what description says.

User avatar
Gwledig
Posts: 537
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: without explicit #undef

Post by Gwledig » July 18th, 2019, 4:20 pm

thanks Ravana I did think it probably wasn't quite correct I had simplified it a bit...

rather than go through my wml looking for every time I use the leadership ability I have just pasted in the canned leadership from the core Wesnoth abilities cfg, so when I can leadership_level_1 or 2 3 4 5, regardless of the macro/ability name, it should hopefully process properly according to level...

Code: Select all

# note these leadership defines are all the same the lv1 2 3 4 5 are used only because they are called as macros this way the code is level dependent

#undef ABILITY_LEADERSHIP_LEVEL_1
#define ABILITY_LEADERSHIP_LEVEL_1
# Canned definition of the Leadership ability to be included in an
# [abilities] clause.
[leadership]
id=leadership
value="(25 * (level - other.level))"
cumulative=no
name= _ "leadership"
female_name= _ "female^leadership"
description= _ "This unit can lead your own units that are next to it, making them fight better.
Adjacent own units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
affect_self=no
[affect_adjacent]
[filter]
formula="level < other.level"
[/filter]
[/affect_adjacent]
[/leadership]
#enddef

#undef ABILITY_LEADERSHIP_LEVEL_2
#define ABILITY_LEADERSHIP_LEVEL_2
# Canned definition of the Leadership ability to be included in an
# [abilities] clause.
[leadership]
id=leadership
value="(25 * (level - other.level))"
cumulative=no
name= _ "leadership"
female_name= _ "female^leadership"
description= _ "This unit can lead your own units that are next to it, making them fight better.
Adjacent own units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
affect_self=no
[affect_adjacent]
[filter]
formula="level < other.level"
[/filter]
[/affect_adjacent]
[/leadership]
#enddef

#undef ABILITY_LEADERSHIP_LEVEL_3
#define ABILITY_LEADERSHIP_LEVEL_3
# Canned definition of the Leadership ability to be included in an
# [abilities] clause.
[leadership]
id=leadership
value="(25 * (level - other.level))"
cumulative=no
name= _ "leadership"
female_name= _ "female^leadership"
description= _ "This unit can lead your own units that are next to it, making them fight better.
Adjacent own units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
affect_self=no
[affect_adjacent]
[filter]
formula="level < other.level"
[/filter]
[/affect_adjacent]
[/leadership]
#enddef

#undef ABILITY_LEADERSHIP_LEVEL_4
#define ABILITY_LEADERSHIP_LEVEL_4
# Canned definition of the Leadership ability to be included in an
# [abilities] clause.
[leadership]
id=leadership
value="(25 * (level - other.level))"
cumulative=no
name= _ "leadership"
female_name= _ "female^leadership"
description= _ "This unit can lead your own units that are next to it, making them fight better.
Adjacent own units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
affect_self=no
[affect_adjacent]
[filter]
formula="level < other.level"
[/filter]
[/affect_adjacent]
[/leadership]
#enddef

#undef ABILITY_LEADERSHIP_LEVEL_5
#define ABILITY_LEADERSHIP_LEVEL_5
# Canned definition of the Leadership ability to be included in an
# [abilities] clause.
[leadership]
id=leadership
value="(25 * (level - other.level))"
cumulative=no
name= _ "leadership"
female_name= _ "female^leadership"
description= _ "This unit can lead your own units that are next to it, making them fight better.
Adjacent own units of lower level will do more damage in battle. When a unit adjacent to, of a lower level than, and on the same side as a unit with Leadership engages in combat, its attacks do 25% more damage times the difference in their levels."
affect_self=no
[affect_adjacent]
[filter]
formula="level < other.level"
[/filter]
[/affect_adjacent]
[/leadership]
#enddef
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)

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

Re: without explicit #undef

Post by Ravana » July 18th, 2019, 4:24 pm

If you do it that way, why you even override it? The reason to override leadership is when you want to have leadership level different from unit level.

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

Re: without explicit #undef

Post by Shiki » July 18th, 2019, 5:13 pm

The same you have above, but a bit shorter:

Code: Select all

#undef ABILITY_LEADERSHIP_LEVEL_1
#define ABILITY_LEADERSHIP_LEVEL_1
{ABILITY_LEADERSHIP}
#enddef
… but if you want that, the proper way is to just call {ABILITY_LEADERSHIP} instead of {ABILITY_LEADERSHIP_LEVEL_1}.
I guess you try to work around it because that means changing it in each file where it is used.

But one can use tools which aid you in doing that.
It's a simple matter of search and replace — and having simpler solutions than opening each file and changing it by hand.

Some editors offer to do search+replace among multiple files, not just the current one. (you need to open them still though)
Other tools can find you all files of an add-on and modify them in a way you specify.

And there's Wesnoths official porting tool wmllint, which is doing some changes for you, the above being one case. It comes also with a graphical user interface, GUI.pyw, in the folder data/tools of your wesnoth installation. What you need to run it is to install python3.

You usually need to set up the tools first, which may or may not be straightforward, but they help a lot! Be it to have syntax highlighting for WML, be it to make bulk modifications without bulk work, or be it editing images.
Introduction to WML filtering and WML variables.

User avatar
Gwledig
Posts: 537
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: without explicit #undef

Post by Gwledig » July 18th, 2019, 5:35 pm

Hm crazy thing is the warnings in my logs re deprecated use of leadership_level_1 2 3 4 5 are to do with me removing these from modified units, e.g.

Code: Select all

[effect]
apply_to=remove_ability
[abilities]
{ABILITY_LEADERSHIP_LEVEL_2}
[/abilities]
[/effect]
[effect]
Just looking at all my units, I don't beleive there is any actual use of leadership as a normal core/macro (I do use [leadership] in custom macros applied to specific units like phalax type ability).

Until it's fully removed from Wesnoth I'd need to keep in these removed leadership abilities, then when it's gone I can remove these from my units AND the custom leadership_level_1 etc. undefs...
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)

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

Re: without explicit #undef

Post by Ravana » July 18th, 2019, 5:58 pm

You dont need to remove same ability multiple times. Look definition of level leadership.

Post Reply