enclave's WML Macros questions Thread

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
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana »

Didnt you ask for equivalent to [filter]ability= ?

However, for filtering special units, why not use filter_wml for where it is efficient, with unit.variables.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Hi everyone again,
back to my replays problems..

when I watch replay of new settlers from server, I can read the following message in beginning of reloaded game (game which was saved on turn x, and then reloaded later from turn x)
<Invalid WML found> [replay], [statistics] not supported at scenario toplevel

What could that be? Why? where is the problem?
At first I thought that prestart event fires after reload... I coded some protection.. but some of codes still work, just ignoring my protection.. so it must be not prestart even the problem.. and my only clue is that invalid wml message...
Any ideas at all? anything? anyone? please..

Thank you!
PS. example game...
http://replays.wesnoth.org/1.12/20160311/
ctrl+f
NS_Tournament_x2_Turn_13_(24921)

http://replays.wesnoth.org/1.12/20160312/
ctrl+f
NS_Tournament_x2_Turn_23_(24951)

I dont know what is happening, but either some of #define just randomly decides it should work in beginning of reload.. (for example regenerate_map.cfg #define REGENERATE_MAP
(map loses all villages)..
and maybe other defines start as well.. i think peasants appear around leader.. (starting_positions.cfg #define LEADER_PLACEMENT)

Could it be that server has other #define(s) with same names? and maybe I just need to rename LEADER_PLACEMENT into something more unique? like NS_LEADER_PLACEMENT_X1X1 ?
Please give me any clues someone..? I can't figure out what is wrong..
I know it's not a big deal.. not being able to watch reloaded games from server.. but why is it happening??... and I'd like to be able to watch replays.. why not.. if I can fix it I would rather fix it...
Thanks!
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

hi!
I think i found way to enable troll shaman for campaign..
it's something like

Code: Select all

[campaign]
extra_defines=ENABLE_TROLL_SHAMAN
but for multiplayer scenario?
Thank you..
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana »

That way is unsynced.

Better use event to change units before advancement.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

thanks.. i thought so too.. just thought maybe is more civilized way :D
thanks!
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Hello! Anyone knows how to use unit type from compaign? (data/campaigns/Sceptre_of_Fire/units/)
for example I would like to create a [unit] type=Caravan
is there a way to link it like images? (my goal is to enable the unit without players needing to download era)
Thank you!
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Hi!
Anyone knows if something like that can be used and work somehow?
for example i set {VARIABLE some_variable BOOM}
and then use it like that:

Code: Select all

{MACRO_NAME_$some_variable}
for me it doesnt work :) says Macro/file BLABLA_$blabla is missing.. (looks like it doesnt translate $some_variable into BOOM)
Thanks!
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana »

Macro is text replace.

So, instead of setting variable, you can #define it to be something.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Thanks Ravana;) not sure if I understood you right though.. so
in my case i want to have for example 5 macros
MACRO1_boom
MACRO1_zoom
MACRO1_doom
MACRO1_poom
MACRO1_ooom
they all do very different things but they all come from 1 choice of options..
I just want to make one of them work, depending on option chosen, instead of combining them into 1 big MACRO1 with a lot of [if][then]
so if option 1 chosen then $varable=boom
then MACRO1_$variable would work.. as MACRO1_boom
so I think maybe fire event will work better for me.. not sure yet..
thought maybe there was way with macros
I guess there isnt? Im not sure if I understood you correctly.. about "#define it to be something"
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana »

Macro happens before variables. To do this, the option needs to be chosen before you start preprocessing.

What you want could likely be done with custom events.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: enclave's WML Macros questions Thread

Post by beetlenaut »

This is exactly the situation that [switch] is designed for. You can fire custom events (like Ravana said) in the case statements if you want to separate the code more.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Thank you both of you! Trying now with fire events.
Knowing that Macros work before variables helps a lot ;) and really answers it all. Thank you!
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

a new question...

I have following code of filter for attack special..

Code: Select all

		[effect]
				apply_to=attack
				name=club
				[set_specials]
					[damage]
					id=flank
					name= _ "flank"
					description= _ "flank"
					multiply=1.5
					apply_to=self
					##active_on=offense,defense
					[filter_self]
					[filter_adjacent]
					[filter_adjacent]
					adjacent=s,n
					is_enemy=true
					count=2
					[/filter_adjacent]
					[/filter_adjacent]
					[/filter_self]
					[/damage]
				[/set_specials]
				[/effect]
What it does it increases my unit's damage exactly like backstab would..
with one annoying difference.. it "backstabs" all units around him.. when should be able to backstab only 1 of them..

How to fix it? Do I need to move it to ability? Or i can continue with attack special by changing code to something?
Seems to me that attack special doesnt work on particular unit.. but just enables if filter matches.. Am i wrong?
Please somebody help=]
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: enclave's WML Macros questions Thread

Post by zookeeper »

Maybe you should explain how you want it to work.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Thank you for your reply zookeeper,

I would like it to work exactly like backstab ability works, just multiplier should be 1.5
I believe in 1.13 backstab already works in some similar way, but I couldnt find the source code yet.
In future I would add more sides, so if unit is surrounded by 4 backstabbers the multiplier would be 2.. and 3 from all sides.

More details in spoiler, but I'm not good at explaining seems to be.
Spoiler:
Thanks for help
Post Reply